PHS module SMA-01 library. see: https://developer.mbed.org/users/phsfan/notebook/abitusbmodem/

Dependencies:   Socket lwip-sys lwip

Dependents:   AbitUSBModem_HTTPTest AbitUSBModem_MQTTTest AbitUSBModem_WebsocketTest AbitUSBModem_SMSTest

Fork of VodafoneUSBModem by mbed official

/media/uploads/phsfan/sma01_003.png

Revision:
61:0bcb8c5216d4
Parent:
59:593fb493172f
Child:
69:9b475f458fbc
Child:
75:ff3e5d1e82ca
--- a/VodafoneUSBModem.cpp	Wed Oct 24 14:15:53 2012 +0000
+++ b/VodafoneUSBModem.cpp	Thu Nov 01 13:01:03 2012 +0000
@@ -214,9 +214,13 @@
   {
     DBG("Connected to %s with %s", copsProcessor.getNetwork(), copsProcessor.getBearer());
     char cmd[48];
+    int tries = 3;
     sprintf(cmd, "AT+CGDCONT=1,\"IP\",\"%s\"", copsProcessor.getAPN());
-    ret = m_at.executeSimple(cmd, &result);
-    DBG("Result of command: Err code=%d", ret);
+    do //Try 3 times because for some reasons it can fail with the K3772-Z dongle
+    {
+      ret = m_at.executeSimple(cmd, &result);
+      DBG("Result of command: Err code=%d", ret);
+    } while(ret && --tries);
     DBG("ATResult: AT return=%d (code %d)", result.result, result.code);
     DBG("APN set to %s", copsProcessor.getAPN());
   }
@@ -224,9 +228,17 @@
   if(apn != NULL)
   {
     char cmd[48];
+    int tries = 30;
     sprintf(cmd, "AT+CGDCONT=1,\"IP\",\"%s\"", apn);
-    ret = m_at.executeSimple(cmd, &result);
-    DBG("Result of command: Err code=%d", ret);
+    do //Try 30 times because for some reasons it can fail *a lot* with the K3772-Z dongle
+    {
+      ret = m_at.executeSimple(cmd, &result);
+      DBG("Result of command: Err code=%d", ret);
+      if(ret)
+      {
+        Thread::wait(500);
+      }
+    } while(ret && --tries);
     DBG("ATResult: AT return=%d (code %d)", result.result, result.code);
     DBG("APN set to %s", apn);
   }