Wifi repeatedly disconnects after 291.992 seconds

ItsFlipp
Posts: 3
Joined: Sat Mar 25, 2017 11:41 pm

Wifi repeatedly disconnects after 291.992 seconds

Postby ItsFlipp » Mon Mar 27, 2017 7:09 pm

Heya!

Been toying with a couple of ESP32s recently and I'm running into an odd issue with the wifi. I set up one chip as an access point and the other as a client. They successfully authenticate, connect, and receive a DHCP assignment, but after 291.992s the client goes appears to go from "run" to "auth", causing a disconnect/reconnect.

Client logs:

Code: Select all

*snip*
I (88) wifi: wifi firmware version: 87530d3
I (88) wifi: config NVS flash: enabled
I (88) wifi: config nano formating: disabled
I (96) wifi: Init dynamic tx buffer num: 32
I (97) wifi: wifi driver task: 3ffbd65c, prio:23, stack:3584
I (97) wifi: Init static rx buffer num: 10
I (99) wifi: Init dynamic rx buffer num: 0
I (103) wifi: Init rx ampdu len mblock:7
I (107) wifi: Init lldesc rx ampdu entry mblock:4
I (111) wifi: wifi power manager task: 0x3ffc2a14 prio: 21 stack: 2560
I (117) wifi_conn: Setting up the WiFis, ssid: XXX, pw: XXX
I (125) wifi: wifi timer task: 3ffc4a98, prio:22, stack:3584
I (151) phy: phy_version: 329, Feb 22 2017, 15:58:07, 0, 0
I (152) wifi: Init ampdu: 0
I (152) wifi: mode : sta (24:0a:c4:04:22:f8)
I (153) wifi_conn: Station started
I (277) wifi: n:1 1, o:1 0, ap:255 255, sta:1 1, prof:1
I (934) wifi: state: init -> auth (b0)
I (936) wifi: state: auth -> assoc (0)
I (940) wifi: state: assoc -> run (10)
I (948) wifi: connected with XXX, channel 1
I (949) wifi_conn: Connected!
I (977) event: ip: 192.168.4.2, mask: 255.255.255.0, gw: 192.168.4.1
I (977) wifi_conn: Got IP address
I (10940) wifi: pm start, type:0

I (302933) wifi: state: run -> auth (4a0)
I (302933) wifi: pm stop, total sleep time: 0/291992907

I (302933) wifi: n:1 0, o:1 1, ap:255 255, sta:1 1, prof:1
I (302936) wifi_conn: Disconnected
I (303060) wifi: n:1 1, o:1 0, ap:255 255, sta:1 1, prof:1
I (303061) wifi: state: auth -> auth (b0)
I (303063) wifi: state: auth -> assoc (0)
I (303067) wifi: state: assoc -> run (10)
I (303078) wifi: connected with XXX, channel 1
I (303079) wifi_conn: Connected!

... repeat forever...
Server logs:

Code: Select all

I (85) wifi: wifi firmware version: 87530d3
I (85) wifi: config NVS flash: enabled
I (85) wifi: config nano formating: disabled
I (104) wifi: Init dynamic tx buffer num: 32
I (105) wifi: wifi driver task: 3ffbd65c, prio:23, stack:3584
I (105) wifi: Init static rx buffer num: 10
I (107) wifi: Init dynamic rx buffer num: 0
I (110) wifi: Init rx ampdu len mblock:7
I (114) wifi: Init lldesc rx ampdu entry mblock:4
I (119) wifi: wifi power manager task: 0x3ffc2a14 prio: 21 stack: 2560
I (125) wifi_conn: Setting up the WiFis, ssid: XXX
I (131) wifi_conn: (Init): 0
I (791) wifi: wifi timer task: 3ffc4a98, prio:22, stack:3584
I (810) phy: phy_version: 329, Feb 22 2017, 15:58:07, 0, 0
I (811) wifi: Init ampdu: 0
I (811) wifi: mode : softAP (24:0a:c4:01:34:c1)
I (814) wifi_conn: AP mode started
I (2159073) wifi_conn: Client connected
I (2461070) wifi: station: 24:0a:c4:04:22:f8 leave, AID = 1
I (2461070) wifi: n:1 0, o:1 1, ap:1 1, sta:255 255, prof:1
I (2461071) wifi_conn: Client disconnected
I (2461203) wifi: n:1 1, o:1 0, ap:1 1, sta:255 255, prof:1
I (2461203) wifi: station: 24:0a:c4:04:22:f8 join, AID=1, n, 40U
I (2461204) wifi_conn: Client connected
I (2763200) wifi: station: 24:0a:c4:04:22:f8 leave, AID = 1
I (2763201) wifi: n:1 0, o:1 1, ap:1 1, sta:255 255, prof:1
I (2763201) wifi_conn: Client disconnected
I (2763333) wifi: n:1 1, o:1 0, ap:1 1, sta:255 255, prof:1
I (2763334) wifi: station: 24:0a:c4:04:22:f8 join, AID=1, n, 40U
I (2763334) wifi_conn: Client connected
I (3065331) wifi: station: 24:0a:c4:04:22:f8 leave, AID = 1
I (3065331) wifi: n:1 0, o:1 1, ap:1 1, sta:255 255, prof:1
I (3065332) wifi_conn: Client disconnected
I (3065464) wifi: n:1 1, o:1 0, ap:1 1, sta:255 255, prof:1
I (3065464) wifi: station: 24:0a:c4:04:22:f8 join, AID=1, n, 40U
I (3065465) wifi_conn: Client connected

... repeat forever ...
Any idea what might be going on? I basically just lifted some of the wifi code out of the examples directory:

Code: Select all

  wifi_config_t wifi_config;
  memset(&wifi_config, 0, sizeof(wifi_config_t));
  memcpy(wifi_config.ap.ssid, _network.ssid, strlen(_network.ssid));
  memcpy(wifi_config.ap.password, _network.password, strlen(_network.password));
  wifi_config.ap.authmode = WIFI_AUTH_WPA2_PSK;
  wifi_config.ap.max_connection = 1;
  ESP_LOGI(TAG, "Setting up the WiFis, ssid: %s, pw: %s", wifi_config.sta.ssid, wifi_config.sta.password);
  ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
  ESP_ERROR_CHECK(esp_wifi_set_config(ESP_IF_WIFI_STA, &wifi_config));
  ESP_ERROR_CHECK(esp_wifi_start());

ItsFlipp
Posts: 3
Joined: Sat Mar 25, 2017 11:41 pm

Re: Wifi repeatedly disconnects after 291.992 seconds

Postby ItsFlipp » Tue Mar 28, 2017 10:32 pm

Digging a bit deeper, it appears that it has something to do with the server chip. If I connect the client ESP32 to a standard wifi network, it never disconnects.

ItsFlipp
Posts: 3
Joined: Sat Mar 25, 2017 11:41 pm

Re: Wifi repeatedly disconnects after 291.992 seconds

Postby ItsFlipp » Sun Apr 09, 2017 1:07 am

Narrowing it down... disconnects are due to "reason: 4", which is WIFI_REASON_AUTH_EXPIRE. According to the 802.11 spec, that means "Disassociated due to inactivity." Looking around the esp-idf source, I found this comment about inactivity in the wpa_supplicant code. Unfortunately the wpa library is closed source, so I can't poke around any further.

So this leaves me with two questions:

1) The comment suggests After AP_MAX_INACTIVITY has passed since last received frame from the station, a nullfunc data frame is sent to the station. If this frame is not acknowledged and no other frames have been received, the station will be disassociated after AP_DISASSOC_DELAY seconds.. Why does the esp-idf's wifi stack not acknowledge this null frame? Is there a setting somewhere to enable acknowledgement of null frames?

2) Is there a way to disable the inactivity filter entirely? I can #define AP_MAX_INACTIVITY to be some absurdly high number, but that seems both brittle and possibly problematic.

Who is online

Users browsing this forum: No registered users and 109 guests