![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Fork with SeeedStudio Xadow GPS v2 enabled
Dependencies: FXOS8700CQ MODSERIAL XadowGPS mbed
Fork of Avnet_ATT_Cellular_IOT by
Diff: wnc_control.cpp
- Revision:
- 10:df54436ecd38
- Parent:
- 2:0e2ef866af95
- Child:
- 19:f89baed3bd6f
--- a/wnc_control.cpp Mon Jul 11 22:17:20 2016 +0000 +++ b/wnc_control.cpp Mon Jul 11 23:54:24 2016 +0000 @@ -23,6 +23,7 @@ // Contains the RAW WNC UART responses static string wncStr; +static int socketOpen = 0; void software_init_mdm(void) { @@ -70,11 +71,15 @@ } else if (WNC_MDM_ERR == WNC_CMD_ERR) pc.puts("Socket open fail!!!!\r\n"); + else + socketOpen = 1; } while (WNC_MDM_ERR != WNC_OK); } void sockwrite_mdm(const char * s) { + if (socketOpen == 1) + { do { WNC_MDM_ERR = WNC_OK; @@ -92,10 +97,15 @@ software_init_mdm(); } } while (WNC_MDM_ERR != WNC_OK); + } + else + puts("Socket is closed for write!\r\n"); } void sockread_mdm(string * sockData, int len, int retries) { + if (socketOpen == 1) + { do { WNC_MDM_ERR = WNC_OK; @@ -108,6 +118,9 @@ else if (WNC_MDM_ERR == WNC_CMD_ERR) puts("Sock read fail!!!!\r\n"); } while (WNC_MDM_ERR != WNC_OK); + } + else + puts("Socket is closed for read\r\n"); } void sockclose_mdm(void) @@ -116,6 +129,10 @@ { WNC_MDM_ERR = WNC_OK; at_sockclose_wnc(); + // Assume close happened even if it went bad + // going bad will result in a re-init anyways and if close + // fails we're pretty much in bad state and not much can do + socketOpen = 0; if (WNC_MDM_ERR == WNC_NO_RESPONSE) { reinitialize_mdm();