-
• #2
I figured this out. setIP() returns true when it successfully finishes.
Updated onInit code:
function onInit() { console.log("Connecting to Ethernet"); SPI2.setup({ mosi:B15, miso:B14, sck:B13 }); eth = require("WIZnet").connect(SPI2, B10); console.log("Connect?: " + isConnected); isConnected = eth.setIP(); console.log("Connect?: " + isConnected); if (isConnected == true) { mqttConnect(); } //eth.getIP(); eth.getIP(function(f,ip) { console.log("IP: ",ip); mqttConnect(); }); }
-
• #3
Great! I think one issue you have might be that
Ethernet.getIP
doesn't use a callback so never calls your function - it just returns the IP as-is.That's definitely an issue, as it should use the same form as other networking APIs to avoid this kind of confusion. I just filed an issue to get it fixed.
I've been attempting to connect to mqtt using the WIZ550io instead of wifi without success. My goal is to use a pico + WIZ550io + mqtt to trigger relays. I doubled checked if my pico has an IP address by typing eth.getIP() into the IDE console and I get the following result:
I'm following this guide: http://www.espruino.com/Home+Automation
I think my issue is with in my onInit function. I'm trying to call mqttConnect(); on a successful
, but I don't think
is getting called:
code: