Mobile Life IoT project using the AT&T IoT Starter Kit Software and files for my device to monitor the status or our Airstream travel trailer RV. A full description of the project is at Hackster.IO here as part of the Realtime AT&T IoT Starter Kit Challenge: https://www.hackster.io/Anubus/mobile-life-iot-9c10be

Dependencies:   FXOS8700CQ MODSERIAL mbed

Committer:
Anubus
Date:
Sun Apr 02 12:28:21 2017 +0000
Revision:
0:bd276b1f1249
public version commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Anubus 0:bd276b1f1249 1 /* ===================================================================
Anubus 0:bd276b1f1249 2 Copyright c 2016, AVNET Inc.
Anubus 0:bd276b1f1249 3
Anubus 0:bd276b1f1249 4 Licensed under the Apache License, Version 2.0 (the "License");
Anubus 0:bd276b1f1249 5 you may not use this file except in compliance with the License.
Anubus 0:bd276b1f1249 6 You may obtain a copy of the License at
Anubus 0:bd276b1f1249 7
Anubus 0:bd276b1f1249 8 http://www.apache.org/licenses/LICENSE-2.0
Anubus 0:bd276b1f1249 9
Anubus 0:bd276b1f1249 10 Unless required by applicable law or agreed to in writing,
Anubus 0:bd276b1f1249 11 software distributed under the License is distributed on an
Anubus 0:bd276b1f1249 12 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
Anubus 0:bd276b1f1249 13 either express or implied. See the License for the specific
Anubus 0:bd276b1f1249 14 language governing permissions and limitations under the License.
Anubus 0:bd276b1f1249 15
Anubus 0:bd276b1f1249 16 ======================================================================== */
Anubus 0:bd276b1f1249 17
Anubus 0:bd276b1f1249 18 #include "mbed.h"
Anubus 0:bd276b1f1249 19 #include <cctype>
Anubus 0:bd276b1f1249 20 #include <string>
Anubus 0:bd276b1f1249 21
Anubus 0:bd276b1f1249 22 #include "config_me.h"
Anubus 0:bd276b1f1249 23 #include "wnc_control.h"
Anubus 0:bd276b1f1249 24 #include "hardware.h"
Anubus 0:bd276b1f1249 25
Anubus 0:bd276b1f1249 26 #define MDM_DBG_OFF 0
Anubus 0:bd276b1f1249 27 #define MDM_DBG_AT_CMDS (1 << 0)
Anubus 0:bd276b1f1249 28 int mdm_dbgmask = MDM_DBG_OFF;
Anubus 0:bd276b1f1249 29
Anubus 0:bd276b1f1249 30 #define WNC_WAIT_FOR_AT_CMD_MS 40
Anubus 0:bd276b1f1249 31
Anubus 0:bd276b1f1249 32 DigitalOut mdm_uart2_rx_boot_mode_sel(PTC17); // on powerup, 0 = boot mode, 1 = normal boot
Anubus 0:bd276b1f1249 33 DigitalOut mdm_power_on(PTB9); // 0 = turn modem on, 1 = turn modem off (should be held high for >5 seconds to cycle modem)
Anubus 0:bd276b1f1249 34 DigitalOut mdm_wakeup_in(PTC2); // 0 = let modem sleep, 1 = keep modem awake -- Note: pulled high on shield
Anubus 0:bd276b1f1249 35
Anubus 0:bd276b1f1249 36 DigitalOut mdm_reset(PTC12); // active high
Anubus 0:bd276b1f1249 37
Anubus 0:bd276b1f1249 38 DigitalOut shield_3v3_1v8_sig_trans_ena(PTC4); // 0 = disabled (all signals high impedence, 1 = translation active
Anubus 0:bd276b1f1249 39 DigitalOut mdm_uart1_cts(PTD0);
Anubus 0:bd276b1f1249 40
Anubus 0:bd276b1f1249 41 #define TOUPPER(a) (a) //toupper(a)
Anubus 0:bd276b1f1249 42
Anubus 0:bd276b1f1249 43 const char ok_str[] = "OK";
Anubus 0:bd276b1f1249 44 const char error_str[] = "ERROR";
Anubus 0:bd276b1f1249 45
Anubus 0:bd276b1f1249 46 #define MDM_OK 0
Anubus 0:bd276b1f1249 47 #define MDM_ERR_TIMEOUT -1
Anubus 0:bd276b1f1249 48
Anubus 0:bd276b1f1249 49 #define MAX_AT_RSP_LEN 255
Anubus 0:bd276b1f1249 50
Anubus 0:bd276b1f1249 51 ssize_t mdm_getline(char *buff, size_t size, int timeout_ms) {
Anubus 0:bd276b1f1249 52 int cin = -1;
Anubus 0:bd276b1f1249 53 int cin_last;
Anubus 0:bd276b1f1249 54
Anubus 0:bd276b1f1249 55 if (NULL == buff || size == 0) {
Anubus 0:bd276b1f1249 56 return -1;
Anubus 0:bd276b1f1249 57 }
Anubus 0:bd276b1f1249 58
Anubus 0:bd276b1f1249 59 size_t len = 0;
Anubus 0:bd276b1f1249 60 Timer timer;
Anubus 0:bd276b1f1249 61 timer.start();
Anubus 0:bd276b1f1249 62 while ((len < (size-1)) && (timer.read_ms() < timeout_ms)) {
Anubus 0:bd276b1f1249 63 if (mdm.readable()) {
Anubus 0:bd276b1f1249 64 cin_last = cin;
Anubus 0:bd276b1f1249 65 cin = mdm.getc();
Anubus 0:bd276b1f1249 66 if (isprint(cin)) {
Anubus 0:bd276b1f1249 67 buff[len++] = (char)cin;
Anubus 0:bd276b1f1249 68 continue;
Anubus 0:bd276b1f1249 69 } else if (('\r' == cin_last) && ('\n' == cin)) {
Anubus 0:bd276b1f1249 70 break;
Anubus 0:bd276b1f1249 71 }
Anubus 0:bd276b1f1249 72 }
Anubus 0:bd276b1f1249 73 // wait_ms(1);
Anubus 0:bd276b1f1249 74 }
Anubus 0:bd276b1f1249 75 buff[len] = (char)NULL;
Anubus 0:bd276b1f1249 76
Anubus 0:bd276b1f1249 77 return len;
Anubus 0:bd276b1f1249 78 }
Anubus 0:bd276b1f1249 79
Anubus 0:bd276b1f1249 80 int mdm_sendAtCmd(const char *cmd, const char **rsp_list, int timeout_ms) {
Anubus 0:bd276b1f1249 81 // Per WNC wait:
Anubus 0:bd276b1f1249 82 wait_ms(WNC_WAIT_FOR_AT_CMD_MS);
Anubus 0:bd276b1f1249 83
Anubus 0:bd276b1f1249 84 if (cmd && strlen(cmd) > 0) {
Anubus 0:bd276b1f1249 85 if (mdm_dbgmask & MDM_DBG_AT_CMDS) {
Anubus 0:bd276b1f1249 86 PRINTF(MAG "ATCMD: " DEF "--> " GRN "%s" DEF "\n", cmd);
Anubus 0:bd276b1f1249 87 }
Anubus 0:bd276b1f1249 88 mdm.puts(cmd);
Anubus 0:bd276b1f1249 89 mdm.puts("\r\n");
Anubus 0:bd276b1f1249 90 }
Anubus 0:bd276b1f1249 91
Anubus 0:bd276b1f1249 92 if (rsp_list) {
Anubus 0:bd276b1f1249 93 Timer timer;
Anubus 0:bd276b1f1249 94 char rsp[MAX_AT_RSP_LEN+1];
Anubus 0:bd276b1f1249 95 int len;
Anubus 0:bd276b1f1249 96
Anubus 0:bd276b1f1249 97 timer.start();
Anubus 0:bd276b1f1249 98 while (timer.read_ms() < timeout_ms) {
Anubus 0:bd276b1f1249 99 len = mdm_getline(rsp, sizeof(rsp), timeout_ms - timer.read_ms());
Anubus 0:bd276b1f1249 100
Anubus 0:bd276b1f1249 101 if (len < 0)
Anubus 0:bd276b1f1249 102 return MDM_ERR_TIMEOUT;
Anubus 0:bd276b1f1249 103
Anubus 0:bd276b1f1249 104 if (len == 0)
Anubus 0:bd276b1f1249 105 continue;
Anubus 0:bd276b1f1249 106
Anubus 0:bd276b1f1249 107 if (mdm_dbgmask & MDM_DBG_AT_CMDS) {
Anubus 0:bd276b1f1249 108 PRINTF(MAG "ATRSP: " DEF "<-- " CYN "%s" DEF "\n", rsp);
Anubus 0:bd276b1f1249 109 }
Anubus 0:bd276b1f1249 110
Anubus 0:bd276b1f1249 111 if (rsp_list) {
Anubus 0:bd276b1f1249 112 int rsp_idx = 0;
Anubus 0:bd276b1f1249 113 while (rsp_list[rsp_idx]) {
Anubus 0:bd276b1f1249 114 if (strcasecmp(rsp, rsp_list[rsp_idx]) == 0) {
Anubus 0:bd276b1f1249 115 return rsp_idx;
Anubus 0:bd276b1f1249 116 } else if (strncmp(rsp, "@EXTERR", 7) == 0){
Anubus 0:bd276b1f1249 117 pc.printf("----- We got EXTERR ---\r\n");
Anubus 0:bd276b1f1249 118 return 2;
Anubus 0:bd276b1f1249 119 } else if (strncmp(rsp, "+CME", 4) == 0){
Anubus 0:bd276b1f1249 120 return 3;
Anubus 0:bd276b1f1249 121 }
Anubus 0:bd276b1f1249 122 rsp_idx++;
Anubus 0:bd276b1f1249 123 }
Anubus 0:bd276b1f1249 124 }
Anubus 0:bd276b1f1249 125 }
Anubus 0:bd276b1f1249 126 return MDM_ERR_TIMEOUT;
Anubus 0:bd276b1f1249 127 }
Anubus 0:bd276b1f1249 128 return MDM_OK;
Anubus 0:bd276b1f1249 129 }
Anubus 0:bd276b1f1249 130
Anubus 0:bd276b1f1249 131 int mdm_init(void) {
Anubus 0:bd276b1f1249 132 // Hard reset the modem (doesn't go through
Anubus 0:bd276b1f1249 133 // the signal level translator)
Anubus 0:bd276b1f1249 134 mdm_reset = 0;
Anubus 0:bd276b1f1249 135
Anubus 0:bd276b1f1249 136 // disable signal level translator (necessary
Anubus 0:bd276b1f1249 137 // for the modem to boot properly). All signals
Anubus 0:bd276b1f1249 138 // except mdm_reset go through the level translator
Anubus 0:bd276b1f1249 139 // and have internal pull-up/down in the module. While
Anubus 0:bd276b1f1249 140 // the level translator is disabled, these pins will
Anubus 0:bd276b1f1249 141 // be in the correct state.
Anubus 0:bd276b1f1249 142 shield_3v3_1v8_sig_trans_ena = 0;
Anubus 0:bd276b1f1249 143
Anubus 0:bd276b1f1249 144 // While the level translator is disabled and ouptut pins
Anubus 0:bd276b1f1249 145 // are tristated, make sure the inputs are in the same state
Anubus 0:bd276b1f1249 146 // as the WNC Module pins so that when the level translator is
Anubus 0:bd276b1f1249 147 // enabled, there are no differences.
Anubus 0:bd276b1f1249 148 mdm_uart2_rx_boot_mode_sel = 1; // UART2_RX should be high
Anubus 0:bd276b1f1249 149 mdm_power_on = 0; // powr_on should be low
Anubus 0:bd276b1f1249 150 mdm_wakeup_in = 1; // wake-up should be high
Anubus 0:bd276b1f1249 151 mdm_uart1_cts = 0; // indicate that it is ok to send
Anubus 0:bd276b1f1249 152
Anubus 0:bd276b1f1249 153 // Now, wait for the WNC Module to perform its initial boot correctly
Anubus 0:bd276b1f1249 154 wait(1.0);
Anubus 0:bd276b1f1249 155
Anubus 0:bd276b1f1249 156 // The WNC module initializes comms at 115200 8N1 so set it up
Anubus 0:bd276b1f1249 157 mdm.baud(115200);
Anubus 0:bd276b1f1249 158
Anubus 0:bd276b1f1249 159 //Now, enable the level translator, the input pins should now be the
Anubus 0:bd276b1f1249 160 //same as how the M14A module is driving them with internal pull ups/downs.
Anubus 0:bd276b1f1249 161 //When enabled, there will be no changes in these 4 pins...
Anubus 0:bd276b1f1249 162 shield_3v3_1v8_sig_trans_ena = 1;
Anubus 0:bd276b1f1249 163
Anubus 0:bd276b1f1249 164 // Now, give the modem 60 seconds to start responding by
Anubus 0:bd276b1f1249 165 // sending simple 'AT' commands to modem once per second.
Anubus 0:bd276b1f1249 166 Timer timer;
Anubus 0:bd276b1f1249 167 timer.start();
Anubus 0:bd276b1f1249 168 while (timer.read() < 60) {
Anubus 0:bd276b1f1249 169 const char * rsp_lst[] = { ok_str, error_str, NULL };
Anubus 0:bd276b1f1249 170 int rc = mdm_sendAtCmd("AT", rsp_lst, 500);
Anubus 0:bd276b1f1249 171 if (rc == 0)
Anubus 0:bd276b1f1249 172 return true; //timer.read();
Anubus 0:bd276b1f1249 173 wait_ms(1000 - (timer.read_ms() % 1000));
Anubus 0:bd276b1f1249 174 PRINTF("\r%d",timer.read_ms()/1000);
Anubus 0:bd276b1f1249 175 }
Anubus 0:bd276b1f1249 176 return false;
Anubus 0:bd276b1f1249 177 }
Anubus 0:bd276b1f1249 178
Anubus 0:bd276b1f1249 179 int mdm_sendAtCmdRsp(const char *cmd, const char **rsp_list, int timeout_ms, string * rsp, int * len) {
Anubus 0:bd276b1f1249 180 static char cmd_buf[3200]; // Need enough room for the WNC sockreads (over 3000 chars)
Anubus 0:bd276b1f1249 181 size_t n = strlen(cmd);
Anubus 0:bd276b1f1249 182
Anubus 0:bd276b1f1249 183 // Per WNC wait:
Anubus 0:bd276b1f1249 184 wait_ms(WNC_WAIT_FOR_AT_CMD_MS);
Anubus 0:bd276b1f1249 185
Anubus 0:bd276b1f1249 186 if (cmd && n > 0) {
Anubus 0:bd276b1f1249 187 if (mdm_dbgmask & MDM_DBG_AT_CMDS) {
Anubus 0:bd276b1f1249 188 PRINTF(MAG "ATCMD: " DEF "--> " GRN "%s" DEF "\n", cmd);
Anubus 0:bd276b1f1249 189 }
Anubus 0:bd276b1f1249 190 // mdm.puts(cmd);
Anubus 0:bd276b1f1249 191 // mdm.puts("\r\n");
Anubus 0:bd276b1f1249 192 while (n--) {
Anubus 0:bd276b1f1249 193 mdm.putc(*cmd++);
Anubus 0:bd276b1f1249 194 wait_us(1000);
Anubus 0:bd276b1f1249 195 };
Anubus 0:bd276b1f1249 196 mdm.putc('\r');
Anubus 0:bd276b1f1249 197 wait_us(1000);
Anubus 0:bd276b1f1249 198 mdm.putc('\n');
Anubus 0:bd276b1f1249 199 wait_us(1000);
Anubus 0:bd276b1f1249 200 }
Anubus 0:bd276b1f1249 201
Anubus 0:bd276b1f1249 202 if (rsp_list) {
Anubus 0:bd276b1f1249 203 rsp->erase(); // Clean up from prior cmd response
Anubus 0:bd276b1f1249 204 *len = 0;
Anubus 0:bd276b1f1249 205 Timer timer;
Anubus 0:bd276b1f1249 206 timer.start();
Anubus 0:bd276b1f1249 207 while (timer.read_ms() < timeout_ms) {
Anubus 0:bd276b1f1249 208 int lenCmd = mdm_getline(cmd_buf, sizeof(cmd_buf), timeout_ms - timer.read_ms());
Anubus 0:bd276b1f1249 209
Anubus 0:bd276b1f1249 210 if (lenCmd == 0)
Anubus 0:bd276b1f1249 211 continue;
Anubus 0:bd276b1f1249 212
Anubus 0:bd276b1f1249 213 if (lenCmd < 0)
Anubus 0:bd276b1f1249 214 return MDM_ERR_TIMEOUT;
Anubus 0:bd276b1f1249 215 else {
Anubus 0:bd276b1f1249 216 *len += lenCmd;
Anubus 0:bd276b1f1249 217 *rsp += cmd_buf;
Anubus 0:bd276b1f1249 218 }
Anubus 0:bd276b1f1249 219
Anubus 0:bd276b1f1249 220 if (mdm_dbgmask & MDM_DBG_AT_CMDS) {
Anubus 0:bd276b1f1249 221 PRINTF(MAG "ATRSP: " DEF "<-- " CYN "%s" DEF "\n", cmd_buf);
Anubus 0:bd276b1f1249 222 }
Anubus 0:bd276b1f1249 223
Anubus 0:bd276b1f1249 224 int rsp_idx = 0;
Anubus 0:bd276b1f1249 225 // TODO: Test if @EXTERR:<code>
Anubus 0:bd276b1f1249 226 while (rsp_list[rsp_idx]) {
Anubus 0:bd276b1f1249 227 if (strcasecmp(cmd_buf, rsp_list[rsp_idx]) == 0) {
Anubus 0:bd276b1f1249 228 return rsp_idx;
Anubus 0:bd276b1f1249 229 } else if (strncmp(cmd_buf, "@EXTERR", 7) == 0){
Anubus 0:bd276b1f1249 230 PRINTF("----- We got EXTERR ---\r\n");
Anubus 0:bd276b1f1249 231 return 2;
Anubus 0:bd276b1f1249 232 } else if (strncmp(cmd_buf, "+CME", 4) == 0){
Anubus 0:bd276b1f1249 233 return 3;
Anubus 0:bd276b1f1249 234 }
Anubus 0:bd276b1f1249 235 rsp_idx++;
Anubus 0:bd276b1f1249 236 }
Anubus 0:bd276b1f1249 237 }
Anubus 0:bd276b1f1249 238 return MDM_ERR_TIMEOUT;
Anubus 0:bd276b1f1249 239 }
Anubus 0:bd276b1f1249 240
Anubus 0:bd276b1f1249 241 return MDM_OK;
Anubus 0:bd276b1f1249 242 }
Anubus 0:bd276b1f1249 243
Anubus 0:bd276b1f1249 244 void reinitialize_mdm(void)
Anubus 0:bd276b1f1249 245 {
Anubus 0:bd276b1f1249 246 // Initialize the modem
Anubus 0:bd276b1f1249 247 PRINTF(GRN "Modem RE-initializing..." DEF "\r\n");
Anubus 0:bd276b1f1249 248 if (!mdm_init()) {
Anubus 0:bd276b1f1249 249 PRINTF(RED "\n\rModem RE-initialization failed!" DEF "\n");
Anubus 0:bd276b1f1249 250 }
Anubus 0:bd276b1f1249 251 PRINTF("\r\n");
Anubus 0:bd276b1f1249 252 }
Anubus 0:bd276b1f1249 253 // These are built on the fly
Anubus 0:bd276b1f1249 254 string MyServerIpAddress;
Anubus 0:bd276b1f1249 255 string MySocketData;
Anubus 0:bd276b1f1249 256
Anubus 0:bd276b1f1249 257 //********************************************************************************************************************************************
Anubus 0:bd276b1f1249 258 //* Process JSON response messages
Anubus 0:bd276b1f1249 259 //********************************************************************************************************************************************
Anubus 0:bd276b1f1249 260 bool extract_JSON(char* search_field, char* found_string)
Anubus 0:bd276b1f1249 261 {
Anubus 0:bd276b1f1249 262 char* beginquote;
Anubus 0:bd276b1f1249 263 char* endquote;
Anubus 0:bd276b1f1249 264 beginquote = strchr(search_field, '{'); //start of JSON
Anubus 0:bd276b1f1249 265 endquote = strchr(search_field, '}'); //end of JSON
Anubus 0:bd276b1f1249 266 if (beginquote)
Anubus 0:bd276b1f1249 267 {
Anubus 0:bd276b1f1249 268 uint16_t ifoundlen;
Anubus 0:bd276b1f1249 269 if (endquote)
Anubus 0:bd276b1f1249 270 {
Anubus 0:bd276b1f1249 271 ifoundlen = (uint16_t) (endquote - beginquote) + 1;
Anubus 0:bd276b1f1249 272 strncpy(found_string, beginquote, ifoundlen );
Anubus 0:bd276b1f1249 273 found_string[ifoundlen] = 0; //null terminate
Anubus 0:bd276b1f1249 274 return true;
Anubus 0:bd276b1f1249 275 }
Anubus 0:bd276b1f1249 276 else
Anubus 0:bd276b1f1249 277 {
Anubus 0:bd276b1f1249 278 endquote = strchr(search_field, '\0'); //end of string... sometimes the end bracket is missing
Anubus 0:bd276b1f1249 279 ifoundlen = (uint16_t) (endquote - beginquote) + 1;
Anubus 0:bd276b1f1249 280 strncpy(found_string, beginquote, ifoundlen );
Anubus 0:bd276b1f1249 281 found_string[ifoundlen] = 0; //null terminate
Anubus 0:bd276b1f1249 282 return false;
Anubus 0:bd276b1f1249 283 }
Anubus 0:bd276b1f1249 284 }
Anubus 0:bd276b1f1249 285 else
Anubus 0:bd276b1f1249 286 {
Anubus 0:bd276b1f1249 287 return false;
Anubus 0:bd276b1f1249 288 }
Anubus 0:bd276b1f1249 289 } //extract_JSON
Anubus 0:bd276b1f1249 290
Anubus 0:bd276b1f1249 291 int cell_modem_init()
Anubus 0:bd276b1f1249 292 {
Anubus 0:bd276b1f1249 293 int i;
Anubus 0:bd276b1f1249 294
Anubus 0:bd276b1f1249 295 pc.baud(115200);
Anubus 0:bd276b1f1249 296 // Initialize the modem
Anubus 0:bd276b1f1249 297 PRINTF(GRN "Modem initializing... will take up to 60 seconds" DEF "\r\n");
Anubus 0:bd276b1f1249 298 do {
Anubus 0:bd276b1f1249 299 i=mdm_init();
Anubus 0:bd276b1f1249 300 if (!i) {
Anubus 0:bd276b1f1249 301 PRINTF(RED "Modem initialization failed!" DEF "\n");
Anubus 0:bd276b1f1249 302 }
Anubus 0:bd276b1f1249 303 } while (!i);
Anubus 0:bd276b1f1249 304
Anubus 0:bd276b1f1249 305 //Software init
Anubus 0:bd276b1f1249 306 software_init_mdm();
Anubus 0:bd276b1f1249 307
Anubus 0:bd276b1f1249 308 // Resolve URL to IP address to connect to
Anubus 0:bd276b1f1249 309 resolve_mdm();
Anubus 0:bd276b1f1249 310 // Open the socket (connect to the server)
Anubus 0:bd276b1f1249 311 sockopen_mdm();
Anubus 0:bd276b1f1249 312 return (0);
Anubus 0:bd276b1f1249 313 }
Anubus 0:bd276b1f1249 314
Anubus 0:bd276b1f1249 315 int cell_modem_Sendreceive(char* tx_string, char* rx_string)
Anubus 0:bd276b1f1249 316 {
Anubus 0:bd276b1f1249 317 int iStatus = 0; //error by default
Anubus 0:bd276b1f1249 318 PRINTF(DEF "\r\n");
Anubus 0:bd276b1f1249 319 PRINTF(BLU "Sending to modem : %s" DEF "\r\n", &tx_string[0]);
Anubus 0:bd276b1f1249 320 sockwrite_mdm(&tx_string[0]);
Anubus 0:bd276b1f1249 321 if (sockread_mdm(&MySocketData, 1024, 20))
Anubus 0:bd276b1f1249 322 {
Anubus 0:bd276b1f1249 323 PRINTF(DEF "\r\n");
Anubus 0:bd276b1f1249 324 PRINTF(YEL "Read back : %s" DEF "\r\n", MySocketData.c_str());
Anubus 0:bd276b1f1249 325 char stringToCharBuf[BUF_SIZE_FOR_N_MAX_SOCKREAD*MAX_WNC_SOCKREAD_PAYLOAD+1]; // WNC can return max of 1500 (per sockread)
Anubus 0:bd276b1f1249 326 if ((MySocketData.length() + 1) < sizeof(stringToCharBuf))
Anubus 0:bd276b1f1249 327 {
Anubus 0:bd276b1f1249 328 strcpy(stringToCharBuf, MySocketData.c_str());
Anubus 0:bd276b1f1249 329 if (extract_JSON(stringToCharBuf, &rx_string[0]))
Anubus 0:bd276b1f1249 330 {
Anubus 0:bd276b1f1249 331 PRINTF(GRN "JSON : %s" DEF "\n", &rx_string[0]);
Anubus 0:bd276b1f1249 332 iStatus = 1; //all good
Anubus 0:bd276b1f1249 333 }
Anubus 0:bd276b1f1249 334 }
Anubus 0:bd276b1f1249 335 else
Anubus 0:bd276b1f1249 336 {
Anubus 0:bd276b1f1249 337 PRINTF(RED "BUFFER not big enough for sock data!" DEF "\r\n");
Anubus 0:bd276b1f1249 338 }
Anubus 0:bd276b1f1249 339 }
Anubus 0:bd276b1f1249 340 else
Anubus 0:bd276b1f1249 341 {
Anubus 0:bd276b1f1249 342 PRINTF(RED "No response..." DEF "\r\n");
Anubus 0:bd276b1f1249 343 }
Anubus 0:bd276b1f1249 344 return iStatus;
Anubus 0:bd276b1f1249 345 }
Anubus 0:bd276b1f1249 346
Anubus 0:bd276b1f1249 347 void display_wnc_firmware_rev(void)
Anubus 0:bd276b1f1249 348 {
Anubus 0:bd276b1f1249 349 display_modem_firmware_version();
Anubus 0:bd276b1f1249 350 }