sms: Handle quirky Wavecom Q2XXX CPMS syntax

This commit is contained in:
Pablo Neira Ayuso 2012-05-29 04:14:26 +02:00 committed by Denis Kenzior
parent 1ccecfe01e
commit 535ff69ded
1 changed files with 23 additions and 5 deletions

View File

@ -985,8 +985,11 @@ static gboolean set_cpms(gpointer user_data)
const char *incoming = storages[data->incoming]; const char *incoming = storages[data->incoming];
char buf[128]; char buf[128];
snprintf(buf, sizeof(buf), "AT+CPMS=\"%s\",\"%s\",\"%s\"", if (data->vendor == OFONO_VENDOR_WAVECOM_Q2XXX)
store, store, incoming); snprintf(buf, sizeof(buf), "AT+CPMS=\"%s\"", store);
else
snprintf(buf, sizeof(buf), "AT+CPMS=\"%s\",\"%s\",\"%s\"",
store, store, incoming);
g_at_chat_send(data->chat, buf, cpms_prefix, g_at_chat_send(data->chat, buf, cpms_prefix,
at_cpms_set_cb, sms, NULL); at_cpms_set_cb, sms, NULL);
@ -1038,7 +1041,7 @@ static void at_cpms_query_cb(gboolean ok, GAtResult *result,
gboolean supported = FALSE; gboolean supported = FALSE;
if (ok) { if (ok) {
int mem = 0; int mem = 0, mem_max;
GAtResultIter iter; GAtResultIter iter;
const char *store; const char *store;
gboolean me_supported[3]; gboolean me_supported[3];
@ -1054,7 +1057,20 @@ static void at_cpms_query_cb(gboolean ok, GAtResult *result,
if (!g_at_result_iter_next(&iter, "+CPMS:")) if (!g_at_result_iter_next(&iter, "+CPMS:"))
goto out; goto out;
for (mem = 0; mem < 3; mem++) { if (data->vendor == OFONO_VENDOR_WAVECOM_Q2XXX) {
/* skip initial `(' */
if (!g_at_result_iter_open_list(&iter))
goto out;
/*
* Wavecom Q2 replies: +CPMS: (("SM","BM","SR"),("SM"))
* This reply is broken according to 3GPP TS 07.05.
*/
mem_max = 2;
} else
mem_max = 3;
for (mem = 0; mem < mem_max; mem++) {
if (!g_at_result_iter_open_list(&iter)) if (!g_at_result_iter_open_list(&iter))
goto out; goto out;
@ -1071,7 +1087,9 @@ static void at_cpms_query_cb(gboolean ok, GAtResult *result,
goto out; goto out;
} }
if (!sm_supported[2] && !me_supported[2] && !mt_supported[2]) if (data->vendor != OFONO_VENDOR_WAVECOM_Q2XXX &&
!sm_supported[2] && !me_supported[2]
&& !mt_supported[2])
goto out; goto out;
if (sm_supported[0] && sm_supported[1]) { if (sm_supported[0] && sm_supported[1]) {