summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2009-06-15 15:45:52 -0500
committerDenis Kenzior <denkenz@gmail.com>2009-06-16 16:38:15 -0500
commitac4aeac3d633cfec448d4646cb9a1d332e0fdc8f (patch)
treeff06fd813f63270dc2fda3b04a3b53481b94785f
parent8241c3f025babbe3ce6267d52644fee3f3642c6b (diff)
downloadofono-ac4aeac3d633cfec448d4646cb9a1d332e0fdc8f.tar.bz2
Rework CMGR as an unsolicited notification
Since the PDU line doesn't have a prefix, the parser can get confused if other unsolicited notifications arrive. There is already explicit support for unsolicited notifications with PDU, so we use that instead
-rw-r--r--drivers/atmodem/sms.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/atmodem/sms.c b/drivers/atmodem/sms.c
index b84f4d18..f5eccea6 100644
--- a/drivers/atmodem/sms.c
+++ b/drivers/atmodem/sms.c
@@ -298,7 +298,7 @@ static void at_cmt_notify(GAtResult *result, gpointer user_data)
g_at_chat_send(at->parser, buf, none_prefix, at_cnma_cb, NULL, NULL);
}
-static void at_cmgr_cb(gboolean ok, GAtResult *result, gpointer user_data)
+static void at_cmgr_notify(GAtResult *result, gpointer user_data)
{
struct ofono_modem *modem = user_data;
GAtResultIter iter;
@@ -307,12 +307,7 @@ static void at_cmgr_cb(gboolean ok, GAtResult *result, gpointer user_data)
long pdu_len;
int tpdu_len;
- dump_response("at_cmgr_cb", ok, result);
-
- if (!ok) {
- ofono_error("Received a CMTI indication but CMGR failed!");
- return;
- }
+ dump_response("at_cmgr_notify", TRUE, result);
g_at_result_iter_init(&iter, result);
@@ -328,10 +323,7 @@ static void at_cmgr_cb(gboolean ok, GAtResult *result, gpointer user_data)
if (!g_at_result_iter_next_number(&iter, &tpdu_len))
goto err;
- if (!g_at_result_iter_next(&iter, NULL))
- goto err;
-
- hexpdu = g_at_result_iter_raw_line(&iter);
+ hexpdu = g_at_result_pdu(result);
ofono_debug("Got PDU: %s, with len: %d", hexpdu, tpdu_len);
@@ -343,6 +335,12 @@ err:
ofono_error("Unable to parse CMGR response");
}
+static void at_cmgr_cb(gboolean ok, GAtResult *result, gpointer user_data)
+{
+ if (!ok)
+ ofono_error("Received a CMTI indication but CMGR failed!");
+}
+
static void at_cmgd_cb(gboolean ok, GAtResult *result, gpointer user_data)
{
if (!ok)
@@ -377,8 +375,7 @@ static void at_cmti_notify(GAtResult *result, gpointer user_data)
sprintf(buf, "AT+CMGR=%d", index);
- /* Can't use a prefix here since a PDU is expected on the next line */
- g_at_chat_send(at->parser, buf, NULL, at_cmgr_cb, modem, NULL);
+ g_at_chat_send(at->parser, buf, none_prefix, at_cmgr_cb, modem, NULL);
sprintf(buf, "AT+CMGD=%d", index);
@@ -404,6 +401,10 @@ static void at_sms_initialized(struct ofono_modem *modem)
g_at_chat_register(at->parser, "+CBM:", at_cbm_notify, TRUE,
modem, NULL);
+ /* We treat CMGR just like a notification */
+ g_at_chat_register(at->parser, "+CMGR:", at_cmgr_notify, TRUE,
+ modem, NULL);
+
ofono_sms_manager_register(modem, &ops);
}