Current Lua downloadable firmware will be posted here

User avatar
By morski_bg
#54310 Hello!
As usual - I'm quite new to Lua and esp8266.
The goal is to create some sort of proximity switch.
The idea is to use esp8266 in SoftAP mode and when my phone (with proper password data) is connected, esp8266 to toggle one GPIO pin, and toggle again when disconnected.
The realization so far - using "wifi.eventmon.AP_STACONNECTED"( and its T.MAC == my_pnone MAC) to detect when my phone is connected , and respectively "wifi.eventmon.AP_STADISCONNECTED" to detect disconnection.
So, everything is working as expected if I disconnect the phone manually by pressing its "WiFi off" button or by choosing another nearby wifi. But if I just walk away from esp8266 with the phone "wifi.eventmon.AP_STADISCONNECTED" fails to detect disconnection, even my phone is already connect to another wifi.
Is this normal behavior of "wifi.eventmon.AP_STADISCONNECTED" or I'm missing something?
Thnaks!
User avatar
By marcelstoer
#54321 First up, I don't know the answer, I can only speculate. But...the behavior doesn't strike me as illogical.

Your client doesn't really disconnect, does it? It just leaves the AP WiFi range - and may bounce back, or not. To properly detect such cases the AP would have to probe all connected clients for reachability (-> lots of WiFi noise).
User avatar
By morski_bg
#54326 Hi, thanks for your response.
I can confirm that when I walked away from esp8266 with the phone, it connects to another wifi (my home router), but there isn't any AP_DISCONNCTED event. I presume that SDK function responsible for this is wifi_softap_get_station_info(). After quick googling found some similar complains.
Regards