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

Fork of WncControllerLibrary by Fred Kellerman

Revision:
6:a656e820d7ff
Parent:
4:c5720f4d13ff
Child:
10:2ec59906a24e
--- a/WncController.h	Tue Sep 06 19:11:14 2016 +0000
+++ b/WncController.h	Thu Sep 08 18:57:56 2016 +0000
@@ -47,6 +47,13 @@
 
 
 static const uint8_t  MAX_LEN_IP_STR = 16;    // Length includes room for the extra NULL
+static const uint16_t WNC_MAX_SMS_MSG_SLOTS     = 3;     // How many SMS messages the WNC can store and receive at a time.
+
+struct WncSmsInfo
+{
+    char idx[WNC_MAX_SMS_MSG_SLOTS];
+    string msgText[WNC_MAX_SMS_MSG_SLOTS];
+};
 
 
 /**
@@ -252,10 +259,8 @@
      */
     bool closeSocket(uint16_t numSock);
 
-    void setWncCmdTimeout(uint16_t toMs) {
-        m_sCmdTimeoutMs = toMs;
-    };
-    
+    void setWncCmdTimeout(uint16_t toMs);
+        
     bool getIpAddr(uint16_t numSock, char myIpAddr[MAX_LEN_IP_STR]);
     
     void enableDebug(bool on, bool moreDebugOn);
@@ -274,7 +279,9 @@
 
     bool deleteSMSTextFromMem(char msgIdx);
     
-    size_t readSMSText(const char ** log);
+    size_t readSMSText(const char n, const char ** msg);
+    
+    bool readUnreadSMSText(WncSmsInfo * w);
     
     ///////////////////////////////////////////
     // Neighborhood Cell Info
@@ -355,6 +362,7 @@
     bool at_get_wnc_net_stats(WncIpStats * s);
     size_t at_readSMSlog_wnc(const char ** log);
     size_t at_readSMStext_wnc(const char ** log);
+    size_t at_readSMStext_wnc(const char n, const char ** log);
     bool at_getrssiber_wnc(int16_t * dBm, int16_t * ber3g);
     void closeOpenSocket(uint16_t numSock);
     bool sockWrite(const char * const s, uint32_t n, uint16_t numSock, bool isTcp);
@@ -373,21 +381,21 @@
     }
     
     // Important constants
-    static const uint16_t MAX_WNC_READ_BYTES        = 1500; // This bounds the largest amount of data that the WNC read from a socket will return, careful here large chunks come out of the heap
-    static const uint16_t MAX_WNC_WRITE_BYTES       = MAX_WNC_READ_BYTES;
-    static const uint16_t MAX_LEN_WNC_CMD_RESPONSE  = (MAX_WNC_READ_BYTES * 2 + 100);  // Max number of text characters in a WNC AT response
-    static const uint16_t WNC_AUTO_POLL_MS          = 250; // Sets default (may be overriden with method) poll interval
-    static const uint16_t WNC_CMD_TIMEOUT_MS        = 40000; // Sets default (may be overriden) time that the software waits for an AT response from the WNC
-    static const uint16_t WNC_QUICK_CMD_TIMEOUT_MS  = 2000; // Used for simple commands that should immediately respond such as "AT"
-    static const uint16_t WNC_WAIT_FOR_AT_CMD_MS    = 0; // 40; // Wait this much between AT commands, this is what WNC advises (they said 20mS, I added margin).
-    static const uint16_t MAX_WNC_SMS_LENGTH        = 150;
-    static const uint16_t WNC_SOFT_INIT_RETRY_COUNT = 10;
-    static const uint16_t WNC_DNS_RESOLVE_WAIT_MS   = 60000;
-    static const uint16_t WNC_TRUNC_DEBUG_LENGTH    = 80;  // Always make this an even number
-    static const uint16_t WNC_APNSET_TIMEOUT_MS     = 60000;
-    static const uint16_t WNC_PING_CMD_TIMEOUT_MS   = 60000;  //  Amount of time to wait for AT@PINGREQ with default params to timeout 
-    static const int      WNC_REINIT_MAX_TIME_MS    = 60000;
-    static const char * const INVALID_IP_STR;
+    static const uint16_t MAX_WNC_READ_BYTES        = 1500;                            // This bounds the largest amount of data that the WNC read from a socket will return
+    static const uint16_t MAX_WNC_WRITE_BYTES       = MAX_WNC_READ_BYTES;              // This is the largest amount of data that the WNC can write per sockwrite.
+    static const uint16_t MAX_LEN_WNC_CMD_RESPONSE  = (MAX_WNC_READ_BYTES * 2 + 100);  // Max number of text characters in a WNC AT response *2 because bytes are converted into 2 hex-digits +100 for other AT@ chars.
+    static const uint16_t WNC_AUTO_POLL_MS          = 250;   // Sets default (may be overriden with method) poll interval (currently not used, future possible feature.
+    static const uint16_t WNC_CMD_TIMEOUT_MS        = 40000; // Sets default (may be overriden) time that the software waits for an AT response from the WNC.
+    static const uint16_t WNC_QUICK_CMD_TIMEOUT_MS  = 2000;  // Used for simple commands that should immediately respond such as "AT", cmds that are quicker than WNC_CMD_TIMEOUT_MS.
+    static const uint16_t WNC_WAIT_FOR_AT_CMD_MS    = 0;     // Wait this much between multiple in a row AT commands to the WNC.
+    static const uint16_t MAX_WNC_SMS_LENGTH        = 150;   // The maximum length of an SMS message the WNC can send and receive.
+    static const uint16_t WNC_SOFT_INIT_RETRY_COUNT = 10;    // How many times the WNC will be tried to revive if it stops responding.
+    static const uint16_t WNC_DNS_RESOLVE_WAIT_MS   = 60000; // How much time to wait for the WNC to respond to a DNS resolve/lookup.
+    static const uint16_t WNC_TRUNC_DEBUG_LENGTH    = 80;    // Always make this an even number, how many chars for the debug output before shortening the debug ouput, this is used when moreDebug = false. 
+    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 char * const INVALID_IP_STR;                // Just a string set to an IP address when DNS resolve fails.
         
     struct WncSocketInfo_s {
         bool open;