Unable to Lock ESP32 wifi to specific BSSID

#1
  1. My goal is:

Be able to connect to a specific BSSID when multiple ESSIDs exist with the same name, or at the very least connect to the ESSID with the highest signal

  1. My actions are:

When scanning for WIFI, if I have multiple stations with the same ESSID (like in a mesh network) they will all show up, but there is no way for me to choose the one with the highest signal. It will also not associate with the highest signal AP, and will often associate with a weaker one, producing marginal connectivity (constant bounces in MQTT, for example).

  1. The result I see is:

Mongoose-os connection results are unpredictable in mesh networks, associating with whatever AP beacon it receives first, ignoring stronger signals with the same ESSID.

  1. My expectation & question is:

Either provide a way to connect to APs via the BSSID so I can choose the ESSID with the highest signal, or search through all AP’s with the saved ESSID when connecting to make sure it will connect with the highest signal one, similar to how every other device that uses WIFI does.

#2

@taryngar - does the underlying ESP-IDF SDK provide the requested functionality?

#3

bssid is provided as a member of the wifi_sta_config_t struct, so I would hope so:
https://docs.espressif.com/projects/esp-idf/en/latest/api-reference/network/esp_wifi.html#_CPPv4N17wifi_sta_config_t5bssidE

It also seems to have built-in support for dealing with multiple ESSIDs that have the same name, as evidenced by some bugs that were filed on it near the end of last year that have since produced fixes for problems stemming from it not being handled correctly. See:

I do see that you just recently (11 days ago) added support for enabling full scanning, which is a good step in the right direction (as full scans will store four ESSIDs together and allow sorting by RSSI).

I also see, looking through the mongoose-os wifi lib, that you’re setting the maximum active scan time to 50ms per channel, which seems to be a little quick given that the default beacon rate is defined as 100TU (102.4ms). Even your own AP code sets the beacon rate at 100ms. This could explain why I often have to scan multiple times to get an accurate wifi environment, because it’s missing the beacons by jumping channels too fast. This is less relevant if I can actually lock to a bssid or if the scan runs enough to find the higher RSSI and stick to it instead of the weaker one that it just happened to catch in the fast scan. However, I still think it should be increased to at least 100ms maximum, or also exposed as a configurable variable.

#4

It has been an entire year now and I still don’t see any progress being made to support bssid locking. the ESP IDF supports it by setting bssid_set to 1 and then supplying a bssid. It should be pretty simple to implement it in the wifi driver.

Also, the ESP IDF supports thresholds, which would allow a user to set a minimum RSSI and authentication mode. This would serve to filter out weak APs in a mesh network to connect to the stronger (and likely closer) ones, instead of just connecting to the first one it sees, which could be on the very edge of functional.