Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of C027_Support_New by
Diff: MDM.cpp
- Revision:
- 121:3e1d84b2d34c
- Parent:
- 120:353754a2bcd9
--- 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, ¶m); - 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, ¶m, 1000)); + UNLOCK(); + return ok; +} + // ---------------------------------------------------------------- int MDMParser::_cbCUSD(int type, const char* buf, int len, char* resp)