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 WncControllerLibrary by
Diff: WncController.cpp
- Revision:
- 28:eece2151e1e5
- Parent:
- 27:c2b9ef5ccbef
- Child:
- 29:69ada8524b4a
--- a/WncController.cpp Wed Sep 21 02:31:23 2016 +0000
+++ b/WncController.cpp Fri Sep 23 03:14:34 2016 +0000
@@ -367,27 +367,31 @@
// Already open ? Must close if want to re-open with new settings.
if (m_sSock[numSock].open == true) {
dbgPuts("Socket already open, close then re-open!");
- at_sockclose_wnc(m_sSock[numSock].numWncSock);
- m_sSock[numSock].open = false;
+ if (true == at_sockclose_wnc(m_sSock[numSock].numWncSock))
+ m_sSock[numSock].open = false;
+ else
+ return (false);
}
m_sSock[numSock].myPort = port;
m_sSock[numSock].isTcp = tcp;
m_sSock[numSock].timeOutSec = timeOutSec;
- int numWncSock = at_sockopen_wnc(m_sSock[numSock].myIpAddressStr.c_str(), port, numSock, tcp, timeOutSec);
+ int16_t numWncSock = at_sockopen_wnc(m_sSock[numSock].myIpAddressStr.c_str(), port, numSock, tcp, timeOutSec);
m_sSock[numSock].numWncSock = numWncSock;
if (numWncSock > 0 && numWncSock <= MAX_NUM_WNC_SOCKETS)
m_sSock[numSock].open = true;
- else
+ else {
m_sSock[numSock].open = false;
-
- if (m_sSock[numSock].open == false) {
dbgPuts("Socket open fail!!!!");
- // Work-around. If the sock open fails it needs to be told
- // to close. If 6 sock opens happen with a fail, it further
- // crashes the WNC. Not sure why the sock won't open.
- at_sockclose_wnc(m_sSock[numSock].numWncSock);
+
+ // If the modem is not responding don't bother it.
+ if (WNC_NO_RESPONSE != getWncStatus()) {
+ // Work-around. If the sock open fails it needs to be told
+ // to close. If 6 sock opens happen with a fail, it further
+ // crashes the WNC. Not sure why the sock won't open.
+ at_sockclose_wnc(m_sSock[numSock].numWncSock);
+ }
}
}
else {
@@ -416,7 +420,7 @@
AtCmdErr_e cmdRes = at_sockwrite_wnc(s, n, m_sSock[numSock].numWncSock, isTcp);
if (cmdRes != WNC_AT_CMD_OK) {
- if ((cmdRes == WNC_AT_CMD_ERREXT) || (cmdRes == WNC_AT_CMD_TIMEOUT) || (cmdRes == WNC_AT_CMD_ERRCME))
+ if ((cmdRes == WNC_AT_CMD_ERREXT) || (cmdRes == WNC_AT_CMD_ERRCME))
{
// This may throw away any data that hasn't been written out of the WNC
// but at this point with the way the WNC currently works we have
@@ -512,7 +516,10 @@
else {
theBuf += readStr; // Append what if any we got before it errored.
dbgPuts("Sockread failed!");
- if (cmdRes == WNC_AT_CMD_ERREXT || cmdRes == WNC_AT_CMD_TIMEOUT)
+ if (WNC_NO_RESPONSE == getWncStatus()) {
+ i = 0;
+ }
+ else if ((cmdRes == WNC_AT_CMD_ERREXT) || (cmdRes == WNC_AT_CMD_ERRCME))
{
// This may throw away any data that hasn't been read out of the WNC
// but at this point with the way the WNC currently works we have
@@ -579,7 +586,10 @@
}
else {
dbgPuts("Sockread failed!");
- if (cmdRes == WNC_AT_CMD_ERREXT || cmdRes == WNC_AT_CMD_TIMEOUT)
+ if (WNC_NO_RESPONSE == getWncStatus()) {
+ i = 0;
+ }
+ else if ((cmdRes == WNC_AT_CMD_ERREXT) || (cmdRes == WNC_AT_CMD_ERRCME))
{
// This may throw away any data that hasn't been read out of the WNC
// but at this point with the way the WNC currently works we have
@@ -850,17 +860,26 @@
// Try to open and close the socket
do {
dbgPuts("Try to close and re-open socket");
- at_sockclose_wnc(m_sSock[numSock].numWncSock);
+ if (false == at_sockclose_wnc(m_sSock[numSock].numWncSock)) {
+ if (WNC_NO_RESPONSE == getWncStatus()) {
+ dbgPuts("No response for closeOpenSocket1");
+ return ;
+ }
+ }
int numWncSock = at_sockopen_wnc(m_sSock[numSock].myIpAddressStr.c_str(), m_sSock[numSock].myPort, numSock, m_sSock[numSock].isTcp, m_sSock[numSock].timeOutSec);
m_sSock[numSock].numWncSock = numWncSock;
if (numWncSock > 0 && numWncSock <= MAX_NUM_WNC_SOCKETS)
m_sSock[numSock].open = true;
- else
+ else {
m_sSock[numSock].open = false;
-
- if (m_sSock[numSock].open == false)
dbgPuts("Failed to re-open socket!");
+ }
+
+ if (WNC_NO_RESPONSE == getWncStatus()) {
+ dbgPuts("No response for closeOpenSocket2");
+ return ;
+ }
} while (m_sSock[numSock].open == false);
}
@@ -1930,7 +1949,7 @@
if (cmd && n > 0) {
sendCmd(cmd, crLf);
-// sendCmdSlow(cmd, n, 500); // 3rd arg is micro seconds between chars sent
+// sendCmd(cmd, n, 1000, crLf); // 3rd arg is micro seconds between chars sent
}
startTimerA();
