gnokii-users
[Top][All Lists]
Advanced

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

gnokii and Motorola C350


From: Ron Yorston
Subject: gnokii and Motorola C350
Date: Sun, 25 Jan 2004 15:47:43 GMT

I've been experimenting with gnokii and a Motorola C350 phone.  Using the
model AT works to some extent, but are problems with both the phone and
gnokii.  I've got fixes for some of these, but others need more work.

The first issue is the response the phone gives to requests for model,
manufacturer, revision and IMEI number ('AT+CG??').  The standard says
that the response should just be the requested data, but the Motorola is
returning '+CG??: ' followed by a quoted string.  I've fixed this by
replacing the REPLY_SIMPLETEXT macro with a function which can handle
both the standard and the Motorola responses.

Message sent: 0x06 / 0x0008
41 54 2b 43 47 4d 49 0d                         | AT+CGMI         
write: [AT+CGMI<cr>]
read : [AT+CGMI<cr><cr><lf>+CGMI: "Motorola CE, Copyright 
2000"<cr><lf><cr><lf>OK<cr><lf>]
Message received: 0x06 / 0x0036
02 41 54 2b 43 47 4d 49 0d 0d 0a 2b 43 47 4d 49 |  AT+CGMI   +CGMI
3a 20 22 4d 6f 74 6f 72 6f 6c 61 20 43 45 2c 20 | : "Motorola CE, 
43 6f 70 79 72 69 67 68 74 20 32 30 30 30 22 0d | Copyright 2000" 
0a 0d 0a 4f 4b 0d                               |    OK

Secondly, in the response to a request to read a phone book entry the
name string (which is hex-encoded UCS2) isn't quoted whereas the code in 
atgen.c expects it to be quoted.  Again I've modified the code so that it
should handle either type of response.

Message sent: 0x0d / 0x000c
41 54 2b 43 50 42 52 3d 31 30 31 0d             | AT+CPBR=101     
write: [AT+CPBR=101<cr>]
read : [AT+CPBR=101<cr><cr><lf>+CPBR: 
101,"987654321",129,0053006F006D0065006F006E0065002000490020004B006E006F0077<cr><lf><cr><lf>OK<cr><lf>]
Message received: 0x0d / 0x0069
02 41 54 2b 43 50 42 52 3d 31 30 31 0d 0d 0a 2b |  AT+CPBR=101   +
43 50 42 52 3a 20 31 30 31 2c 22 39 38 37 36 35 | CPBR: 101,"98765
34 33 32 31 22 2c 31 32 39 2c 30 30 35 33 30 30 | 4321",129,005300
36 46 30 30 36 44 30 30 36 35 30 30 36 46 30 30 | 6F006D0065006F00
36 45 30 30 36 35 30 30 32 30 30 30 34 39 30 30 | 6E00650020004900
32 30 30 30 34 42 30 30 36 45 30 30 36 46 30 30 | 20004B006E006F00
37 37 0d 0a 0d 0a 4f 4b 0d                      | 77    OK        
Received message type 0d
101. Name: Someone I Know
Number: 987654321
Group id: 0

Other things that need to be looked into are:

   The response to '+CPBS?' doesn't include any information about the
   number of free/used slots.

   The code in atgen.c doesn't handle the  response to '+CPBR=?'.  In
   the Motorola this includes useful information about the valid range
   of phone book slots.  In particular, the index numbers for the SIM
   entries have index values from 101-300, whereas xgnokii only looks
   for 1-100.

   The phone doesn't support PDU mode, so it isn't possible to fetch
   SMS messages because the code assumes that PDU mode works.  There
   are also problems with the names of the folders for messages.

I'm sure there are other problems too.  I'll investigate these later.  In
the meantime I've attached a patch that should address the first two issues
without breaking the AT model for phones that work already.

Ron

---
--- gnokii-0.5.9.orig/common/phones/atgen.c     2004-01-19 23:23:20.000000000 
+0000
+++ gnokii-0.5.9.rmy/common/phones/atgen.c      2004-01-25 15:08:00.000000000 
+0000
@@ -128,9 +128,31 @@
        { GN_OP_GetNetworkInfo,        AT_GetNetworkInfo,        
ReplyGetNetworkInfo },
 };
 
-#define REPLY_SIMPLETEXT(l1, l2, c, t) \
-       if ((strcmp(l1, c) == 0) && (t != NULL)) strcpy(t, l2)
+static char *strip_quotes(char *s)
+{
+       char *t ;
+
+       if ( *s == '"' ) {
+               if ( (t=strrchr(++s, '"')) ) {
+                       *t = '\0' ;
+               }
+       }
 
+       return s ;
+}
+
+static void reply_simpletext(char *l1, char *l2, char *c, char *t)
+{
+       if ((strncmp(l1, c, 5) == 0) && (t != NULL)) {
+               if ( strncmp(l2, c, 7) == 0 )  {
+                       strcpy(t, strip_quotes(l2+7)) ;
+               }
+               else {
+                       strcpy(t, l2) ;
+               }
+       }
+}
+ 
 gn_driver driver_at = {
        NULL,
        pgen_incoming_default,
@@ -825,20 +847,11 @@
                /* store name */
                pos = NULL;
                if (endpos)
-                       pos = strchr(++endpos, '\"');
+                       pos = strchr(endpos+2, ',');
                endpos = NULL;
                if (pos) {
-                       pos++;
-                       /* parse the string form behind for quotation.
-                        * this will allways succede because quotation
-                        * was found at pos.
-                        */
-                       endpos = buf.line1 + length - 1;
-                       for (;;) {
-                               if (*endpos == '\"') break;
-                               endpos--;
-                       }
-                       l = endpos - pos;
+                       pos = strip_quotes(pos+1) ;
+                       l = strlen(pos) ;
                        switch (drvinst->charset) {
                        case AT_CHAR_GSM:
                                char_ascii_decode(data->phonebook_entry->name, 
pos, l);
@@ -1002,10 +1015,10 @@
        buf.length = length;
        splitlines(&buf);
        if (!strncmp(buf.line1, "AT+CG", 5)) {
-               REPLY_SIMPLETEXT(buf.line1+5, buf.line2, "SN", data->imei);
-               REPLY_SIMPLETEXT(buf.line1+5, buf.line2, "MM", data->model);
-               REPLY_SIMPLETEXT(buf.line1+5, buf.line2, "MI", 
data->manufacturer);
-               REPLY_SIMPLETEXT(buf.line1+5, buf.line2, "MR", data->revision);
+               reply_simpletext(buf.line1+2, buf.line2, "+CGSN: ", data->imei);
+               reply_simpletext(buf.line1+2, buf.line2, "+CGMM: ", 
data->model);
+               reply_simpletext(buf.line1+2, buf.line2, "+CGMI: ", 
data->manufacturer);
+               reply_simpletext(buf.line1+2, buf.line2, "+CGMR: ", 
data->revision);
        }
        return GN_ERR_NONE;
 }




reply via email to

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