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 MTS-Cellular by
Diff: Cellular/EasyIP.cpp
- Revision:
- 54:a6c738bfc391
- Parent:
- 52:2cb58398a4f9
- Child:
- 56:43205bd2752a
--- a/Cellular/EasyIP.cpp Mon Aug 11 16:27:27 2014 +0000 +++ b/Cellular/EasyIP.cpp Mon Aug 11 19:54:54 2014 +0000 @@ -138,8 +138,12 @@ } //Sends AT#SGACT=1,0 command - if (sendBasicCommand("AT#SGACT=1,0", 1000) == MTS_SUCCESS) { - logDebug("Successfully closed PPP Connection"); + for (int y = 0; y < 5; y++) { + Code code = sendBasicCommand("AT#SGACT=1,0", 1000); + if (code == MTS_SUCCESS) { + logDebug("Successfully closed PPP Connection"); + break; + } } /* Ensure PPP link is down, else ping commands will put radio in unknown state @@ -377,7 +381,7 @@ socketOpened = false; } - if(sendBasicCommand("AT#SH=1", 2000) != MTS_SUCCESS) { + if (sendBasicCommand("AT#SH=1", 2000) != MTS_SUCCESS) { logDebug("Failed to close socket connection"); } @@ -661,10 +665,10 @@ if(size > 0) { result.append(tmp, size); } - if(result.find("OK") != std::string::npos) { + if(result.find("OK\r\n") != std::string::npos) { exitmode = true; done = true; - } else if(result.find("NO CARRIER") != std::string::npos) { + } else if(result.find("NO CARRIER\r\n") != std::string::npos) { socketOpened = false; exitmode = true; done = true; @@ -679,6 +683,8 @@ } } while (!done); + wait(0.1); //Without a slight wait time after receiving OK, radio would + //fail to correctly receive and respond to the next AT command return exitmode; } @@ -710,7 +716,7 @@ } else if(socketInfo == SOCKETCLOSED || socketInfo == SOCKETINCOMING) { status = false; } else { - logError("Could not determine socket status"); + logError("Could not determine socket status[%d]",socketInfo); status = false; }