+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(-)
diff --git a/plugins/xmm7xxx.c b/plugins/xmm7xxx.c
index 32c024e..f62a093 100644
--- a/plugins/xmm7xxx.c
+++ b/plugins/xmm7xxx.c
@@ -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);
--
1.9.1
_______________________________________________
ofono mailing list -- [email protected]
To unsubscribe send an email to [email protected]