Own fork of C027_Support

Dependents:   MbedSmartRestMain MbedSmartRestMain

Fork of C027_Support by u-blox

Files at this revision

API Documentation at this revision

Comitter:
mazgch
Date:
Tue Apr 08 15:48:16 2014 +0000
Parent:
28:4d9509e3b1cf
Child:
30:1a647403171b
Commit message:
add sms count api

Changed in this revision

MDM.cpp Show annotated file Show diff for this revision Revisions of this file
MDM.h Show annotated file Show diff for this revision Revisions of this file
--- a/MDM.cpp	Tue Apr 08 14:11:03 2014 +0000
+++ b/MDM.cpp	Tue Apr 08 15:48:16 2014 +0000
@@ -3,7 +3,7 @@
 #include "MDM.h"
 
 #define TRACE           (0)?:printf
-//#define DEBUG         // enable this for AT command debugging
+#define DEBUG         // enable this for AT command debugging
 #define PROFILE         "0"   // this is the psd profile used
 #define MAX_SIZE        256  // max expected messages
 // some helper 
@@ -715,22 +715,25 @@
 }
 
 // ----------------------------------------------------------------
-#if 0
-void _cbCMGL()
+int MDMParser::_cbCPMS(int type, const char* buf, int len, int* num)
 { 
-    //
+    if ((type == TYPE_PLUS) && num) {
+        // AT+CPMS: <used1>,<total1>,<used2>,<total2>,<used3>,<total3>;
+        if (sscanf(buf, "\r\n+CPMS: %d,%*d", num) == 1)
+            /*nothing*/;
+    }
+    return WAIT;
 }
 
 int MDMParser::smsCount(void)
 {
     int num = 0;
-    sendFormated("AT+CMGL=ALL\r\n");
-    if (OK != waitFinalResp(_cbCMGL,&num)) {
-        return false;
+    sendFormated("AT+CPMS=\"ME\"\r\n");
+    if (OK != waitFinalResp(_cbCPMS,&num)) {
+        return 0;
     }
-    return true;
+    return num;
 }
-#endif
 
 bool MDMParser::smsSend(const char* num, const char* buf)
 {
--- a/MDM.h	Tue Apr 08 14:11:03 2014 +0000
+++ b/MDM.h	Tue Apr 08 15:48:16 2014 +0000
@@ -88,6 +88,7 @@
     bool socketClose(int socket);
     bool socketFree(int socket);
     // sms
+    int smsCount(void);
     bool smsSend(const char* num, const char* buf);
     bool smsDelete(int ix);
     bool smsRead(int ix, char* num, char* buf, int len);
@@ -108,6 +109,7 @@
     static int _cbUSORF(int type, const char* buf, int len, USORFparam* param);
     typedef struct { char* buf; char* num; } CMGRparam;
     static int _cbCUSD(int type, const char* buf, int len, char* buf);
+    static int _cbCPMS(int type, const char* buf, int len, int* num);
     static int _cbCMGR(int type, const char* buf, int len, CMGRparam* param);
     static int _cbCGSN(int type, const char* buf, int len, char* imei);
     static int _cbGSN(int type, const char* buf, int len, char* imei);