Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

event_handler SYSTEM_EVENT_AP_STADISCONNECTED sometimes not received (IDFGH-15) #2375

Closed
francescofcf opened this issue Sep 5, 2018 · 10 comments

Comments

@francescofcf
Copy link

SO: Windows 10
IDE: Eclipse IDE for C/C++ Developers Version: Photon Release (4.8.0) Build id: 20180619-1200
environment: esp32_win32_msys2_environment_and_toolchain-20180110
ESP-IDF version: v3.2-dev-362-g1c7a8b3b
EspTools : esptool.py v2.5.0
Source code : "Simple WiFi Example" in "esp-idf \ examples \ wifi \ simple_wifi \ main"
Source Code config : AP mode
Client : Iphone 6s
Power : external 3.3V

DevBoard1 : ESP32 DEVKITV1
Chip is ESP32D0WDQ6 (revision 0)
Features: WiFi, BT, Dual Core
MAC: 24:0a:c4:80:32:e8

DevBoard2: my board with
Chip is ESP32D0WDQ6 (revision 1)
Features: WiFi, BT, Dual Core, 240MHz, VRef calibration in efuse
MAC: 80:7d:3a:82:1c:50

Hi, I have an problem about event_handler(void *ctx, system_event_t *event)

I have chek the problem also in "Simple WiFi Example" in "esp-idf \ examples \ wifi \ simple_wifi \ main" whitout modify.
The simple project "Simple WiFi Example" has the same problem!
Below there is the output about "Simple WiFi Example", see output on UART at “57148 “ and “127508”

I have add as first row the below in event_handler:
ESP_LOGI(TAG, "EVENT: %d",event->event_id);
The problem is:
At startup the event_handler receive:
Event 13 : SYSTEM_EVENT_AP_START
after connected
Event 15 : SYSTEM_EVENT_AP_STACONNECTED
Event 17 : SYSTEM_EVENT_AP_STAIPASSIGNED
but after disconnected sometimes (often the first time) the
Event 16 : SYSTEM_EVENT_AP_STADISCONNECTED
it is not received.

After If I add a task and print this information:

esp_wifi_ap_get_sta_list(&wifi_sta_list);
tcpip_adapter_get_sta_list(&wifi_sta_list, &adapter_sta_list);

the old station now disconnected is given as connected
The procedure that I use to disconnect the station (Apple smartphone) is to turn off the your wifi.

Output on UART

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)                         
ets Jun  8 2016 00:22:57                                                      
                                                                            
rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)                     
configsip: 0, SPIWP:0xee                                                        
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00         
mode:DIO, clock div:1                                                           
load:0x3fff0018,len:4                                                           
load:0x3fff001c,len:5916                                                        
load:0x40078000,len:9076                                                        
load:0x40080400,len:6140                                                        
entry 0x40080748                                                                
I (29) boot: ESP-IDF v3.2-dev-362-g1c7a8b3b-dirty 2nd stage bootloader          
I (29) boot: compile time 14:32:38                                              
I (30) boot: Enabling RNG early entropy source...                               
I (35) boot: SPI Speed      : 80MHz                                             
I (39) boot: SPI Mode       : DIO                                               
I (43) boot: SPI Flash Size : 4MB                                               
I (47) boot: Partition Table:                                                   
I (51) boot: ## Label            Usage          Type ST Offset   Length         
I (58) boot:  0 nvs              WiFi data        01 02 00009000 00006000       
I (66) boot:  1 phy_init         RF data          01 01 0000f000 00001000       
I (73) boot:  2 factory          factory app      00 00 00010000 00100000       
I (81) boot: End of partition table                                             
I (85) esp_image: segment 0: paddr=0x00010020 vaddr=0x3f400020 size=0x11fc8 ( 73
672) map                                                                        
I (115) esp_image: segment 1: paddr=0x00021ff0 vaddr=0x3ffb0000 size=0x03500 ( 1
3568) load                                                                      
I (120) esp_image: segment 2: paddr=0x000254f8 vaddr=0x3ffb3500 size=0x00000 (  
   0) load                                                                      
I (122) esp_image: segment 3: paddr=0x00025500 vaddr=0x40080000 size=0x00400 (  
1024) load                                                                      
I (131) esp_image: segment 4: paddr=0x00025908 vaddr=0x40080400 size=0x0a708 ( 4
2760) load                                                                      
I (155) esp_image: segment 5: paddr=0x00030018 vaddr=0x400d0018 size=0x61b20 (40
0160) map                                                                       
I (272) esp_image: segment 6: paddr=0x00091b40 vaddr=0x4008ab08 size=0x05880 ( 2
2656) load                                                                      
I (280) esp_image: segment 7: paddr=0x000973c8 vaddr=0x400c0000 size=0x00000 (  
   0) load                                                                      
I (280) esp_image: segment 8: paddr=0x000973d0 vaddr=0x50000000 size=0x00000 (  
   0) load                                                                      
I (297) boot: Loaded app from partition at offset 0x10000                       
I (297) boot: Disabling RNG early entropy source...                             
I (299) cpu_start: Pro cpu up.                                                  
I (303) cpu_start: Starting app cpu, entry point is 0x40080fdc                  
I (0) cpu_start: App cpu up.                                                    
I (313) heap_init: Initializing. RAM available for dynamic allocation:          
I (320) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM                       
I (326) heap_init: At 3FFB94D8 len 00026B28 (154 KiB): DRAM                     
I (332) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM                    
I (339) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM                   
I (345) heap_init: At 40090388 len 0000FC78 (63 KiB): IRAM                      
I (351) cpu_start: Pro cpu start user code                                      
I (33) cpu_start: Starting scheduler on PRO CPU.                                
I (0) cpu_start: Starting scheduler on APP CPU.                                 
I (78) br_10: ESP_WIFI_MODE_AP                                                  
I (78) wifi: wifi driver task: 3ffc0cbc, prio:23, stack:3584, core=0            
I (78) wifi: wifi firmware version: e4d8ac5                                     
I (78) wifi: config NVS flash: enabled                                          
I (88) wifi: config nano formating: disabled                                    
I (88) system_api: Base MAC address is not set, read default base MAC address fr
om BLK0 of EFUSE                                                                
I (98) system_api: Base MAC address is not set, read default base MAC address fr
om BLK0 of EFUSE                                                                
I (128) wifi: Init dynamic tx buffer num: 32                                    
I (128) wifi: Init data frame dynamic rx buffer num: 32                         
I (128) wifi: Init management frame dynamic rx buffer num: 32                   
I (128) wifi: Init static rx buffer size: 1600                                  
I (138) wifi: Init static rx buffer num: 10                                     
I (138) wifi: Init dynamic rx buffer num: 32                                    
I (218) phy: phy_version: 3910, c0c45a3, May 21 2018, 18:07:06, 0, 0            
I (218) wifi: mode : softAP (24:0a:c4:80:32:e9)                                 
I (228) br_10: wifi_init_softap finished.SSID:myssid password:mypassword        
I (228) br_10: EVENT: 13                                                        
I (10818) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                       
I (10818) wifi: station: f4:31:c3:c3:41:f9 join, AID=1, bg, 20                  
I (10828) br_10: EVENT: 15                                                      
I (10828) br_10: station:f4:31:c3:c3:41:f9 join, AID=1                          
                                                                                
I (11988) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.2         
I (11988) br_10: EVENT: 17                                                      
I (16888) wifi: station: f4:31:c3:c3:41:f9 leave, AID = 1                       
I (16888) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                       
I (16888) br_10: EVENT: 16                                                      
I (16888) br_10: station:f4:31:c3:c3:41:f9leave, AID=1                          
                                                                                
I (23598) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                       
I (23598) wifi: station: f4:31:c3:c3:41:f9 join, AID=1, bg, 20                  
I (23598) br_10: EVENT: 15                                                      
I (23598) br_10: station:f4:31:c3:c3:41:f9 join, AID=1                          
                                                                                
I (23758) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.2         
I (23758) br_10: EVENT: 17                                                      
I (27438) wifi: station: f4:31:c3:c3:41:f9 leave, AID = 1                       
I (27438) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                       
I (27438) br_10: EVENT: 16                                                      
I (27438) br_10: station:f4:31:c3:c3:41:f9leave, AID=1                          
                                                                                
I (37288) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                       
I (37288) wifi: station: f4:31:c3:c3:41:f9 join, AID=1, bg, 20                  
I (37288) br_10: EVENT: 15                                                      
I (37288) br_10: station:f4:31:c3:c3:41:f9 join, AID=1                          
                                                                                
I (37478) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.2         
I (37478) br_10: EVENT: 17                                                      
I (42238) wifi: station: f4:31:c3:c3:41:f9 leave, AID = 1                       
I (42238) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                       
I (42238) br_10: EVENT: 16                                                      
I (42238) br_10: station:f4:31:c3:c3:41:f9leave, AID=1                          
                                                                                
I (48148) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                       
I (48148) wifi: station: f4:31:c3:c3:41:f9 join, AID=1, bg, 20                  
I (48148) br_10: EVENT: 15                                                      
I (48148) br_10: station:f4:31:c3:c3:41:f9 join, AID=1                          
                                                                                
I (48318) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.2         
I (48318) br_10: EVENT: 17                                                      
I (50468) wifi: station: f4:31:c3:c3:41:f9 leave, AID = 1                       
I (50468) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                       
I (50468) br_10: EVENT: 16                                                      
I (50468) br_10: station:f4:31:c3:c3:41:f9leave, AID=1                          
                                                                                
I (57008) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                       
I (57008) wifi: station: f4:31:c3:c3:41:f9 join, AID=1, bg, 20                  
I (57008) br_10: EVENT: 15                                                      
I (57008) br_10: station:f4:31:c3:c3:41:f9 join, AID=1                          
                                                                                
I (57148) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.2         
I (57148) br_10: EVENT: 17                                                      
I (93138) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                       
I (93138) wifi: station: f4:31:c3:c3:41:f9 join, AID=1, bg, 20                  
I (93138) br_10: EVENT: 15                                                      
I (93138) br_10: station:f4:31:c3:c3:41:f9 join, AID=1                          
                                                                                
I (93278) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.2         
I (93278) br_10: EVENT: 17                                                      
I (100848) wifi: station: f4:31:c3:c3:41:f9 leave, AID = 1                      
I (100848) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                      
I (100848) br_10: EVENT: 16                                                     
I (100848) br_10: station:f4:31:c3:c3:41:f9leave, AID=1                         
                                                                                
I (115338) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                      
I (115338) wifi: station: f4:31:c3:c3:41:f9 join, AID=1, bg, 20                 
I (115348) br_10: EVENT: 15                                                     
I (115348) br_10: station:f4:31:c3:c3:41:f9 join, AID=1                         
                                                                                
I (115518) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.2        
I (115518) br_10: EVENT: 17                                                     
I (119138) wifi: station: f4:31:c3:c3:41:f9 leave, AID = 1                      
I (119138) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                      
I (119138) br_10: EVENT: 16                                                     
I (119138) br_10: station:f4:31:c3:c3:41:f9leave, AID=1                         
                                                                                
I (127328) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                      
I (127328) wifi: station: f4:31:c3:c3:41:f9 join, AID=1, bg, 20                 
I (127328) br_10: EVENT: 15                                                     
I (127328) br_10: station:f4:31:c3:c3:41:f9 join, AID=1                         
                                                                                
I (127508) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.2        
I (127508) br_10: EVENT: 17                                                     
I (129188) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.2        
I (129188) br_10: EVENT: 17                                                     
I (129268) wifi: station: f4:31:c3:c3:41:f9 leave, AID = 1                      
I (129268) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                      
I (129268) br_10: EVENT: 16                                                     
I (129268) br_10: station:f4:31:c3:c3:41:f9leave, AID=1                         
                                                                                
I (136808) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                      
I (136808) wifi: station: f4:31:c3:c3:41:f9 join, AID=1, bg, 20                 
I (136808) br_10: EVENT: 15                                                     
I (136808) br_10: station:f4:31:c3:c3:41:f9 join, AID=1                         
                                                                                
I (136948) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.2        
I (136948) br_10: EVENT: 17                                                     
I (139498) wifi: station: f4:31:c3:c3:41:f9 leave, AID = 1                      
I (139498) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                      
I (139498) br_10: EVENT: 16                                                     
I (139498) br_10: station:f4:31:c3:c3:41:f9leave, AID=1                         
                                                                                
I (145588) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                      
I (145588) wifi: station: f4:31:c3:c3:41:f9 join, AID=1, bg, 20                 
I (145588) br_10: EVENT: 15                                                     
I (145588) br_10: station:f4:31:c3:c3:41:f9 join, AID=1                         
                                                                                
I (145728) tcpip_adapter: softAP assign IP to station,IP is: 192.168.4.2        
I (145728) br_10: EVENT: 17                                                     
I (166348) wifi: station: f4:31:c3:c3:41:f9 leave, AID = 1                      
I (166348) wifi: n:1 0, o:1 0, ap:1 1, sta:255 255, prof:1                      
I (166348) br_10: EVENT: 16                                                     
I (166348) br_10: station:f4:31:c3:c3:41:f9leave, AID=1    
@FayeY FayeY changed the title event_handler SYSTEM_EVENT_AP_STADISCONNECTED sometimes not received [TW#26169] event_handler SYSTEM_EVENT_AP_STADISCONNECTED sometimes not received Sep 11, 2018
@akshar001
Copy link

akshar001 commented Sep 23, 2018

Hello can somebody tell us when this thing is going to get fixed?

@francescofcf
Copy link
Author

I would like to know if it is a problem that can be solved, even using a workaround.
Thank you very much

@vonnieda
Copy link
Contributor

@francescofcf In my project I have had to use several different checks to see if the WiFi connection is still active. I ping a number of servers and after a certain number of pings I try to reconnect. In addition, when starting a connection I set a timer and if I don't get either a CONNECTED or DISCONNECTED message within several seconds I abort and try again. This works, but it's certainly not ideal.

@francescofcf
Copy link
Author

Unfortunately, I can't do anything like that. I open only a communication and do not do traffic.
I am a fake server and work as an access point, for my purpose I need only about the keepAlive and know if it is connected :(

@XinDeng11
Copy link
Contributor

@francescofcf hi, can you offer your reproduce step, because I can always receive AP_STADISCONNECTED event after connected event, maybe there is unknow gap between us

@francescofcf
Copy link
Author

only simple_wifi example, connect and diaconnect repeataly and loose the disconnect event.
Read first post and output on uart terminal.

@akshar001
Copy link

As i have understood throughout reading the problem over and over again , i don't think this event can happen at exact time as we wanted because this is how all the wifi works, for continuous checking that the station is available or not there should be some ping a like (AP pings every station connected to it to check it is still there) method in wifi standards , there is one but it is slow , it will took roughly 2-10 minutes to get to know that station is disconnected in every router ( when station just stopped working without notifying ap ) so if anyone who wants to check whether station is disconnected or not (fast) should have to implement a ping a like mechanism on your own in the code from AP side and if you handle the station code as well you can send message to AP in regular interval and if it didn't get received in AP side in some time (using some timer mechanism) you can get to know that station is disconnected!

@projectgus projectgus changed the title [TW#26169] event_handler SYSTEM_EVENT_AP_STADISCONNECTED sometimes not received event_handler SYSTEM_EVENT_AP_STADISCONNECTED sometimes not received (IDFGH-15) Mar 12, 2019
@zhangyanjiaoesp
Copy link
Collaborator

@akshar001 @francescofcf
We have two different scenario to trigger the SYSTEM_EVENT_AP_STADISCONNECTED event:

  • It will be triggered immediately when softAP receives the deauth/disassociation frame from the STA.
  • It will be triggered when the 5 minutes keep-alive timer expires, the timer expire if the softAP doesn't receive any packets from STA for 5 minutes. Generally this scenario happens when the STA do hardware reset/power-off, or when the disassociation/de-auth frame is failed received by softAP. Currently we don't have an API to configure the keep-alive timer,but we will consider to add such API to make the keep-alive timer can be user configured.

@nopnop2002
Copy link

Maybe Wifi power savings is involved.

Try this

#2183 (comment)

@liuzfesp
Copy link
Contributor

Same one as #4987, we will close this one and keep #4987.

espressif-bot pushed a commit that referenced this issue Aug 16, 2020
1. add sta connect again ap sent disconnect event
2. add set/get inactive time api

Closes #4401
Closes #4987
Closes #2375
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants