From d8e7a7b5e310ac0663ef163e2d95e44a11a5c621 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Thu, 10 Jun 2010 20:13:50 -0500 Subject: [PATCH] atmodem: Add support for status report via CDSI --- drivers/atmodem/sms.c | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/drivers/atmodem/sms.c b/drivers/atmodem/sms.c index 89afa3c6..7b2c08c3 100644 --- a/drivers/atmodem/sms.c +++ b/drivers/atmodem/sms.c @@ -348,6 +348,7 @@ static void at_cmt_notify(GAtResult *result, gpointer user_data) static void at_cmgr_notify(GAtResult *result, gpointer user_data) { struct ofono_sms *sms = user_data; + struct sms_data *data = ofono_sms_get_data(sms); GAtResultIter iter; const char *hexpdu; unsigned char pdu[176]; @@ -376,7 +377,11 @@ static void at_cmgr_notify(GAtResult *result, gpointer user_data) DBG("Got PDU: %s, with len: %d", hexpdu, tpdu_len); decode_hex_own_buf(hexpdu, -1, &pdu_len, 0, pdu); - ofono_sms_deliver_notify(sms, pdu, pdu_len, tpdu_len); + + if (data->store == AT_UTIL_SMS_STORE_SR) + ofono_sms_status_notify(sms, pdu, pdu_len, tpdu_len); + else + ofono_sms_deliver_notify(sms, pdu, pdu_len, tpdu_len); return; err: @@ -403,7 +408,7 @@ static void at_cmgr_cpms_cb(gboolean ok, GAtResult *result, gpointer user_data) char buf[128]; if (!ok) { - ofono_error("Received CMTI, but CPMS request failed"); + ofono_error("Received CMTI/CDSI, but CPMS request failed"); return; } @@ -467,6 +472,27 @@ error: ofono_error("Unable to parse CMTI notification"); } +static void at_cdsi_notify(GAtResult *result, gpointer user_data) +{ + struct ofono_sms *sms = user_data; + enum at_util_sms_store store; + int index; + + if (at_util_parse_sms_index_delivery(result, "+CDSI:", + &store, &index) == FALSE) + goto error; + + if (store != AT_UTIL_SMS_STORE_SR) + goto error; + + DBG("Got a CDSI indication at %s, index: %d", storages[store], index); + at_send_cmgr_cpms(sms, store, index); + return; + +error: + ofono_error("Unable to parse CDSI notification"); +} + static void at_cmgl_done(struct ofono_sms *sms) { struct sms_data *data = ofono_sms_get_data(sms); @@ -483,6 +509,8 @@ static void at_cmgl_done(struct ofono_sms *sms) sms, NULL); g_at_chat_register(data->chat, "+CDS:", at_cds_notify, TRUE, sms, NULL); + g_at_chat_register(data->chat, "+CDSI:", at_cdsi_notify, FALSE, + sms, NULL); /* We treat CMGR just like a notification */ g_at_chat_register(data->chat, "+CMGR:", at_cmgr_notify, TRUE,