gnokii-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[patch] Use +CPMS (SMS preferred memory store) more correctly.


From: David Vrabel
Subject: [patch] Use +CPMS (SMS preferred memory store) more correctly.
Date: Tue, 11 Jan 2005 15:54:08 +0000
User-agent: Mozilla Thunderbird 0.9 (X11/20041124)

Hi,

The +CPMS (SMS preferred memory store) AT command has the following syntax (refer to GSM 07.05 section 3.2.3):

+CPMS=<mem1>[,<mem2>[,<mem3>]]

Where:
  <mem1> is the message store used in read and delete operations.
  <mem2> is the message store used in write operation.
  <mem3> is the message store for received messages.

The current code in common/phones/atgen.c only sets/queries <mem1>. On certain phones (Sony Ericsson GM47) this results in smsd being unable to read received SMSes. Consider the following:

AT+CPMS="SM"
+CPMS: 0,20,0,20,3,40
OK
AT+CMPS?
+CPMS: "SM",0,20,"SM",0,20,"ME",3,40
OK

Observe that <mem3> is "ME" and yet we only check the "SM" store therefore, we'd fail to see new messages as they were stored in "ME".

The "solution" presented in the patch is to set all three messages stores to be the same and to use +CPMS? to get the status. The does require that the phone is preconfigured (and the setting saved) with the correct preferred memory setting.

AT+CPMS="SM","SM","SM"
+CPMS: 0,20,0,20,0,20
OK
AT+CMPS?
+CPMS: "SM",0,20,"SM",0,20,"SM",0,20
OK

Ideally, smsd would query all available message stores. But I'm not familar enough with gnokii to see how this would be done.

David Vrabel
--
David Vrabel, Design Engineer

Arcom, Clifton Road           Tel: +44 (0)1223 411200 ext. 3233
Cambridge CB1 7EA, UK         Web: http://www.arcom.com/
diff -ur gnokii-0.6.4.orig/common/gsm-encoding.c 
gnokii-0.6.4/common/gsm-encoding.c
--- gnokii-0.6.4.orig/common/gsm-encoding.c     Sun Oct 17 20:44:20 2004
+++ gnokii-0.6.4/common/gsm-encoding.c  Tue Jan 11 10:27:24 2005
@@ -519,8 +519,9 @@
           only international and unknown number. */
 
        *out_num++ = type;
-       if (type == GN_GSM_NUMBER_International) in_num++; /* Skip '+' */
-       if ((type == GN_GSM_NUMBER_Unknown) && (*in_num == '+')) in_num++; /* 
Optional '+' in Unknown number type */
+
+       if ((type == GN_GSM_NUMBER_International || type ==  
GN_GSM_NUMBER_Unknown) && *in_num == '+')
+               in_num++; /* skip leading '+' */
 
        /* The next field is the number. It is in semi-octet representation - 
see
           GSM scpecification 03.40 version 6.1.0, section 9.1.2.3, page 31. */
diff -ur gnokii-0.6.4.orig/common/phones/atgen.c 
gnokii-0.6.4/common/phones/atgen.c
--- gnokii-0.6.4.orig/common/phones/atgen.c     Sun Oct 17 20:44:21 2004
+++ gnokii-0.6.4/common/phones/atgen.c  Mon Jan 10 16:03:06 2005
@@ -527,8 +527,8 @@
        gn_error ret = GN_ERR_NONE;
 
        if (mt != drvinst->smsmemorytype) {
-               sprintf(req, "AT+CPMS=\"%s\"\r", memorynames[mt]);
-               ret = sm_message_send(13, GN_OP_Init, req, state);
+               sprintf(req, "AT+CPMS=\"%s\",\"%s\",\"%s\"\r", memorynames[mt], 
memorynames[mt], memorynames[mt]);
+               ret = sm_message_send(23, GN_OP_Init, req, state);
                if (ret != GN_ERR_NONE)
                        return GN_ERR_NOTREADY;
                gn_data_clear(&data);
@@ -830,7 +830,7 @@
 
        if (!data->sms_status) return GN_ERR_INTERNALERROR;
 
-       ret = sm_message_send(13, GN_OP_GetSMSStatus, "AT+CPMS=\"SM\"\r", 
state);
+       ret = sm_message_send(13, GN_OP_GetSMSStatus, "AT+CPMS?\r", state);
        if (ret != GN_ERR_NONE)
                return GN_ERR_NOTREADY;
        return sm_block_no_retry(GN_OP_GetSMSStatus, data, state);
@@ -1324,7 +1324,7 @@
        buf.length = length;
        splitlines(&buf);
 
-       if (sscanf(buf.line2, "+CPMS: %d", &data->sms_status->number) != 1)
+       if (sscanf(buf.line2, "+CPMS: \"%*c%*c\",%d", 
&data->sms_status->number) != 1)
                return GN_ERR_FAILED;
 
        data->sms_status->unread = 0;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]