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.
Fork of AvnetATT_shape_hackathon by
Diff: wnc_control.cpp
- Revision:
- 10:df54436ecd38
- Parent:
- 2:0e2ef866af95
- Child:
- 19:f89baed3bd6f
diff -r 01144f2b8e03 -r df54436ecd38 wnc_control.cpp --- 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();