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

WIFI_ALL_CHANNEL_SCAN, this parameter doesn't seem to work (IDFGH-6630) #8269

Closed
shun-dgut opened this issue Jan 21, 2022 · 91 comments
Closed
Assignees
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally

Comments

@shun-dgut
Copy link

Environment

  • Development Kit: [ESP32-C3-DevKitM-1]
  • IDF version (run git describe --tags to find it):
    v4.3.2-198-gb9a96186fd
  • Build System: [idf.py]
  • Compiler version
    riscv32-esp-elf-gcc (crosstool-NG esp-2021r2) 8.4.0
  • Operating System: [Windows]
  • (Windows only) environment type: [ESP Command Prompt].
  • Power Supply: [USB]

Problem Description

Using full channel scanning doesn't work, I built two wifi with the same SSID and password, but ESP32C3 doesn't always choose the connection with the best signal.

Code to reproduce this issue

wifi_config_t wifi_config = {
    .sta = {
        .ssid = DEFAULT_SSID,
        .password = DEFAULT_PWD,
        .scan_method = WIFI_ALL_CHANNEL_SCAN, // WIFI_FAST_SCAN, // 
        .sort_method = WIFI_CONNECT_AP_BY_SIGNAL,
        .threshold.rssi = DEFAULT_RSSI,
        .threshold.authmode = DEFAULT_AUTHMODE,
    },
 };
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifi_config));
@Alvin1Zhang
Copy link
Collaborator

Thanks for reporting.

@espressif-bot espressif-bot added the Status: Opened Issue is new label Jan 21, 2022
@github-actions github-actions bot changed the title WIFI_ALL_CHANNEL_SCAN, this parameter doesn't seem to work WIFI_ALL_CHANNEL_SCAN, this parameter doesn't seem to work (IDFGH-6630) Jan 21, 2022
@nishanth-radja
Copy link
Collaborator

@shun-dgut can we have the console logs of the DUT when it connects to both the AP's, We will be able to see the RSSI when it connects to the AP and compare the RSSI difference it sees between the AP's.

@shun-dgut
Copy link
Author

Thank you for your reply. Here is the log, rebooting the board via the rst pin appears to be random every time the bssid it connects to.
测试ssid.log

@nishanth-radja
Copy link
Collaborator

@shun-dgut Thanks for the logs.From the logs,we see that there is a 20db difference between the RSSI of the AP's.Still the Client connects randomly.On further analysis, It is seen that the AP1 with lower RSSI is at channel 1 and AP2 with higher RSSI is at channel 7.
This issue is seen as the AP's are on different channels and we are also observing the same behavior in lab.we will get back to you on this issue.
Meanwhile can you check if this issue is seen when both the AP's are on same channel?

@xueyunfei998
Copy link

hi @shun-dgut

[2022-01-25 19:05:48.138]# RECV ASCII>
I (2550) wifi:new:<7,0>, old:<1,0>, ap:<255,255>, sta:<7,0>, prof:1
I (2550) wifi:state: init -> auth (b0)
I (2550) wifi:state: auth -> assoc (0)
I (2560) wifi:state: assoc -> init (2c0)
I (2560) wifi:new:<7,0>, old:<7,0>, ap:<255,255>, sta:<7,0>, prof:1
I (2560) wifi:new:<1,0>, old:<7,0>, ap:<255,255>, sta:<1,0>, prof:1
I (2570) wifi:state: init -> auth (b0)
I (2580) wifi:state: auth -> assoc (0)
I (2580) wifi:state: assoc -> run (10)
I (2610) wifi:connected with tototo2.4g, aid = 1, channel 1, BW

hi @shun-dgut

In the log you provided, channel 7, the ap with the best rssi, will be scanned every time

I (2560) wifi:new:<7,0>, old:<7,0>, ap:<255,255>, sta:<7,0>, prof:1

However, during the connection process, there was a connection error in channel 7, and then channel 1 was rescanned to connect to the ap of channel 1.

I (2560) wifi:state: assoc -> init (2c0)
I (2560) wifi:new:<1,0>, old:<7,0>, ap:<255,255>, sta:<1,0>, prof:1

The reason may be that when connecting to channel 7, the router kicked out the sta and failed to connect successfully.

@AxelLin
Copy link
Contributor

AxelLin commented Feb 8, 2022

However, during the connection process, there was a connection error in channel 7, and then channel 1 was rescanned to connect to the ap of channel 1.

I (2560) wifi:state: assoc -> init (2c0) I (2560) wifinew<1,0>, old:<7,0>, ap:<255,255>, sta:<1,0>, prof:1

The reason may be that when connecting to channel 7, the router kicked out the sta and failed to connect successfully.

But this connect error should not happen.
The log shows it sometimes can join channel 7.
So how to confirm if this connect error is esp32's issue or router's issue?
Does verbose build help to clarify the issue?

@xueyunfei998
Copy link

hi @shun-dgut

Please provide the model of the router, and I will try to reproduce this problem locally.

@shun-dgut
Copy link
Author

shun-dgut commented Feb 8, 2022

one is RT-AX56U and other one is OpenWrt 19.07.4 r11208-ce6496d796

hi @shun-dgut

Please provide the model of the router, and I will try to reproduce this problem locally.

@AxelLin
Copy link
Contributor

AxelLin commented Feb 8, 2022

one is RT-AX56U and other one is OpenWrt 19.07.4 r11208-ce6496d796

@shun-dgut Which one is the channel 7 AP?

@AxelLin
Copy link
Contributor

AxelLin commented Feb 8, 2022

@shun-dgut

BTW, just for comparison.
If you move esp32 close to the channel 1 AP, will it hit connect error with channel 1 AP?
i.e. will it connect to channel 7 AP sometimes?

@shun-dgut
Copy link
Author

channel 7 AP is RT-AX56U

@shun-dgut
Copy link
Author

I use esp32c3, I also experimented on 8266 and found that 8266 basically chooses a router with a stronger signal value.

@nishanth-radja
Copy link
Collaborator

@shun-dgut can we get the sniffer capture on channel 7 and also can you enable the wpa_supplicant logs on DUT.

@shun-dgut
Copy link
Author

@shun-dgut can we get the sniffer capture on channel 7 and also can you enable the wpa_supplicant logs on DUT.

Can you tell me how to set it in the firmware?

@nishanth-radja
Copy link
Collaborator

@shun-dgut To enable the logs, go to idf.py menuconfig->component config->supplicant->print debug message from wpa_supplicant.
once the log is enabled in the SDK config you will see that "CONFIG_WPA_DEBUG_PRINT=y" is present.

@shun-dgut
Copy link
Author

wpa_supplicant.log

@shun-dgut To enable the logs, go to idf.py menuconfig->component config->supplicant->print debug message from wpa_supplicant. once the log is enabled in the SDK config you will see that "CONFIG_WPA_DEBUG_PRINT=y" is present.

@nishanth-radja
Copy link
Collaborator

@shun-dgut Thank you,Can we have the corresponding sniffer log on channel 7.To know the reason why the AP is rejecting the STA assoc every alternate attempt.

@shun-dgut
Copy link
Author

@shun-dgut Thank you,Can we have the corresponding sniffer log on channel 7.To know the reason why the AP is rejecting the STA assoc every alternate attempt.

Do I need to use the packet capture card to capture network packets?

@nishanth-radja
Copy link
Collaborator

@shun-dgut if you have a linux laptop,You can use it to sniff the channel.

ifconfig down
iwconfig mode monitor
ifconfig up
iwconfig channel 7
wireshark

@shun-dgut
Copy link
Author

shun-dgut commented Feb 10, 2022

image
image
ssid.zip

ssid log.txt

This is the log and data packets in the two processes. The first time it was successfully connected to the router with strong signal, the second time it was not.

@shun-dgut if you have a linux laptop,You can use it to sniff the channel.

ifconfig down iwconfig mode monitor ifconfig up iwconfig channel 7 wireshark

@nishanth-radja
Copy link
Collaborator

nishanth-radja commented Feb 10, 2022

@shun-dgut Looks like this issue is similar to the existing issue 8192
DUT initially sends the Deauth to the AP before association.This is done to clear the station entry in the assoc table of the AP.
But few AP's process this Deauth late,They send the auth response and then send a deauth again as a confirmation.
image

Since you are working c3, I will get back to you with a patch for the same.

@shun-dgut
Copy link
Author

@shun-dgut Looks like this issue is similar to the existing issue 8192 DUT initially sends the Deauth to the AP before association.This is done to clear the station entry in the assoc table of the AP. But few AP's process this Deauth late,They send the auth response and then send a deauth again as a confirmation. image

Since you are working c3, I will get back to you with a patch for the same.

Thanks . When can you give me these patch tests

@GarMingLi
Copy link

GarMingLi commented Feb 11, 2022 via email

@nishanth-radja
Copy link
Collaborator

Hi @shun-dgut on the idf 4.3, pls use the following patch
patch_for_reconnect_issue_4.3.zip
replace the files in the location "esp-idf/components/esp_wifi/lib/esp32c3" with the attached files .

clean the already existing build and rebuild again.
idf.py fullclean
idf.py build

@AxelLin
Copy link
Contributor

AxelLin commented Feb 13, 2022

But few AP's process this Deauth late,They send the auth response and then send a deauth again as a confirmation.

Then how do you address this issue in your patch?

@shun-dgut
Copy link
Author

Hi @shun-dgut on the idf 4.3, pls use the following patch patch_for_reconnect_issue_4.3.zip replace the files in the location "esp-idf/components/esp_wifi/lib/esp32c3" with the attached files .

clean the already existing build and rebuild again. idf.py fullclean idf.py build

Tried it and it doesn't seem to work

log

I (2604) wifi:connected with tototo2.4g, aid = 1, channel 6, BW
[2022-02-14 11:06:06.097]# RECV ASCII>
20, bssid = 74:44:01:02:a3:e7
I (2604) wifi:security: WPA2-PSK, phy: bgn, rssi: -64
I (2614) wifi:pm start, type: 1
I (2614) wifi:set rx beacon pti, rx_bcn_pti: 0, bcn_timeout: 0, mt_pti: 25000, mt_time: 10000
I (2644) wifi:BcnInt:102400, DTIM:2
[2022-02-14 11:06:06.809]# RECV ASCII>
�[0;32mI (3344) scan: got ip:192.168.100.243�[0m
�[0;32mI (3344) esp_netif_handlers: sta ip: 192.168.100.243, mask: 255.255.255.0, gw: 192.168.100.1�[0m
[2022-02-14 11:06:11.529]# RECV ASCII>
W (8074) wifi:<ba-add>idx:0 (ifx:0, 74:44:01:02:a3:e7), tid:0, ssn:1, winSize:64

@nishanth-radja
Copy link
Collaborator

Hi @shun-dgut , can we have the capture on channel 7 with this patch?

@nishanth-radja
Copy link
Collaborator

But few AP's process this Deauth late,They send the auth response and then send a deauth again as a confirmation.

Then how do you address this issue in your patch?

There is a delay between the deauth and Auth so that the deauth of the AP is processed before sending the Auth.

@AxelLin
Copy link
Contributor

AxelLin commented Oct 25, 2022

We would soon have this on the main branches.
One of us would keep you posted on the update.

@vik-gokhale Any update for the fix?

@Irfan93
Copy link

Irfan93 commented Oct 31, 2022

Hi @AxelLin, we are able to see the issue in lab.Dev team is working on the same for a stable fix.

Could you confirm only esp32c3 has this issue or all esp32 chips have the same issue?

Could someone verify similar problem exist on the esp32 or if this is only for esp32c3? Also if this AP specific, do we have list of these APs?

@vik-gokhale
Copy link
Collaborator

vik-gokhale commented Oct 31, 2022

@AxelLin @Irfan93
So, we made a change to solve this problem and it did help solve the same.
However, it is causing problems on the Mesh feature and that is being solved now. Hence the delay.
We expect this to be solved in a few weeks now.

As soon as the fix is merged and released, one of us would update the thread.

Regards,
Vikram

@barbestack
Copy link

We're seeing this problem in an Orbi Wifi mesh network environment, with multiple APs in the household. Our gateway running ESP-IDF 4.3.2 frequently selects the AP on the other side of the home with the worst RSSI even though it's literally sitting next to an AP. This greatly impacts connectivity.

Module: ESP32-WROMM-32D
ESP-IDF: 4.3.2

2022-11-27T23:56:20.796 - I (14029) wifi:security: WPA2-PSK, phy: bgn, rssi: -31
2022-11-28T09:23:04.069 - I (14659) wifi:connected with ORBI51, aid = 4, channel 4, BW20, bssid = b6:39:56:7f:50:3e
2022-11-28T09:23:04.089 - I (14659) wifi:security: WPA2-PSK, phy: bgn, rssi: -28
2022-11-28T09:35:12.959 - I (14189) wifi:connected with ORBI51, aid = 4, channel 4, BW20, bssid = 92:3b:ad:16:bb:1d
2022-11-28T09:35:12.973 - I (14189) wifi:security: WPA2-PSK, phy: bgn, rssi: -50
2022-11-28T18:06:11.009 - I (14009) wifi:connected with ORBI51, aid = 2, channel 4, 40U, bssid = 92:3b:ad:16:bb:1d
2022-11-28T18:06:11.024 - I (14009) wifi:security: WPA2-PSK, phy: bgn, rssi: -44
2022-11-28T20:39:38.555 - I (14259) wifi:connected with ORBI51, aid = 4, channel 4, BW20, bssid = b6:39:56:7f:50:3e
2022-11-28T20:39:38.572 - I (14259) wifi:security: WPA2-PSK, phy: bgn, rssi: -29
2022-11-28T20:39:53.507 - I (29199) wifi:connected with ORBI51, aid = 2, channel 4, 40U, bssid = 92:3b:ad:16:aa:51
2022-11-28T20:39:53.528 - I (29199) wifi:security: WPA2-PSK, phy: bgn, rssi: -73
2022-11-28T20:47:59.859 - I (14059) wifi:connected with ORBI51, aid = 4, channel 4, BW20, bssid = b6:39:56:7f:50:3e
2022-11-28T20:47:59.879 - I (14059) wifi:security: WPA2-PSK, phy: bgn, rssi: -30

b6:39:56:7f:50:3e = next to gateway
92:3b:ad:16:aa:51 = downstairs and on other side of home

Unfortunately, Wireshark data is hard to come by. But if needed to progress this issue we can work with the end-user to obtain it.

@vik-gokhale
Copy link
Collaborator

vik-gokhale commented Nov 29, 2022

hi!
An update - Fix for this is merged on the master branch.
Backporting is in progress for v4.x and v5.0 release branches.
One of us would post an update once this is available on all branches.

Regards,
Vikram

@AxelLin
Copy link
Contributor

AxelLin commented Nov 30, 2022

hi! An update - Fix for this is merged on the master branch.

52b2491

@Irfan93
Copy link

Irfan93 commented Dec 2, 2022

hi! An update - Fix for this is merged on the master branch. Backporting is in progress for v4.x and v5.0 release branches. One of us would post an update once this is available on all branches.

Regards, Vikram

Thank you sir. Please do mention the commit for each release branches when the time comes as it will be helpful.

@AxelLin
Copy link
Contributor

AxelLin commented Dec 17, 2022

hi! An update - Fix for this is merged on the master branch.

52b2491

@vik-gokhale

How to use this fix?
Just set failure_retry_cnt? Any other change is required from application side?
The application won't know the connect failure if the retry count is less than failure_retry_cnt?
Can the application know if retry failure count reaches failure_retry_cnt ?

@vik-gokhale
Copy link
Collaborator

Hi!
This feature is now available on v4.4 and v4.3 in addition to v5.0 versions of the release.

Usage

wifi_config_t wifi_config = {
    .sta = {
        .ssid = <intended SSID>
        .password = <corresponding Password>
        .failure_retry_cnt = 3,
        .scan_method = WIFI_ALL_CHANNEL_SCAN,
    },
};

Please let us know in case of any more problems.

Thanks,
Vikram.

@AxelLin
Copy link
Contributor

AxelLin commented Jan 13, 2023

Hi! This feature is now available on v4.4 and v4.3 in addition to v5.0 versions of the release.

Usage

wifi_config_t wifi_config = {
    .sta = {
        .ssid = <intended SSID>
        .password = <corresponding Password>
        .failure_retry_cnt = 3,
        .scan_method = WIFI_ALL_CHANNEL_SCAN,
    },
};

Please let us know in case of any more problems.

Thanks, Vikram.

@vik-gokhale
So how do you decide 3 is the good setting for failure_retry_cnt?

@vik-gokhale
Copy link
Collaborator

@AxelLin
User is free to set whatever attempts suit.
Based on our experience we concluded and we suggest to keep this below 5.

@AxelLin
Copy link
Contributor

AxelLin commented Jan 13, 2023

@AxelLin User is free to set whatever attempts suit.

But it's not easy to verify the appropriate setting.
What is the bad side-effect of increasing this setting? Will it cause longer time to join AP?

@marko-savic
Copy link

Hi! This feature is now available on v4.4 and v4.3 in addition to v5.0 versions of the release.

Usage

wifi_config_t wifi_config = {
    .sta = {
        .ssid = <intended SSID>
        .password = <corresponding Password>
        .failure_retry_cnt = 3,
        .scan_method = WIFI_ALL_CHANNEL_SCAN,
    },
};

Please let us know in case of any more problems.

Thanks, Vikram.

Hi,
I have v4.4.3 (https://github.com/espressif/esp-idf/releases/tag/v4.4.3) can't see that option.
Will be a new release or I am missing something?

@AxelLin
Copy link
Contributor

AxelLin commented Jan 15, 2023

Hi, I have v4.4.3 (https://github.com/espressif/esp-idf/releases/tag/v4.4.3) can't see that option. Will be a new release or I am missing something?

The fix (d688fc3) is committed after v4.4.3 release, so you have to either update v4.4 branch or wait until next release.

@vik-gokhale
Copy link
Collaborator

Hi @marko-savic,
The commit tag that you're working on (6407ecb), is older by almost two months.
So, Yes. The fix would be available when the next tag on v4.4 branch gets generated.

@marko-savic
Copy link

Cristal clear and logical, thank you.

@Irfan93
Copy link

Irfan93 commented Jan 20, 2023

Hi! This feature is now available on v4.4 and v4.3 in addition to v5.0 versions of the release.

Usage

wifi_config_t wifi_config = {
    .sta = {
        .ssid = <intended SSID>
        .password = <corresponding Password>
        .failure_retry_cnt = 3,
        .scan_method = WIFI_ALL_CHANNEL_SCAN,
    },
};

Please let us know in case of any more problems.

Thanks, Vikram.

Hello @vik-gokhale ,
Can you specify the commit for this fix meant for version 4.3? Unfortunately we have some custom stuff in our esp-idf and would like to maintain that while just pulling this commit changes.

@Irfan93
Copy link

Irfan93 commented Feb 6, 2023

Hoping that this question is relevant here, please explain to correctly use the WIFI ALL CHANNEL SCAN for ESP4.3. I am a newbie to the use of this config for it to work correctly in a mesh network but it also needs to work correctly in a single AP environment? Any links and examples will be greatly appreciated.

@gstrakabsci
Copy link

gstrakabsci commented May 18, 2023

hi! An update - Fix for this is merged on the master branch. Backporting is in progress for v4.x and v5.0 release branches. One of us would post an update once this is available on all branches.

Regards, Vikram

Hi @vik-gokhale ,
Any idea on when this change will be backported to release v5.0.x branch? Or will it only be in v5.1+ branches?
Thanks

Edit: my mistake, the change is already in v5.0.1. Thank you.

@kapilkedawat
Copy link
Collaborator

@gstrakabsci Its already available on v5.0(f8e2c30).

@Irfan93 Please see the comment https://github.com/espressif/esp-idf/blob/release/v5.0/components/esp_wifi/include/esp_wifi_types.h#L212

@espressif-bot espressif-bot added Status: Done Issue is done internally Resolution: Done Issue is done internally and removed Status: Opened Issue is new labels Feb 27, 2024
@Alvin1Zhang
Copy link
Collaborator

Thanks for reporting, feel free to reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Resolution: Done Issue is done internally Status: Done Issue is done internally
Projects
None yet
Development

No branches or pull requests