Sub Process_Globals
Public Serial1 As Serial
Private wifi As ESP8266WiFi
Dim ConnectStart As ULong
Dim count As Int
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
'example of connecting to a local network
connectloop(0)
End Sub
Sub connectloop(loopcount As Byte)
'non-blocking delay - doesn't seem to help with error message
If loopcount > 4 Then Return
Log("Connect: ", loopcount)
Connect
CallSubPlus("connectloop", 10000, loopcount + 1)
End Sub
Sub Connect
ConnectStart = Millis
' wifi.ConnectAsync("SSID", "Password", 0, Null, "wifi_Connected")
If wifi.Connect2("SSID", "Password") Then
Log("Connected to network after ", (Millis - ConnectStart), " Millis")
Else
Log("Failed to connect to network after", (Millis - ConnectStart), " Millis")
'wifi.Disconnect 'doesn't make any difference
End If
End Sub
Sub wifi_Connected(Success As Boolean)
If Success Then
Log("Async success after ", (Millis - ConnectStart), " Millis")
Else
Log("Async failed after ", (Millis - ConnectStart), " Millis")
End If
End Sub