• 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...

    ...to be continued.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview
About

How to apply Wifi in an Espruino and ESP8266 contexts uniform?

Posted by Avatar for allObjects @allObjects

Actions