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
Parent:
5:9a57892f206c
--- 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