xmm7xxx: handling of sms ready state for xmm7xxx plugin
PATCH 1/1 xmm7xxx: handling of sms ready state for xmm7xxx plugin
+XSIM:7 state as defined in xmm7560 functional AT specification only indicates ready for attach. PB ready and SMS ready has to be quired seperately using +XSIMSTATE command after +XSIM:12 state is received indicating SIM SMS Caching Completed. (Sent only when SMS caching enabled). +XSIM:12 may or may not be received so moving the sms ready and pb ready logic to post sim function afteR receiving +CPIN:READY
--- plugins/xmm7xxx.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 11 deletions(-)
plugins/xmm7xxx.c +61 -11
@@ -106,7 +106,8 @@ struct xmm7xxx_data {GAtChat *chat;/* AT chat */ struct ofono_sim *sim;ofono_bool_t have_sim; -ofono_bool_t sms_phonebook_added; +ofono_bool_t phonebook_added; +ofono_bool_t sms_added;unsigned int netreg_watch; };
@@ -968,6 +969,59 @@ static GAtChat *open_device(struct ofono_modem *modem, NULL); } +static void xsimstate_sms_ready_query_cb (gboolean ok,GAtResult *result, +gpointer user_data) +{ +struct ofono_modem *modem = user_data; +struct xmm7xxx_data *data =ofono_modem_get_data (modem); +int sms_ready, pb_ready; +GAtResultIter iter; + +DBG ("%p" , modem); + +if (!ok) +return ; + +g_at_result_iter_init (&iter, result); + +if (!g_at_result_iter_next (&iter,"+XSIMSTATE:" )) +return ; + +if (!g_at_result_iter_skip_next (&iter)) +return ; + +if (!g_at_result_iter_skip_next (&iter)) +return ; + +if (!g_at_result_iter_next_number (&iter, &pb_ready)) +return ; + +if (!g_at_result_iter_next_number (&iter, &sms_ready)) +return ; + +DBG ("sms_ready=%d\n" , sms_ready); + +DBG ("data->sms_added=%d\n" , data->sms_added); + +if (pb_ready && data->phonebook_added == FALSE) { +ofono_phonebook_create (modem,0 ,"atmodem" , data->chat); + data->phonebook_added = TRUE; + } + +if (sms_ready && data->sms_added == FALSE) { +ofono_sms_create (modem,0 ,"atmodem" , data->chat); + data->sms_added = TRUE; + } +} + +static void xmm7xxx_get_sms_ready_state (struct ofono_modem *modem) +{ +struct xmm7xxx_data *data =ofono_modem_get_data (modem); + +g_at_chat_send (data->chat,"AT+XSIMSTATE?" , xsimstate_prefix, + xsimstate_sms_ready_query_cb, modem,NULL ); +} +static void switch_sim_state_status (struct ofono_modem *modem,int status) {struct xmm7xxx_data *data =ofono_modem_get_data (modem);
@@ -980,7 +1034,8 @@ static void switch_sim_state_status(struct ofono_modem *modem, int status)if (data->have_sim == TRUE) {ofono_sim_inserted_notify (data->sim, FALSE); data->have_sim = FALSE; - data->sms_phonebook_added = FALSE; + data->phonebook_added = FALSE; + data->sms_added = FALSE; }break ;case 1 :/* SIM inserted, PIN verification needed */
@@ -991,20 +1046,13 @@ static void switch_sim_state_status(struct ofono_modem *modem, int status)break ;case 2 :/* SIM inserted, PIN verification not needed - READY */ case 3 :/* SIM inserted, PIN verified - READY */ -case 7 :/* SIM inserted, SMS and phonebook - READY */ +case 7 :/* SIM inserted, READY for ATTACH - READY */ if (data->have_sim == FALSE) {ofono_sim_inserted_notify (data->sim, TRUE); data->have_sim = TRUE; }ofono_sim_initialized_notify (data->sim); - -if (data->sms_phonebook_added == FALSE) { -ofono_phonebook_create (modem,0 ,"atmodem" , data->chat); -ofono_sms_create (modem,0 ,"atmodem" , data->chat); - data->sms_phonebook_added = TRUE; - } -break ;default :ofono_warn ("Unknown SIM state %d received" , status);
@@ -1083,7 +1131,8 @@ static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)g_at_chat_send (data->chat,"AT&C0" ,NULL ,NULL ,NULL ,NULL ); data->have_sim = FALSE; - data->sms_phonebook_added = FALSE; + data->phonebook_added = FALSE; + data->sms_added = FALSE;ofono_modem_set_powered (modem, TRUE);
@@ -1225,6 +1274,7 @@ static void xmm7xxx_post_sim(struct ofono_modem *modem) {struct xmm7xxx_data *data =ofono_modem_get_data (modem); +xmm7xxx_get_sms_ready_state (modem);ofono_lte_create (modem,0 ,"atmodem" , data->chat);ofono_radio_settings_create (modem,0 ,"xmm7modem" , data->chat);ofono_sim_auth_create (modem);
Signature · 1 line
1.9.1
Hi Antara,
Quoted 1 line · Antara Borwankar
+XSIM:7 state as defined in xmm7560 functional AT specification
Is this different compared to earlier models?
Quoted 2 lines
only indicates ready for attach. PB ready and SMS ready has to be quired seperately using +XSIMSTATE command after +XSIM:12 state
typos? queried and separately?
Quoted 61 lines
is received indicating SIM SMS Caching Completed. (Sent only when SMS caching enabled). +XSIM:12 may or may not be received so moving the sms ready and pb ready logic to post sim function afteR receiving
(quoted diff) +1
-1+CPIN:READY --- plugins/xmm7xxx.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 61 insertions(+), 11 deletions(-)plugins/xmm7xxx.c +37
-1@@ -106,7 +106,8 @@ struct xmm7xxx_data {GAtChat *chat;/* AT chat */ struct ofono_sim *sim;ofono_bool_t have_sim; -ofono_bool_t sms_phonebook_added; +ofono_bool_t phonebook_added; +ofono_bool_t sms_added;unsigned int netreg_watch; };@@ -968,6 +969,59 @@ static GAtChat *open_device(struct ofono_modem *modem, NULL); } +static void xsimstate_sms_ready_query_cb (gboolean ok,GAtResult *result, +gpointer user_data) +{ +struct ofono_modem *modem = user_data; +struct xmm7xxx_data *data =ofono_modem_get_data (modem); +int sms_ready, pb_ready; +GAtResultIter iter; + +DBG ("%p" , modem); + +if (!ok) +return ; + +g_at_result_iter_init (&iter, result); + +if (!g_at_result_iter_next (&iter,"+XSIMSTATE:" )) +return ; + +if (!g_at_result_iter_skip_next (&iter)) +return ; + +if (!g_at_result_iter_skip_next (&iter)) +return ; + +if (!g_at_result_iter_next_number (&iter, &pb_ready)) +return ; + +if (!g_at_result_iter_next_number (&iter, &sms_ready)) +return ; + +DBG ("sms_ready=%d\n" , sms_ready); + +DBG ("data->sms_added=%d\n" , data->sms_added); + +if (pb_ready && data->phonebook_added == FALSE) {
plugins/xmm7xxx.c static GAtChat *open_device(struct ofono_modem *modem, · line 1016
Quoted 10 lines
plugins/xmm7xxx.c +10
-0+ofono_phonebook_create (modem,0 ,"atmodem" , data->chat); + data->phonebook_added = TRUE; + } + +if (sms_ready && data->sms_added == FALSE) { +ofono_sms_create (modem,0 ,"atmodem" , data->chat); + data->sms_added = TRUE; + } +} +
Ok, but it seems to me like this needs to be polled? What if the initial query fails to report sms or phonebook as ready?
Can you use +PBREADY and whatever the SMS equivalent is instead?
Quoted 30 lines
plugins/xmm7xxx.c +11
-2+static void xmm7xxx_get_sms_ready_state (struct ofono_modem *modem) +{ +struct xmm7xxx_data *data =ofono_modem_get_data (modem); + +g_at_chat_send (data->chat,"AT+XSIMSTATE?" , xsimstate_prefix, + xsimstate_sms_ready_query_cb, modem,NULL ); +} +static void switch_sim_state_status (struct ofono_modem *modem,int status) {struct xmm7xxx_data *data =ofono_modem_get_data (modem);@@ -980,7 +1034,8 @@ static void switch_sim_state_status(struct ofono_modem *modem, int status)if (data->have_sim == TRUE) {ofono_sim_inserted_notify (data->sim, FALSE); data->have_sim = FALSE; - data->sms_phonebook_added = FALSE; + data->phonebook_added = FALSE; + data->sms_added = FALSE; }break ;case 1 :/* SIM inserted, PIN verification needed */ @@ -991,20 +1046,13 @@ static void switch_sim_state_status(struct ofono_modem *modem, int status)break ;case 2 :/* SIM inserted, PIN verification not needed - READY */ case 3 :/* SIM inserted, PIN verified - READY */ -case 7 :/* SIM inserted, SMS and phonebook - READY */ +case 7 :/* SIM inserted, READY for ATTACH - READY */ if (data->have_sim == FALSE) {ofono_sim_inserted_notify (data->sim, TRUE); data->have_sim = TRUE;
plugins/xmm7xxx.c static void switch_sim_state_status(struct ofono_modem *modem, int status) · line 1007
Quoted 10 lines
plugins/xmm7xxx.c +0
-7}ofono_sim_initialized_notify (data->sim); - -if (data->sms_phonebook_added == FALSE) { -ofono_phonebook_create (modem,0 ,"atmodem" , data->chat); -ofono_sms_create (modem,0 ,"atmodem" , data->chat); - data->sms_phonebook_added = TRUE; - } -
If you can't use +PBREADY / SMS equivalent, can you kick off the XSIMSTATE query/polling here...?
Quoted 14 lines
plugins/xmm7xxx.c +2
-1break ;default :ofono_warn ("Unknown SIM state %d received" , status);@@ -1083,7 +1131,8 @@ static void cfun_enable_cb(gboolean ok, GAtResult *result, gpointer user_data)g_at_chat_send (data->chat,"AT&C0" ,NULL ,NULL ,NULL ,NULL ); data->have_sim = FALSE; - data->sms_phonebook_added = FALSE; + data->phonebook_added = FALSE; + data->sms_added = FALSE;ofono_modem_set_powered (modem, TRUE);
plugins/xmm7xxx.c static void xmm7xxx_post_sim(struct ofono_modem *modem) · line 1277
Quoted 4 lines
plugins/xmm7xxx.c +1
-0@@ -1225,6 +1274,7 @@ static void xmm7xxx_post_sim(struct ofono_modem *modem) {struct xmm7xxx_data *data =ofono_modem_get_data (modem); +xmm7xxx_get_sms_ready_state (modem);
... because .pre_sim, .post_sim, .post_online hooks are only for atom creation.
plugins/xmm7xxx.c static void xmm7xxx_post_sim(struct ofono_modem *modem) · line 1280
Quoted 4 lines
plugins/xmm7xxx.c +0
-0ofono_lte_create (modem,0 ,"atmodem" , data->chat);ofono_radio_settings_create (modem,0 ,"xmm7modem" , data->chat);ofono_sim_auth_create (modem);
Regards,
-Denis