#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 300
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Serial1 As Serial
Private wifi As ESP8266WiFi
Private stim As ULong
Private etim As ULong
End Sub
Private Sub AppStart
RunNative("StopPersistent",Null) ' no effect on connect time issue if taken out
Serial1.Initialize(115200)
Log("AppStart")
Delay(500) ' if delay is more than a few 100ms then connect time nearly doubles
wifi.Disconnect ' this appears to be the cause of the issue.
' Use If wifi.Isconnected to avoid unecessarily calling it
stim = Millis
Log("Start connect time = ",stim)
If wifi.Connect2("xyz","12345678") = False Then
Log("Error connecting to network")
Return
Else
etim = Millis
Log("End connect time = ",etim)
Log("Connected to network")
End If
Log("Time taken = ",NumberFormat((etim-stim)/1000,0,2),"s")
End Sub
#if C
void StopPersistent(B4R::Object* o) {
WiFi.persistent(false);
}
#end if