You are reading a single comment by @Gordon and its replies.
Click here to read the full conversation.
-
doooh... me... sorry bothering you for the callback... now I recall that the first argument is the error, and if first argument - error - is null, second argument is the actual data...
I adjusted my code and it does what I needed. THANKS...
Adjusted with 'assuming' I get no err(or) in
getIP()
:... wifi.getIP(function(err,data){ console.log("getIP() in callback: ",data.ip); })); ...
with console output:
... Running onInit()... Connected! getIP() in callback: 192.168.0.113 >
That's as you'd expect I think?
So it's that there are two arguments returned by the callback -
err
andip
. It's odd, but it's just the way node.js tended to handle callback functions that can return an error, so I wanted to keep things compliant with them.Since on EspruinoWiFi the WiFi is basically async,
getIP
can't immediately return an IP address.Unfortunately when running on ESP8266 the callback format is different - it's something I'd like to change to bring everything more in-line really.