Hello,
My phone is by default connected to the home router "Andromeda".
My app needs to switch the connection to another AP, an ESP8266 configured as an AP "ESP_Blue". On exiting the app, the phone needs to re-connect with the home router.
I use the excellent library jhwifi ver 1.2 to do the switching.
Sub Activity_Create(FirstTime As Boolean)
jhw.Initialize()
' 'n=jhw.findConfiguredNetwork("Andromeda") 'For STATION MODE
n=jhw.findConfiguredNetwork("ESP_Blue") 'For SOFTAP MODE
jhw.startscan()
timer1.Initialize("timer1", 2000)
timer1.Enabled = True
Sub timer1_Tick
Dim n As Int
n=jhw.findConfiguredNetwork("ESP_Blue")
Log("ESP_Blue: " & n)
' Connect to network
jhw.enableNetwork(n, True)
End Sub
And to disconnect, and connect to the default router on exit:
Sub ButtDisc_Click
WiFi_Socket.Close
TcpStreams.Close
ButtDisc.Text = "Disconnecting.."
TTS1.Speak (ButtDisc.Text,True)
Activity.Finish
'THIS AUTOMATICALLY CONNECTS BACK TO THE HOME ROUTER
jhw.Initialize()
n=jhw.findConfiguredNetwork("Andromeda")
jhw.enableNetwork(n, True)
End Sub
Now, when I run the program, it takes quite a while for it to connect to the ESP_Blue. Could be a anything from 10 to 20 seconds, at times its fast enough at about 5 seconds.
When I quit the program, the phone reconnects to the home router immediately.
The ESP_Blue module is not to be suspected (I think), it shows a robust operation, and I can connect to it very fast from outside my app, manually.
Am I using the jhwifi library in an incorrect manner? Or is it something else?