Host library for controlling a WiConnect enabled Wi-Fi module.
Dependents: wiconnect-ota_example wiconnect-web_setup_example wiconnect-test-console wiconnect-tcp_server_example ... more
Diff: internal/types/WiconnectSocket.cpp
- Revision:
- 21:17bb3eddcbae
- Parent:
- 17:7268f365676b
- Child:
- 24:e27e23297f02
--- a/internal/types/WiconnectSocket.cpp Sat Aug 23 05:57:52 2014 -0700 +++ b/internal/types/WiconnectSocket.cpp Tue Aug 26 16:38:19 2014 -0700 @@ -170,9 +170,12 @@ CHECK_CONNECTED(); CHECK_OTHER_COMMAND_EXECUTING(); - if(WICONNECT_SUCCEEDED(result, wiconnect->sendCommand("close %d", handle))) + result = wiconnect->sendCommand("close %d", handle); + + if(result != WICONNECT_PROCESSING) { - connected = false; + connected = false; + wiconnect->socketClosedCallback(this); } CHECK_CLEANUP_COMMAND(); @@ -309,11 +312,11 @@ { return WICONNECT_BAD_ARG; } - else if(rxBuffer.bytesPending < rxBuffer.size - 2) + else if(rxBuffer.bytesPending < rxBuffer.size) { - const int bytesToRead = rxBuffer.size - rxBuffer.bytesPending - 2; + const int bytesToRead = rxBuffer.size - rxBuffer.bytesPending; char* ptr = (char*)&rxBuffer.buffer[rxBuffer.bytesPending]; - if(!WICONNECT_FAILED(result, wiconnect->sendCommand(ptr, bytesToRead+2, "read %d %d", handle, bytesToRead))) + if(!WICONNECT_FAILED(result, wiconnect->sendCommand(ptr, bytesToRead, "read %d %d", handle, bytesToRead))) { rxBuffer.bytesPending += wiconnect->getLastCommandResponseLength(); }