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 VodafoneUSBModem by
Diff: VodafoneUSBModem.cpp
- Revision:
- 61:0bcb8c5216d4
- Parent:
- 59:593fb493172f
diff -r 763eefc845b1 -r 0bcb8c5216d4 VodafoneUSBModem.cpp
--- 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);
}
