Connecting android/b4a application as client to an esp32 as the server using the MLScan/MLWifi library with a regular socket on the b4a side. i can connect easily to the esp32 server (softAP) and transmit data/files back and forth, but the wifi connection randomly disconnects. it "appears" it may be every 60 seconds or so but it is not that specific. it will even disconnect during a file transfer as well as sitting idle. i am trying to determine which side is causing the problem, is the client dropping or is the server timing out? for testing the phone/esp32 are withing 3 feet of each other. here is the b4a message when the astream errors out:
********b4a logger astream error:*********
android.system.ErrnoException: recvfrom failed: ETIMEDOUT (Connection timed out)
at:1517615820075
and the corresponding log when the esp times out:
********esp error **********************
Opening port
Port open
I (3139) wifi: wifi firmware version: 708a055
I (3140) wifi: config NVS flash: enabled
I (3140) wifi: config nano formating: disabled
I (3147) wifi: Init dynamic tx buffer num: 32
I (3147) wifi: Init data frame dynamic rx buffer num: 64
I (3147) wifi: Init management frame dynamic rx buffer num: 64
I (3151) wifi: wifi driver task: 3ffd4780, prio:23, stack:4096
I (3156) wifi: Init static rx buffer num: 10
I (3160) wifi: Init dynamic rx buffer num: 0
I (3165) wifi: wifi power manager task: 0x3ffd94bc prio: 21 stack: 2560
I (6440) wifi: mode : softAP (30:ae:a4:04:93:99)
wifi event:13
AP Started
IP address:192.168.4.1
IP Mac address:30:AE:A4:04:93:99
Host name:espressif
I (13626) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1
I (13626) wifi: station: 08:d4:2b:10:9c:06 join, AID=1, g, 20
wifi event:15
AP station connected to esp32
time (ms)=10386
client connected:false
server has client:false
---loop until client found---
server has client:true
server is available:true
found client
time (ms)=13149
client.connected:true
I (77912) wifi: station: 08:d4:2b:10:9c:06 leave, AID = 1
I (77913) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1
wifi event:16
AP station disconnected from esp32
time (ms)=74673
client connected:true
server has client:false
Port closed
----------------------------------------------------
Question:
1) what does the b4a error message mean? how do i determine which side is causing the issue?
2) is it possible the phone is continually searching for the strongest signal and will automatically switch to my home router? if so can i prevent this?
********b4a logger astream error:*********
android.system.ErrnoException: recvfrom failed: ETIMEDOUT (Connection timed out)
at:1517615820075
and the corresponding log when the esp times out:
********esp error **********************
Opening port
Port open
I (3139) wifi: wifi firmware version: 708a055
I (3140) wifi: config NVS flash: enabled
I (3140) wifi: config nano formating: disabled
I (3147) wifi: Init dynamic tx buffer num: 32
I (3147) wifi: Init data frame dynamic rx buffer num: 64
I (3147) wifi: Init management frame dynamic rx buffer num: 64
I (3151) wifi: wifi driver task: 3ffd4780, prio:23, stack:4096
I (3156) wifi: Init static rx buffer num: 10
I (3160) wifi: Init dynamic rx buffer num: 0
I (3165) wifi: wifi power manager task: 0x3ffd94bc prio: 21 stack: 2560
I (6440) wifi: mode : softAP (30:ae:a4:04:93:99)
wifi event:13
AP Started
IP address:192.168.4.1
IP Mac address:30:AE:A4:04:93:99
Host name:espressif
I (13626) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1
I (13626) wifi: station: 08:d4:2b:10:9c:06 join, AID=1, g, 20
wifi event:15
AP station connected to esp32
time (ms)=10386
client connected:false
server has client:false
---loop until client found---
server has client:true
server is available:true
found client
time (ms)=13149
client.connected:true
I (77912) wifi: station: 08:d4:2b:10:9c:06 leave, AID = 1
I (77913) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1
wifi event:16
AP station disconnected from esp32
time (ms)=74673
client connected:true
server has client:false
Port closed
----------------------------------------------------
Question:
1) what does the b4a error message mean? how do i determine which side is causing the issue?
2) is it possible the phone is continually searching for the strongest signal and will automatically switch to my home router? if so can i prevent this?
B4X:
Sub ConnectToSocket
Log("connecting to socket at " & DateTime.Now)
Log(espWifi.WifiSSID)
Log(espWifi.WifiStrength)
Log(espWifi.WifiLinkSpeed)
If espsocket.IsInitialized Then espsocket.Close
Sleep(250)
If espWifi.WifiSSID = "mpscilink" Then
Log("connect to socket at " & DateTime.Now)
If espWifi.isSavedWifiAP(espWifi.WifiSSID) = False Then
Log("save mpscilink to phone")
End If
If espWifi.isWifiHeldOn = False Then
Log("turn on wifi hold with lock")
Dim hld As Boolean = espWifi.holdWifiOn2(espWifi.WIFI_MODE_FULL_HIGH_PERF)
Log("holdwifion2 results:" & hld)
Else
Log("wifiheldon already set")
End If
Dim espsocket As Socket
espsocket.Initialize("socket")
espsocket.Connect(esphost,espport,10000) 'esphost=192.168.4.1 espport=21351
Else
CallSubDelayed2(Main,"mainscreenmsg","connection to mpscilink failed")
Log("couldn't connect to mpscilink. using default")
End If
End Sub
Sub socket_NewConnection (Successful As Boolean, NewSocket As Socket)
Log("new ss connection")
End Sub
Sub socket_Connected (Successful As Boolean)
Log("socket connected is " & Successful & " at " & DateTime.Now)
espconnected = Successful
If espconnected Then
ph.KeepAlive(True)
Log("connected")
CallSubDelayed2(Main,"mainscreenmsg","connected to mpscilink")
Log("start service")
Else
CallSubDelayed2(Main,"mainscreenmsg","connection to mpscilink failed")
End If
End Sub