C027_Support library plus AT Comand for dialing.

Fork of C027_Support_New by irsan julfikar

Files at this revision

API Documentation at this revision

Comitter:
irsanjul
Date:
Sun Oct 11 09:56:57 2015 +0000
Parent:
120:353754a2bcd9
Commit message:
C027_Support library from mbed plus AT Command for dialing

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	Thu Oct 08 04:05:30 2015 +0000
+++ b/MDM.cpp	Sun Oct 11 09:56:57 2015 +0000
@@ -7,6 +7,7 @@
 #include <sstream>
 
 extern Serial dbg;
+extern time_t t;
                 
 #define PROFILE         "0"   //!< this is the psd profile used
 #define MAX_SIZE        128   //!< max expected messages
@@ -482,13 +483,13 @@
     if (RESP_OK != waitFinalResp())
         goto failure;
     // setup audio path mode
-    sendFormated("AT+USPM=0,3,0,0,0\r\n");
-    if (RESP_OK != waitFinalResp())
-        goto failure;
+    //sendFormated("AT+USPM=0,0,0,0,0\r\n");
+    //if (RESP_OK != waitFinalResp())
+        //goto failure;
     // setup loudness speaker
-    sendFormated("ATL2\r\n");
-    if (RESP_OK != waitFinalResp())
-        goto failure;
+    //sendFormated("ATL2\r\n");
+    //if (RESP_OK != waitFinalResp())
+        //goto failure;
     // setup report
     sendFormated("AT+CMER=1,0,0,2,1\r\n");
     if (RESP_OK != waitFinalResp())
@@ -1348,27 +1349,12 @@
     return ok;
 }
 
-int MDMParser::_cbRing(int type, const char* buf, int len, char* str)
-{
-    if(type == TYPE_RING)
-    {
-        return RESP_OK;
-    }
-    return WAIT;
-}
-
 bool MDMParser::dialAns()
 {
     bool ok = false;
     LOCK();
-    char dbg[64];
-    if(RESP_OK == waitFinalResp(_cbRing, dbg))
-    {
-        sendFormated("ATA\r\n");
-        wait_us(200);
-        ok = (RESP_OK == waitFinalResp());
-        TRACE("ATA YES\\r\n");
-    }
+    sendFormated("ATA\r\n");
+    ok = (RESP_OK == waitFinalResp());
     UNLOCK();
     return ok;
 }
@@ -1400,30 +1386,6 @@
 }
 
 // ----------------------------------------------------------------
-int MDMParser::chkSig(MDMParser::NetStatus *status)
-{
-    /*
-    int sigStr;
-    LOCK();
-    sendFormated("AT+CSQ\r\n");
-    CSQparam param;
-    param.sig = &sigStr;
-    waitFinalResp(_cbCSQ, &param);
-    UNLOCK();
-    return sigStr;
-    */
-    int sigStr = 0;
-    LOCK();
-    sendFormated("AT+CSQ\r\n");
-    waitFinalResp(_cbCSQ, &_net);
-    if(status)
-        memcpy(status, &_net, sizeof(NetStatus));
-    sigStr = status->rssi;
-    UNLOCK();
-    return sigStr;
-}
-
-// ----------------------------------------------------------------
 int MDMParser::_cbDBG(int type, const char* buf, int len, DBGparam* param)
 {
    if(type == TYPE_PLUS)
@@ -1507,6 +1469,49 @@
         return false;
     }
 }
+//-----------------------------------------------------------------
+
+bool MDMParser::CopsCtzu()
+{
+   bool ok = 0;
+   LOCK();
+   sendFormated("AT+COPS=2\r\n");
+   ok = (RESP_OK == waitFinalResp());
+   sendFormated("AT+CTZU=1\r\n");
+   ok = (RESP_OK == waitFinalResp());
+   sendFormated("AT+COPS=0\r\n");
+   ok = (RESP_OK == waitFinalResp());
+   UNLOCK();
+   return ok;
+}
+
+int MDMParser::_cbCCLK(int type, const char* buf, int len, CCLKparam* param)
+{
+    if(type == TYPE_PLUS)
+    {
+        dbg.printf("masuk _cbCCLK\r\n");
+        if(sscanf(buf, "\r\n+CCLK: \"%[^\"]", param->buf) == 1)
+        {
+            dbg.printf("masuk if nya\r\n");
+            return RESP_OK;
+        }
+        else return WAIT;
+    }
+    else return WAIT;
+}
+
+bool MDMParser::clk(char *buf)
+{
+   bool ok = 0;
+   LOCK();
+   CCLKparam param;
+   param.buf = buf;
+   sendFormated("AT+CCLK?\r\n");
+   ok = (RESP_OK == waitFinalResp(_cbCCLK, &param, 1000));
+   UNLOCK();
+   return ok;
+}
+
 // ----------------------------------------------------------------
   
 int MDMParser::_cbCUSD(int type, const char* buf, int len, char* resp)
--- a/MDM.h	Thu Oct 08 04:05:30 2015 +0000
+++ b/MDM.h	Sun Oct 11 09:56:57 2015 +0000
@@ -315,6 +315,10 @@
     
     bool dbgSts();
     
+    bool CopsCtzu();
+    
+    bool clk(char *num);
+    
     // ----------------------------------------------------------------
     // Signal Service
     // ----------------------------------------------------------------
@@ -592,7 +596,7 @@
     typedef struct { char* buf; IP ip; int port; } USORFparam;
     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 _cbCUSD(int type, const char* buf, int len, char* buff);
     // sms
     typedef struct { int* ix; int num; } CMGLparam;
     static int _cbCMGL(int type, const char* buf, int len, CMGLparam* param);
@@ -608,6 +612,9 @@
     // status dbg
     typedef struct { char* buf; int* signal; int *status; char* num; int* indeks;} DBGparam;
     static int _cbDBG(int type, const char* buf, int len, DBGparam* param);
+    //time
+    typedef struct { char* buf; int *mtime;} CCLKparam;
+    static int _cbCCLK(int type, const char* buf, int len, CCLKparam* param);
     // file
     typedef struct { const char* filename; char* buf; int sz; int len; } URDFILEparam;
     static int _cbUDELFILE(int type, const char* buf, int len, void*);