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 ESP8266Interface by
Diff: ESP8266Interface.cpp
- Branch:
- api-changes
- Revision:
- 44:7ac7eb406603
- Parent:
- 43:7c010b1db697
- Child:
- 45:538e5ce2f0d3
diff -r 7c010b1db697 -r 7ac7eb406603 ESP8266Interface.cpp --- a/ESP8266Interface.cpp Wed Feb 24 23:14:45 2016 -0600 +++ b/ESP8266Interface.cpp Thu Feb 25 03:25:00 2016 -0600 @@ -37,8 +37,8 @@ virtual int32_t open(const char *ip, uint16_t port); virtual int32_t close(); - virtual int32_t send(const void *data, uint32_t len); - virtual int32_t recv(void *data, uint32_t len); + virtual int32_t send(const void *data, uint32_t size); + virtual int32_t recv(void *data, uint32_t size); private: ESP8266 *_esp; @@ -166,23 +166,26 @@ return 0; } -int32_t ESP8266Socket::send(const void *data, uint32_t amount) +int32_t ESP8266Socket::send(const void *data, uint32_t size) { - if (!_esp->send(_id, data, amount)) { + if (!_esp->send(_id, data, size)) { return NS_ERROR_TIMEOUT; } return 0; } -int32_t ESP8266Socket::recv(void *data, uint32_t amount) +int32_t ESP8266Socket::recv(void *data, uint32_t size) { - int32_t size = _esp->recv(_id, data, amount); - if (size < 0) { - return NS_ERROR_TIMEOUT; + _esp->setTimeout(0); + + int32_t recv = _esp->recv(_id, data, size); + + if (recv < 0) { + return 0; } - return size; + return recv; } int ESP8266Socket::getID() const {