This library controls the WNC. There is a derived class for usage from the K64F board.

Fork of WncControllerLibrary by Fred Kellerman

Files at this revision

API Documentation at this revision

Comitter:
fkellermavnet
Date:
Fri Sep 23 05:00:00 2016 +0000
Parent:
28:eece2151e1e5
Child:
30:98c9ff850c1b
Commit message:
Found that WNC is giving an error on socket close once in a while.

Changed in this revision

WncController.cpp Show annotated file Show diff for this revision Revisions of this file
WncController.h Show annotated file Show diff for this revision Revisions of this file
--- a/WncController.cpp	Fri Sep 23 03:14:34 2016 +0000
+++ b/WncController.cpp	Fri Sep 23 05:00:00 2016 +0000
@@ -1681,8 +1681,19 @@
     string cmd_str("AT@SOCKCLOSE=");
 
     cmd_str += _to_string(numSock);
+ 
     // Don't check the cell status to close the socket
-    return (WNC_AT_CMD_OK == at_send_wnc_cmd(cmd_str.c_str(), &pRespStr, m_sCmdTimeoutMs));
+    AtCmdErr_e res = at_send_wnc_cmd(cmd_str.c_str(), &pRespStr, m_sCmdTimeoutMs);
+    
+    if ((res != WNC_AT_CMD_TIMEOUT) && (res != WNC_AT_CMD_OK)) {
+        for (unsigned i = 0; i < WNC_SOCK_CLOSE_RETRY_CNT; i++) {
+            res = at_send_wnc_cmd(cmd_str.c_str(), &pRespStr, m_sCmdTimeoutMs);
+            if ((res == WNC_AT_CMD_TIMEOUT) || (res == WNC_AT_CMD_OK))
+                break;
+        }
+    }
+    
+    return (res == WNC_AT_CMD_OK); 
 }
 
 bool WncController::at_dnsresolve_wnc(const char * s, string * ipStr)
--- a/WncController.h	Fri Sep 23 03:14:34 2016 +0000
+++ b/WncController.h	Fri Sep 23 05:00:00 2016 +0000
@@ -426,6 +426,7 @@
     static const uint16_t WNC_APNSET_TIMEOUT_MS     = 60000; // How long to wait for the WNC to respond to setting the APN string.
     static const uint16_t WNC_PING_CMD_TIMEOUT_MS   = 60000; // Amount of time to wait for the WNC to respond to AT@PINGREQ (with cmd default params for timeout, does not change WNC cmd's timeout) 
     static const int      WNC_REINIT_MAX_TIME_MS    = 60000; // How long to wait for the WNC to reset after it was already up and running after power-up.
+    static const uint16_t WNC_SOCK_CLOSE_RETRY_CNT  = 3;     // How many times to try to close the socket if the WNC gives an error.
     static const char * const INVALID_IP_STR;                // Just a string set to an IP address when DNS resolve fails.
         
     struct WncSocketInfo_s {