B4R Question esp tcp server disconnected client when modem not found

mzelecom

Member
hi.
i used esp in mode acsespoint and station together.
B4X:
server.Initialize(port, "server_NewConnection")
    server.Listen

Log("StartAP: ", wifi.StartAccessPoint("esp"))
    Log("My AP ip: ", wifi.AccessPointIp)
    Log("My local ip: ", wifi.LocalIp)

    If wifi.Connect2("modem", "password") Then
        Log("Connected successfully : ")
        Log("Local IP: ", wifi.LocalIp)
    Else
        Log("Failed to connect.")
    End If
i connect android phone to esp directly.
when my modem ok and esp connected to it my android app connected normally as tcp client.
but if esp Failed to connect to modem (wrong password) when my app connected to esp as tcp socket it disconnected client after 2 second.
if i remove below code.its ok and not disconnected.

B4X:
   If wifi.Connect2("modem", "password") Then
        Log("Connected successfully : ")
        Log("Local IP: ", wifi.LocalIp)
    Else
        Log("Failed to connect.")
    End If

what was wrong?
 

miker2069

Active Member
Licensed User
Longtime User
If I'm following you correctly, you're starting an access point and also attempting to connect to another access point at the same time on the same device? I don't think this is possible (have the device in STA and AP mode concurrently). So I can see why you're having issues and when you remove the attempt to connect to another AP the ESP AP works correctly.
 
Upvote 0

mzelecom

Member
in esp we have 4 mode .
WIFI_AP
WIFI_STA
WIFI_AP_STA
WIFI_OFF

i used WIFI_AP_STA .why i used it because i want to change setting off esp when my modem not work and i must connect to esp directly and change setting.
when esp connect to modem correctly i can connect to esp directly or connect from modem and not disconnected .
 
Upvote 0
Top