WiFi: Getting WIFI_REASON_NO_AP_FOUND Despite Being Able to See AP in Scan Results

khaaaaaan
Posts: 9
Joined: Sat Jul 15, 2023 9:04 pm

WiFi: Getting WIFI_REASON_NO_AP_FOUND Despite Being Able to See AP in Scan Results

Postby khaaaaaan » Wed Aug 09, 2023 2:03 am

Hello all,

I am having a bit of trouble getting WiFi to work on ESP-IDF 4.4.5. Specifically, I can perform a WiFi scan, see my AP in the results along with the correct details but, when I actually attempt to connect, I receive WIFI_REASON_NO_AP_FOUND every time. Logs and sources attached for reference.

Some things I have already checked:

  • Verify SSID and password are correct. NOTE: In the log, my SSID is "iot"; my neighbor's SSIDs have been redacted.
  • Configure the router for B/G only (vs. the usual B/G/N) at 20MHz channel width.
  • Configure the router for TKIP (currently AES CCM).
  • Configure the router for 20MHz channel width in B/G/N mode (currently 20MHz / 40MHz).
  • Ensure SSID and password contain only alphanumeric characters.
What is most strange to me about this situation is that the scan works the first time, every time and shows my SSID without fail. This seems to indicate the antenna path is, at least, somewhat stable. For reference, this path was verified by one of my EE colleagues and has the recommended impedance, inner ground plane, via stitching, pi filter and ground plane cutout for the chip antenna itself.

So, can anybody think of anything I am missing?

Additionally, is there any way to get more information about why IDF is rejecting my AP? (Notice in the logs that there are 3 extra messages when IDF scans the channel that my AP is on which indicates that it finds something there).

Thanks in advance for any assistance on this!
Attachments
wifi.c
(6.06 KiB) Downloaded 174 times
connect-fail.log
(42.57 KiB) Downloaded 170 times

ESP_Penguin_Helper
Posts: 156
Joined: Tue Jul 11, 2023 6:55 am

Re: WiFi: Getting WIFI_REASON_NO_AP_FOUND Despite Being Able to See AP in Scan Results

Postby ESP_Penguin_Helper » Wed Aug 09, 2023 2:37 am

Hi, this means your scan fails to find the target AP. You can refer to this document:

https://docs.espressif.com/projects/esp ... scan-phase

First, let's make sure your device and Wi-Fi AP are able to connect. Can you test it using this IDF example:

https://github.com/espressif/esp-idf/tr ... ed/station

If the example code works with no issue on your device, you can try to use your phone to create a Hotpoint with the same SSID and password. Then check if your device can connect to the Hotpoint.

khaaaaaan
Posts: 9
Joined: Sat Jul 15, 2023 9:04 pm

Re: WiFi: Getting WIFI_REASON_NO_AP_FOUND Despite Being Able to See AP in Scan Results

Postby khaaaaaan » Thu Aug 10, 2023 12:46 am

Ah, crap, looks like the example works when run unmodified. I must have missed something when I implemented it for my project; my bad. On the bright side, at least my board design works!

Thanks again for the quick idiot-check.

khaaaaaan
Posts: 9
Joined: Sat Jul 15, 2023 9:04 pm

Re: WiFi: Getting WIFI_REASON_NO_AP_FOUND Despite Being Able to See AP in Scan Results

Postby khaaaaaan » Thu Aug 10, 2023 1:09 am

Ok, I was able to hunt this back down to the following line in the WiFi config:

Code: Select all

.threshold.authmode = WIFI_AUTH_WPA2_WPA3_PSK,
If I comment this, everything works as expected. What I don't understand is why. If I look over my AP configuration the only authentication mode I have enabled is WPA2 PSK. Shouldn't this match the above auth mode and work?

Additionally, is there any way to determine when a connection is rejected due to something like this? I would like to print a more helpful error message than "AP not found" if possible. There doesn't seem to be much in esp_event_base.h and the earlier driver documentation doesn't actually say anything about getting a reason code when a disconnect event happens (ex. WIFI_EVENT_STA_DISCONNECTED).

ESP_Penguin_Helper
Posts: 156
Joined: Tue Jul 11, 2023 6:55 am

Re: WiFi: Getting WIFI_REASON_NO_AP_FOUND Despite Being Able to See AP in Scan Results

Postby ESP_Penguin_Helper » Thu Aug 10, 2023 3:12 am

I see where the problem is. The only authentication mode you have enabled for your AP is WPA2 PSK. But you set your authmode = WIFI_AUTH_WPA2_WPA3_PSK, which is higher than WIFI_AUTH_WPA2_PSK. That's why your device won’t connect to AP.

If you set the authmode, only WiFi networks with an authentication mode no weaker than the specified value will be accepted. You can refer to: https://docs.espressif.com/projects/esp ... 8authmodeE

All available WiFi Reason Codes can be found here: https://docs.espressif.com/projects/esp ... eason-code

For your situation, we would recommend you check the STA and AP configuration. For now, our API won't return additional information.
Attachments
wifi_authmodes.png
wifi_authmodes.png (71.73 KiB) Viewed 1473 times

khaaaaaan
Posts: 9
Joined: Sat Jul 15, 2023 9:04 pm

Re: WiFi: Getting WIFI_REASON_NO_AP_FOUND Despite Being Able to See AP in Scan Results

Postby khaaaaaan » Thu Aug 10, 2023 3:54 pm

Ah, I see. I had interpreted that define as being either WPA2 PSK or WPA3 PSK. Which define should be used if I want to support anything WPA2 or above? Essentially, I want to reject WEP and WPA (these protocols have been broken for a very long time) and accept anything above that.

ESP_Penguin_Helper
Posts: 156
Joined: Tue Jul 11, 2023 6:55 am

Re: WiFi: Getting WIFI_REASON_NO_AP_FOUND Despite Being Able to See AP in Scan Results

Postby ESP_Penguin_Helper » Fri Aug 11, 2023 3:14 am

It will be defaulted to WPA2 and the device won’t connect to deprecated WEP/WPA networks. You can also set it to WIFI_AUTH_WPA2_PSK, which will function the same way.

Who is online

Users browsing this forum: Chand Bhadaniya and 113 guests