Hi.
My phone is normaly connected to my home wifi network. Have an IOT with its own network.
When starting my app I want to connect to my iot AP. Tried for a week with no luck.
(When setting up my phone manually to connect to the IOT everything is OK!)
Have B4A V12, MlWIFI 4.41 and Android 13
So, here is what I'm trying;
Sub ConnectToIOT()
If wifi2.WifiSSID<>"ABC" Then
Log("NOPE" & wifi2.WifiSSID)
wifi2.disconnectWifiAP
Do While wifi2.isWifiConnected=True
Sleep(100)
Loop
wifi2.connectWifiAP("ABC", wifi2.SECURITY_WPA2PSK, "DEF", 3000)
End if
.
.
Sub wifi2_connectionresult(success As Boolean)
Log("CON=" & success)
If success=True Then
server.Initialize( PORT, "server")
ConnectToServer( "MyIOTIP")
Else
Msgbox("Unable to connect to ABC","Fault")
B4XPages.ClosePage(Me)
End If
End Sub
When App starts I get the log: "Nope ..." and the name of my home network
Then the App hangs in the forever loop
Do While wifi2.isWifiConnected=True
as it doesnt disconnect from my home network.
It also never enters the Wifi2_connectionresult sub??
My Manifest is;
AddManifestText(<uses-permission
android:name="android.permission.ACCESS_NETWORK_STATE"/>)
AddManifestText(<uses-permission
android:name="android.permission.ACCESS_WIFI_STATE"/>)
AddManifestText(<uses-permission
android:name="android.permission.CHANGE_WIFI_STATE"/>)
AddManifestText(<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"/>)
AddManifestText(<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"/>)
Any help would be greatly apreciated.
Regards svein
I have also tried wifi2.disconnectap before trying to connect to my IOT, but did not help.