Page 1 of 1

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

Posted: Sat Nov 24, 2018 10:36 pm
by bfriedkin
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

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

Posted: Sun Nov 25, 2018 5:54 am
by brp80000
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

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

Posted: Tue Nov 27, 2018 4:26 pm
by liuzhifu
HI bfriedkin, do you configure scan_method in wifi_sta_config_t to WIFI_FAST_SCAN? The default scan is WIFI_ALL_CHANNEL_SCAN.

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

Posted: Tue Nov 27, 2018 4:30 pm
by liuzhifu
Hi brp80000, for your question, we will try to reproduce and debug it.

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

Posted: Tue Nov 27, 2018 5:54 pm
by bfriedkin
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

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

Posted: Wed Nov 28, 2018 1:56 am
by liuzhifu
OK, we will investigate this issue in recent some days.

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

Posted: Wed Nov 28, 2018 2:10 am
by littlesky
`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.

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

Posted: Wed Nov 28, 2018 2:18 am
by bfriedkin
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

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

Posted: Wed Nov 28, 2018 6:21 am
by littlesky
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.

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

Posted: Wed Nov 28, 2018 1:28 pm
by liuzhifu
Little sky give the right answer.