A fork of the original interface for OS/2. Features a correctly-implemented recv (but retains the old behavior via recv2).
Dependents: weather_clock weather_clock
Diff: ESP8266/ESP8266.cpp
- Revision:
- 52:a5c7a72aa707
- Parent:
- 51:c8c727b413d9
- Child:
- 53:4224de23da9e
diff -r c8c727b413d9 -r a5c7a72aa707 ESP8266/ESP8266.cpp --- a/ESP8266/ESP8266.cpp Sun Mar 31 15:39:31 2019 +0000 +++ b/ESP8266/ESP8266.cpp Fri May 24 23:19:03 2019 +0000 @@ -38,6 +38,10 @@ #define INFO(x, ...) #endif +#ifndef ESP8226_NEW_NODE +#define ESP8226_NEW_NODE 0 +#endif + ESP8266 *ESP8266::_inst; ESP8266::ESP8266(PinName tx, PinName rx, PinName reset, int baud, int timeout) : @@ -68,6 +72,19 @@ bool ESP8266::connect(const char *ssid, const char *phrase) { // Configure as station with passed ssid and passphrase + // If we're in the new lua interpreter, then this is wrong - how do we know? + // TODO: ESCAPE!!! + // Actually, we can try both... + #if ESP8226_NEW_NODE == 1 + if (!(command("wifi.setmode(wifi.STATION);") && + command("cfg={};cfg.ssid=\"") && + command(ssid) && + command("\";cfg.pwd=\"") && + command(phrase) && + command("\";wifi.sta.config(cfg)") && + execute())) + return false; + #else if (!(command("wifi.setmode(wifi.STATION);") && command("wifi.sta.config(\"") && command(ssid) && @@ -76,7 +93,7 @@ command("\")") && execute())) return false; - + #endif // Wait for an IP address // TODO WISHLIST make this a seperate check so it can run asynch? Timer timer;