* [PATCH 2/6] voicecall: use ofono_call_status_name in DBG messages
2017-09-07 20:22 [PATCH 1/6] voicecall, common: promote call_status_to_string() to be public Alexander Couzens
@ 2017-09-07 20:22 ` Alexander Couzens
2017-09-07 20:22 ` [PATCH 3/6] qmimodem: add strength (in %) to the debug output Alexander Couzens
` (4 subsequent siblings)
5 siblings, 0 replies; 17+ messages in thread
From: Alexander Couzens @ 2017-09-07 20:22 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 931 bytes --]
status names are more readable then integer values.
---
src/voicecall.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/voicecall.c b/src/voicecall.c
index c99f11fabc01..e3ae80cfd914 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -2250,9 +2250,10 @@ void ofono_voicecall_notify(struct ofono_voicecall *vc,
struct voicecall *v = NULL;
struct ofono_call *newcall;
- DBG("Got a voicecall event, status: %d, id: %u, number: %s"
- " called_number: %s, called_name %s", call->status,
- call->id, call->phone_number.number,
+ DBG("Got a voicecall event, status: %s (%d), id: %u, number: %s"
+ " called_number: %s, called_name %s",
+ ofono_call_status_to_string(call->status),
+ call->status, call->id, call->phone_number.number,
call->called_number.number, call->name);
l = g_slist_find_custom(vc->call_list, GUINT_TO_POINTER(call->id),
--
2.14.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 3/6] qmimodem: add strength (in %) to the debug output
2017-09-07 20:22 [PATCH 1/6] voicecall, common: promote call_status_to_string() to be public Alexander Couzens
2017-09-07 20:22 ` [PATCH 2/6] voicecall: use ofono_call_status_name in DBG messages Alexander Couzens
@ 2017-09-07 20:22 ` Alexander Couzens
2017-09-07 21:49 ` Denis Kenzior
2017-09-07 20:22 ` [PATCH 4/6] qmimodem: extract network time from serving system Alexander Couzens
` (3 subsequent siblings)
5 siblings, 1 reply; 17+ messages in thread
From: Alexander Couzens @ 2017-09-07 20:22 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 730 bytes --]
---
drivers/qmimodem/network-registration.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/qmimodem/network-registration.c b/drivers/qmimodem/network-registration.c
index 04de5a5b87f9..41caa414477b 100644
--- a/drivers/qmimodem/network-registration.c
+++ b/drivers/qmimodem/network-registration.c
@@ -450,10 +450,11 @@ static void event_notify(struct qmi_result *result, void *user_data)
if (ss) {
int strength;
- DBG("signal with %d dBm on %d", ss->dbm, ss->rat);
-
strength = dbm_to_strength(ss->dbm);
+ DBG("signal with %d%%(%d dBm) on %d",
+ strength, ss->dbm, ss->rat);
+
ofono_netreg_strength_notify(netreg, strength);
}
--
2.14.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 4/6] qmimodem: extract network time from serving system
2017-09-07 20:22 [PATCH 1/6] voicecall, common: promote call_status_to_string() to be public Alexander Couzens
2017-09-07 20:22 ` [PATCH 2/6] voicecall: use ofono_call_status_name in DBG messages Alexander Couzens
2017-09-07 20:22 ` [PATCH 3/6] qmimodem: add strength (in %) to the debug output Alexander Couzens
@ 2017-09-07 20:22 ` Alexander Couzens
2017-09-07 21:50 ` Denis Kenzior
2017-09-08 8:48 ` Jonas Bonn
2017-09-07 20:22 ` [PATCH 5/6] gprs: use registration_status_to_string in debug messages Alexander Couzens
` (2 subsequent siblings)
5 siblings, 2 replies; 17+ messages in thread
From: Alexander Couzens @ 2017-09-07 20:22 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2952 bytes --]
---
drivers/qmimodem/nas.h | 12 +++++++++++
drivers/qmimodem/network-registration.c | 37 +++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/drivers/qmimodem/nas.h b/drivers/qmimodem/nas.h
index c3e7546bbfa1..9f67707ea721 100644
--- a/drivers/qmimodem/nas.h
+++ b/drivers/qmimodem/nas.h
@@ -152,6 +152,18 @@ struct qmi_nas_current_plmn {
#define QMI_NAS_REGISTRATION_STATE_DENIED 0x03
#define QMI_NAS_REGISTRATION_STATE_UNKNOWN 0x04
+#define QMI_NAS_RESULT_3GGP_DST 0x1b
+#define QMI_NAS_RESULT_3GPP_TIME 0x1c
+struct qmi_nas_3gpp_time {
+ uint16_t year;
+ uint8_t month;
+ uint8_t day;
+ uint8_t hour;
+ uint8_t minute;
+ uint8_t second;
+ uint8_t timezone;
+} __attribute__((__packed__));
+
/* cs_state/ps_state */
#define QMI_NAS_ATTACH_STATE_INVALID 0x00
#define QMI_NAS_ATTACH_STATE_ATTACHED 0x01
diff --git a/drivers/qmimodem/network-registration.c b/drivers/qmimodem/network-registration.c
index 41caa414477b..c88e80bdf711 100644
--- a/drivers/qmimodem/network-registration.c
+++ b/drivers/qmimodem/network-registration.c
@@ -23,6 +23,7 @@
#include <config.h>
#endif
+#include <endian.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -43,6 +44,38 @@ struct netreg_data {
uint8_t current_rat;
};
+static bool extract_ss_info_time(
+ struct qmi_result *result,
+ struct ofono_network_time *time)
+{
+ const struct qmi_nas_3gpp_time *time_3gpp = NULL;
+ uint8_t dst_3gpp;
+ bool dst_3gpp_valid;
+ uint16_t len;
+
+ /* parse 3gpp time & dst */
+ dst_3gpp_valid = qmi_result_get_uint8(result, QMI_NAS_RESULT_3GGP_DST,
+ &dst_3gpp);
+
+ time_3gpp = qmi_result_get(result, QMI_NAS_RESULT_3GPP_TIME, &len);
+ if (time_3gpp && len == sizeof(struct qmi_nas_3gpp_time) &&
+ dst_3gpp_valid) {
+ time->year = le16toh(time_3gpp->year);
+ time->mon = time_3gpp->month;
+ time->mday = time_3gpp->day;
+ time->hour = time_3gpp->hour;
+ time->min = time_3gpp->minute;
+ time->sec = time_3gpp->second;
+ time->utcoff = time_3gpp->timezone * 15 * 60;
+ time->dst = dst_3gpp;
+ return true;
+ }
+
+ /* TODO: 3gpp2 */
+
+ return false;
+}
+
static bool extract_ss_info(struct qmi_result *result, int *status,
int *lac, int *cellid, int *tech,
struct ofono_network_operator *operator)
@@ -124,11 +157,15 @@ static bool extract_ss_info(struct qmi_result *result, int *status,
static void ss_info_notify(struct qmi_result *result, void *user_data)
{
struct ofono_netreg *netreg = user_data;
+ struct ofono_network_time net_time;
struct netreg_data *data = ofono_netreg_get_data(netreg);
int status, lac, cellid, tech;
DBG("");
+ if (extract_ss_info_time(result, &net_time))
+ ofono_netreg_time_notify(netreg, &net_time);
+
if (!extract_ss_info(result, &status, &lac, &cellid, &tech,
&data->operator))
return;
--
2.14.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH 4/6] qmimodem: extract network time from serving system
2017-09-07 20:22 ` [PATCH 4/6] qmimodem: extract network time from serving system Alexander Couzens
@ 2017-09-07 21:50 ` Denis Kenzior
2017-09-08 8:48 ` Jonas Bonn
1 sibling, 0 replies; 17+ messages in thread
From: Denis Kenzior @ 2017-09-07 21:50 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 305 bytes --]
Hi Alexander,
On 09/07/2017 03:22 PM, Alexander Couzens wrote:
> ---
> drivers/qmimodem/nas.h | 12 +++++++++++
> drivers/qmimodem/network-registration.c | 37 +++++++++++++++++++++++++++++++++
> 2 files changed, 49 insertions(+)
>
Applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 4/6] qmimodem: extract network time from serving system
2017-09-07 20:22 ` [PATCH 4/6] qmimodem: extract network time from serving system Alexander Couzens
2017-09-07 21:50 ` Denis Kenzior
@ 2017-09-08 8:48 ` Jonas Bonn
2017-09-08 9:33 ` Jonas Bonn
2017-09-08 17:20 ` Denis Kenzior
1 sibling, 2 replies; 17+ messages in thread
From: Jonas Bonn @ 2017-09-08 8:48 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 4715 bytes --]
Hi Alexander,
On 09/07/2017 10:22 PM, Alexander Couzens wrote:
> ---
> drivers/qmimodem/nas.h | 12 +++++++++++
> drivers/qmimodem/network-registration.c | 37 +++++++++++++++++++++++++++++++++
> 2 files changed, 49 insertions(+)
>
> diff --git a/drivers/qmimodem/nas.h b/drivers/qmimodem/nas.h
> index c3e7546bbfa1..9f67707ea721 100644
> --- a/drivers/qmimodem/nas.h
> +++ b/drivers/qmimodem/nas.h
> @@ -152,6 +152,18 @@ struct qmi_nas_current_plmn {
> #define QMI_NAS_REGISTRATION_STATE_DENIED 0x03
> #define QMI_NAS_REGISTRATION_STATE_UNKNOWN 0x04
>
> +#define QMI_NAS_RESULT_3GGP_DST 0x1b
> +#define QMI_NAS_RESULT_3GPP_TIME 0x1c
Calling these *_RESULT_* isn't really correct. It should probably be
*_IND_* (indication) instead. For the "serving system" case, the
'result' and the 'indication' parameter have the same value, so the
_RESULT_ parameter gets re-used and the extract_ss_info function is
called from both get_ss_info_cb and ss_info_notify. For the _time_
parameters, however, the parameter ID is _not_ the same so separate
RESULT and INDication ID's are needed.
Personally, I find this nas.h header file to be rather convoluted; it's
a mishmash of defines with long names that aren't particularly easy to
parse. My personal preference would be to skip these defines altogether
and just
document the parameter together with it's use in the source code... they
are only referenced one time anyway. See below for an example of how I
would do this.
> +struct qmi_nas_3gpp_time {
> + uint16_t year;
> + uint8_t month;
> + uint8_t day;
> + uint8_t hour;
> + uint8_t minute;
> + uint8_t second;
> + uint8_t timezone;
> +} __attribute__((__packed__));
> +
> /* cs_state/ps_state */
> #define QMI_NAS_ATTACH_STATE_INVALID 0x00
> #define QMI_NAS_ATTACH_STATE_ATTACHED 0x01
> diff --git a/drivers/qmimodem/network-registration.c b/drivers/qmimodem/network-registration.c
> index 41caa414477b..c88e80bdf711 100644
> --- a/drivers/qmimodem/network-registration.c
> +++ b/drivers/qmimodem/network-registration.c
> @@ -23,6 +23,7 @@
> #include <config.h>
> #endif
>
> +#include <endian.h>
> #include <stdio.h>
> #include <stdlib.h>
> #include <string.h>
> @@ -43,6 +44,38 @@ struct netreg_data {
> uint8_t current_rat;
> };
>
> +static bool extract_ss_info_time(
> + struct qmi_result *result,
> + struct ofono_network_time *time)
> +{
> + const struct qmi_nas_3gpp_time *time_3gpp = NULL;
> + uint8_t dst_3gpp;
> + bool dst_3gpp_valid;
> + uint16_t len;
> +
> + /* parse 3gpp time & dst */
> + dst_3gpp_valid = qmi_result_get_uint8(result, QMI_NAS_RESULT_3GGP_DST,
> + &dst_3gpp);
Here's what I mean... replace the above line with:
/* Daylight Saving Time Adjustment 3GPP */
dst_3gpp_valid = qmi_result_get_uint8(result, 0x1b,
&dst_3gpp);
> +
> + time_3gpp = qmi_result_get(result, QMI_NAS_RESULT_3GPP_TIME, &len);
And here:
/* Universal Time and Local Time Zone 3GPP */
time_3gpp = qmi_result_get(result, 0x1c, &len);
(That might be the sound of Denis screaming in the background you hear!
:) I'm not sure he'll agree with this... we'll see).
> + if (time_3gpp && len == sizeof(struct qmi_nas_3gpp_time) &&
> + dst_3gpp_valid) {
> + time->year = le16toh(time_3gpp->year);
> + time->mon = time_3gpp->month;
> + time->mday = time_3gpp->day;
> + time->hour = time_3gpp->hour;
> + time->min = time_3gpp->minute;
> + time->sec = time_3gpp->second;
> + time->utcoff = time_3gpp->timezone * 15 * 60;
> + time->dst = dst_3gpp;
> + return true;
> + }
> +
> + /* TODO: 3gpp2 */
> +
> + return false;
> +}
> +
> static bool extract_ss_info(struct qmi_result *result, int *status,
> int *lac, int *cellid, int *tech,
> struct ofono_network_operator *operator)
> @@ -124,11 +157,15 @@ static bool extract_ss_info(struct qmi_result *result, int *status,
> static void ss_info_notify(struct qmi_result *result, void *user_data)
> {
> struct ofono_netreg *netreg = user_data;
> + struct ofono_network_time net_time;
> struct netreg_data *data = ofono_netreg_get_data(netreg);
> int status, lac, cellid, tech;
>
> DBG("");
>
> + if (extract_ss_info_time(result, &net_time))
> + ofono_netreg_time_notify(netreg, &net_time);
> +
> if (!extract_ss_info(result, &status, &lac, &cellid, &tech,
> &data->operator))
> return;
I tested this and didn't get any time info... I'm not sure these are
always sent by default but might need to be enabled with the 'Register
Indications' method (NAS method 0x03)...
/Jonas
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH 4/6] qmimodem: extract network time from serving system
2017-09-08 8:48 ` Jonas Bonn
@ 2017-09-08 9:33 ` Jonas Bonn
2017-09-08 17:20 ` Denis Kenzior
1 sibling, 0 replies; 17+ messages in thread
From: Jonas Bonn @ 2017-09-08 9:33 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 485 bytes --]
On 09/08/2017 10:48 AM, Jonas Bonn wrote:
>
> I tested this and didn't get any time info... I'm not sure these are
> always sent by default but might need to be enabled with the 'Register
> Indications' method (NAS method 0x03)...
I tested this. 'Register Indications' is not necessarily the right way
forward as that has nothing to do with the 'serving system' indication.
I'm not getting the Time parameters on the Serving System indication, in
any case.
/Jonas
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH 4/6] qmimodem: extract network time from serving system
2017-09-08 8:48 ` Jonas Bonn
2017-09-08 9:33 ` Jonas Bonn
@ 2017-09-08 17:20 ` Denis Kenzior
1 sibling, 0 replies; 17+ messages in thread
From: Denis Kenzior @ 2017-09-08 17:20 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 1287 bytes --]
Hi Jonas,
>> +
>> + time_3gpp = qmi_result_get(result, QMI_NAS_RESULT_3GPP_TIME, &len);
> And here:
>
> /* Universal Time and Local Time Zone 3GPP */
> time_3gpp = qmi_result_get(result, 0x1c, &len);
>
> (That might be the sound of Denis screaming in the background you hear!
> :) I'm not sure he'll agree with this... we'll see).
>
So generally our preferred approach is not to spend lots of time
defining data structures and #defines that end up being used only once.
They belong directly in the driver code. If you look at the RIL plugin,
that is mostly how things are done, e.g. very much along the lines you
propose.
In the case of QMI, we had plans to have a command line tool that could
interact with QMI devices without running full-blown oFono. So that is
why we placed many of the protocol numbers and structure definitions
into .h files.
For things that are unlikely to go into such a tool, I'm fine with
directly implementing / decoding the data structures inside, but its
hard to determine what might or might not be wanted in such a tool. So
it may be worthwhile to just put all structure definitions into
nas/wds/etc .h for now and make sure that the naming stays sane and
consistent.
Regards,
-Denis
^ permalink raw reply [flat|nested] 17+ messages in thread
* [PATCH 5/6] gprs: use registration_status_to_string in debug messages
2017-09-07 20:22 [PATCH 1/6] voicecall, common: promote call_status_to_string() to be public Alexander Couzens
` (2 preceding siblings ...)
2017-09-07 20:22 ` [PATCH 4/6] qmimodem: extract network time from serving system Alexander Couzens
@ 2017-09-07 20:22 ` Alexander Couzens
2017-09-07 21:51 ` Denis Kenzior
2017-09-07 20:23 ` [PATCH 6/6] plugins/udevng: use else if instead of if Alexander Couzens
2017-09-07 21:57 ` [PATCH 1/6] voicecall, common: promote call_status_to_string() to be public Denis Kenzior
5 siblings, 1 reply; 17+ messages in thread
From: Alexander Couzens @ 2017-09-07 20:22 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 578 bytes --]
---
src/gprs.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/gprs.c b/src/gprs.c
index a4132cc06760..420c96f92238 100644
--- a/src/gprs.c
+++ b/src/gprs.c
@@ -2596,7 +2596,8 @@ void ofono_gprs_detached_notify(struct ofono_gprs *gprs)
void ofono_gprs_status_notify(struct ofono_gprs *gprs, int status)
{
- DBG("%s status %d", __ofono_atom_get_path(gprs->atom), status);
+ DBG("%s status %s (%d)", __ofono_atom_get_path(gprs->atom),
+ registration_status_to_string(status), status);
gprs->status = status;
--
2.14.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH 6/6] plugins/udevng: use else if instead of if
2017-09-07 20:22 [PATCH 1/6] voicecall, common: promote call_status_to_string() to be public Alexander Couzens
` (3 preceding siblings ...)
2017-09-07 20:22 ` [PATCH 5/6] gprs: use registration_status_to_string in debug messages Alexander Couzens
@ 2017-09-07 20:23 ` Alexander Couzens
2017-09-07 21:52 ` Denis Kenzior
2017-09-07 21:57 ` [PATCH 1/6] voicecall, common: promote call_status_to_string() to be public Denis Kenzior
5 siblings, 1 reply; 17+ messages in thread
From: Alexander Couzens @ 2017-09-07 20:23 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 685 bytes --]
The same variable is checked in two `if's.
---
plugins/udevng.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/plugins/udevng.c b/plugins/udevng.c
index aa28bcb8911e..0f6ab2b21d77 100644
--- a/plugins/udevng.c
+++ b/plugins/udevng.c
@@ -261,7 +261,7 @@ static gboolean setup_sierra(struct modem_info *modem)
if (g_strcmp0(info->interface, "255/255/255") == 0) {
if (g_strcmp0(info->number, "01") == 0)
diag = info->devnode;
- if (g_strcmp0(info->number, "03") == 0)
+ else if (g_strcmp0(info->number, "03") == 0)
mdm = info->devnode;
else if (g_strcmp0(info->number, "04") == 0)
app = info->devnode;
--
2.14.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH 1/6] voicecall, common: promote call_status_to_string() to be public
2017-09-07 20:22 [PATCH 1/6] voicecall, common: promote call_status_to_string() to be public Alexander Couzens
` (4 preceding siblings ...)
2017-09-07 20:23 ` [PATCH 6/6] plugins/udevng: use else if instead of if Alexander Couzens
@ 2017-09-07 21:57 ` Denis Kenzior
2017-09-07 22:27 ` [PATCH][v2 1/2] voicecall, common: move call_status_to_string() to common Alexander Couzens
5 siblings, 1 reply; 17+ messages in thread
From: Denis Kenzior @ 2017-09-07 21:57 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 3506 bytes --]
Hi Alexander,
On 09/07/2017 03:22 PM, Alexander Couzens wrote:
> call_status_to_string() is useful for debug output.
> Change signature to contain enum call_status
> Replace default case to get compiler warning when new enums added
> ---
> src/common.c | 21 +++++++++++++++++++++
> src/common.h | 1 +
> src/voicecall.c | 24 ++----------------------
> 3 files changed, 24 insertions(+), 22 deletions(-)
>
> diff --git a/src/common.c b/src/common.c
> index ce07b934970d..d99647998a6f 100644
> --- a/src/common.c
> +++ b/src/common.c
> @@ -743,3 +743,24 @@ void ofono_call_init(struct ofono_call *call)
> call->cnap_validity = CNAP_VALIDITY_NOT_AVAILABLE;
> call->clip_validity = CLIP_VALIDITY_NOT_AVAILABLE;
> }
> +
> +const char *ofono_call_status_to_string(enum call_status status)
> +{
> + switch (status) {
> + case CALL_STATUS_ACTIVE:
> + return "active";
> + case CALL_STATUS_HELD:
> + return "held";
> + case CALL_STATUS_DIALING:
> + return "dialing";
> + case CALL_STATUS_ALERTING:
> + return "alerting";
> + case CALL_STATUS_INCOMING:
> + return "incoming";
> + case CALL_STATUS_WAITING:
> + return "waiting";
> + case CALL_STATUS_DISCONNECTED:
> + return "disconnected";
> + }
> + return "unknown";
doc/coding-style.txt item M1
> +}
> diff --git a/src/common.h b/src/common.h
> index 05f2a851bd57..de72bd418792 100644
> --- a/src/common.h
> +++ b/src/common.h
> @@ -184,3 +184,4 @@ const char *registration_tech_to_string(int tech);
> const char *packet_bearer_to_string(int bearer);
>
> gboolean is_valid_apn(const char *apn);
> +const char *ofono_call_status_to_string(enum call_status status);
This API is still private as it is not placed inside include/ anywhere.
So please call it call_status_to_string or properly expose it inside
include/voicecall.h, though I'm not sure if that would be useful.
> diff --git a/src/voicecall.c b/src/voicecall.c
> index 6907b5025cb4..c99f11fabc01 100644
> --- a/src/voicecall.c
> +++ b/src/voicecall.c
> @@ -174,26 +174,6 @@ static const char *disconnect_reason_to_string(enum ofono_disconnect_reason r)
> }
> }
>
> -static const char *call_status_to_string(int status)
> -{
> - switch (status) {
> - case CALL_STATUS_ACTIVE:
> - return "active";
> - case CALL_STATUS_HELD:
> - return "held";
> - case CALL_STATUS_DIALING:
> - return "dialing";
> - case CALL_STATUS_ALERTING:
> - return "alerting";
> - case CALL_STATUS_INCOMING:
> - return "incoming";
> - case CALL_STATUS_WAITING:
> - return "waiting";
> - default:
> - return "disconnected";
> - }
> -}
> -
> static const char *phone_and_clip_to_string(const struct ofono_phone_number *n,
> int clip_validity)
> {
> @@ -421,7 +401,7 @@ static void append_voicecall_properties(struct voicecall *v,
> ofono_bool_t mpty;
> dbus_bool_t emergency_call;
>
> - status = call_status_to_string(call->status);
> + status = ofono_call_status_to_string(call->status);
>
> ofono_dbus_dict_append(dict, "State", DBUS_TYPE_STRING, &status);
>
> @@ -920,7 +900,7 @@ static void voicecall_set_call_status(struct voicecall *call, int status)
>
> call->call->status = status;
>
> - status_str = call_status_to_string(status);
> + status_str = ofono_call_status_to_string(status);
> path = voicecall_build_path(call->vc, call->call);
>
> ofono_dbus_signal_property_changed(conn, path,
>
Regards,
-Denis
^ permalink raw reply [flat|nested] 17+ messages in thread* [PATCH][v2 1/2] voicecall, common: move call_status_to_string() to common
2017-09-07 21:57 ` [PATCH 1/6] voicecall, common: promote call_status_to_string() to be public Denis Kenzior
@ 2017-09-07 22:27 ` Alexander Couzens
2017-09-07 22:27 ` [PATCH][v2 2/2] voicecall: use ofono_call_status_name in DBG messages Alexander Couzens
2017-09-07 22:30 ` [PATCH][v2 1/2] voicecall, common: move call_status_to_string() to common Denis Kenzior
0 siblings, 2 replies; 17+ messages in thread
From: Alexander Couzens @ 2017-09-07 22:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 2291 bytes --]
call_status_to_string() is useful for debug output.
Change signature to contain enum call_status
Replace default case to get compiler warning when new enums added
---
src/common.c | 22 ++++++++++++++++++++++
src/common.h | 1 +
src/voicecall.c | 20 --------------------
3 files changed, 23 insertions(+), 20 deletions(-)
diff --git a/src/common.c b/src/common.c
index ce07b934970d..d44b001868ca 100644
--- a/src/common.c
+++ b/src/common.c
@@ -743,3 +743,25 @@ void ofono_call_init(struct ofono_call *call)
call->cnap_validity = CNAP_VALIDITY_NOT_AVAILABLE;
call->clip_validity = CLIP_VALIDITY_NOT_AVAILABLE;
}
+
+const char *call_status_to_string(enum call_status status)
+{
+ switch (status) {
+ case CALL_STATUS_ACTIVE:
+ return "active";
+ case CALL_STATUS_HELD:
+ return "held";
+ case CALL_STATUS_DIALING:
+ return "dialing";
+ case CALL_STATUS_ALERTING:
+ return "alerting";
+ case CALL_STATUS_INCOMING:
+ return "incoming";
+ case CALL_STATUS_WAITING:
+ return "waiting";
+ case CALL_STATUS_DISCONNECTED:
+ return "disconnected";
+ }
+
+ return "unknown";
+}
diff --git a/src/common.h b/src/common.h
index 05f2a851bd57..1b6b01d457a5 100644
--- a/src/common.h
+++ b/src/common.h
@@ -184,3 +184,4 @@ const char *registration_tech_to_string(int tech);
const char *packet_bearer_to_string(int bearer);
gboolean is_valid_apn(const char *apn);
+const char *call_status_to_string(enum call_status status);
diff --git a/src/voicecall.c b/src/voicecall.c
index 6907b5025cb4..408c72162ca7 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -174,26 +174,6 @@ static const char *disconnect_reason_to_string(enum ofono_disconnect_reason r)
}
}
-static const char *call_status_to_string(int status)
-{
- switch (status) {
- case CALL_STATUS_ACTIVE:
- return "active";
- case CALL_STATUS_HELD:
- return "held";
- case CALL_STATUS_DIALING:
- return "dialing";
- case CALL_STATUS_ALERTING:
- return "alerting";
- case CALL_STATUS_INCOMING:
- return "incoming";
- case CALL_STATUS_WAITING:
- return "waiting";
- default:
- return "disconnected";
- }
-}
-
static const char *phone_and_clip_to_string(const struct ofono_phone_number *n,
int clip_validity)
{
--
2.14.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* [PATCH][v2 2/2] voicecall: use ofono_call_status_name in DBG messages
2017-09-07 22:27 ` [PATCH][v2 1/2] voicecall, common: move call_status_to_string() to common Alexander Couzens
@ 2017-09-07 22:27 ` Alexander Couzens
2017-09-07 22:30 ` [PATCH][v2 1/2] voicecall, common: move call_status_to_string() to common Denis Kenzior
1 sibling, 0 replies; 17+ messages in thread
From: Alexander Couzens @ 2017-09-07 22:27 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 925 bytes --]
status names are more readable then integer values.
---
src/voicecall.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/voicecall.c b/src/voicecall.c
index 408c72162ca7..e5b9f505fbd3 100644
--- a/src/voicecall.c
+++ b/src/voicecall.c
@@ -2250,9 +2250,10 @@ void ofono_voicecall_notify(struct ofono_voicecall *vc,
struct voicecall *v = NULL;
struct ofono_call *newcall;
- DBG("Got a voicecall event, status: %d, id: %u, number: %s"
- " called_number: %s, called_name %s", call->status,
- call->id, call->phone_number.number,
+ DBG("Got a voicecall event, status: %s (%d), id: %u, number: %s"
+ " called_number: %s, called_name %s",
+ call_status_to_string(call->status),
+ call->status, call->id, call->phone_number.number,
call->called_number.number, call->name);
l = g_slist_find_custom(vc->call_list, GUINT_TO_POINTER(call->id),
--
2.14.1
^ permalink raw reply related [flat|nested] 17+ messages in thread* Re: [PATCH][v2 1/2] voicecall, common: move call_status_to_string() to common
2017-09-07 22:27 ` [PATCH][v2 1/2] voicecall, common: move call_status_to_string() to common Alexander Couzens
2017-09-07 22:27 ` [PATCH][v2 2/2] voicecall: use ofono_call_status_name in DBG messages Alexander Couzens
@ 2017-09-07 22:30 ` Denis Kenzior
1 sibling, 0 replies; 17+ messages in thread
From: Denis Kenzior @ 2017-09-07 22:30 UTC (permalink / raw)
To: ofono
[-- Attachment #1: Type: text/plain, Size: 477 bytes --]
Hi Alexander,
On 09/07/2017 05:27 PM, Alexander Couzens wrote:
> call_status_to_string() is useful for debug output.
> Change signature to contain enum call_status
> Replace default case to get compiler warning when new enums added
> ---
> src/common.c | 22 ++++++++++++++++++++++
> src/common.h | 1 +
> src/voicecall.c | 20 --------------------
> 3 files changed, 23 insertions(+), 20 deletions(-)
>
Both applied, thanks.
Regards,
-Denis
^ permalink raw reply [flat|nested] 17+ messages in thread