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
- Revision:
- 33:276cb279df57
- Parent:
- 30:c19f1e61063b
- Child:
- 34:9c26a3dcdc1f
--- a/ESP8266Interface.cpp Tue Feb 02 22:22:11 2016 +0000 +++ b/ESP8266Interface.cpp Mon Feb 22 23:56:33 2016 +0000 @@ -24,18 +24,6 @@ int32_t ESP8266Interface::init(void) { - if (!esp8266.startup()) { - return -1; - } - if (!esp8266.reset()) { - return -1; - } - if (!esp8266.wifiMode(3)) { - return -1; - } - if (!esp8266.multipleConnections(true)) { - return -1; - } return 0; } @@ -52,12 +40,18 @@ int32_t ESP8266Interface::connect(const char *ap, const char *pass_phrase, wifi_security_t security, uint32_t timeout_ms) { esp8266.setTimeout(timeout_ms); - if (!esp8266.dhcp(1, true)) { + if (!esp8266.startup(3)) { + return -1; + } + if (!esp8266.dhcp(true, 1)) { return -1; } if (!esp8266.connect(ap, pass_phrase)) { return -1; } + if (!esp8266.isConnected()) { + return -1; + } return 0; } @@ -77,9 +71,10 @@ char *ESP8266Interface::getIPAddress(void) { - if(!esp8266.getIPAddress(ip)) { - return NULL; - } + const char *src = esp8266.getIPAddress(); + if (!src) return 0; + + strcpy(ip, src); return ip; } @@ -207,8 +202,8 @@ int32_t ESP8266Socket::open() { - string sock_type = (SOCK_UDP == _type) ? "UDP" : "TCP"; - if (!_driver->openSocket(sock_type, _id, _port, _addr)) { + const char *sock_type = (SOCK_UDP == _type) ? "UDP" : "TCP"; + if (!_driver->open(sock_type, _id, _addr, _port)) { return -1; } return 0; @@ -218,7 +213,7 @@ int32_t ESP8266Socket::send(const void *data, uint32_t amount, uint32_t timeout_ms) { _driver->setTimeout((int)timeout_ms); - if(!_driver->sendData(_id, data, amount)) { + if(!_driver->send(_id, data, amount)) { return -1; } return 0; @@ -227,7 +222,7 @@ uint32_t ESP8266Socket::recv(void *data, uint32_t amount, uint32_t timeout_ms) { _driver->setTimeout((int)timeout_ms); - return _driver->recv(data, amount); + return _driver->recv(_id, data, amount); } int32_t ESP8266Socket::close() const