Dependencies: TextLCD MQTT IAP
Diff: MQTTNetwork.h
- Revision:
- 2:562744909841
- Parent:
- 1:91e33a7fe0b5
--- a/MQTTNetwork.h Sat Oct 07 14:52:56 2017 +0000 +++ b/MQTTNetwork.h Thu Nov 29 03:28:14 2018 +0000 @@ -14,7 +14,13 @@ } int read(unsigned char* buffer, int len, int timeout) { - return socket->recv(buffer, len); + socket->set_blocking(false); + socket->set_timeout(timeout); + int ret = socket->recv(buffer, len); + if (NSAPI_ERROR_WOULD_BLOCK == ret) + return 0; + else + return ret; } int write(unsigned char* buffer, int len, int timeout) {