Base library for cellular modem implementations
Dependencies: Socket lwip-sys lwip
Dependents: CellularUSBModem CellularUSBModem
Deprecated
This is an mbed 2 networking library. For mbed 5, the networking libraries have been revised to better support additional network stacks and thread safety here.
Revision 7:0fd95907b5b3, committed 2014-03-04
- Comitter:
- mbed_official
- Date:
- Tue Mar 04 10:00:52 2014 +0000
- Parent:
- 6:6e0ca3539adf
- Child:
- 8:944cd194963e
- Commit message:
- Synchronized with git revision e4faeb42a7013bfc4d1dccf0a6d905d10aca5c00
Full URL: https://github.com/mbedmicro/mbed/commit/e4faeb42a7013bfc4d1dccf0a6d905d10aca5c00/
Update of cellular modem
Changed in this revision
--- a/at/ATCommandsInterface.cpp Tue Dec 17 15:23:32 2013 +0000 +++ b/at/ATCommandsInterface.cpp Tue Mar 04 10:00:52 2014 +0000 @@ -32,7 +32,7 @@ #include "ATCommandsInterface.h" ATCommandsInterface::ATCommandsInterface(IOStream* pStream) : - m_pStream(pStream), m_open(false), m_env2AT(), m_AT2Env(), m_processingMtx(), + m_pStream(pStream), m_open(false), m_transactionState(IDLE), m_env2AT(), m_AT2Env(), m_processingMtx(), m_processingThread(&ATCommandsInterface::staticCallback, this, (osPriority)AT_THREAD_PRIORITY, 4*192), m_eventsMgmtMtx(), m_eventsProcessingMtx() { @@ -270,6 +270,7 @@ } while(msgResult != AT_TIMEOUT); WARN("Command returned no message"); + WARN("Command \"%s\" returned no message", command); return NET_TIMEOUT; } DBG("Command returned with message %d", *msg); @@ -285,6 +286,7 @@ if(ret != OK) { WARN("Command returned AT result %d with code %d", m_transactionResult.result, m_transactionResult.code); + WARN("Command \"%s\" returned AT result %d with code %d", command, m_transactionResult.result, m_transactionResult.code); } DBG("Command returned successfully"); @@ -751,12 +753,13 @@ { m_eventsHandlers[i]->onDispatchStart(); //Enable this kind of events - if(m_eventsHandlers[i]->getEventsEnableCommand() != NULL) + const char* cmd = m_eventsHandlers[i]->getEventsEnableCommand(); + if(cmd != NULL) { - int ret = executeInternal(m_eventsHandlers[i]->getEventsEnableCommand(), this, NULL); //Execute enable command + int ret = executeInternal(cmd, this, NULL); //Execute enable command if(ret) { - WARN("Events enabling command failed"); + WARN("Events enabling command \"%s\" failed", cmd); } } } @@ -775,12 +778,13 @@ { m_eventsHandlers[i]->onDispatchStart(); //Disable this kind of events - if(m_eventsHandlers[i]->getEventsDisableCommand() != NULL) + const char* cmd = m_eventsHandlers[i]->getEventsDisableCommand(); + if(cmd != NULL) { - int ret = executeInternal(m_eventsHandlers[i]->getEventsDisableCommand(), this, NULL); //Execute disable command + int ret = executeInternal(cmd, this, NULL); //Execute disable command if(ret) { - WARN("Events disabling command failed"); + WARN("Events disabling command \"%s\" failed", cmd); } } }
--- a/link/LinkMonitor.cpp Tue Dec 17 15:23:32 2013 +0000 +++ b/link/LinkMonitor.cpp Tue Mar 04 10:00:52 2014 +0000 @@ -58,6 +58,8 @@ /*virtual*/ int LinkMonitor::onNewATResponseLine(ATCommandsInterface* pInst, const char* line) { DBG("Line is %s", line); + char n[32] = ""; + char s[32] = ""; int v; if( sscanf(line, "+CREG: %*d,%d", &v) >= 1 ) //Reg state is valid { @@ -127,6 +129,13 @@ m_rssi = -113 + 2*v; } } + else if ( (sscanf(line, "+CNUM: \"%[^\"]\",\"%[^\"]\",%d", n, s, &v) == 3) || + (sscanf(line, "+CNUM: \"\",\"%[^\"]\",%d", s, &v) == 2) ) + { + if (*s && ((v == 145/*number includes + */) || (v == 129/*otherwise*/))) { + strcpy(m_phoneNumber, s); + } + } return OK; } @@ -150,3 +159,17 @@ *pBearer = m_bearer; return OK; } + +int LinkMonitor::getPhoneNumber(char* phoneNumber) +{ + *m_phoneNumber = '\0'; + if (m_gsm) { + int ret = m_pIf->execute("AT+CNUM", this, NULL, DEFAULT_TIMEOUT); + if(ret != OK) + { + return NET_PROTOCOL; + } + } + strcpy(phoneNumber, m_phoneNumber); + return OK; +} \ No newline at end of file
--- a/link/LinkMonitor.h Tue Dec 17 15:23:32 2013 +0000 +++ b/link/LinkMonitor.h Tue Mar 04 10:00:52 2014 +0000 @@ -73,6 +73,11 @@ */ int getState(int* pRssi, REGISTRATION_STATE* pRegistrationState, BEARER* pBearer); + /** Get my phone number + @param phoneNumber pointer to store the current phoneNumber + @return 0 on success, error code on failure + */ + int getPhoneNumber(char* phoneNumber); protected: //IATCommandsProcessor virtual int onNewATResponseLine(ATCommandsInterface* pInst, const char* line); @@ -85,7 +90,7 @@ bool m_gsm; REGISTRATION_STATE m_registrationState; BEARER m_bearer; - + char m_phoneNumber[16]; }; #endif /* LINKMONITOR_H_ */