Detect WiFi router disconnect

#1

If you are asking a question, please follow this template:

  1. My goal is: [detect WiFi router disconnect]
  2. My actions are:
    [
    This is ESP8266 chip using Mongoose web-server
  3. mgos_event_add_group_handler(MGOS_EVENT_GRP_WIFI, WiFi_Event_cb, NULL);
  4. mgos_wifi_get_connected_ssid() show connected SSID
    ]
  5. The result I see is:
    [ MGOS_WIFI_EV_STA_DISCONNECTED does come back (~5 secs) when I pull the power on my WiFi router]
  6. My expectation & question is:
    [
  7. Is there any API which I can use as ping to monitor WiFi connection quickly (say in 100ms) ?
  8. Is there HTTP API which can “ping” the Server IP ?
    ]
#2

I’m no expert in WiFi, IIRC the disconnect detection is related to a beacon interval which is around 100ms, so to really know you lost your connection you must wait for several beacons. The beacon interval can probably be configured at the Access Point, I don’t know if the detection window timeout in mOS can be changed too.
The ESP8266 version of mOS uses Espressif’s nonOS SDK, which uses a modified version of lwIP, which has an API to ping (ICMP Echo Request). I don’t know if it is present in the SDK. You will need to know which IP to ping, though, and some admins don’t like devices being pinged nor frequent “pingers”.

#3

Do you know such API available in Mongoose-os or web-server lib ?

  1. Change the beacon timeout or retry ? Since it takes more then 5 secs to detect now.
  2. Ping or HTTP connect without going a GET ? Just to confirm server is there.
  3. How do I look up the Espressif’s nonOS SDK
    API for ESP8266