FRDM-K64F, Avnet M14A2A, Grove Shield, to create smart home system. In use with AT&Ts M2x & Flow.
Dependencies: mbed FXOS8700CQ MODSERIAL
Diff: wnc_control.cpp
- Revision:
- 84:fc8c9b39723a
- Parent:
- 82:65cde5d7070c
- Child:
- 85:0cf65ceb4492
diff -r 55778a2d5c5e -r fc8c9b39723a wnc_control.cpp --- a/wnc_control.cpp Mon Dec 11 21:51:32 2017 +0000 +++ b/wnc_control.cpp Wed Mar 06 21:11:49 2019 +0000 @@ -53,7 +53,7 @@ // Temp put here to fix new boards needing init, // the check for on the cellular network was preventing the PDNSET from happening!!!! { - PUTS("SET APN STRING!\r\n"); + //PUTS("SET APN STRING!\r\n"); string * pRespStr; string cmd_str("AT%PDNSET=1,"); cmd_str += MY_APN_STR; @@ -64,12 +64,12 @@ static bool reportStatus = true; do { - PUTS("------------ software_init_mdm! --------->\r\n"); + //PUTS("------------ software_init_mdm! --------->\r\n"); if (check_wnc_ready() == 0) { if (reportStatus == false) { - PUTS("Re-connected to cellular network!\n\r"); + //PUTS("Re-connected to cellular network!\n\r"); reportStatus = true; } @@ -89,7 +89,7 @@ { if (reportStatus == true) { - PUTS("Not connected to cellular network!\n\r"); + //PUTS("Not connected to cellular network!\n\r"); reportStatus = false; } // Atempt to re-register @@ -108,11 +108,11 @@ { string * pRespStr; - PUTS("<-------- WNC Firmware Revision --------\r\n"); + //PUTS("<-------- WNC Firmware Revision --------\r\n"); at_send_wnc_cmd("ATI", &pRespStr, WNC_TIMEOUT_MS); - PUTS(pRespStr->c_str()); - PUTS("\r\n"); - PUTS("--------------------------------------->\r\n"); + //PUTS(pRespStr->c_str()); + //PUTS("\r\n"); + //PUTS("--------------------------------------->\r\n"); } void resolve_mdm(void) @@ -127,11 +127,11 @@ } else if (WNC_MDM_ERR == WNC_CMD_ERR) { - PUTS("Bad URL!!!!!!\r\n"); + //PUTS("Bad URL!!!!!!\r\n"); } } while (WNC_MDM_ERR != WNC_OK); - PRINTF("My Server IP: %s\r\n", MyServerIpAddress.c_str()); + //PRINTF("My Server IP: %s\r\n", MyServerIpAddress.c_str()); } void sockopen_mdm(void) @@ -144,8 +144,8 @@ { software_init_mdm(); } - else if (WNC_MDM_ERR == WNC_CMD_ERR) - PUTS("Socket open fail!!!!\r\n"); + else if (WNC_MDM_ERR == WNC_CMD_ERR); + //PUTS("Socket open fail!!!!\r\n"); else socketOpen = 1; } while (WNC_MDM_ERR != WNC_OK); @@ -161,24 +161,24 @@ at_sockwrite_wnc(s); if (WNC_MDM_ERR == WNC_NO_RESPONSE) { - PUTS("Sock write no response!\r\n"); + //PUTS("Sock write no response!\r\n"); software_init_mdm(); } else if (WNC_MDM_ERR == WNC_CMD_ERR) { - PUTS("Socket Write fail!!!\r\n"); + //PUTS("Socket Write fail!!!\r\n"); software_init_mdm(); }else if (WNC_MDM_ERR == WNC_EXTERR) { - PUTS("Socket Disconnected (broken) !!!\r\n"); + //PUTS("Socket Disconnected (broken) !!!\r\n"); sockclose_mdm(); sockopen_mdm(); //software_init_mdm(); } } while (WNC_MDM_ERR != WNC_OK); } - else - PUTS("Socket is closed for write!\r\n"); + else; + //PUTS("Socket is closed for write!\r\n"); } unsigned sockread_mdm(string * sockData, int len, int retries) @@ -195,16 +195,16 @@ { if (n == 0) software_init_mdm(); - else - PUTS("Sock read partial data!!!\r\n"); + else; + //PUTS("Sock read partial data!!!\r\n"); } - else if (WNC_MDM_ERR == WNC_CMD_ERR) - PUTS("Sock read fail!!!!\r\n"); + else if (WNC_MDM_ERR == WNC_CMD_ERR); + //PUTS("Sock read fail!!!!\r\n"); } while (WNC_MDM_ERR == WNC_NO_RESPONSE); } else { - PUTS("Socket is closed for read\r\n"); + //PUTS("Socket is closed for read\r\n"); sockData->erase(); } @@ -225,8 +225,8 @@ { software_init_mdm(); } - else if (WNC_MDM_ERR == WNC_CMD_ERR) - PUTS("Sock close fail!!!\r\n"); + else if (WNC_MDM_ERR == WNC_CMD_ERR); + //PUTS("Sock close fail!!!\r\n"); } while (WNC_MDM_ERR != WNC_OK); } @@ -277,7 +277,7 @@ int cmdRes1, cmdRes2; #ifdef WNC_CMD_DEBUG_ON_VERBOSE - PUTS("<-------- Begin Cell Status ------------\r\n"); + //PUTS("<-------- Begin Cell Status ------------\r\n"); #endif cmdRes1 = at_send_wnc_cmd("AT+CSQ", &pRespStr, WNC_TIMEOUT_MS); // Check RSSI,BER cmdRes2 = at_send_wnc_cmd("AT+CPIN?", &pRespStr, WNC_TIMEOUT_MS); // Check if SIM locked @@ -285,7 +285,7 @@ if ((cmdRes1 != 0) && (cmdRes2 != 0)) { #ifdef WNC_CMD_DEBUG_ON_VERBOSE - PUTS("------------ WNC No Response! --------->\r\n"); + //PUTS("------------ WNC No Response! --------->\r\n"); #endif return (-2); } @@ -294,7 +294,7 @@ if (pRespStr->find("CPIN: READY") == string::npos) { #ifdef WNC_CMD_DEBUG_ON_VERBOSE - PUTS("------------ WNC SIM Problem! --------->\r\n"); + //PUTS("------------ WNC SIM Problem! --------->\r\n"); #endif return (-1); } @@ -313,20 +313,20 @@ if ((regSts != 1) && (regSts != 5)) { #ifdef WNC_CMD_DEBUG_ON_VERBOSE - PUTS("------------ WNC Cell Link Down! ------>\r\n"); + //PUTS("------------ WNC Cell Link Down! ------>\r\n"); #endif return (-2); } } #ifdef WNC_CMD_DEBUG_ON_VERBOSE - PUTS("------------ WNC Ready ---------------->\r\n"); + //PUTS("------------ WNC Ready ---------------->\r\n"); #endif } else { #ifdef WNC_CMD_DEBUG_ON_VERBOSE - PUTS("------------ CREG No Reply !----------->\r\n"); + //PUTS("------------ CREG No Reply !----------->\r\n"); #endif return (-2); } @@ -344,17 +344,17 @@ static string noRespStr; #ifdef WNC_CMD_DEBUG_ON - PUTS("FAIL send cmd: "); + //PUTS("FAIL send cmd: "); #ifdef WNC_CMD_DEBUG_ON_VERBOSE - PUTS(s); - PUTS("\r\n"); + //PUTS(s); + //PUTS("\r\n"); #else string truncStr(s, 50); truncStr += "\r\n"; - PUTS(truncStr.c_str()); + //PUTS(truncStr.c_str()); #endif #else - PUTS("FAIL send cmd!\r\n"); + //PUTS("FAIL send cmd!\r\n"); #endif WNC_MDM_ERR = WNC_CELL_LINK_DOWN; @@ -365,12 +365,12 @@ #ifdef WNC_CMD_DEBUG_ON #ifdef WNC_CMD_DEBUG_ON_VERBOSE - PUTS("[---------- Network Status -------------\r\n"); + //PUTS("[---------- Network Status -------------\r\n"); #endif string * pRespStr; at_send_wnc_cmd("AT@SOCKDIAL?", &pRespStr, 5000); #ifdef WNC_CMD_DEBUG_ON_VERBOSE - PUTS("---------------------------------------]\r\n"); + //PUTS("---------------------------------------]\r\n"); #endif #endif @@ -385,7 +385,7 @@ if (cmdRes == -3) { WNC_MDM_ERR = WNC_EXTERR; - PRINTF("[[WNC_MDM_ERR = WNC_EXTERR]] \r\n"); + //PRINTF("[[WNC_MDM_ERR = WNC_EXTERR]] \r\n"); } if (cmdRes == 0) @@ -408,11 +408,11 @@ { string truncStr(s,57); truncStr += "..."; - PRINTF("Send: <<%s>>\r\n",truncStr.c_str()); + //PRINTF("Send: <<%s>>\r\n",truncStr.c_str()); } - else + else; #endif - PRINTF("Send: <<%s>>\r\n",s); + //PRINTF("Send: <<%s>>\r\n",s); #endif int res = mdm_sendAtCmdRsp(s, rsp_lst, ms_timeout, &wncStr, &len); @@ -422,19 +422,19 @@ { #ifdef WNC_CMD_DEBUG_ON - PUTS("["); + //PUTS("["); #ifdef WNC_CMD_DEBUG_ON_VERBOSE - PUTS(wncStr.c_str()); - PUTS("]\r\n"); + //PUTS(wncStr.c_str()); + //PUTS("]\r\n"); #else - if (wncStr.size() < 51) - PUTS(wncStr.c_str()); + if (wncStr.size() < 51); + //PUTS(wncStr.c_str()); else { string truncStr = wncStr.substr(0,50) + "..."; - PUTS(truncStr.c_str()); + //PUTS(truncStr.c_str()); } - PUTS("]\r\n"); + //PUTS("]\r\n"); #endif #endif @@ -450,7 +450,7 @@ return 0; } else if (res == 2) { /* @EXTERR */ - PRINTF("@EXTERR and res = %d \r\n", res); + //PRINTF("@EXTERR and res = %d \r\n", res); return -3; } else return -1; @@ -458,7 +458,7 @@ } else { - PUTS("No response from WNC!\n\r"); + //PUTS("No response from WNC!\n\r"); return -2; } } @@ -480,13 +480,13 @@ if (hardReset == true) { - PUTS("Hard Reset!\r\n"); + //PUTS("Hard Reset!\r\n"); pdnSet = false; intSet = false; sockDialSet = false; } - PUTS("Start AT init of WNC:\r\n"); + //PUTS("Start AT init of WNC:\r\n"); // Quick commands below do not need to check cellular connectivity cmdRes = at_send_wnc_cmd("AT", &pRespStr, WNC_TIMEOUT_MS); // Heartbeat? cmdRes += at_send_wnc_cmd("ATE0", &pRespStr, WNC_TIMEOUT_MS); // Echo Off @@ -540,7 +540,7 @@ else return ; - PUTS("SUCCESS: AT init of WNC!\r\n"); + //PUTS("SUCCESS: AT init of WNC!\r\n"); } void at_sockopen_wnc(const string & ipStr, const char * port ) @@ -590,14 +590,14 @@ *ipStr = pRespStr->substr(pos_start, pos_end - pos_start + 1); return 1; } - else - PUTS("URL Resolve fail, substr Err\r\n"); + else; + //PUTS("URL Resolve fail, substr Err\r\n"); } - else - PUTS("URL Resolve fail, no quotes\r\n"); + else; + //PUTS("URL Resolve fail, no quotes\r\n"); } else - PUTS("URL Resolve fail, WNC cmd fail\r\n"); + //PUTS("URL Resolve fail, WNC cmd fail\r\n"); *ipStr = "192.168.0.1"; @@ -630,11 +630,11 @@ } cmd_str += "\""; res = send_wnc_cmd(cmd_str.c_str(), &pRespStr, 120000); - if (res == -3) - PUTS("sockwrite is disconnect \r\n"); + if (res == -3); + //PUTS("sockwrite is disconnect \r\n"); } - else - PUTS("sockwrite Err, string to long\r\n"); + else; + //PUTS("sockwrite Err, string to long\r\n"); } unsigned at_sockread_wnc(string * pS, unsigned n, unsigned retries = 0) @@ -687,13 +687,13 @@ } else { - PUTS("no readsock reply!\r\n"); + //PUTS("no readsock reply!\r\n"); return (0); } } } else - PUTS("sockread Err, to many to read\r\n"); + //PUTS("sockread Err, to many to read\r\n"); return (numBytes); }