[PATCH] minore fixs on smsc_at.c

Vincent CHAVANIS <[email protected]>
Newsgroups gmane.comp.mobile.kannel.devel
Message-ID <[email protected]>
- optimizing detection process on CME/CMS Errors
(avoid to check if CMS when CME was detected.)
- renaming param value code -> errcode to make it more clean

Vincent.
patch_at.c.txt (text/plain, 2.4 KB)
--- /gateway-cvs/gw/smsc/smsc_at.c	2009-06-22 10:26:10.000000000 +0200
+++ /gateway/gw/smsc/smsc_at.c	2009-06-26 11:40:58.000000000 +0200
@@ -786,15 +786,20 @@
                 privdata->pin_ready = 1;
                 continue;
             }
-            if (octstr_search(line, octstr_imm("+CMS ERROR"), 0) != -1 ||
-                octstr_search(line, octstr_imm("+CME ERROR"), 0) != -1) {
+            if (octstr_search(line, octstr_imm("+CMS ERROR"), 0) != -1) {
                 int errcode;
-                error(0, "AT2[%s]: CMx ERROR: %s", octstr_get_cstr(privdata->name), 
+                error(0, "AT2[%s]: +CMS ERROR: %s", octstr_get_cstr(privdata->name), 
                       octstr_get_cstr(line));
                 if (sscanf(octstr_get_cstr(line), "+CMS ERROR: %d", &errcode) == 1)
                     error(0, "AT2[%s]: +CMS ERROR: %s (%d)", octstr_get_cstr(privdata->name), 
                           at2_error_string(errcode), errcode);
-                else if (sscanf(octstr_get_cstr(line), "+CME ERROR: %d", &errcode) == 1)   
+                ret = 1;
+                goto end;
+            } else if (octstr_search(line, octstr_imm("+CME ERROR"), 0) != -1) {
+                int errcode;
+                error(0, "AT2[%s]: +CME ERROR: %s", octstr_get_cstr(privdata->name),
+                      octstr_get_cstr(line));
+                if (sscanf(octstr_get_cstr(line), "+CME ERROR: %d", &errcode) == 1)
                     error(0, "AT2[%s]: +CME ERROR: %s (%d)", octstr_get_cstr(privdata->name),
                           at2_error_string(errcode), errcode);
                 ret = 1;
@@ -2897,7 +2902,7 @@
 }
 
 
-static const char *at2_error_string(int code)
+static const char *at2_error_string(int errcode)
 {
     /*
      * +CMS ERRORS
@@ -2912,7 +2917,7 @@
      * GPRS-related errors - (GSM 04.08 cause codes)
      * 
      */
-    switch (code) {
+    switch (errcode) {
     case 0:
         /*
          * Default the code to 0 then when you extract the value from the
@@ -2954,7 +2959,7 @@
          * This cause indicates that the outgoing call barred service applies to
          * the short message service for the called destination.
          */
-        return "Call barred or SIM not inserted or Card inserted is not a SIM";
+        return "Call barred (+CMS) or SIM not inserted or Card inserted is not a SIM (+CME)";
     case 11:
         return "SIM PIN required";
     case 12:
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.