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 doesn't switch to the strongest Access Point as you move around #54

Open
ba58smith opened this issue May 3, 2021 · 5 comments
Open
Labels
enhancement New feature or request

Comments

@ba58smith
Copy link
Collaborator

ba58smith commented May 3, 2021

I have three wifi Access Points on my boat - engine room, salon, flybridge. The Watch connects to one of them, and then doesn't switch to the strongest one as I move around the boat. So if I start the Watch on the flybridge, then go through the salon to the engine room, it stays connected to the flybridge, and will lose wifi if I go into the engine room.

Helpful links:
https://esp32.com/viewtopic.php?t=18979

@JohnySeven JohnySeven added the enhancement New feature or request label May 4, 2021
@JohnySeven
Copy link
Owner

Regarding this, we could setup callback from Wi-Fi driver using this method: https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-reference/network/esp_wifi.html#_CPPv427esp_wifi_set_rssi_threshold7int32_t it will inform us if the RSSI of connected AP is below some threshold, and then we could eventually run active scan (while connected) and check if there are any other APs with same SSID with better signal. Also I would add this as configuration value (on/off) as it will consume more power and in cases where you have only one AP (my case) it won't help :-) This configuration could be set automatically if connecting to Wi-Fi that has multiple SSIDs.

It would be maybe good to have some data from your watch to set the Threshold correctly - something like -80 is expected value.

Thanks!

@ba58smith
Copy link
Collaborator Author

How do you find these things? (Like that method to set the RSSI threshold?) That's WAY better than the other solutions I've found that request the RSSI every few seconds. I'll definitely use that method / callback approach. Thanks!

@JohnySeven
Copy link
Owner

When I was playing with Wifi power saving I was reading those docs and when I was reading your issue for second time it just came to my mind :-)

@ba58smith
Copy link
Collaborator Author

The method referred to above (esp_wifi_set_rssi_threshold) is not available in the version of ESP-IDF that we're currently using. So we either wait until we upgrade to that version, or set up an "every X seconds" check of the strength of the wifi connection, and if it goes below a set level (I suggest -75), then scan for another AP with a better signal.

@ba58smith
Copy link
Collaborator Author

From a conversation with Jan on Slack:

  1. enable this roaming feature if you scan wifi and find multiple SSIDs after user has picked the Wifi name.
  2. if this feature is enabled and Wifi is connected just create new task that will be watching RSSI and this task will be in WifiManager
  3. if RSSI is lower than specific value just run the scan and pick Wifi with same SSID but better signal and then use BSSID to connect to network
    I would image task to be like:
    while(_check_wifi_rssi && connected)
    {
    if(current_rssi < rssi_threshold)
    {
    //run online scan and sort the result by RSSI
    //when done just connect to wifi
    }
    delay(5000);
    }
    it's just and idea before I'm going into bed, the code is just for illustration, will update it tomorrow with something real, the pain will be that scan is async, so you'll have to handle, then it's just simple go through the list of Wifi and find first with the same name and different BSSID than current Wifi, if you find the same BSSID as current AP it means you have the best signal available.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants