I have been using this code for a while now, but since I’m re-writing large portions, I thought I would run this important snippet by everyone. I’m initializing my wireless using static IP addressing:
WiFi.off(); IPAddress myAddress(192,168,1,2); IPAddress gateway(192,168,1,1); IPAddress netmask(255,255,255,0); IPAddress dns(8,8,8,8); WiFi.setStaticIP(myAddress, netmask, gateway, dns); WiFi.useStaticIP(); WiFi.on(); WiFi.setCredentials("SSID", "password", WPA2, WLAN_CIPHER_AES); WiFi.connect(); waitUntil(WiFi.ready); Particle.connect(); waitUntil(Particle.connected);
I think everything is correct, but I’m not 100% sure I need the initial
WiFi.off() before setting the IP address.
Does my code need any tweaks to make it more bulletproof? In case it matters, I’m running non-threaded in SEMI-AUTOMATIC mode.