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.
WncController.h
00001 /** 00002 Copyright (c) 2016 Fred Kellerman 00003 00004 Permission is hereby granted, free of charge, to any person obtaining a copy 00005 of this software and associated documentation files (the "Software"), to deal 00006 in the Software without restriction, including without limitation the rights 00007 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 00008 copies of the Software, and to permit persons to whom the Software is 00009 furnished to do so, subject to the following conditions: 00010 00011 The above copyright notice and this permission notice shall be included in 00012 all copies or substantial portions of the Software. 00013 00014 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 00015 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 00016 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 00017 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 00018 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 00019 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 00020 THE SOFTWARE. 00021 00022 @file WncController.h 00023 @purpose Controls WNC Cellular Modem 00024 @version 1.0 00025 @date July 2016 00026 @author Fred Kellerman 00027 00028 Notes: This code originates from the following mbed repository: 00029 00030 https://developer.mbed.org/teams/Avnet/code/WncControllerLibrary/ 00031 */ 00032 00033 00034 #ifndef __WNCCONTROLLER_H_ 00035 #define __WNCCONTROLLER_H_ 00036 00037 #include <string> 00038 #include <stdint.h> 00039 00040 namespace WncController_fk { 00041 00042 using namespace std; 00043 00044 /** @defgroup API The WncControllerLibrary API */ 00045 /** @defgroup MISC Misc WncControllerLibrary functions */ 00046 /** @defgroup INTERNALS WncControllerLibrary Internals */ 00047 00048 static const uint8_t MAX_LEN_IP_STR = 16; // Length includes room for the extra NULL 00049 00050 /** \brief Contains info fields for the WNC Internet Attributes */ 00051 struct WncIpStats 00052 { 00053 string wncMAC; 00054 char ip[MAX_LEN_IP_STR]; 00055 char mask[MAX_LEN_IP_STR]; 00056 char gateway[MAX_LEN_IP_STR]; 00057 char dnsPrimary[MAX_LEN_IP_STR]; 00058 char dnsSecondary[MAX_LEN_IP_STR]; 00059 }; 00060 00061 00062 /** 00063 * @author Fred Kellerman 00064 * @see API 00065 * 00066 * <b>WncController</b> This mbed C++ class is for controlling the WNC 00067 * Cellular modem via the serial AT command interface. This was 00068 * developed with respect to version 1.3 of the WNC authored 00069 * unpublished spec. This class is only designed to have 1 instantiation, 00070 * it is also not multi-thread safe. There are no OS specific 00071 * entities being used, there are pure virtual methods that an 00072 * inheriting class must fulfill. That inheriting class will have 00073 * OS and platform specific entities. See WncControllerK64F for an 00074 * example for the NXP K64F Freedom board. 00075 */ 00076 class WncController 00077 { 00078 public: 00079 00080 static const unsigned MAX_NUM_WNC_SOCKETS = 5; // Max number of simultaneous sockets that the WNC supports 00081 static const unsigned MAX_POWERUP_TIMEOUT = 60; // How long the powerUp method will try to turn on the WNC Shield 00082 // (this is the default if the user does not over-ride on power-up 00083 00084 /** Tracks mode of the WNC Shield hardware */ 00085 enum WncState_e { 00086 WNC_OFF = 0, 00087 WNC_ON, // This is intended to mean all systems go, including cell link up but socket may not be open 00088 WNC_ON_NO_CELL_LINK, 00089 WNC_NO_RESPONSE 00090 }; 00091 00092 /** 00093 * 00094 * Constructor for WncController class, sets up internals. 00095 * @ingroup API 00096 * @return none. 00097 */ 00098 WncController (void); 00099 virtual ~WncController ()=0; 00100 00101 /** 00102 * 00103 * Used internally but also make public for a user of the Class to 00104 * interrogate state as well. 00105 * @ingroup API 00106 * @return the current state of the Wnc hardware. 00107 */ 00108 WncState_e getWncStatus(void); 00109 00110 /** 00111 * 00112 * Allows a user to set the WNC modem to use the given Cellular APN 00113 * @ingroup API 00114 * @param apnStr - a null terminated c-string 00115 * @return true if the APN set was succesful, else false 00116 */ 00117 bool setApnName(const char * const apnStr); 00118 00119 /** 00120 * 00121 * Queries the WNC modem for the current RX RSSI in units of coded dBm 00122 * @ingroup API 00123 * @return 0 – -113 dBm or less 00124 * 1 – -111 dBm 00125 * 2...30 – -109 dBm to –53 dBm 00126 * 31 – -51 dBm or greater 00127 * 99 – not known or not detectable 00128 */ 00129 int16_t getDbmRssi(void); 00130 00131 /** 00132 * 00133 * Queries the WNC modem for the current Bit Error Rate 00134 * @ingroup API 00135 * @return 0...7 – as RXQUAL values in the table in 3GPP TS 45.008 00136 * subclause 8.2.4 00137 * 99 – not known or not detectable 00138 */ 00139 int16_t get3gBer(void); 00140 00141 /** 00142 * 00143 * Powers up the WNC modem 00144 * @ingroup API 00145 * @param apn - the apn c-string to set the WNC modem to use 00146 * @param powerUpTimeoutSecs - the amount of time to wait for the WNC modem to turn on 00147 * @return true if powerup was a success, else false. 00148 */ 00149 bool powerWncOn(const char * const apn, uint8_t powerUpTimeoutSecs = MAX_POWERUP_TIMEOUT); 00150 00151 /** 00152 * 00153 * Returns the NAT Self, gateway, masks and dns IP 00154 * @ingroup API 00155 * @param s - a pointer to a struct that will contain the IP info. 00156 * @return true if success, else false. 00157 */ 00158 bool getWncNetworkingStats(WncIpStats * s); 00159 00160 /** 00161 * 00162 * Takes a text URL and converts it internally to an IP address for the 00163 * socket number given. 00164 * @ingroup API 00165 * @param numSock - The number of the socket to lookup the IP address for. 00166 * @param url - a c-string text URL 00167 * @return true if success, else false. 00168 */ 00169 bool resolveUrl(uint16_t numSock, const char * url); 00170 00171 /** 00172 * 00173 * If you know the IP address you can set the socket up to use it rather 00174 * than using a text URL. 00175 * @ingroup API 00176 * @param numSock - The number of the socket to use the IP address for. 00177 * @param ipStr - a c-string text IP addrese like: 192.168.0.1 00178 * @return true if success, else false. 00179 */ 00180 bool setIpAddr(uint16_t numSock, const char * ipStr); 00181 00182 /** 00183 * 00184 * Opens a socket for the given number, port and IP protocol. Before 00185 * using open, you must use either resolveUrl() or setIpAddr(). 00186 * @ingroup API 00187 * @param numSock - The number of the socket to open. 00188 * @param port - the IP port to open 00189 * @param tcp - set true for TCP, false for UDP 00190 * @param timeoutSec - the amount of time in seconds to wait for the open to complete 00191 * @return true if success, else false. 00192 */ 00193 bool openSocket(uint16_t numSock, uint16_t port, bool tcp, uint16_t timeOutSec = 30); 00194 00195 /** 00196 * 00197 * Opens a socket for the given text URL, number, port and IP protocol. 00198 * @ingroup API 00199 * @param numSock - The number of the socket to open. 00200 * @param url - a c-string text URL, the one to open a socket for. 00201 * @param port - the IP port to open. 00202 * @param tcp - set true for TCP, false for UDP. 00203 * @param timeoutSec - the amount of time in seconds to wait for the open to complete. 00204 * @return true if success, else false. 00205 */ 00206 bool openSocketUrl(uint16_t numSock, const char * url, uint16_t port, bool tcp, uint16_t timeOutSec = 30); 00207 00208 /** 00209 * 00210 * Opens a socket for the given text IP address, number, port and IP protocol. 00211 * @ingroup API 00212 * @param numSock - The number of the socket to open. 00213 * @param ipAddr - a c-string text IP address like: "192.168.0.1". 00214 * @param port - the IP port to open. 00215 * @param tcp - set true for TCP, false for UDP. 00216 * @param timeoutSec - the amount of time in seconds to wait for the open to complete. 00217 * @return true if success, else false. 00218 */ 00219 bool openSocketIpAddr(uint16_t numSock, const char * ipAddr, uint16_t port, bool tcp, uint16_t timeOutSec = 30); 00220 00221 00222 /** 00223 * 00224 * Write data bytes to a Socket, the Socket must already be open. 00225 * @ingroup API 00226 * @param numSock - The number of the socket to open. 00227 * @parma s - an array of bytes to write to the socket. 00228 * @param n - the number of bytes to write. 00229 * @return true if success, else false. 00230 */ 00231 bool write(uint16_t numSock, const uint8_t * s, uint32_t n); 00232 00233 /** 00234 * 00235 * Poll to read available data bytes from an already open Socket. This method 00236 * will retry reads to what setReadRetries() sets it to and the delay in between 00237 * retries that is set with setReadRetryWait() 00238 * @ingroup API 00239 * @param numSock - The number of the socket to open. 00240 * @parma readBuf - a pointer to where read will put the data. 00241 * @param maxReadBufLen - The number of bytes readBuf has room for. 00242 * @return the number of bytes actually read into readBuf. 0 is a valid value if no data is available. 00243 */ 00244 size_t read(uint16_t numSock, uint8_t * readBuf, uint32_t maxReadBufLen); 00245 00246 /** 00247 * 00248 * Poll to read available data bytes from an already open Socket. This method 00249 * will retry reads to what setReadRetries() sets it to and the delay in between 00250 * retries that is set with setReadRetryWait() 00251 * @ingroup API 00252 * @param numSock - The number of the socket to open. 00253 * @parma readBuf - a pointer to pointer that will be set to point to an internal byte buffer that contains any read data. 00254 * @return the number of bytes actually read into the pointer that readBuf points to. 0 is a valid value if no data is available. 00255 */ 00256 size_t read(uint16_t numSock, const uint8_t ** readBuf); 00257 00258 /** 00259 * 00260 * Set the number of retries that the read methods will use. If a read returns 0 data this setting will have the read 00261 * re-read to see if new data is available. 00262 * @ingroup API 00263 * @param numSock - The number of the socket to open. 00264 * @parma retries - the number of retries to perform. 00265 * @return none. 00266 */ 00267 void setReadRetries(uint16_t numSock, uint16_t retries); 00268 00269 /** 00270 * 00271 * Set the time between retires that the read methods will use. If a read returns 0 data this setting will have the read 00272 * re-read and use this amount of delay in between the re-reads. 00273 * @ingroup API 00274 * @param numSock - The number of the socket to open. 00275 * @parma waitMs - the amount of time in mS to wait between retries. 00276 * @return none. 00277 */ 00278 void setReadRetryWait(uint16_t numSock, uint16_t waitMs); 00279 00280 /** 00281 * 00282 * Closes an already open Socket. 00283 * @ingroup API 00284 * @param numSock - The number of the socket to open. 00285 * @return true if success else false. 00286 */ 00287 bool closeSocket(uint16_t numSock); 00288 00289 /** 00290 * 00291 * Sets the amount of time to wait between the raw AT commands that are sent to the WNC modem. 00292 * Generally you don't want to use this but it is here just in case. 00293 * @ingroup API 00294 * @param toMs - num mS to wait between the AT cmds. 00295 * @return none. 00296 */ 00297 void setWncCmdTimeout(uint16_t toMs); 00298 00299 /** 00300 * 00301 * Gets the IP address of the given socket number. 00302 * @ingroup API 00303 * @param numSock - The number of the socket to open. 00304 * @param myIpAddr - a c-string that contains the socket's IP address. 00305 * @return true if success else false. 00306 */ 00307 bool getIpAddr(uint16_t numSock, char myIpAddr[MAX_LEN_IP_STR]); 00308 00309 /** 00310 * 00311 * Enables debug output from this class. 00312 * @ingroup API 00313 * @param on - true enables debug output, false disables 00314 * @param moreDebugOn - true enables verbose debug, false truncates debug output. 00315 * @return none. 00316 */ 00317 void enableDebug(bool on, bool moreDebugOn); 00318 00319 /** 00320 * 00321 * Reports the WNC Firmware Revision info. 00322 * @ingroup API 00323 * @param none. 00324 * @return char * 00325 */ 00326 const char* getFirmRev(void); 00327 00328 /////////////////////////////////////////// 00329 // SMS messaging 00330 /////////////////////////////////////////// 00331 00332 static const uint16_t MAX_WNC_SMS_MSG_SLOTS = 3; // How many SMS messages the WNC can store and receive at a time. 00333 static const uint16_t MAX_WNC_SMS_LENGTH = 160; // The maximum length of a 7-bit SMS message the WNC can send and receive. 00334 00335 /** Struct for SMS messages */ 00336 struct WncSmsInfo 00337 { 00338 // Content 00339 char idx; 00340 string number; 00341 string date; 00342 string time; 00343 string msg; 00344 00345 // Attributes 00346 bool incoming; 00347 bool unsent; 00348 bool unread; 00349 bool pduMode; 00350 bool msgReceipt; 00351 }; 00352 00353 /** Struct to contain a list of SMS message structs */ 00354 struct WncSmsList 00355 { 00356 uint8_t msgCount; 00357 WncSmsInfo e[MAX_WNC_SMS_MSG_SLOTS]; 00358 }; 00359 00360 /** 00361 * 00362 * Sends an SMS text message to someone. 00363 * @ingroup API 00364 * @param phoneNum - c-string 15 digit MSISDN number or ATT Jasper number (standard phone number not supported because ATT IoT SMS does not support it). 00365 * @param text - the c-string text to send to someone. 00366 * @return true if success else false. 00367 */ 00368 bool sendSMSText(const char * const phoneNum, const char * const text); 00369 00370 /** 00371 * 00372 * Incoming messages are stored in a log in the WNC modem, this will read that 00373 * log. 00374 * @ingroup API 00375 * @param log - the log contents if reading it was successful. 00376 * @return true if success else false. 00377 */ 00378 bool readSMSLog(struct WncSmsList * log); 00379 00380 /** 00381 * 00382 * Incoming messages are stored in a log in the WNC modem, this will read out 00383 * messages that are unread and also then mark them read. 00384 * @ingroup API 00385 * @param w - a list of SMS messages that unread messages will be put into. 00386 * @param deleteRead - if a message is read and this is set true the message will be deleted from the WNC modem log. 00387 * If it is false the message will remain in the internal log but be marked as read. 00388 * @return true if success else false. 00389 */ 00390 bool readUnreadSMSText(struct WncSmsList * w, bool deleteRead = true); 00391 00392 /** 00393 * 00394 * Saves a text message into internal SIM card memory of the WNC modem. 00395 * There are only 3 slots available this is for unread, read and saved. 00396 * @ingroup API 00397 * @param phoneNum - c-string 15 digit MSISDN number or ATT Jasper number (standard phone number not supported because ATT IoT SMS does not support it). 00398 * @param text - the c-string text to send to someone. 00399 * @param msgIdx - the slot position to save the message: '1', '2', '3' 00400 * @return true if success else false. 00401 */ 00402 bool saveSMSText(const char * const phoneNum, const char * const text, char * msgIdx); 00403 00404 /** 00405 * 00406 * Sends a prior stored a text message from internal SIM card memory of the WNC modem. 00407 * If no messages are stored the behaviour of this method is undefined. 00408 * @ingroup API 00409 * @param msgIdx - the slot position to save the message: '1', '2', '3' 00410 * @return true if success else false. 00411 */ 00412 bool sendSMSTextFromMem(char msgIdx); 00413 00414 /** 00415 * 00416 * Deletes a prior stored a text message from internal SIM card memory of the WNC modem. 00417 * If no messages are stored the behaviour of this method is undefined. 00418 * @ingroup API 00419 * @param msgIdx - the slot position to save the message: '1', '2', '3' or '*' deletes them all. 00420 * @return true if success else false. 00421 */ 00422 bool deleteSMSTextFromMem(char msgIdx); 00423 00424 /** 00425 * 00426 * Retreives the SIM card ICCID number. 00427 * @ingroup API 00428 * @param iccid - a pointer to C++ string that contains the retrieved number. 00429 * @return true if success else false. 00430 */ 00431 bool getICCID(string * iccid); 00432 00433 /** 00434 * 00435 * Converts an ICCID number into a MSISDN number. The ATT SMS system for IoT only allows use of the 15-digit MSISDN number. 00436 * @ingroup API 00437 * @param iccid - the number to convert. 00438 * @param msisdn - points to a C++ string that has the converted number. 00439 * @return true if success else false. 00440 */ 00441 bool convertICCIDtoMSISDN(const string & iccid, string * msisdn); 00442 00443 /////////////////////////////////////////// 00444 // Neighborhood Cell Info 00445 /////////////////////////////////////////// 00446 00447 /** 00448 * 00449 * Fetches the signal quality log from the WNC modem. 00450 * @ingroup API 00451 * @param log - a pointer to an internal buffer who's contents contain the signal quality metrics. 00452 * @return The number of chars in the log. 00453 */ 00454 size_t getSignalQuality(const char ** log); 00455 00456 /** A struct for the WNC modem Date and Time */ 00457 struct WncDateTime 00458 { 00459 uint8_t year; 00460 uint8_t month; 00461 uint8_t day; 00462 uint8_t hour; 00463 uint8_t min; 00464 uint8_t sec; 00465 }; 00466 00467 /** 00468 * 00469 * Fetches the cell tower's time and date. The time is accurate when read 00470 * but significant delays exist between the time it is read and returned. 00471 * @ingroup API 00472 * @param tod - User supplies a pointer to a tod struct and this method fills it in. 00473 * @return true if success else false. 00474 */ 00475 bool getTimeDate(struct WncDateTime * tod); 00476 00477 /** 00478 * 00479 * ICMP Pings a URL, the results are only output to the debug log for now! 00480 * @ingroup API 00481 * @param url - a c-string whose URL is to be pinged. 00482 * @return true if success else false. 00483 */ 00484 bool pingUrl(const char * url); 00485 00486 /** 00487 * 00488 * ICMP Pings an IP, the results are only output to the debug log for now! 00489 * @ingroup API 00490 * @param ip - a c-string whose IP is to be pinged. 00491 * @return true if success else false. 00492 */ 00493 bool pingIp(const char * ip); 00494 00495 /** 00496 * 00497 * Allows a user to send a raw AT command to the WNC modem. 00498 * @ingroup API 00499 * @param cmd - the c-string cmd to send like: "AT" 00500 * @param resp - a pointer to the c-string cmd's response. 00501 * @param sizeRespBuf - how large the command response buffer is, sets the max response length. 00502 * @param ms_timeout - how long to wait for the WNC to respond to your command. 00503 * @return the number of characters in the response from the WNC modem. 00504 */ 00505 size_t sendCustomCmd(const char * cmd, char * resp, size_t sizeRespBuf, int ms_timeout); 00506 00507 protected: 00508 00509 // Debug output methods 00510 int dbgPutsNoTime(const char * s, bool crlf = true); 00511 int dbgPuts(const char * s, bool crlf = true); 00512 const char * _to_string(int64_t value); 00513 const char * _to_hex_string(uint8_t value); 00514 00515 // Sends commands to WNC via 00516 enum AtCmdErr_e { 00517 WNC_AT_CMD_OK, 00518 WNC_AT_CMD_ERR, 00519 WNC_AT_CMD_ERREXT, 00520 WNC_AT_CMD_ERRCME, 00521 WNC_AT_CMD_INVALID_RESPONSE, 00522 WNC_AT_CMD_TIMEOUT, 00523 WNC_AT_CMD_NO_CELL_LINK, 00524 WNC_AT_CMD_WNC_NOT_ON 00525 }; 00526 00527 bool waitForPowerOnModemToRespond(uint8_t powerUpTimeoutSecs); 00528 AtCmdErr_e sendWncCmd(const char * const s, string ** r, int ms_timeout); 00529 00530 // Users must define these functionalities in the inheriting class: 00531 // General I/O and timing: 00532 virtual int putc(char c) = 0; 00533 virtual int puts(const char * s) = 0; 00534 virtual char getc(void) = 0; 00535 virtual int charReady(void) = 0; 00536 virtual int dbgWriteChar(char b) = 0; 00537 virtual int dbgWriteChars(const char *b) = 0; 00538 virtual void waitMs(int t) = 0; 00539 virtual void waitUs(int t) = 0; 00540 virtual bool initWncModem(uint8_t powerUpTimeoutSecs) = 0; 00541 00542 // Isolate OS timers 00543 virtual int getLogTimerTicks(void) = 0; 00544 virtual void startTimerA(void) = 0; 00545 virtual void stopTimerA(void) = 0; 00546 virtual int getTimerTicksA_mS(void) = 0; 00547 virtual void startTimerB(void) = 0; 00548 virtual void stopTimerB(void) = 0; 00549 virtual int getTimerTicksB_mS(void) = 0; 00550 00551 private: 00552 00553 bool softwareInitMdm(void); 00554 bool checkCellLink(void); 00555 AtCmdErr_e mdmSendAtCmdRsp(const char * cmd, int timeout_ms, string * rsp, bool crLf = true); 00556 size_t mdmGetline(string * buff, int timeout_ms); 00557 bool at_at_wnc(void); 00558 bool at_init_wnc(bool hardReset = false); 00559 int16_t at_sockopen_wnc(const char * const ip, uint16_t port, uint16_t numSock, bool tcp, uint16_t timeOutSec); 00560 bool at_sockclose_wnc(uint16_t numSock); 00561 bool at_dnsresolve_wnc(const char * s, string * ipStr); 00562 AtCmdErr_e at_sockwrite_wnc(const uint8_t * s, uint16_t n, uint16_t numSock, bool isTcp); 00563 AtCmdErr_e at_sockread_wnc(uint8_t * pS, uint16_t * numRead, uint16_t n, uint16_t numSock, bool isTcp); 00564 AtCmdErr_e at_sockread_wnc(string * pS, uint16_t numSock, bool isTcp); 00565 bool at_reinitialize_mdm(void); 00566 AtCmdErr_e at_send_wnc_cmd(const char * s, string ** r, int ms_timeout); 00567 bool at_setapn_wnc(const char * const apnStr); 00568 bool at_sendSMStext_wnc(const char * const phoneNum, const char * const text); 00569 bool at_get_wnc_net_stats(WncIpStats * s); 00570 bool at_readSMSlog_wnc(string ** log); 00571 size_t at_readSMStext_wnc(const char ** log); 00572 size_t at_readSMStext_wnc(const char n, const char ** log); 00573 bool at_getrssiber_wnc(int16_t * dBm, int16_t * ber3g); 00574 void closeOpenSocket(uint16_t numSock); 00575 bool sockWrite(const uint8_t * const s, uint16_t n, uint16_t numSock, bool isTcp); 00576 bool at_sendSMStextMem_wnc(char n); 00577 bool at_deleteSMSTextFromMem_wnc(char n); 00578 bool at_saveSMStext_wnc(const char * const phoneNum, const char * const text, char * msgIdx); 00579 size_t at_getSignalQuality_wnc(const char ** log); 00580 bool at_gettimedate_wnc(struct WncDateTime * tod); 00581 bool at_ping_wnc(const char * ip); 00582 bool at_geticcid_wnc(string * iccid); 00583 00584 // Utility methods 00585 void sendCmd(const char * cmd, bool crLf); 00586 void sendCmd(const char * cmd, unsigned n, unsigned wait_uS, bool crLf); 00587 inline void rx_char_wait(void) { 00588 // waitUs(1000); 00589 } 00590 00591 // Important constants 00592 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 00593 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. 00594 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. 00595 static const uint16_t WNC_AUTO_POLL_MS = 250; // Sets default (may be overriden with method) poll interval (currently not used, future possible feature. 00596 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. 00597 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. 00598 static const uint16_t WNC_WAIT_FOR_AT_CMD_MS = 0; // Wait this much between multiple in a row AT commands to the WNC. 00599 static const uint16_t WNC_SOFT_INIT_RETRY_COUNT = 10; // How many times the WNC will be tried to revive if it stops responding. 00600 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. 00601 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. 00602 static const uint16_t WNC_APNSET_TIMEOUT_MS = 60000; // How long to wait for the WNC to respond to setting the APN string. 00603 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) 00604 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. 00605 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. 00606 static const char * const INVALID_IP_STR; // Just a string set to an IP address when DNS resolve fails. 00607 00608 struct WncSocketInfo_s { 00609 int16_t numWncSock; 00610 bool open; 00611 string myIpAddressStr; 00612 uint16_t myPort; 00613 uint8_t readRetries; 00614 uint16_t readRetryWaitMs; 00615 bool isTcp; 00616 uint16_t timeOutSec; 00617 }; 00618 00619 static WncSocketInfo_s m_sSock[MAX_NUM_WNC_SOCKETS]; 00620 static const WncSocketInfo_s defaultSockStruct; 00621 static WncState_e m_sState; 00622 static uint16_t m_sCmdTimeoutMs; 00623 static string m_sApnStr; 00624 static string m_sWncStr; 00625 static string m_FirmwareRevision; 00626 static uint8_t m_sPowerUpTimeoutSecs; 00627 static bool m_sDebugEnabled; 00628 static bool m_sMoreDebugEnabled; 00629 static bool m_sCheckNetStatus; 00630 static bool m_sReadyForSMS; 00631 }; 00632 00633 }; // End namespace WncController_fk 00634 00635 #endif 00636
Generated on Tue Jul 12 2022 19:02:38 by
1.7.2