atmodem: sms: add quectel m95 quirks

CNMA isn't mentioned in the m95 documentation, but trial'n'error has
revealed some details:
 * the CSMS query returns the list (0,128) instead of a range
 * CNMA is enabled by setting 128 as CSMS service
 * once enabled, SMS deliveries are acked by sending AT+CNMA without a
   value setting

Add m95 quirks to the atmodem driver, so that CNMA is correctly
detected, configured, and used.
This commit is contained in:
Martin Hundebøll 2019-07-10 23:51:40 +02:00 committed by Denis Kenzior
parent 47021f9950
commit 46616a52d9
1 changed files with 19 additions and 5 deletions

View File

@ -339,6 +339,9 @@ static inline void at_ack_delivery(struct ofono_sms *sms)
case OFONO_VENDOR_GEMALTO:
snprintf(buf, sizeof(buf), "AT+CNMA=1");
break;
case OFONO_VENDOR_QUECTEL_M95:
snprintf(buf, sizeof(buf), "AT+CNMA");
break;
default:
snprintf(buf, sizeof(buf), "AT+CNMA=1,%d\r%s",
data->cnma_ack_pdu_len,
@ -1238,7 +1241,7 @@ static void at_csms_status_cb(gboolean ok, GAtResult *result,
if (!g_at_result_iter_next_number(&iter, &mo))
goto out;
if (service == 1)
if (service == 1 || service == 128)
data->cnma_enabled = TRUE;
if (mt == 1 && mo == 1)
@ -1269,10 +1272,10 @@ static void at_csms_query_cb(gboolean ok, GAtResult *result,
{
struct ofono_sms *sms = user_data;
struct sms_data *data = ofono_sms_get_data(sms);
gboolean cnma_supported = FALSE;
GAtResultIter iter;
int status_min, status_max;
char buf[128];
int csms = 0;
if (!ok)
return at_sms_not_supported(sms);
@ -1285,14 +1288,25 @@ static void at_csms_query_cb(gboolean ok, GAtResult *result,
if (!g_at_result_iter_open_list(&iter))
goto out;
while (g_at_result_iter_next_range(&iter, &status_min, &status_max))
switch (data->vendor) {
case OFONO_VENDOR_QUECTEL_M95:
g_at_result_iter_next_number(&iter, &status_min);
g_at_result_iter_next_number(&iter, &status_max);
if (status_min <= 1 && 1 <= status_max)
cnma_supported = TRUE;
csms = 128;
break;
default:
while (g_at_result_iter_next_range(&iter, &status_min,
&status_max))
if (status_min <= 1 && 1 <= status_max)
csms = 1;
break;
}
DBG("CSMS query parsed successfully");
out:
snprintf(buf, sizeof(buf), "AT+CSMS=%d", cnma_supported ? 1 : 0);
snprintf(buf, sizeof(buf), "AT+CSMS=%d", csms);
g_at_chat_send(data->chat, buf, csms_prefix,
at_csms_set_cb, sms, NULL);
}