• Best to look at the actual board reference: https://www.espruino.com/WiFi#using-wifi

    /* Get the IP and MAC address when connected to an AP and call
    `callback(err, { ip : ..., mac : ...})`. If err isn't null,
    it contains a string describing the error. You must be connected to
    an access point to be able to call this successfully. For AP mode use getAPIP
    */
    exports.getIP = function (callback) { ... }
    

    So:

    wifi.getIP(function(err,ip) {
      print(ip);
    });
    

    An object representing the station IP information, if available immediately (ONLY on ESP8266/ESP32).

    I feel like this is reasonably clear. Or at least given it not working you could try using the other method of calling it.

    • On ESP32/ESP8266 you get the result back immediately (if you want it)
    • On other devices you don't get a result back immediately, and need to use the callback
About

Avatar for Gordon @Gordon started