Raghav Ganesh
/
AvnetATT_shape_hackathon
This program simply connects to a HTS221 I2C device to read Temperature
Revision 10:df54436ecd38, committed 2016-07-11
- Comitter:
- fkellermavnet
- Date:
- Mon Jul 11 23:54:24 2016 +0000
- Parent:
- 9:01144f2b8e03
- Child:
- 11:e6602513730f
- Commit message:
- Changed wnc control code so that it can't do a read or a write to a socket if the socket is not opened successfully.
Changed in this revision
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
wnc_control.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/mbed.bld Mon Jul 11 22:17:20 2016 +0000 +++ b/mbed.bld Mon Jul 11 23:54:24 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/aae6fcc7d9bb \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/6c34061e7c34 \ No newline at end of file
--- 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();