Patch Description
cover Patch Description
This series of patch is to add provide local info support by requesting the terminal to send time and language info. Please comment on the following aspects as I'm not sure after reading the spec:
1. Timezone may be a number in the range -47 through +48. In struct sms_scts, timezone is defined as gint8, thus 0xFF should shand for -1, which is a valid input. Thus I think build_dataobj_datetime_timezone() in src/stkutil.c is not correct. But I'm still not sure what value should be passed to oFono when timezone is absent.
2. DBUS_TYPE_BYTE represents an 8-bit unsigned integer, and D-Bus doesn't have a type related to 8-bit signed integer. So what's the best way to represent a timezone?
3. Only one byte is used to represent the year. Is the following logic correct to get the year with one byte?
if (year_dbus >= 2000)
year = year_dbus - 2000; else year = year_dbus - 1900;
Yang Gu (3):
network: Use bit as size instead of byte
stk: Handle provide local info proactive command
test-stk: Add provide local info
src/network.c | 4 +- src/smsutil.c | 6 +- src/stk.c | 113 ++++++++++++++++++++++++++++++++++++++ src/stkagent.c | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++ src/stkagent.h | 14 +++++ src/stkutil.c | 2 +- test/test-stk-menu | 36 ++++++++++++ 7 files changed, 322 insertions(+), 6 deletions(-)
Signature · 1 line
1.7.2.3
PATCH 1/3 network: Use bit as size instead of byte
--- src/network.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
src/network.c +2 -2
@@ -129,7 +129,7 @@ static char **network_operator_technologies(struct network_operator_data *opd)char **techs;unsigned int i; -for (i =0 ; i <sizeof (opd->techs); i++) { +for (i =0 ; i <sizeof (opd->techs) *8 ; i++) {if (opd->techs & (1 << i)) ntechs +=1 ; }
@@ -137,7 +137,7 @@ static char **network_operator_technologies(struct network_operator_data *opd) techs = g_new0(char *, ntechs + 1); ntechs =0 ; -for (i =0 ; i <sizeof (opd->techs); i++) { +for (i =0 ; i <sizeof (opd->techs) *8 ; i++) {if (!(opd->techs & (1 << i)))continue ;
Signature · 1 line
1.7.2.3
Re: [PATCH 1/3] network: Use bit as size instead of byte
Hi Yang,
Quoted 4 lines · Yang Gu
--- src/network.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
Good catch! Patch has been applied, thanks.
Regards,
-Denis
PATCH 2/3 stk: Handle provide local info proactive command
In reply to Yang Gu--- src/smsutil.c | 6 +- src/stk.c | 113 +++++++++++++++++++++++++++++++++++++++++ src/stkagent.c | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/stkagent.h | 14 +++++ src/stkutil.c | 2 +- 5 files changed, 284 insertions(+), 4 deletions(-)
src/smsutil.c +3 -3
@@ -324,10 +324,10 @@ gboolean sms_encode_scts(const struct sms_scts *in, unsigned char *pdu,if (in->year >99 )return FALSE; -if (in->month >12 ) +if (in->month >12 || in->month ==0 )return FALSE; -if (in->day >31 ) +if (in->day >31 || in->day ==0 )return FALSE;if (in->hour >23 )
@@ -339,7 +339,7 @@ gboolean sms_encode_scts(const struct sms_scts *in, unsigned char *pdu,if (in->second >59 )return FALSE; -if ((in->timezone >12 *4 -1 ) || (in->timezone < -(12 *4 -1 ))) +if ((in->timezone >12 *4 ) || (in->timezone < -(12 *4 -1 )))return FALSE; pdu = pdu + *offset;
src/stk.c +113 -0
125 lines not on this page · raw message
src/stkagent.c +153 -0
156 lines not on this page · raw message
src/stkagent.h +14 -0
@@ -59,6 +59,12 @@ typedef void (*stk_agent_string_cb)(enum stk_agent_result result,typedef void (*stk_agent_tone_cb )(enum stk_agent_result result,void *user_data); +typedef void (*stk_agent_time_cb )(enum stk_agent_result result, +unsigned char year,unsigned char month, +unsigned char day,unsigned char hour, +unsigned char minute,unsigned char second, +char timezone,void *user_data); +struct stk_agent *stk_agent_new (const char *path,const char *sender,ofono_bool_t remove_on_terminate);
@@ -136,3 +142,11 @@ int stk_agent_loop_tone(struct stk_agent *agent, const char *text,void append_menu_items_variant (DBusMessageIter *iter,const struct stk_menu_item *items); + +int stk_agent_request_time (struct stk_agent *agent,stk_agent_time_cb cb, +void *user_data,ofono_destroy_func destroy, +int timeout); + +int stk_agent_request_lang (struct stk_agent *agent,stk_agent_string_cb cb, +void *user_data,ofono_destroy_func destroy, +int timeout);
src/stkutil.c +1 -1
@@ -4553,7 +4553,7 @@ static gboolean build_dataobj_datetime_timezone(struct stk_tlv_builder *tlv,return TRUE;/* Time zone information is optional */ -if (scts->timezone == (gint8 )0xff ) { +if (scts->timezone ==-48 ) {memcpy (×tamp, scts,sizeof (timestamp)); timestamp.timezone =0 ;if (sms_encode_scts (×tamp, value, &offset) != TRUE)
Signature · 1 line
1.7.2.3
Re: [PATCH 2/3] stk: Handle provide local info proactive command
Quoted 26 lines · Yang Gu
---
src/smsutil.c | 6 +-
src/stk.c | 113 +++++++++++++++++++++++++++++++++++++++++src/stkagent.c| 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++src/stkagent.h| 14 +++++
src/stkutil.c | 2 +-5 files changed, 284 insertions(+), 4 deletions(-)src/smsutil.c +2
-2@@ -324,10 +324,10 @@ gboolean sms_encode_scts(const struct sms_scts *in, unsigned char *pdu, if (in->year > 99) return FALSE; - if (in->month > 12) + if (in->month > 12 || in->month == 0) return FALSE; - if (in->day > 31) + if (in->day > 31 || in->day == 0) return FALSE; if (in->hour > 23)
src/smsutil.c gboolean sms_encode_scts(const struct sms_scts *in, unsigned char *pdu, · line 342
Quoted 5 lines
src/smsutil.c +1
-1@@ -339,7 +339,7 @@ gboolean sms_encode_scts(const struct sms_scts *in, unsigned char *pdu, if (in->second > 59) return FALSE; - if ((in->timezone > 12*4-1) || (in->timezone < -(12*4-1))) + if ((in->timezone > 12*4) || (in->timezone < -(12*4-1)))
Please ignore my comment about the range in the other, because you already fixed this :)
Quoted 34 lines
src/smsutil.c +0
-0return FALSE; pdu = pdu + *offset;src/stk.c +23
-0@@ -1992,6 +1992,114 @@ static gboolean handle_command_refresh(const struct stk_command *cmd, return TRUE; } +static void request_time_cb (enum stk_agent_result result,unsigned char year, + unsigned char month, unsigned char day, + unsigned char hour, unsigned char minute, + unsigned char second, char timezone, + void *user_data) +{ + struct ofono_stk *stk = user_data; + static struct ofono_error error = { .type = OFONO_ERROR_TYPE_FAILURE }; + struct stk_response rsp; + + stk->respond_on_exit = FALSE; + + switch (result) { + case STK_AGENT_RESULT_OK: + memset(&rsp, 0, sizeof(rsp)); + + rsp.result.type = STK_RESULT_TYPE_SUCCESS; + rsp.provide_local_info.datetime.year = year; + rsp.provide_local_info.datetime.month = month; + rsp.provide_local_info.datetime.day = day; + rsp.provide_local_info.datetime.hour = hour; + rsp.provide_local_info.datetime.minute = minute; + rsp.provide_local_info.datetime.second = second;
src/stk.c static gboolean handle_command_refresh(const struct stk_command *cmd, · line 2027
Quoted 10 lines
src/stk.c +10
-0+ rsp.provide_local_info.datetime.timezone = timezone; + + if (stk_respond(stk, &rsp, stk_command_cb)) + stk_command_cb(&error, stk); + + break; + + case STK_AGENT_RESULT_BACK: + send_simple_response(stk, STK_RESULT_TYPE_GO_BACK); + break;
Note that "Backward move", "No reponse" and "User terminated" are not allowed responses for Provide Local Info in TS102.223 6.11.
Quoted 105 lines
src/stk.c +80
-0+ + case STK_AGENT_RESULT_TIMEOUT: + send_simple_response(stk, STK_RESULT_TYPE_NO_RESPONSE); + break; + + case STK_AGENT_RESULT_TERMINATE: + send_simple_response(stk, STK_RESULT_TYPE_USER_TERMINATED); + break; + } +} + +static void request_lang_cb (enum stk_agent_result result,char *lang, + void *user_data) +{ + struct ofono_stk *stk = user_data; + static struct ofono_error error = { .type = OFONO_ERROR_TYPE_FAILURE }; + struct stk_response rsp; + + stk->respond_on_exit = FALSE; + + switch (result) { + case STK_AGENT_RESULT_OK: + memset(&rsp, 0, sizeof(rsp)); + + rsp.result.type = STK_RESULT_TYPE_SUCCESS; + rsp.provide_local_info.language = lang; + + if (stk_respond(stk, &rsp, stk_command_cb)) + stk_command_cb(&error, stk); + + break; + + case STK_AGENT_RESULT_BACK: + send_simple_response(stk, STK_RESULT_TYPE_GO_BACK); + break; + + case STK_AGENT_RESULT_TIMEOUT: + send_simple_response(stk, STK_RESULT_TYPE_NO_RESPONSE); + break; + + case STK_AGENT_RESULT_TERMINATE: + send_simple_response(stk, STK_RESULT_TYPE_USER_TERMINATED); + break; + } +} + +static gboolean handle_command_provide_local_info (const struct stk_command *cmd, + struct stk_response *rsp, struct ofono_stk *stk) +{ + int timeout = stk->timeout * 1000; + int err; + + switch (cmd->qualifier) { + case 3: + DBG("Date, time and time zone"); + err = stk_agent_request_time(stk->current_agent, + request_time_cb, + stk, NULL, timeout); + return FALSE; + + case 4: + DBG("Language setting"); + err = stk_agent_request_lang(stk->current_agent, + request_lang_cb, + stk, NULL, timeout); + return FALSE; + + default: + ofono_info("Unsupported Provide Local Info qualifier: %d", + cmd->qualifier); + rsp->result.type = STK_RESULT_TYPE_NOT_CAPABLE; + return TRUE; + } +} + static void send_dtmf_cancel(struct ofono_stk *stk) { struct ofono_voicecall *vc = NULL;@@ -2424,6 +2532,11 @@ void ofono_stk_proactive_command_notify(struct ofono_stk *stk, &rsp, stk); break; + case STK_COMMAND_TYPE_PROVIDE_LOCAL_INFO: + respond = handle_command_provide_local_info(stk->pending_cmd, + &rsp, stk); + break; +case
STK_COMMAND_TYPE_SEND_DTMF:
respond =handle_command_send_dtmf(stk->pending_cmd, &rsp, stk);src/stkagent.c +7
-0@@ -956,3 +956,156 @@ int stk_agent_loop_tone(struct stk_agent *agent, const char *text, return 0; } + +static void get_time_cb (DBusPendingCall *call,void *data) +{ + struct stk_agent *agent = data; + stk_agent_time_cb cb = agent->user_cb; + DBusMessage *reply = dbus_pending_call_steal_reply(call); + enum stk_agent_result result;
src/stkagent.c int stk_agent_loop_tone(struct stk_agent *agent, const char *text, · line 975
Quoted 10 lines
src/stkagent.c +10
-0+ gboolean remove_agent; + int year_dbus; + unsigned char year; + unsigned char month; + unsigned char day; + unsigned char hour; + unsigned char minute; + unsigned char second; + int timezone_dbus; + char timezone;
I think you need to use "signed char" to achieve the same type as int8_t/guin8 because the sign of "char" depends on the ABI.
src/stkagent.c int stk_agent_loop_tone(struct stk_agent *agent, const char *text, · line 979
Quoted 4 lines
src/stkagent.c +4
-0+ + if (check_error(agent, reply, + ALLOWED_ERROR_GO_BACK | ALLOWED_ERROR_TERMINATE, + &result) == -EINVAL) {
Go back and Terminate are not allowed for this command. (same comment as above)
Quoted 18 lines
src/stkagent.c +18
-0+ remove_agent = TRUE; + goto error; + } + + if (result != STK_AGENT_RESULT_OK) { + cb(result, 0, 0, 0, 0, 0, 0, 0xFF, agent->user_data); + goto done; + } + + if (dbus_message_get_args(reply, NULL, + DBUS_TYPE_INT32, &year_dbus, + DBUS_TYPE_BYTE, &month, + DBUS_TYPE_BYTE, &day, + DBUS_TYPE_BYTE, &hour, + DBUS_TYPE_BYTE, &minute, + DBUS_TYPE_BYTE, &second, + DBUS_TYPE_INT32, &timezone_dbus, + DBUS_TYPE_INVALID) == FALSE) {
src/stkagent.c int stk_agent_loop_tone(struct stk_agent *agent, const char *text, · line 1007
Quoted 10 lines
src/stkagent.c +10
-0+ ofono_error("Can't parse the reply to RequestTime()"); + remove_agent = TRUE; + goto error; + } + + if (year_dbus < 1900) { + ofono_error("Invalid year"); + remove_agent = TRUE; + goto error; + }
I believe the range is actually 1970-2069 or similar (only values 0-99 in the sms header are allowed)
Quoted 138 lines
src/stkagent.c +104
-0+ + if (year_dbus >= 2000) + year = year_dbus - 2000; + else + year = year_dbus - 1900; + + timezone = timezone_dbus; + + cb(result, year, month, day, hour, minute, second, timezone, + agent->user_data); + + CALLBACK_END(); +} + +int stk_agent_request_time (struct stk_agent *agent,stk_agent_time_cb cb, + void *user_data, ofono_destroy_func destroy, + int timeout) +{ + DBusConnection *conn = ofono_dbus_get_connection(); + + agent->msg = dbus_message_new_method_call(agent->bus, agent->path, + OFONO_SIM_APP_INTERFACE, + "RequestTime"); + if (agent->msg == NULL) + return -ENOMEM; + + dbus_message_append_args(agent->msg, DBUS_TYPE_INVALID); + + if (dbus_connection_send_with_reply(conn, agent->msg, &agent->call, + timeout) == FALSE || + agent->call == NULL) + return -EIO; + + agent->user_cb = cb; + agent->user_data = user_data; + agent->user_destroy = destroy; + + dbus_pending_call_set_notify(agent->call, get_time_cb, agent, NULL); + + return 0; +} + +static void get_lang_cb (DBusPendingCall *call,void *data) +{ + struct stk_agent *agent = data; + stk_agent_string_cb cb = agent->user_cb; + DBusMessage *reply = dbus_pending_call_steal_reply(call); + enum stk_agent_result result; + gboolean remove_agent; + char *lang; + + if (check_error(agent, reply, + ALLOWED_ERROR_GO_BACK | ALLOWED_ERROR_TERMINATE, + &result) == -EINVAL) { + remove_agent = TRUE; + goto error; + } + + if (result != STK_AGENT_RESULT_OK) { + cb(result, NULL, agent->user_data); + goto done; + } + + if (dbus_message_get_args(reply, NULL, + DBUS_TYPE_STRING, &lang, + DBUS_TYPE_INVALID) == FALSE || + strlen(lang) != 2) { + ofono_error("Can't parse the reply to RequestLanguage()"); + remove_agent = TRUE; + goto error; + } + + cb(result, lang, agent->user_data); + + CALLBACK_END(); +} + +int stk_agent_request_lang (struct stk_agent *agent,stk_agent_string_cb cb, + void *user_data, ofono_destroy_func destroy, + int timeout) +{ + DBusConnection *conn = ofono_dbus_get_connection(); + + agent->msg = dbus_message_new_method_call(agent->bus, agent->path, + OFONO_SIM_APP_INTERFACE, + "RequestLanguage"); + if (agent->msg == NULL) + return -ENOMEM; + + dbus_message_append_args(agent->msg, DBUS_TYPE_INVALID); + + if (dbus_connection_send_with_reply(conn, agent->msg, &agent->call, + timeout) == FALSE || + agent->call == NULL) + return -EIO; + + agent->user_cb = cb; + agent->user_data = user_data; + agent->user_destroy = destroy; + + dbus_pending_call_set_notify(agent->call, get_lang_cb, agent, NULL); + + return 0; +}src/stkagent.h +14
-0@@ -59,6 +59,12 @@ typedef void (*stk_agent_string_cb)(enum stk_agent_result result, typedef void (*stk_agent_tone_cb)(enum stk_agent_result result, void *user_data); +typedef void (*stk_agent_time_cb )(enum stk_agent_result result, + unsigned char year, unsigned char month, + unsigned char day, unsigned char hour, + unsigned char minute, unsigned char second, + char timezone, void *user_data); + struct stk_agent *stk_agent_new(const char *path, const char *sender, ofono_bool_t remove_on_terminate);@@ -136,3 +142,11 @@ int stk_agent_loop_tone(struct stk_agent *agent, const char *text, void append_menu_items_variant(DBusMessageIter *iter, const struct stk_menu_item *items); + +int stk_agent_request_time (struct stk_agent *agent,stk_agent_time_cb cb, + void *user_data, ofono_destroy_func destroy, + int timeout); + +int stk_agent_request_lang (struct stk_agent *agent,stk_agent_string_cb cb, + void *user_data, ofono_destroy_func destroy, + int timeout);src/stkutil.c +0
-0
src/stkutil.c static gboolean build_dataobj_datetime_timezone(struct stk_tlv_builder *tlv, · line 4556
Quoted 5 lines
src/stkutil.c +1
-1@@ -4553,7 +4553,7 @@ static gboolean build_dataobj_datetime_timezone(struct stk_tlv_builder *tlv, return TRUE; /* Time zone information is optional */ - if (scts->timezone == (gint8) 0xff) { + if (scts->timezone == -48) {
Ah, -48 is also a good value :)
But wouldn't the parser also need to translate 0xff into -48?
Best regards
Re: [PATCH 2/3] stk: Handle provide local info proactive command
In reply to Yang GuHi Yang,
Quoted 2 lines · Yang Gu
--- src/smsutil.c | 6 +-
Please send patches against smsutil separately.
Quoted 4 lines
src/stk.c | 113 +++++++++++++++++++++++++++++++++++++++++ src/stkagent.c | 153 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/stkagent.h | 14 +++++ src/stkutil.c | 2 +-
Same goes for stkutil
Quoted 20 lines
5 files changed, 284 insertions(+), 4 deletions(-)src/smsutil.c +2
-2@@ -324,10 +324,10 @@ gboolean sms_encode_scts(const struct sms_scts *in, unsigned char *pdu,if (in->year >99 )return FALSE; -if (in->month >12 ) +if (in->month >12 || in->month ==0 )return FALSE; -if (in->day >31 ) +if (in->day >31 || in->day ==0 )return FALSE;if (in->hour >23 )
src/smsutil.c gboolean sms_encode_scts(const struct sms_scts *in, unsigned char *pdu, · line 342
Quoted 5 lines
src/smsutil.c +1
-1@@ -339,7 +339,7 @@ gboolean sms_encode_scts(const struct sms_scts *in, unsigned char *pdu,if (in->second >59 )return FALSE; -if ((in->timezone >12 *4 -1 ) || (in->timezone < -(12 *4 -1 ))) +if ((in->timezone >12 *4 ) || (in->timezone < -(12 *4 -1 )))
Err, why would +48 be valid?
<snip>
src/stkagent.c int stk_agent_loop_tone(struct stk_agent *agent, const char *text, · line 961
Quoted 11 lines
src/stkagent.c +3
-0@@ -956,3 +956,156 @@ int stk_agent_loop_tone(struct stk_agent *agent, const char *text,return 0 ; } +int stk_agent_request_time (struct stk_agent *agent,stk_agent_time_cb cb, +void *user_data,ofono_destroy_func destroy, +int timeout)
So I really don't think we need an agent for this one. Just having oFono grab the time and return the info should be enough.
<snip>
src/stkagent.c int stk_agent_loop_tone(struct stk_agent *agent, const char *text, · line 1088
Quoted 4 lines
src/stkagent.c +4
-0+int stk_agent_request_lang (struct stk_agent *agent,stk_agent_string_cb cb, +void *user_data,ofono_destroy_func destroy, +int timeout) +{
I'm not an expert on i18n, but this seems to be something oFono can handle internally. Perhaps querying the LANG environment variable or something?
<snip>
src/stkutil.c static gboolean build_dataobj_datetime_timezone(struct stk_tlv_builder *tlv, · line 4559
Quoted 13 lines
src/stkutil.c +1
-1@@ -4553,7 +4553,7 @@ static gboolean build_dataobj_datetime_timezone(struct stk_tlv_builder *tlv,return TRUE;/* Time zone information is optional */ -if (scts->timezone == (gint8 )0xff ) { +if (scts->timezone ==-48 ) {memcpy (×tamp, scts,sizeof (timestamp)); timestamp.timezone =0 ;if (sms_encode_scts (×tamp, value, &offset) != TRUE)
As mentioned previously, my vote is for has_tz here.
Regards,
-Denis
Gu
RE: [PATCH 2/3] stk: Handle provide local info proactive command
Hi Denis,
Quoted 20 lines
src/smsutil.c gboolean sms_encode_scts(const struct sms_scts *in,
Quoted 5 lines
src/smsutil.c +0
-0@@ -324,10 +324,10 @@ gboolean sms_encode_scts(const struct sms_scts *in,unsigned char *pdu,
src/smsutil.c gboolean sms_encode_scts(const struct sms_scts *in,
Quoted 13 lines
src/smsutil.c +2
-2if (in->year >99 )return FALSE; -if (in->month >12 ) +if (in->month >12 || in->month ==0 )return FALSE; -if (in->day >31 ) +if (in->day >31 || in->day ==0 )return FALSE;if (in->hour >23 )@@ -339,7 +339,7 @@ gboolean sms_encode_scts(const struct sms_scts *in,unsigned char *pdu,
Quoted 7 lines
src/smsutil.c gboolean sms_encode_scts(const struct sms_scts *in, unsigned char *pdu, · line 342
Quoted 5 lines
src/smsutil.c +1
-1if (in->second >59 )return FALSE; -if ((in->timezone >12 *4 -1 ) || (in->timezone < -(12 *4 -1 ))) +if ((in->timezone >12 *4 ) || (in->timezone < -(12 *4 -1 )))Err, why would +48 be valid?
I think all the timezone should be a circle (24 hours). If it can't be -48, it needs to contain +48.
Also please see 9.2.6.9 in http://gsm-history.org/fileadmin/user_upload/Key_SMS_Documents/GSM_Rec_03.40_v_2.2.0.pdf, which says "The Time Zone may be a number in the range -47 to +48".
Regards,
-Yang
Re: [PATCH 2/3] stk: Handle provide local info proactive command
Hi Yang,
Quoted 25 lines · Yang
Hi Denis,
Quoted 23 lines
src/smsutil.c gboolean sms_encode_scts(const struct sms_scts *in,
Quoted 5 lines
src/smsutil.c +0
-0@@ -324,10 +324,10 @@ gboolean sms_encode_scts(const struct sms_scts *in,unsigned char *pdu,
src/smsutil.c gboolean sms_encode_scts(const struct sms_scts *in,
Quoted 13 lines
src/smsutil.c +2
-2if (in->year >99 )return FALSE; -if (in->month >12 ) +if (in->month >12 || in->month ==0 )return FALSE; -if (in->day >31 ) +if (in->day >31 || in->day ==0 )return FALSE;if (in->hour >23 )@@ -339,7 +339,7 @@ gboolean sms_encode_scts(const struct sms_scts *in,unsigned char *pdu,
Quoted 3 lines
src/smsutil.c +0
-0if (in->second >59 )return FALSE;
Quoted 8 lines
Quoted 4 lines
src/smsutil.c gboolean sms_encode_scts(const struct sms_scts *in, unsigned char *pdu, · line 342
Quoted 2 lines
src/smsutil.c +1
-1-if ((in->timezone >12 *4 -1 ) || (in->timezone < -(12 *4 -1 ))) +if ((in->timezone >12 *4 ) || (in->timezone < -(12 *4 -1 )))Err, why would +48 be valid?
I think all the timezone should be a circle (24 hours). If it can't be -48, it needs to contain +48.
Also please see 9.2.6.9 in http://gsm-history.org/fileadmin/user_upload/Key_SMS_Documents/GSM_Rec_03.40_v_2.2.0.pdf, which says "The Time Zone may be a number in the range -47 to +48".
Ok, fair enough. Though do note that the timezone field must account for daylight savings time. So in theory GMT+14 and GMT-12 are valid timezone values as well. See
http://en.wikipedia.org/wiki/List_of_time_zones_by_UTC_offset
Regards,
-Denis
PATCH 3/3 test-stk: Add provide local info
In reply to Yang Gu--- test/test-stk-menu | 36 ++++++++++++++++++++++++++++++++++++ 1 files changed, 36 insertions(+), 0 deletions(-)
test/test-stk-menu +36 -0
@@ -134,6 +134,42 @@ class StkAgent(dbus.service.Object): return False @dbus.service.method("org.ofono.SimToolkitAgent", + in_signature="", out_signature="iyyyyyi") + def RequestTime(self): + print "Time should be in format: year, month, day, hour, minute, second[, timezone]" + userin = raw_input("Enter Time (t, b, time):") + + if userin == 'b': + raise GoBack("User wishes to go back"); + elif userin == 't': + raise EndSession("User wishes to terminate session"); + else: + time = userin.split(',') + + if len(time) != 6 and len(time) != 7: + raise GoBack("The input time is invalid"); + + if len(time) == 6: + timezone = -48; + else: + timezone = int(time[6]) + + return int(time[0]), int(time[1]), int(time[2]), int(time[3]), int(time[4]), int(time[5]), timezone + + @dbus.service.method("org.ofono.SimToolkitAgent", + in_signature="", out_signature="s") + def RequestLanguage(self): + print "Follow ISO 639-1 to input language, that is, a pair of alpha-numeric characters" + userin = raw_input("Enter Language (t, b):") + + if userin == 'b': + raise GoBack("User wishes to go back"); + elif userin == 't': + raise EndSession("User wishes to terminate session"); + else: + return userin + + @dbus.service.method("org.ofono.SimToolkitAgent", in_signature="", out_signature="") def Cancel(self): print "Cancel"
Signature · 1 line
1.7.2.3
Hi Yang,
Quoted 2 lines · Yang Gu
This series of patch is to add provide local info support by requesting the terminal to send time and language info. Please comment on the following aspects as I'm not sure after reading the spec:
1. Timezone may be a number in the range -47 through +48. In structsms_scts, timezone is defined as gint8, thus0xFFshould shand for -1, which is a valid input. Thus I thinkbuild_dataobj_datetime_timezone()insrc/stkutil.cis not correct. But I'm still not sure what value should be passed to oFono when timezone is absent.
I think you're right that build_dataobj_datetime_timezone() is wrong. Also note that sms_decode_scts() and sms_encode_scts() only allow the range -47 to 47, 48 would return an error. I'm not sure what the unknown time zone should be represented as, here are some options:
* 0 (same as no offset)
* 0xff because there's currently no GMT-00:15 time zone on earth
(http://en.wikipedia.org/wiki/List_of_time_zones_by_country)
* 0x80 (a currently unused value could be #defined as unknown time zone)
* the struct could be extended with a .has_tz boolean.
Quoted 1 line
2.
DBUS_TYPE_BYTErepresents an 8-bit unsigned integer, and D-Bus doesn't have a type related to 8-bit signed integer. So what's the best way to represent a timezone?
Maybe instead of asking D-bus, ofono should use tzset() to retrieve the time zone information and use localtime() for the other fields?
Quoted 5 lines
3. Only one byte is used to represent the year. Is the following logic correct to get the year with one byte? if (
year_dbus>= 2000)
year =year_dbus- 2000;
else
year =year_dbus- 1900;
I believe this is correct.
Best regards
Gu
Hi Andrew,
Quoted 23 lines
-----Original Message-----
From: ofono-bounces(a)ofono.org [mailto:ofono-bounces(a)ofono.org] On Behalf Of andrzej zaborowski
Sent: Friday, November 26, 2010 7:26 AM
To: ofono(a)ofono.org
Subject: Re: [PATCH 0/3] Patch DescriptionHi Yang,
Quoted 1 line · Yang Gu
This series of patch is to add provide local info support by requesting the terminal to
send time and language info. Please comment on the following aspects as I'm not sure after reading the spec:
Quoted 1 line
1. Timezone may be a number in the range -47 through +48. In struct
sms_scts,timezone is defined as gint8, thus
0xFFshould shand for -1, which is a valid input. Thus I thinkbuild_dataobj_datetime_timezone()insrc/stkutil.cis not correct. But I'm still not sure what value should be passed to oFono when timezone is absent.I think you're right that
build_dataobj_datetime_timezone()is wrong. Also note thatsms_decode_scts()andsms_encode_scts()only allow the range -47 to 47, 48 would return an error. I'm not sure what the unknown time zone should be represented as, here are some options:
Quoted 5 lines
* 0 (same as no offset)
*0xffbecause there's currently no GMT-00:15 time zone on earth
(http://en.wikipedia.org/wiki/List_of_time_zones_by_country)
*0x80(a currently unused value could be #defined as unknown time zone)
* the struct could be extended with a .has_tz boolean.
Personally I'd prefer has_tz Boolean, which is consistent with other structs.
Quoted 7 lines
Quoted 2 lines
2.
DBUS_TYPE_BYTErepresents an 8-bit unsigned integer, and D-Bus doesn'thave a type related to 8-bit signed integer. So what's the best way to represent a timezone?
Maybe instead of asking D-bus, ofono should use
tzset()to retrieve the time zone information and uselocaltime()for the other fields?
If we don't need to ask D-Bus, we'd not bother defining the situation when timezone is absent. Denis, what's the requirement here? Andrew, thanks for the comments in the other mail thread. I accept them all, but I will modify the patch until we're clear on this requirement.
Regards,
-Yang
Hi Andrew,
Quoted 11 lines · andrzej zaborowski
Hi Yang,
Quoted 2 lines · Yang Gu
This series of patch is to add provide local info support by requesting the terminal to send time and language info. Please comment on the following aspects as I'm not sure after reading the spec:
1. Timezone may be a number in the range -47 through +48. In structsms_scts, timezone is defined as gint8, thus0xFFshould shand for -1, which is a valid input. Thus I thinkbuild_dataobj_datetime_timezone()insrc/stkutil.cis not correct. But I'm still not sure what value should be passed to oFono when timezone is absent.I think you're right that
build_dataobj_datetime_timezone()is wrong. Also note thatsms_decode_scts()andsms_encode_scts()only allow the range -47 to 47, 48 would return an error. I'm not sure what the unknown time zone should be represented as, here are some options:
Quoted 5 lines
* 0 (same as no offset)
*0xffbecause there's currently no GMT-00:15 time zone on earth
(http://en.wikipedia.org/wiki/List_of_time_zones_by_country)
*0x80(a currently unused value could be #defined as unknown time zone)
* the struct could be extended with a .has_tz boolean.
The has_tz variable gets my vote. The rest looks ugly, and I don't really see +48 as a valid value.
Quoted 5 lines
Quoted 2 lines
2.
DBUS_TYPE_BYTErepresents an 8-bit unsigned integer, and D-Bus doesn't have a type related to 8-bit signed integer. So what's the best way to represent a timezone?Maybe instead of asking D-bus, ofono should use
tzset()to retrieve the time zone information and uselocaltime()for the other fields?
That is my preference as well. Perhaps one can use the tm_gmtoff value from struct tm to figure out the timezone. See sms_scts_to_time for more details.
Regards,
-Denis