Debugging wifi connection issues

markwj
Posts: 90
Joined: Tue Mar 08, 2016 5:03 am

Debugging wifi connection issues

Postby markwj » Sun Mar 18, 2018 12:47 pm

I'm having a problem where sometimes it takes a long time (a minute or two) to connect to wifi. My setup is I have 3 access points, distributed around the house, and all have the same SSID and are broadcasting on different channels:

If I force connection to one particular AP (by setting wifi_sta_cfg.sta.bssid_set=1 and wifi_sta_cfg.sta.bssid) it is quick and simple. But, if I let it choose it's own AP, it sometimes takes a minute or two to connect. Here is some of the output I get:

Code: Select all

I (140428) wifi: wifi firmware version: ebd3e5d
I (140438) wifi: config NVS flash: enabled
I (140438) wifi: config nano formating: disabled
I (140448) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (140448) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (140458) wifi: Init dynamic tx buffer num: 16
I (140458) wifi: Init data frame dynamic rx buffer num: 16
I (140468) wifi: Init management frame dynamic rx buffer num: 16
I (140468) wifi: wifi driver task: 3ffe3464, prio:23, stack:4096
I (140468) wifi: Init static rx buffer num: 4
I (140478) wifi: Init dynamic rx buffer num: 16
I (140478) wifi: wifi power manager task: 0x3ffed774 prio: 21 stack: 2560
I (140488) wifi: mode : sta (da:ta:re:da:ct:ed)
I (142908) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (143568) wifi: state: init -> auth (b0)
I (143578) wifi: state: auth -> assoc (0)
I (143588) wifi: state: assoc -> run (10)
I (143608) wifi: state: run -> auth (ec0)
I (143608) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (153438) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (153448) wifi: state: auth -> auth (b0)
I (153448) wifi: state: auth -> assoc (0)
I (153468) wifi: state: assoc -> run (10)
I (153468) wifi: state: run -> auth (ec0)
I (153478) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (163438) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (163448) wifi: state: auth -> auth (b0)
I (163458) wifi: state: auth -> assoc (0)
I (163458) wifi: state: assoc -> run (10)
I (163468) wifi: state: run -> auth (ec0)
I (163478) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (173438) wifi: n:8 2, o:1 0, ap:255 255, sta:8 2, prof:1
I (173448) wifi: state: auth -> auth (b0)
I (173448) wifi: state: auth -> assoc (0)
I (174458) wifi: state: assoc -> init (4)
I (174468) wifi: n:8 0, o:8 2, ap:255 255, sta:8 2, prof:1
I (183438) wifi: n:1 0, o:8 0, ap:255 255, sta:1 0, prof:1
I (183448) wifi: state: init -> auth (b0)
I (183448) wifi: state: auth -> assoc (0)
I (183458) wifi: state: assoc -> run (10)
I (183468) wifi: state: run -> auth (ec0)
I (183478) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (193438) wifi: n:8 2, o:1 0, ap:255 255, sta:8 2, prof:1
I (193448) wifi: state: auth -> auth (b0)
I (193468) wifi: state: auth -> assoc (0)
I (194228) event: station ip lost
I (194478) wifi: state: assoc -> init (4)
I (194488) wifi: n:8 0, o:8 2, ap:255 255, sta:8 2, prof:1
I (203438) wifi: n:8 2, o:8 0, ap:255 255, sta:8 2, prof:1
I (203448) wifi: state: init -> auth (b0)
I (203458) wifi: state: auth -> assoc (0)
I (203468) wifi: state: assoc -> run (10)
I (203488) wifi: connected with MYSSID, channel 8
I (206478) wifi: pm start, type:0
I (207058) event: sta ip: a.b.c.212, mask: 255.255.255.0, gw: a.b.c.1
Needless to say, I don't get any issue connecting with other WIFI devices (such as phones, tablets, etc).

I had a look in ESP-IDF components/esp32/wifi*, but not much there and no clues as to what those messages mean.

Any pointers / suggestions as to how I can go about diagnosing this particular problem, as well as wifi connectivity issues in general?

User avatar
kolban
Posts: 1683
Joined: Mon Nov 16, 2015 4:43 pm
Location: Texas, USA

Re: Debugging wifi connection issues

Postby kolban » Sun Mar 18, 2018 3:28 pm

I'm wondering if you made a list of the three bssids corresponding to your three access points and tried each of them in turn. Does one show the delay and the others don't?
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32

markwj
Posts: 90
Joined: Tue Mar 08, 2016 5:03 am

Re: Debugging wifi connection issues

Postby markwj » Mon Mar 19, 2018 8:14 am

kolban wrote:I'm wondering if you made a list of the three bssids corresponding to your three access points and tried each of them in turn. Does one show the delay and the others don't?
If I connect using specific BSSIDs, two show the delay and one doesn't.

My questions is more in general about debugging this. Without source code, is there any documentation that can be released on those state transitions and debug messages?

markwj
Posts: 90
Joined: Tue Mar 08, 2016 5:03 am

Re: Debugging wifi connection issues

Postby markwj » Thu Mar 22, 2018 1:46 pm

I've managed to narrow this down by setting the bsid in the station config structure.

There are four APs with the same SSID showing up in scans, and the problem always seems to be the AP with the best RSSI (presumably the first in the list). It is about 8feet away from the ESP32.

Here are the logs:

Code: Select all

Starting WIFI as a client to STATION (re:da:ct:ed:da:ta)...
I (25599) wifi: mode : sta (da:ta:re:da:ct:ed)
I (25599) events: Signal(system.event)
I (25599) events: Signal(system.wifi.sta.start)
I (28009) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (28759) wifi: state: init -> auth (b0)
I (28769) wifi: state: auth -> assoc (0)
I (28769) wifi: state: assoc -> run (10)
I (28779) wifi: state: run -> auth (ec0)
I (28779) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (28779) events: Signal(system.event)
I (28779) events: Signal(system.wifi.sta.disconnected)
I (28779) esp32wifi: STA disconnected with reason 14
I (63289) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (63299) wifi: state: auth -> auth (b0)
I (63299) wifi: state: auth -> assoc (0)
I (63299) wifi: state: assoc -> run (10)
I (63309) wifi: state: run -> auth (ec0)
I (63309) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (63309) events: Signal(system.event)
I (63309) events: Signal(system.wifi.sta.disconnected)
I (63309) esp32wifi: STA disconnected with reason 14
Reason 14 is supposedly MIC_FAILURE (Message integrity code (MIC) failure).

Currently, I can never connect to that access point from ESP32, no matter how many times I try. The Access Point config is identical to the others, and channel is different.

Channel is 1, RSSI is -55 and authentication is WIFI_AUTH_WPA2_PSK.

Any ideas?

Who is online

Users browsing this forum: No registered users and 119 guests