Wifi is pretty compatible in Espruino with ESP8266 as well as in Espruino on ESP8266... including wifi.getIP(), which works in callback style the same way, even though for Espruino on ESP8266 the direct approach is still available (see my ddddooohhh-post at Espruino/Wifi - getIP() returns undefined but callback receives null,ip... - LOL).
The uniform way for getIP() looks as follows:
wifi.getIP(function(err,ip){
if (err) { // ...ever in ESP8266?
console.log(`error on getIP: ${err}`);
wifi.disconnect();
} else {
console.log(ip);
console.log(process.env);
console.log(process.memory());
// ... application code / invocation here...
}
});
...But it falls all apart when I setHostname(...) before (before connecting). With Espruino Wifi I still get the IP... but on ESP8266 I get 0.0.0.0. May be I do not understand setting the hostName yet... have to play a bit more...
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Wifi is pretty compatible in Espruino with ESP8266 as well as in Espruino on ESP8266... including
wifi.getIP()
, which works in callback style the same way, even though for Espruino on ESP8266 the direct approach is still available (see my ddddooohhh-post atEspruino/Wifi - getIP() returns undefined but callback receives null,ip... - LOL).
The uniform way for
getIP()
looks as follows:...But it falls all apart when I
setHostname(...)
before (before connecting). With Espruino Wifi I still get the IP... but on ESP8266 I get0.0.0.0
. May be I do not understand setting thehostName
yet... have to play a bit more......to be continued.