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

Fork of WncControllerLibrary by Fred Kellerman

Committer:
jmf
Date:
Thu Apr 06 21:42:30 2017 -0400
Revision:
36:d1a98d5f2bbd
Parent:
33:2958e09ad308
jdfjadfjadlkjfasd;lkj

Who changed what in which revision?

UserRevisionLine numberNew contents of line
jmf 36:d1a98d5f2bbd 1 /**
jmf 36:d1a98d5f2bbd 2 Copyright (c) 2016 Fred Kellerman
jmf 36:d1a98d5f2bbd 3
jmf 36:d1a98d5f2bbd 4 Permission is hereby granted, free of charge, to any person obtaining a copy
jmf 36:d1a98d5f2bbd 5 of this software and associated documentation files (the "Software"), to deal
jmf 36:d1a98d5f2bbd 6 in the Software without restriction, including without limitation the rights
jmf 36:d1a98d5f2bbd 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
jmf 36:d1a98d5f2bbd 8 copies of the Software, and to permit persons to whom the Software is
jmf 36:d1a98d5f2bbd 9 furnished to do so, subject to the following conditions:
jmf 36:d1a98d5f2bbd 10
jmf 36:d1a98d5f2bbd 11 The above copyright notice and this permission notice shall be included in
jmf 36:d1a98d5f2bbd 12 all copies or substantial portions of the Software.
jmf 36:d1a98d5f2bbd 13
jmf 36:d1a98d5f2bbd 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
jmf 36:d1a98d5f2bbd 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
jmf 36:d1a98d5f2bbd 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
jmf 36:d1a98d5f2bbd 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
jmf 36:d1a98d5f2bbd 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
jmf 36:d1a98d5f2bbd 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
jmf 36:d1a98d5f2bbd 20 THE SOFTWARE.
jmf 36:d1a98d5f2bbd 21
jmf 36:d1a98d5f2bbd 22 @file WncController.h
jmf 36:d1a98d5f2bbd 23 @purpose Controls WNC Cellular Modem
jmf 36:d1a98d5f2bbd 24 @version 1.0
jmf 36:d1a98d5f2bbd 25 @date July 2016
jmf 36:d1a98d5f2bbd 26 @author Fred Kellerman
jmf 36:d1a98d5f2bbd 27
jmf 36:d1a98d5f2bbd 28 Notes: This code originates from the following mbed repository:
jmf 36:d1a98d5f2bbd 29
jmf 36:d1a98d5f2bbd 30 https://developer.mbed.org/teams/Avnet/code/WncControllerLibrary/
jmf 36:d1a98d5f2bbd 31 */
jmf 36:d1a98d5f2bbd 32
jmf 36:d1a98d5f2bbd 33
jmf 36:d1a98d5f2bbd 34 #ifndef __WNCCONTROLLER_H_
jmf 36:d1a98d5f2bbd 35 #define __WNCCONTROLLER_H_
jmf 36:d1a98d5f2bbd 36
jmf 36:d1a98d5f2bbd 37 #include <string>
jmf 36:d1a98d5f2bbd 38 #include <stdint.h>
jmf 36:d1a98d5f2bbd 39
jmf 36:d1a98d5f2bbd 40 namespace WncController_fk {
jmf 36:d1a98d5f2bbd 41
jmf 36:d1a98d5f2bbd 42 using namespace std;
jmf 36:d1a98d5f2bbd 43
jmf 36:d1a98d5f2bbd 44 /** @defgroup API The WncControllerLibrary API */
jmf 36:d1a98d5f2bbd 45 /** @defgroup MISC Misc WncControllerLibrary functions */
jmf 36:d1a98d5f2bbd 46 /** @defgroup INTERNALS WncControllerLibrary Internals */
jmf 36:d1a98d5f2bbd 47
jmf 36:d1a98d5f2bbd 48 static const uint8_t MAX_LEN_IP_STR = 16; // Length includes room for the extra NULL
jmf 36:d1a98d5f2bbd 49
jmf 36:d1a98d5f2bbd 50 /** \brief Contains info fields for the WNC Internet Attributes */
jmf 36:d1a98d5f2bbd 51 struct WncIpStats
jmf 36:d1a98d5f2bbd 52 {
jmf 36:d1a98d5f2bbd 53 string wncMAC;
jmf 36:d1a98d5f2bbd 54 char ip[MAX_LEN_IP_STR];
jmf 36:d1a98d5f2bbd 55 char mask[MAX_LEN_IP_STR];
jmf 36:d1a98d5f2bbd 56 char gateway[MAX_LEN_IP_STR];
jmf 36:d1a98d5f2bbd 57 char dnsPrimary[MAX_LEN_IP_STR];
jmf 36:d1a98d5f2bbd 58 char dnsSecondary[MAX_LEN_IP_STR];
jmf 36:d1a98d5f2bbd 59 };
jmf 36:d1a98d5f2bbd 60
jmf 36:d1a98d5f2bbd 61
jmf 36:d1a98d5f2bbd 62 /**
jmf 36:d1a98d5f2bbd 63 * @author Fred Kellerman
jmf 36:d1a98d5f2bbd 64 * @see API
jmf 36:d1a98d5f2bbd 65 *
jmf 36:d1a98d5f2bbd 66 * <b>WncController</b> This mbed C++ class is for controlling the WNC
jmf 36:d1a98d5f2bbd 67 * Cellular modem via the serial AT command interface. This was
jmf 36:d1a98d5f2bbd 68 * developed with respect to version 1.3 of the WNC authored
jmf 36:d1a98d5f2bbd 69 * unpublished spec. This class is only designed to have 1 instantiation,
jmf 36:d1a98d5f2bbd 70 * it is also not multi-thread safe. There are no OS specific
jmf 36:d1a98d5f2bbd 71 * entities being used, there are pure virtual methods that an
jmf 36:d1a98d5f2bbd 72 * inheriting class must fulfill. That inheriting class will have
jmf 36:d1a98d5f2bbd 73 * OS and platform specific entities. See WncControllerK64F for an
jmf 36:d1a98d5f2bbd 74 * example for the NXP K64F Freedom board.
jmf 36:d1a98d5f2bbd 75 */
jmf 36:d1a98d5f2bbd 76 class WncController
jmf 36:d1a98d5f2bbd 77 {
jmf 36:d1a98d5f2bbd 78 public:
jmf 36:d1a98d5f2bbd 79
jmf 36:d1a98d5f2bbd 80 static const unsigned MAX_NUM_WNC_SOCKETS = 5; // Max number of simultaneous sockets that the WNC supports
jmf 36:d1a98d5f2bbd 81 static const unsigned MAX_POWERUP_TIMEOUT = 60; // How long the powerUp method will try to turn on the WNC Shield
jmf 36:d1a98d5f2bbd 82 // (this is the default if the user does not over-ride on power-up
jmf 36:d1a98d5f2bbd 83
jmf 36:d1a98d5f2bbd 84 /** Tracks mode of the WNC Shield hardware */
jmf 36:d1a98d5f2bbd 85 enum WncState_e {
jmf 36:d1a98d5f2bbd 86 WNC_OFF = 0,
jmf 36:d1a98d5f2bbd 87 WNC_ON, // This is intended to mean all systems go, including cell link up but socket may not be open
jmf 36:d1a98d5f2bbd 88 WNC_ON_NO_CELL_LINK,
jmf 36:d1a98d5f2bbd 89 WNC_NO_RESPONSE
jmf 36:d1a98d5f2bbd 90 };
jmf 36:d1a98d5f2bbd 91
jmf 36:d1a98d5f2bbd 92 /**
jmf 36:d1a98d5f2bbd 93 *
jmf 36:d1a98d5f2bbd 94 * Constructor for WncController class, sets up internals.
jmf 36:d1a98d5f2bbd 95 * @ingroup API
jmf 36:d1a98d5f2bbd 96 * @return none.
jmf 36:d1a98d5f2bbd 97 */
jmf 36:d1a98d5f2bbd 98 WncController(void);
jmf 36:d1a98d5f2bbd 99
jmf 36:d1a98d5f2bbd 100 /**
jmf 36:d1a98d5f2bbd 101 *
jmf 36:d1a98d5f2bbd 102 * Used internally but also make public for a user of the Class to
jmf 36:d1a98d5f2bbd 103 * interrogate state as well.
jmf 36:d1a98d5f2bbd 104 * @ingroup API
jmf 36:d1a98d5f2bbd 105 * @return the current state of the Wnc hardware.
jmf 36:d1a98d5f2bbd 106 */
jmf 36:d1a98d5f2bbd 107 WncState_e getWncStatus(void);
jmf 36:d1a98d5f2bbd 108
jmf 36:d1a98d5f2bbd 109 /**
jmf 36:d1a98d5f2bbd 110 *
jmf 36:d1a98d5f2bbd 111 * Allows a user to set the WNC modem to use the given Cellular APN
jmf 36:d1a98d5f2bbd 112 * @ingroup API
jmf 36:d1a98d5f2bbd 113 * @param apnStr - a null terminated c-string
jmf 36:d1a98d5f2bbd 114 * @return true if the APN set was succesful, else false
jmf 36:d1a98d5f2bbd 115 */
jmf 36:d1a98d5f2bbd 116 bool setApnName(const char * const apnStr);
jmf 36:d1a98d5f2bbd 117
jmf 36:d1a98d5f2bbd 118 /**
jmf 36:d1a98d5f2bbd 119 *
jmf 36:d1a98d5f2bbd 120 * Queries the WNC modem for the current RX RSSI in units of coded dBm
jmf 36:d1a98d5f2bbd 121 * @ingroup API
jmf 36:d1a98d5f2bbd 122 * @return 0 – -113 dBm or less
jmf 36:d1a98d5f2bbd 123 * 1 – -111 dBm
jmf 36:d1a98d5f2bbd 124 * 2...30 – -109 dBm to –53 dBm
jmf 36:d1a98d5f2bbd 125 * 31 – -51 dBm or greater
jmf 36:d1a98d5f2bbd 126 * 99 – not known or not detectable
jmf 36:d1a98d5f2bbd 127 */
jmf 36:d1a98d5f2bbd 128 int16_t getDbmRssi(void);
jmf 36:d1a98d5f2bbd 129
jmf 36:d1a98d5f2bbd 130 /**
jmf 36:d1a98d5f2bbd 131 *
jmf 36:d1a98d5f2bbd 132 * Queries the WNC modem for the current Bit Error Rate
jmf 36:d1a98d5f2bbd 133 * @ingroup API
jmf 36:d1a98d5f2bbd 134 * @return 0...7 – as RXQUAL values in the table in 3GPP TS 45.008
jmf 36:d1a98d5f2bbd 135 * subclause 8.2.4
jmf 36:d1a98d5f2bbd 136 * 99 – not known or not detectable
jmf 36:d1a98d5f2bbd 137 */
jmf 36:d1a98d5f2bbd 138 int16_t get3gBer(void);
jmf 36:d1a98d5f2bbd 139
jmf 36:d1a98d5f2bbd 140 /**
jmf 36:d1a98d5f2bbd 141 *
jmf 36:d1a98d5f2bbd 142 * Powers up the WNC modem
jmf 36:d1a98d5f2bbd 143 * @ingroup API
jmf 36:d1a98d5f2bbd 144 * @param apn - the apn c-string to set the WNC modem to use
jmf 36:d1a98d5f2bbd 145 * @param powerUpTimeoutSecs - the amount of time to wait for the WNC modem to turn on
jmf 36:d1a98d5f2bbd 146 * @return true if powerup was a success, else false.
jmf 36:d1a98d5f2bbd 147 */
jmf 36:d1a98d5f2bbd 148 bool powerWncOn(const char * const apn, uint8_t powerUpTimeoutSecs = MAX_POWERUP_TIMEOUT);
jmf 36:d1a98d5f2bbd 149
jmf 36:d1a98d5f2bbd 150 /**
jmf 36:d1a98d5f2bbd 151 *
jmf 36:d1a98d5f2bbd 152 * Returns the NAT Self, gateway, masks and dns IP
jmf 36:d1a98d5f2bbd 153 * @ingroup API
jmf 36:d1a98d5f2bbd 154 * @param s - a pointer to a struct that will contain the IP info.
jmf 36:d1a98d5f2bbd 155 * @return true if success, else false.
jmf 36:d1a98d5f2bbd 156 */
jmf 36:d1a98d5f2bbd 157 bool getWncNetworkingStats(WncIpStats * s);
jmf 36:d1a98d5f2bbd 158
jmf 36:d1a98d5f2bbd 159 /**
jmf 36:d1a98d5f2bbd 160 *
jmf 36:d1a98d5f2bbd 161 * Takes a text URL and converts it internally to an IP address for the
jmf 36:d1a98d5f2bbd 162 * socket number given.
jmf 36:d1a98d5f2bbd 163 * @ingroup API
jmf 36:d1a98d5f2bbd 164 * @param numSock - The number of the socket to lookup the IP address for.
jmf 36:d1a98d5f2bbd 165 * @param url - a c-string text URL
jmf 36:d1a98d5f2bbd 166 * @return true if success, else false.
jmf 36:d1a98d5f2bbd 167 */
jmf 36:d1a98d5f2bbd 168 bool resolveUrl(uint16_t numSock, const char * url);
jmf 36:d1a98d5f2bbd 169
jmf 36:d1a98d5f2bbd 170 /**
jmf 36:d1a98d5f2bbd 171 *
jmf 36:d1a98d5f2bbd 172 * If you know the IP address you can set the socket up to use it rather
jmf 36:d1a98d5f2bbd 173 * than using a text URL.
jmf 36:d1a98d5f2bbd 174 * @ingroup API
jmf 36:d1a98d5f2bbd 175 * @param numSock - The number of the socket to use the IP address for.
jmf 36:d1a98d5f2bbd 176 * @param ipStr - a c-string text IP addrese like: 192.168.0.1
jmf 36:d1a98d5f2bbd 177 * @return true if success, else false.
jmf 36:d1a98d5f2bbd 178 */
jmf 36:d1a98d5f2bbd 179 bool setIpAddr(uint16_t numSock, const char * ipStr);
jmf 36:d1a98d5f2bbd 180
jmf 36:d1a98d5f2bbd 181 /**
jmf 36:d1a98d5f2bbd 182 *
jmf 36:d1a98d5f2bbd 183 * Opens a socket for the given number, port and IP protocol. Before
jmf 36:d1a98d5f2bbd 184 * using open, you must use either resolveUrl() or setIpAddr().
jmf 36:d1a98d5f2bbd 185 * @ingroup API
jmf 36:d1a98d5f2bbd 186 * @param numSock - The number of the socket to open.
jmf 36:d1a98d5f2bbd 187 * @param port - the IP port to open
jmf 36:d1a98d5f2bbd 188 * @param tcp - set true for TCP, false for UDP
jmf 36:d1a98d5f2bbd 189 * @param timeoutSec - the amount of time in seconds to wait for the open to complete
jmf 36:d1a98d5f2bbd 190 * @return true if success, else false.
jmf 36:d1a98d5f2bbd 191 */
jmf 36:d1a98d5f2bbd 192 bool openSocket(uint16_t numSock, uint16_t port, bool tcp, uint16_t timeOutSec = 30);
jmf 36:d1a98d5f2bbd 193
jmf 36:d1a98d5f2bbd 194 /**
jmf 36:d1a98d5f2bbd 195 *
jmf 36:d1a98d5f2bbd 196 * Opens a socket for the given text URL, number, port and IP protocol.
jmf 36:d1a98d5f2bbd 197 * @ingroup API
jmf 36:d1a98d5f2bbd 198 * @param numSock - The number of the socket to open.
jmf 36:d1a98d5f2bbd 199 * @param url - a c-string text URL, the one to open a socket for.
jmf 36:d1a98d5f2bbd 200 * @param port - the IP port to open.
jmf 36:d1a98d5f2bbd 201 * @param tcp - set true for TCP, false for UDP.
jmf 36:d1a98d5f2bbd 202 * @param timeoutSec - the amount of time in seconds to wait for the open to complete.
jmf 36:d1a98d5f2bbd 203 * @return true if success, else false.
jmf 36:d1a98d5f2bbd 204 */
jmf 36:d1a98d5f2bbd 205 bool openSocketUrl(uint16_t numSock, const char * url, uint16_t port, bool tcp, uint16_t timeOutSec = 30);
jmf 36:d1a98d5f2bbd 206
jmf 36:d1a98d5f2bbd 207 /**
jmf 36:d1a98d5f2bbd 208 *
jmf 36:d1a98d5f2bbd 209 * Opens a socket for the given text IP address, number, port and IP protocol.
jmf 36:d1a98d5f2bbd 210 * @ingroup API
jmf 36:d1a98d5f2bbd 211 * @param numSock - The number of the socket to open.
jmf 36:d1a98d5f2bbd 212 * @param ipAddr - a c-string text IP address like: "192.168.0.1".
jmf 36:d1a98d5f2bbd 213 * @param port - the IP port to open.
jmf 36:d1a98d5f2bbd 214 * @param tcp - set true for TCP, false for UDP.
jmf 36:d1a98d5f2bbd 215 * @param timeoutSec - the amount of time in seconds to wait for the open to complete.
jmf 36:d1a98d5f2bbd 216 * @return true if success, else false.
jmf 36:d1a98d5f2bbd 217 */
jmf 36:d1a98d5f2bbd 218 bool openSocketIpAddr(uint16_t numSock, const char * ipAddr, uint16_t port, bool tcp, uint16_t timeOutSec = 30);
jmf 36:d1a98d5f2bbd 219
jmf 36:d1a98d5f2bbd 220
jmf 36:d1a98d5f2bbd 221 /**
jmf 36:d1a98d5f2bbd 222 *
jmf 36:d1a98d5f2bbd 223 * Write data bytes to a Socket, the Socket must already be open.
jmf 36:d1a98d5f2bbd 224 * @ingroup API
jmf 36:d1a98d5f2bbd 225 * @param numSock - The number of the socket to open.
jmf 36:d1a98d5f2bbd 226 * @parma s - an array of bytes to write to the socket.
jmf 36:d1a98d5f2bbd 227 * @param n - the number of bytes to write.
jmf 36:d1a98d5f2bbd 228 * @return true if success, else false.
jmf 36:d1a98d5f2bbd 229 */
jmf 36:d1a98d5f2bbd 230 bool write(uint16_t numSock, const uint8_t * s, uint32_t n);
jmf 36:d1a98d5f2bbd 231
jmf 36:d1a98d5f2bbd 232 /**
jmf 36:d1a98d5f2bbd 233 *
jmf 36:d1a98d5f2bbd 234 * Poll to read available data bytes from an already open Socket. This method
jmf 36:d1a98d5f2bbd 235 * will retry reads to what setReadRetries() sets it to and the delay in between
jmf 36:d1a98d5f2bbd 236 * retries that is set with setReadRetryWait()
jmf 36:d1a98d5f2bbd 237 * @ingroup API
jmf 36:d1a98d5f2bbd 238 * @param numSock - The number of the socket to open.
jmf 36:d1a98d5f2bbd 239 * @parma readBuf - a pointer to where read will put the data.
jmf 36:d1a98d5f2bbd 240 * @param maxReadBufLen - The number of bytes readBuf has room for.
jmf 36:d1a98d5f2bbd 241 * @return the number of bytes actually read into readBuf. 0 is a valid value if no data is available.
jmf 36:d1a98d5f2bbd 242 */
jmf 36:d1a98d5f2bbd 243 size_t read(uint16_t numSock, uint8_t * readBuf, uint32_t maxReadBufLen);
jmf 36:d1a98d5f2bbd 244
jmf 36:d1a98d5f2bbd 245 /**
jmf 36:d1a98d5f2bbd 246 *
jmf 36:d1a98d5f2bbd 247 * Poll to read available data bytes from an already open Socket. This method
jmf 36:d1a98d5f2bbd 248 * will retry reads to what setReadRetries() sets it to and the delay in between
jmf 36:d1a98d5f2bbd 249 * retries that is set with setReadRetryWait()
jmf 36:d1a98d5f2bbd 250 * @ingroup API
jmf 36:d1a98d5f2bbd 251 * @param numSock - The number of the socket to open.
jmf 36:d1a98d5f2bbd 252 * @parma readBuf - a pointer to pointer that will be set to point to an internal byte buffer that contains any read data.
jmf 36:d1a98d5f2bbd 253 * @return the number of bytes actually read into the pointer that readBuf points to. 0 is a valid value if no data is available.
jmf 36:d1a98d5f2bbd 254 */
jmf 36:d1a98d5f2bbd 255 size_t read(uint16_t numSock, const uint8_t ** readBuf);
jmf 36:d1a98d5f2bbd 256
jmf 36:d1a98d5f2bbd 257 /**
jmf 36:d1a98d5f2bbd 258 *
jmf 36:d1a98d5f2bbd 259 * Set the number of retries that the read methods will use. If a read returns 0 data this setting will have the read
jmf 36:d1a98d5f2bbd 260 * re-read to see if new data is available.
jmf 36:d1a98d5f2bbd 261 * @ingroup API
jmf 36:d1a98d5f2bbd 262 * @param numSock - The number of the socket to open.
jmf 36:d1a98d5f2bbd 263 * @parma retries - the number of retries to perform.
jmf 36:d1a98d5f2bbd 264 * @return none.
jmf 36:d1a98d5f2bbd 265 */
jmf 36:d1a98d5f2bbd 266 void setReadRetries(uint16_t numSock, uint16_t retries);
jmf 36:d1a98d5f2bbd 267
jmf 36:d1a98d5f2bbd 268 /**
jmf 36:d1a98d5f2bbd 269 *
jmf 36:d1a98d5f2bbd 270 * Set the time between retires that the read methods will use. If a read returns 0 data this setting will have the read
jmf 36:d1a98d5f2bbd 271 * re-read and use this amount of delay in between the re-reads.
jmf 36:d1a98d5f2bbd 272 * @ingroup API
jmf 36:d1a98d5f2bbd 273 * @param numSock - The number of the socket to open.
jmf 36:d1a98d5f2bbd 274 * @parma waitMs - the amount of time in mS to wait between retries.
jmf 36:d1a98d5f2bbd 275 * @return none.
jmf 36:d1a98d5f2bbd 276 */
jmf 36:d1a98d5f2bbd 277 void setReadRetryWait(uint16_t numSock, uint16_t waitMs);
jmf 36:d1a98d5f2bbd 278
jmf 36:d1a98d5f2bbd 279 /**
jmf 36:d1a98d5f2bbd 280 *
jmf 36:d1a98d5f2bbd 281 * Closes an already open Socket.
jmf 36:d1a98d5f2bbd 282 * @ingroup API
jmf 36:d1a98d5f2bbd 283 * @param numSock - The number of the socket to open.
jmf 36:d1a98d5f2bbd 284 * @return true if success else false.
jmf 36:d1a98d5f2bbd 285 */
jmf 36:d1a98d5f2bbd 286 bool closeSocket(uint16_t numSock);
jmf 36:d1a98d5f2bbd 287
jmf 36:d1a98d5f2bbd 288 /**
jmf 36:d1a98d5f2bbd 289 *
jmf 36:d1a98d5f2bbd 290 * Sets the amount of time to wait between the raw AT commands that are sent to the WNC modem.
jmf 36:d1a98d5f2bbd 291 * Generally you don't want to use this but it is here just in case.
jmf 36:d1a98d5f2bbd 292 * @ingroup API
jmf 36:d1a98d5f2bbd 293 * @param toMs - num mS to wait between the AT cmds.
jmf 36:d1a98d5f2bbd 294 * @return none.
jmf 36:d1a98d5f2bbd 295 */
jmf 36:d1a98d5f2bbd 296 void setWncCmdTimeout(uint16_t toMs);
jmf 36:d1a98d5f2bbd 297
jmf 36:d1a98d5f2bbd 298 /**
jmf 36:d1a98d5f2bbd 299 *
jmf 36:d1a98d5f2bbd 300 * Gets the IP address of the given socket number.
jmf 36:d1a98d5f2bbd 301 * @ingroup API
jmf 36:d1a98d5f2bbd 302 * @param numSock - The number of the socket to open.
jmf 36:d1a98d5f2bbd 303 * @param myIpAddr - a c-string that contains the socket's IP address.
jmf 36:d1a98d5f2bbd 304 * @return true if success else false.
jmf 36:d1a98d5f2bbd 305 */
jmf 36:d1a98d5f2bbd 306 bool getIpAddr(uint16_t numSock, char myIpAddr[MAX_LEN_IP_STR]);
jmf 36:d1a98d5f2bbd 307
jmf 36:d1a98d5f2bbd 308 /**
jmf 36:d1a98d5f2bbd 309 *
jmf 36:d1a98d5f2bbd 310 * Enables debug output from this class.
jmf 36:d1a98d5f2bbd 311 * @ingroup API
jmf 36:d1a98d5f2bbd 312 * @param on - true enables debug output, false disables
jmf 36:d1a98d5f2bbd 313 * @param moreDebugOn - true enables verbose debug, false truncates debug output.
jmf 36:d1a98d5f2bbd 314 * @return none.
jmf 36:d1a98d5f2bbd 315 */
jmf 36:d1a98d5f2bbd 316 void enableDebug(bool on, bool moreDebugOn);
jmf 36:d1a98d5f2bbd 317
jmf 36:d1a98d5f2bbd 318 ///////////////////////////////////////////
jmf 36:d1a98d5f2bbd 319 // SMS messaging
jmf 36:d1a98d5f2bbd 320 ///////////////////////////////////////////
jmf 36:d1a98d5f2bbd 321
jmf 36:d1a98d5f2bbd 322 static const uint16_t MAX_WNC_SMS_MSG_SLOTS = 3; // How many SMS messages the WNC can store and receive at a time.
jmf 36:d1a98d5f2bbd 323 static const uint16_t MAX_WNC_SMS_LENGTH = 160; // The maximum length of a 7-bit SMS message the WNC can send and receive.
jmf 36:d1a98d5f2bbd 324
jmf 36:d1a98d5f2bbd 325 /** Struct for SMS messages */
jmf 36:d1a98d5f2bbd 326 struct WncSmsInfo
jmf 36:d1a98d5f2bbd 327 {
jmf 36:d1a98d5f2bbd 328 // Content
jmf 36:d1a98d5f2bbd 329 char idx;
jmf 36:d1a98d5f2bbd 330 string number;
jmf 36:d1a98d5f2bbd 331 string date;
jmf 36:d1a98d5f2bbd 332 string time;
jmf 36:d1a98d5f2bbd 333 string msg;
jmf 36:d1a98d5f2bbd 334
jmf 36:d1a98d5f2bbd 335 // Attributes
jmf 36:d1a98d5f2bbd 336 bool incoming;
jmf 36:d1a98d5f2bbd 337 bool unsent;
jmf 36:d1a98d5f2bbd 338 bool unread;
jmf 36:d1a98d5f2bbd 339 bool pduMode;
jmf 36:d1a98d5f2bbd 340 bool msgReceipt;
jmf 36:d1a98d5f2bbd 341 };
jmf 36:d1a98d5f2bbd 342
jmf 36:d1a98d5f2bbd 343 /** Struct to contain a list of SMS message structs */
jmf 36:d1a98d5f2bbd 344 struct WncSmsList
jmf 36:d1a98d5f2bbd 345 {
jmf 36:d1a98d5f2bbd 346 uint8_t msgCount;
jmf 36:d1a98d5f2bbd 347 WncSmsInfo e[MAX_WNC_SMS_MSG_SLOTS];
jmf 36:d1a98d5f2bbd 348 };
jmf 36:d1a98d5f2bbd 349
jmf 36:d1a98d5f2bbd 350 /**
jmf 36:d1a98d5f2bbd 351 *
jmf 36:d1a98d5f2bbd 352 * Sends an SMS text message to someone.
jmf 36:d1a98d5f2bbd 353 * @ingroup API
jmf 36:d1a98d5f2bbd 354 * @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).
jmf 36:d1a98d5f2bbd 355 * @param text - the c-string text to send to someone.
jmf 36:d1a98d5f2bbd 356 * @return true if success else false.
jmf 36:d1a98d5f2bbd 357 */
jmf 36:d1a98d5f2bbd 358 bool sendSMSText(const char * const phoneNum, const char * const text);
jmf 36:d1a98d5f2bbd 359
jmf 36:d1a98d5f2bbd 360 /**
jmf 36:d1a98d5f2bbd 361 *
jmf 36:d1a98d5f2bbd 362 * Incoming messages are stored in a log in the WNC modem, this will read that
jmf 36:d1a98d5f2bbd 363 * log.
jmf 36:d1a98d5f2bbd 364 * @ingroup API
jmf 36:d1a98d5f2bbd 365 * @param log - the log contents if reading it was successful.
jmf 36:d1a98d5f2bbd 366 * @return true if success else false.
jmf 36:d1a98d5f2bbd 367 */
jmf 36:d1a98d5f2bbd 368 bool readSMSLog(struct WncSmsList * log);
jmf 36:d1a98d5f2bbd 369
jmf 36:d1a98d5f2bbd 370 /**
jmf 36:d1a98d5f2bbd 371 *
jmf 36:d1a98d5f2bbd 372 * Incoming messages are stored in a log in the WNC modem, this will read out
jmf 36:d1a98d5f2bbd 373 * messages that are unread and also then mark them read.
jmf 36:d1a98d5f2bbd 374 * @ingroup API
jmf 36:d1a98d5f2bbd 375 * @param w - a list of SMS messages that unread messages will be put into.
jmf 36:d1a98d5f2bbd 376 * @param deleteRead - if a message is read and this is set true the message will be deleted from the WNC modem log.
jmf 36:d1a98d5f2bbd 377 * If it is false the message will remain in the internal log but be marked as read.
jmf 36:d1a98d5f2bbd 378 * @return true if success else false.
jmf 36:d1a98d5f2bbd 379 */
jmf 36:d1a98d5f2bbd 380 bool readUnreadSMSText(struct WncSmsList * w, bool deleteRead = true);
jmf 36:d1a98d5f2bbd 381
jmf 36:d1a98d5f2bbd 382 /**
jmf 36:d1a98d5f2bbd 383 *
jmf 36:d1a98d5f2bbd 384 * Saves a text message into internal SIM card memory of the WNC modem.
jmf 36:d1a98d5f2bbd 385 * There are only 3 slots available this is for unread, read and saved.
jmf 36:d1a98d5f2bbd 386 * @ingroup API
jmf 36:d1a98d5f2bbd 387 * @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).
jmf 36:d1a98d5f2bbd 388 * @param text - the c-string text to send to someone.
jmf 36:d1a98d5f2bbd 389 * @param msgIdx - the slot position to save the message: '1', '2', '3'
jmf 36:d1a98d5f2bbd 390 * @return true if success else false.
jmf 36:d1a98d5f2bbd 391 */
jmf 36:d1a98d5f2bbd 392 bool saveSMSText(const char * const phoneNum, const char * const text, char * msgIdx);
jmf 36:d1a98d5f2bbd 393
jmf 36:d1a98d5f2bbd 394 /**
jmf 36:d1a98d5f2bbd 395 *
jmf 36:d1a98d5f2bbd 396 * Sends a prior stored a text message from internal SIM card memory of the WNC modem.
jmf 36:d1a98d5f2bbd 397 * If no messages are stored the behaviour of this method is undefined.
jmf 36:d1a98d5f2bbd 398 * @ingroup API
jmf 36:d1a98d5f2bbd 399 * @param msgIdx - the slot position to save the message: '1', '2', '3'
jmf 36:d1a98d5f2bbd 400 * @return true if success else false.
jmf 36:d1a98d5f2bbd 401 */
jmf 36:d1a98d5f2bbd 402 bool sendSMSTextFromMem(char msgIdx);
jmf 36:d1a98d5f2bbd 403
jmf 36:d1a98d5f2bbd 404 /**
jmf 36:d1a98d5f2bbd 405 *
jmf 36:d1a98d5f2bbd 406 * Deletes a prior stored a text message from internal SIM card memory of the WNC modem.
jmf 36:d1a98d5f2bbd 407 * If no messages are stored the behaviour of this method is undefined.
jmf 36:d1a98d5f2bbd 408 * @ingroup API
jmf 36:d1a98d5f2bbd 409 * @param msgIdx - the slot position to save the message: '1', '2', '3' or '*' deletes them all.
jmf 36:d1a98d5f2bbd 410 * @return true if success else false.
jmf 36:d1a98d5f2bbd 411 */
jmf 36:d1a98d5f2bbd 412 bool deleteSMSTextFromMem(char msgIdx);
jmf 36:d1a98d5f2bbd 413
jmf 36:d1a98d5f2bbd 414 /**
jmf 36:d1a98d5f2bbd 415 *
jmf 36:d1a98d5f2bbd 416 * Retreives the SIM card ICCID number.
jmf 36:d1a98d5f2bbd 417 * @ingroup API
jmf 36:d1a98d5f2bbd 418 * @param iccid - a pointer to C++ string that contains the retrieved number.
jmf 36:d1a98d5f2bbd 419 * @return true if success else false.
jmf 36:d1a98d5f2bbd 420 */
jmf 36:d1a98d5f2bbd 421 bool getICCID(string * iccid);
jmf 36:d1a98d5f2bbd 422
jmf 36:d1a98d5f2bbd 423 /**
jmf 36:d1a98d5f2bbd 424 *
jmf 36:d1a98d5f2bbd 425 * Converts an ICCID number into a MSISDN number. The ATT SMS system for IoT only allows use of the 15-digit MSISDN number.
jmf 36:d1a98d5f2bbd 426 * @ingroup API
jmf 36:d1a98d5f2bbd 427 * @param iccid - the number to convert.
jmf 36:d1a98d5f2bbd 428 * @param msisdn - points to a C++ string that has the converted number.
jmf 36:d1a98d5f2bbd 429 * @return true if success else false.
jmf 36:d1a98d5f2bbd 430 */
jmf 36:d1a98d5f2bbd 431 bool convertICCIDtoMSISDN(const string & iccid, string * msisdn);
jmf 36:d1a98d5f2bbd 432
jmf 36:d1a98d5f2bbd 433 ///////////////////////////////////////////
jmf 36:d1a98d5f2bbd 434 // Neighborhood Cell Info
jmf 36:d1a98d5f2bbd 435 ///////////////////////////////////////////
jmf 36:d1a98d5f2bbd 436
jmf 36:d1a98d5f2bbd 437 /**
jmf 36:d1a98d5f2bbd 438 *
jmf 36:d1a98d5f2bbd 439 * Fetches the signal quality log from the WNC modem.
jmf 36:d1a98d5f2bbd 440 * @ingroup API
jmf 36:d1a98d5f2bbd 441 * @param log - a pointer to an internal buffer who's contents contain the signal quality metrics.
jmf 36:d1a98d5f2bbd 442 * @return The number of chars in the log.
jmf 36:d1a98d5f2bbd 443 */
jmf 36:d1a98d5f2bbd 444 size_t getSignalQuality(const char ** log);
jmf 36:d1a98d5f2bbd 445
jmf 36:d1a98d5f2bbd 446 /** A struct for the WNC modem Date and Time */
jmf 36:d1a98d5f2bbd 447 struct WncDateTime
jmf 36:d1a98d5f2bbd 448 {
jmf 36:d1a98d5f2bbd 449 uint8_t year;
jmf 36:d1a98d5f2bbd 450 uint8_t month;
jmf 36:d1a98d5f2bbd 451 uint8_t day;
jmf 36:d1a98d5f2bbd 452 uint8_t hour;
jmf 36:d1a98d5f2bbd 453 uint8_t min;
jmf 36:d1a98d5f2bbd 454 uint8_t sec;
jmf 36:d1a98d5f2bbd 455 };
jmf 36:d1a98d5f2bbd 456
jmf 36:d1a98d5f2bbd 457 /**
jmf 36:d1a98d5f2bbd 458 *
jmf 36:d1a98d5f2bbd 459 * Fetches the cell tower's time and date. The time is accurate when read
jmf 36:d1a98d5f2bbd 460 * but significant delays exist between the time it is read and returned.
jmf 36:d1a98d5f2bbd 461 * @ingroup API
jmf 36:d1a98d5f2bbd 462 * @param tod - User supplies a pointer to a tod struct and this method fills it in.
jmf 36:d1a98d5f2bbd 463 * @return true if success else false.
jmf 36:d1a98d5f2bbd 464 */
jmf 36:d1a98d5f2bbd 465 bool getTimeDate(struct WncDateTime * tod);
jmf 36:d1a98d5f2bbd 466
jmf 36:d1a98d5f2bbd 467 /**
jmf 36:d1a98d5f2bbd 468 *
jmf 36:d1a98d5f2bbd 469 * ICMP Pings a URL, the results are only output to the debug log for now!
jmf 36:d1a98d5f2bbd 470 * @ingroup API
jmf 36:d1a98d5f2bbd 471 * @param url - a c-string whose URL is to be pinged.
jmf 36:d1a98d5f2bbd 472 * @return true if success else false.
jmf 36:d1a98d5f2bbd 473 */
jmf 36:d1a98d5f2bbd 474 bool pingUrl(const char * url);
jmf 36:d1a98d5f2bbd 475
jmf 36:d1a98d5f2bbd 476 /**
jmf 36:d1a98d5f2bbd 477 *
jmf 36:d1a98d5f2bbd 478 * ICMP Pings an IP, the results are only output to the debug log for now!
jmf 36:d1a98d5f2bbd 479 * @ingroup API
jmf 36:d1a98d5f2bbd 480 * @param ip - a c-string whose IP is to be pinged.
jmf 36:d1a98d5f2bbd 481 * @return true if success else false.
jmf 36:d1a98d5f2bbd 482 */
jmf 36:d1a98d5f2bbd 483 bool pingIp(const char * ip);
jmf 36:d1a98d5f2bbd 484
jmf 36:d1a98d5f2bbd 485 /**
jmf 36:d1a98d5f2bbd 486 *
jmf 36:d1a98d5f2bbd 487 * Allows a user to send a raw AT command to the WNC modem.
jmf 36:d1a98d5f2bbd 488 * @ingroup API
jmf 36:d1a98d5f2bbd 489 * @param cmd - the c-string cmd to send like: "AT"
jmf 36:d1a98d5f2bbd 490 * @param resp - a pointer to the c-string cmd's response.
jmf 36:d1a98d5f2bbd 491 * @param sizeRespBuf - how large the command response buffer is, sets the max response length.
jmf 36:d1a98d5f2bbd 492 * @param ms_timeout - how long to wait for the WNC to respond to your command.
jmf 36:d1a98d5f2bbd 493 * @return the number of characters in the response from the WNC modem.
jmf 36:d1a98d5f2bbd 494 */
jmf 36:d1a98d5f2bbd 495 size_t sendCustomCmd(const char * cmd, char * resp, size_t sizeRespBuf, int ms_timeout);
jmf 36:d1a98d5f2bbd 496
jmf 36:d1a98d5f2bbd 497 protected:
jmf 36:d1a98d5f2bbd 498
jmf 36:d1a98d5f2bbd 499 // Debug output methods
jmf 36:d1a98d5f2bbd 500 int dbgPutsNoTime(const char * s, bool crlf = true);
jmf 36:d1a98d5f2bbd 501 int dbgPuts(const char * s, bool crlf = true);
jmf 36:d1a98d5f2bbd 502 const char * _to_string(int64_t value);
jmf 36:d1a98d5f2bbd 503 const char * _to_hex_string(uint8_t value);
jmf 36:d1a98d5f2bbd 504
jmf 36:d1a98d5f2bbd 505 // Sends commands to WNC via
jmf 36:d1a98d5f2bbd 506 enum AtCmdErr_e {
jmf 36:d1a98d5f2bbd 507 WNC_AT_CMD_OK,
jmf 36:d1a98d5f2bbd 508 WNC_AT_CMD_ERR,
jmf 36:d1a98d5f2bbd 509 WNC_AT_CMD_ERREXT,
jmf 36:d1a98d5f2bbd 510 WNC_AT_CMD_ERRCME,
jmf 36:d1a98d5f2bbd 511 WNC_AT_CMD_INVALID_RESPONSE,
jmf 36:d1a98d5f2bbd 512 WNC_AT_CMD_TIMEOUT,
jmf 36:d1a98d5f2bbd 513 WNC_AT_CMD_NO_CELL_LINK,
jmf 36:d1a98d5f2bbd 514 WNC_AT_CMD_WNC_NOT_ON
jmf 36:d1a98d5f2bbd 515 };
jmf 36:d1a98d5f2bbd 516
jmf 36:d1a98d5f2bbd 517 bool waitForPowerOnModemToRespond(uint8_t powerUpTimeoutSecs);
jmf 36:d1a98d5f2bbd 518 AtCmdErr_e sendWncCmd(const char * const s, string ** r, int ms_timeout);
jmf 36:d1a98d5f2bbd 519
jmf 36:d1a98d5f2bbd 520 // Users must define these functionalities in the inheriting class:
jmf 36:d1a98d5f2bbd 521 // General I/O and timing:
jmf 36:d1a98d5f2bbd 522 virtual int putc(char c) = 0;
jmf 36:d1a98d5f2bbd 523 virtual int puts(const char * s) = 0;
jmf 36:d1a98d5f2bbd 524 virtual char getc(void) = 0;
jmf 36:d1a98d5f2bbd 525 virtual int charReady(void) = 0;
jmf 36:d1a98d5f2bbd 526 virtual int dbgWriteChar(char b) = 0;
jmf 36:d1a98d5f2bbd 527 virtual int dbgWriteChars(const char *b) = 0;
jmf 36:d1a98d5f2bbd 528 virtual void waitMs(int t) = 0;
jmf 36:d1a98d5f2bbd 529 virtual void waitUs(int t) = 0;
jmf 36:d1a98d5f2bbd 530 virtual bool initWncModem(uint8_t powerUpTimeoutSecs) = 0;
jmf 36:d1a98d5f2bbd 531
jmf 36:d1a98d5f2bbd 532 // Isolate OS timers
jmf 36:d1a98d5f2bbd 533 virtual int getLogTimerTicks(void) = 0;
jmf 36:d1a98d5f2bbd 534 virtual void startTimerA(void) = 0;
jmf 36:d1a98d5f2bbd 535 virtual void stopTimerA(void) = 0;
jmf 36:d1a98d5f2bbd 536 virtual int getTimerTicksA_mS(void) = 0;
jmf 36:d1a98d5f2bbd 537 virtual void startTimerB(void) = 0;
jmf 36:d1a98d5f2bbd 538 virtual void stopTimerB(void) = 0;
jmf 36:d1a98d5f2bbd 539 virtual int getTimerTicksB_mS(void) = 0;
jmf 36:d1a98d5f2bbd 540
jmf 36:d1a98d5f2bbd 541 private:
jmf 36:d1a98d5f2bbd 542
jmf 36:d1a98d5f2bbd 543 bool softwareInitMdm(void);
jmf 36:d1a98d5f2bbd 544 bool checkCellLink(void);
jmf 36:d1a98d5f2bbd 545 AtCmdErr_e mdmSendAtCmdRsp(const char * cmd, int timeout_ms, string * rsp, bool crLf = true);
jmf 36:d1a98d5f2bbd 546 size_t mdmGetline(string * buff, int timeout_ms);
jmf 36:d1a98d5f2bbd 547 bool at_at_wnc(void);
jmf 36:d1a98d5f2bbd 548 bool at_init_wnc(bool hardReset = false);
jmf 36:d1a98d5f2bbd 549 int16_t at_sockopen_wnc(const char * const ip, uint16_t port, uint16_t numSock, bool tcp, uint16_t timeOutSec);
jmf 36:d1a98d5f2bbd 550 bool at_sockclose_wnc(uint16_t numSock);
jmf 36:d1a98d5f2bbd 551 bool at_dnsresolve_wnc(const char * s, string * ipStr);
jmf 36:d1a98d5f2bbd 552 AtCmdErr_e at_sockwrite_wnc(const uint8_t * s, uint16_t n, uint16_t numSock, bool isTcp);
jmf 36:d1a98d5f2bbd 553 AtCmdErr_e at_sockread_wnc(uint8_t * pS, uint16_t * numRead, uint16_t n, uint16_t numSock, bool isTcp);
jmf 36:d1a98d5f2bbd 554 AtCmdErr_e at_sockread_wnc(string * pS, uint16_t numSock, bool isTcp);
jmf 36:d1a98d5f2bbd 555 bool at_reinitialize_mdm(void);
jmf 36:d1a98d5f2bbd 556 AtCmdErr_e at_send_wnc_cmd(const char * s, string ** r, int ms_timeout);
jmf 36:d1a98d5f2bbd 557 bool at_setapn_wnc(const char * const apnStr);
jmf 36:d1a98d5f2bbd 558 bool at_sendSMStext_wnc(const char * const phoneNum, const char * const text);
jmf 36:d1a98d5f2bbd 559 bool at_get_wnc_net_stats(WncIpStats * s);
jmf 36:d1a98d5f2bbd 560 bool at_readSMSlog_wnc(string ** log);
jmf 36:d1a98d5f2bbd 561 size_t at_readSMStext_wnc(const char ** log);
jmf 36:d1a98d5f2bbd 562 size_t at_readSMStext_wnc(const char n, const char ** log);
jmf 36:d1a98d5f2bbd 563 bool at_getrssiber_wnc(int16_t * dBm, int16_t * ber3g);
jmf 36:d1a98d5f2bbd 564 void closeOpenSocket(uint16_t numSock);
jmf 36:d1a98d5f2bbd 565 bool sockWrite(const uint8_t * const s, uint16_t n, uint16_t numSock, bool isTcp);
jmf 36:d1a98d5f2bbd 566 bool at_sendSMStextMem_wnc(char n);
jmf 36:d1a98d5f2bbd 567 bool at_deleteSMSTextFromMem_wnc(char n);
jmf 36:d1a98d5f2bbd 568 bool at_saveSMStext_wnc(const char * const phoneNum, const char * const text, char * msgIdx);
jmf 36:d1a98d5f2bbd 569 size_t at_getSignalQuality_wnc(const char ** log);
jmf 36:d1a98d5f2bbd 570 bool at_gettimedate_wnc(struct WncDateTime * tod);
jmf 36:d1a98d5f2bbd 571 bool at_ping_wnc(const char * ip);
jmf 36:d1a98d5f2bbd 572 bool at_geticcid_wnc(string * iccid);
jmf 36:d1a98d5f2bbd 573
jmf 36:d1a98d5f2bbd 574 // Utility methods
jmf 36:d1a98d5f2bbd 575 void sendCmd(const char * cmd, bool crLf);
jmf 36:d1a98d5f2bbd 576 void sendCmd(const char * cmd, unsigned n, unsigned wait_uS, bool crLf);
jmf 36:d1a98d5f2bbd 577 inline void rx_char_wait(void) {
jmf 36:d1a98d5f2bbd 578 // waitUs(1000);
jmf 36:d1a98d5f2bbd 579 }
jmf 36:d1a98d5f2bbd 580
jmf 36:d1a98d5f2bbd 581 // Important constants
jmf 36:d1a98d5f2bbd 582 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
jmf 36:d1a98d5f2bbd 583 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.
jmf 36:d1a98d5f2bbd 584 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.
jmf 36:d1a98d5f2bbd 585 static const uint16_t WNC_AUTO_POLL_MS = 250; // Sets default (may be overriden with method) poll interval (currently not used, future possible feature.
jmf 36:d1a98d5f2bbd 586 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.
jmf 36:d1a98d5f2bbd 587 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.
jmf 36:d1a98d5f2bbd 588 static const uint16_t WNC_WAIT_FOR_AT_CMD_MS = 0; // Wait this much between multiple in a row AT commands to the WNC.
jmf 36:d1a98d5f2bbd 589 static const uint16_t WNC_SOFT_INIT_RETRY_COUNT = 10; // How many times the WNC will be tried to revive if it stops responding.
jmf 36:d1a98d5f2bbd 590 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.
jmf 36:d1a98d5f2bbd 591 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.
jmf 36:d1a98d5f2bbd 592 static const uint16_t WNC_APNSET_TIMEOUT_MS = 60000; // How long to wait for the WNC to respond to setting the APN string.
jmf 36:d1a98d5f2bbd 593 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)
jmf 36:d1a98d5f2bbd 594 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.
jmf 36:d1a98d5f2bbd 595 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.
jmf 36:d1a98d5f2bbd 596 static const char * const INVALID_IP_STR; // Just a string set to an IP address when DNS resolve fails.
jmf 36:d1a98d5f2bbd 597
jmf 36:d1a98d5f2bbd 598 struct WncSocketInfo_s {
jmf 36:d1a98d5f2bbd 599 int16_t numWncSock;
jmf 36:d1a98d5f2bbd 600 bool open;
jmf 36:d1a98d5f2bbd 601 string myIpAddressStr;
jmf 36:d1a98d5f2bbd 602 uint16_t myPort;
jmf 36:d1a98d5f2bbd 603 uint8_t readRetries;
jmf 36:d1a98d5f2bbd 604 uint16_t readRetryWaitMs;
jmf 36:d1a98d5f2bbd 605 bool isTcp;
jmf 36:d1a98d5f2bbd 606 uint16_t timeOutSec;
jmf 36:d1a98d5f2bbd 607 };
jmf 36:d1a98d5f2bbd 608
jmf 36:d1a98d5f2bbd 609 static WncSocketInfo_s m_sSock[MAX_NUM_WNC_SOCKETS];
jmf 36:d1a98d5f2bbd 610 static const WncSocketInfo_s defaultSockStruct;
jmf 36:d1a98d5f2bbd 611 static WncState_e m_sState;
jmf 36:d1a98d5f2bbd 612 static uint16_t m_sCmdTimeoutMs;
jmf 36:d1a98d5f2bbd 613 static string m_sApnStr;
jmf 36:d1a98d5f2bbd 614 static string m_sWncStr;
jmf 36:d1a98d5f2bbd 615 static uint8_t m_sPowerUpTimeoutSecs;
jmf 36:d1a98d5f2bbd 616 static bool m_sDebugEnabled;
jmf 36:d1a98d5f2bbd 617 static bool m_sMoreDebugEnabled;
jmf 36:d1a98d5f2bbd 618 static bool m_sCheckNetStatus;
jmf 36:d1a98d5f2bbd 619 static bool m_sReadyForSMS;
jmf 36:d1a98d5f2bbd 620 };
jmf 36:d1a98d5f2bbd 621
jmf 36:d1a98d5f2bbd 622 }; // End namespace WncController_fk
jmf 36:d1a98d5f2bbd 623
jmf 36:d1a98d5f2bbd 624 #endif
jmf 36:d1a98d5f2bbd 625