WiFi not generating WIFI_EVENT_STA_DISCONNECTED event
Posted: Sat Nov 13, 2021 8:04 pm
Hello all,
new to ESP32 and to this forum.
I'm using wifi_station from esp-idf example to connect to wifi to send temperatures from onewire sensor to mqtt server. ESP will connect to wifi without problems and connection is stable. I'm receiving and processing events using event_handler function.
BUT - event_handler function is not called when wifi is disconnected (e.g. Access Point rebooted). So I'm not able to react to lost wifi connection.
event_handler calls print similar line in the log
I'm using esp-idf v4.4-dev-2977-gdd491ee851
In the log below, you can see when wifi AP was rebooted at the end. There was no WIFI_EVENT received by the handler. I can force ESP to reconnect by manually calling esp_wifi_connect(), which will reestablish connection without problems.
What am I doing wrong?
Thanks and have fun
Rasto
new to ESP32 and to this forum.
I'm using wifi_station from esp-idf example to connect to wifi to send temperatures from onewire sensor to mqtt server. ESP will connect to wifi without problems and connection is stable. I'm receiving and processing events using event_handler function.
BUT - event_handler function is not called when wifi is disconnected (e.g. Access Point rebooted). So I'm not able to react to lost wifi connection.
event_handler calls print similar line in the log
Code: Select all
wifi station: Event dispatched from event loop base=WIFI_EVENT, event_id=4
In the log below, you can see when wifi AP was rebooted at the end. There was no WIFI_EVENT received by the handler. I can force ESP to reconnect by manually calling esp_wifi_connect(), which will reestablish connection without problems.
Code: Select all
I (461) onewire: OneWire Initialized
I (491) onewire: Found device 0: 1d000001b437cc28
I (501) onewire: Device 0 set as DS18B20
I (581) wifi:wifi driver task: 3ffc00c0, prio:23, stack:6656, core=0
I (581) system_api: Base MAC address is not set
I (581) system_api: read default base MAC address from EFUSE
I (601) wifi:wifi firmware version: d683787
I (601) wifi:wifi certification version: v7.0
I (601) wifi:config NVS flash: enabled
I (601) wifi:config nano formating: disabled
I (601) wifi:Init data frame dynamic rx buffer num: 32
I (611) wifi:Init management frame dynamic rx buffer num: 32
I (611) wifi:Init management short buffer num: 32
I (621) wifi:Init dynamic tx buffer num: 32
I (621) wifi:Init static rx buffer size: 1600
I (621) wifi:Init static rx buffer num: 10
I (631) wifi:Init dynamic rx buffer num: 32
I (631) wifi_init: rx ba win: 6
I (641) wifi_init: tcpip mbox: 32
I (641) wifi_init: udp mbox: 6
I (641) wifi_init: tcp mbox: 6
I (651) wifi_init: tcp tx win: 5744
I (651) wifi_init: tcp rx win: 5744
I (661) wifi_init: tcp mss: 1440
I (661) wifi_init: WiFi IRAM OP enabled
I (661) wifi_init: WiFi RX IRAM OP enabled
I (671) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
I (781) wifi:mode : sta (24:6f:28:b2:3e:60)
I (781) wifi:enable tsf
I (781) wifi station: wifi_init_sta finished.
I (781) wifi station: Event dispatched from event loop base=WIFI_EVENT, event_id=2
I (791) wifi station: wifi event: 2
I (791) wifi station: wifi connect called
I (801) wpa: BSS: Add new id 0 BSSID 18:e8:29:a6:e6:39 SSID 'loulou' chan 11
I (811) wifi:new:<11,0>, old:<1,0>, ap:<255,255>, sta:<11,0>, prof:1
I (811) wifi:state: init -> auth (b0)
I (821) wifi:state: auth -> assoc (0)
I (821) wifi:state: assoc -> run (10)
I (841) wifi:connected with loulou, aid = 2, channel 11, BW20, bssid = 18:e8:29:a6:e6:39
I (841) wifi:security: WPA2-PSK, phy: bgn, rssi: -66
I (851) wifi:pm start, type: 1
I (851) wifi station: Event dispatched from event loop base=WIFI_EVENT, event_id=4
I (851) wifi station: wifi event: 4
I (921) wifi:AP's beacon interval = 102400 us, DTIM period = 2
I (1571) esp_netif_handlers: sta ip: 192.168.1.139, mask: 255.255.255.0, gw: 192.168.1.1
I (1571) wifi station: Event dispatched from event loop base=IP_EVENT, event_id=0
I (1571) wifi station: got ip:192.168.1.139
I (1581) wifi station: connected to ap SSID:loulou password:Un-loulou-qui-chantait
I (1591) onewire: Convert all DS18B20
I (2201) onewire: Device 0: Read Temperature
I (2211) onewire: Device 0: Temperature: 28.750000
W (5941) wifi:<ba-add>idx:0 (ifx:0, 18:e8:29:a6:e6:39), tid:0, ssn:1, winSize:64
I (54131) wifi:bcn_timout,ap_probe_send_start
I (56631) wifi:ap_probe_send over, resett wifi status to disassoc
I (56631) wifi:state: run -> init (c800)
I (56631) wifi:pm stop, total sleep time: 45291222 us / 55787413 us
W (56641) wifi:<ba-del>idx
I (56641) wifi:new:<11,0>, old:<11,0>, ap:<255,255>, sta:<11,0>, prof:1
Thanks and have fun
Rasto