Wi-Fi station mode: Setting BSSID and/or channel does not accelerate connection

bfriedkin
Posts: 5
Joined: Sat Nov 24, 2018 10:21 pm

Wi-Fi station mode: Setting BSSID and/or channel does not accelerate connection

Postby bfriedkin » Sat Nov 24, 2018 10:36 pm

Hello -

On the ESP8266, we have found that specifying the access point BSSID in the station_config before calling wifi_station_set_config_current() accelerates the connection by about 50%. Further, if we additionally set the channel via wifi_set_channel() after calling wifi_station_set_config_current(), the connection speed is further reduced. We have tested this against multiple access points where we know the BSSID and channel.

When we try the same on ESP32, we don't experience any reduction in connection speed when setting the BSSID and/or channel. And if we set the channel in the wifi_config_t structure, we are unable to connect at all. The Wi-Fi setup and connection code we use on ESP32 is roughly as follows:
  1. memcpy(config.sta.bssid, bssid, sizeof(config.sta.bssid));
  2. config.sta.bssid_set = 1;
  3. memcpy(config.sta.ssid, ssid, strlen(ssid));
  4. memcpy(config.sta.password, password, strlen(password));
  5.  
  6. esp_wifi_set_mode(WIFI_MODE_STA);
  7.  
  8. esp_wifi_set_config(WIFI_IF_STA, &config);
  9. esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);
  10. esp_wifi_connect();
None of the esp_wifi_* calls return an error. How can we accelerate connections to Wi-Fi access points on ESP32 when we know the access point BSSID and/or channel?

Regards,
Brian

User avatar
brp80000
Posts: 138
Joined: Thu Oct 04, 2018 7:13 pm

Re: Wi-Fi station mode: Setting BSSID and/or channel does not accelerate connection

Postby brp80000 » Sun Nov 25, 2018 5:54 am

After updating IDF to 3-1-1 I have problems connecting WIFI devices with Android 6.0.1 when specified
wifi_config_t wifi_config.ap.authmode = WIFI_AUTH_WPA_WPA2_PSK (also set the SSID and PASS)
At the same time devices with Android 4.0 and IOS connect without problems. if I use WIFI_AUTH_WEP or WIFI_AUTH_OPEN then all devices connect successfully. Before the update WIFI_AUTH_WPA_WPA2_PSK worked

liuzhifu
Posts: 39
Joined: Tue Dec 13, 2016 2:18 am

Re: Wi-Fi station mode: Setting BSSID and/or channel does not accelerate connection

Postby liuzhifu » Tue Nov 27, 2018 4:26 pm

HI bfriedkin, do you configure scan_method in wifi_sta_config_t to WIFI_FAST_SCAN? The default scan is WIFI_ALL_CHANNEL_SCAN.

liuzhifu
Posts: 39
Joined: Tue Dec 13, 2016 2:18 am

Re: Wi-Fi station mode: Setting BSSID and/or channel does not accelerate connection

Postby liuzhifu » Tue Nov 27, 2018 4:30 pm

Hi brp80000, for your question, we will try to reproduce and debug it.

bfriedkin
Posts: 5
Joined: Sat Nov 24, 2018 10:21 pm

Re: Wi-Fi station mode: Setting BSSID and/or channel does not accelerate connection

Postby bfriedkin » Tue Nov 27, 2018 5:54 pm

Hello liuzhifu -

Thank you for the follow-up. We do effectively set WIFI_FAST_SCAN mode, because we first initialize the wifi_config_t to all zeros:

  1. wifi_config_t config;
  2. memset(&config, 0, sizeof(config));
  3. ...
  4.  
  5. In esp_wifi_types:
  6.  
  7. typedef enum {
  8.     WIFI_FAST_SCAN = 0,                   /**< Do fast scan, scan will end after find SSID match AP */
  9.     WIFI_ALL_CHANNEL_SCAN,                /**< All channel scan, scan will end after scan all the channel */
  10. }wifi_scan_method_t;
Regards,
Brian

liuzhifu
Posts: 39
Joined: Tue Dec 13, 2016 2:18 am

Re: Wi-Fi station mode: Setting BSSID and/or channel does not accelerate connection

Postby liuzhifu » Wed Nov 28, 2018 1:56 am

OK, we will investigate this issue in recent some days.

littlesky
Posts: 51
Joined: Fri Jun 09, 2017 7:49 am

Re: Wi-Fi station mode: Setting BSSID and/or channel does not accelerate connection

Postby littlesky » Wed Nov 28, 2018 2:10 am

`esp_wifi_set_channel()` does not work for fast connection. To accelerate connection, you should specify `channel` field of `wifi_sta_config_t` to that of AP instead.
ESP32 is different with ESP8266, it can not accelerate connection with BSSID and WIFI_FAST_SCAN specified.
Last edited by littlesky on Wed Nov 28, 2018 6:22 am, edited 1 time in total.

bfriedkin
Posts: 5
Joined: Sat Nov 24, 2018 10:21 pm

Re: Wi-Fi station mode: Setting BSSID and/or channel does not accelerate connection

Postby bfriedkin » Wed Nov 28, 2018 2:18 am

Hello littlesky -

Thank you for your reply.

We do specify both the channel and BSSID when connecting to the access point on ESP32. Please refer to my original post.

Are there any other configuration options that I missed?

- Brian

littlesky
Posts: 51
Joined: Fri Jun 09, 2017 7:49 am

Re: Wi-Fi station mode: Setting BSSID and/or channel does not accelerate connection

Postby littlesky » Wed Nov 28, 2018 6:21 am

I don't think you have set channel in the right way. You should set it like this,

Code: Select all

    
    memcpy(config.sta.bssid, bssid, sizeof(config.sta.bssid));
    config.sta.bssid_set = 1;
    memcpy(config.sta.ssid, ssid, strlen(ssid));
    memcpy(config.sta.password, password, strlen(password));
    config.sta.channel = channel;
     
    esp_wifi_set_mode(WIFI_MODE_STA);
     
    esp_wifi_set_config(WIFI_IF_STA, &config);
    //esp_wifi_set_channel(channel, WIFI_SECOND_CHAN_NONE);//Should not call this API !!!
    esp_wifi_connect();
For BSSID, it will not accelerate connection in ESP32.

liuzhifu
Posts: 39
Joined: Tue Dec 13, 2016 2:18 am

Re: Wi-Fi station mode: Setting BSSID and/or channel does not accelerate connection

Postby liuzhifu » Wed Nov 28, 2018 1:28 pm

Little sky give the right answer.

Who is online

Users browsing this forum: Bing [Bot], hape65 and 115 guests