fix(wifi): Require RSSI gain before low-RSSI roam

Low-RSSI roaming used determine_best_ap(0), so a 1 dB better AP was
enough and nearby APs could ping-pong. Add ESP_WIFI_ROAMING_LOW_RSSI_ROAM_DIFF
(default 5 dB) as hysteresis for that path.
This commit is contained in:
tarun.kumar
2026-08-12 15:29:10 +05:30
committed by BOT
parent 52ea19338a
commit e0aa51f8bf
4 changed files with 24 additions and 5 deletions

View File

@@ -20,6 +20,7 @@ struct roam_config {
bool low_rssi_roam_trigger;
int8_t low_rssi_threshold;
uint8_t rssi_threshold_reduction_offset;
uint8_t low_rssi_roam_diff;
bool scan_monitor;
#if CONFIG_ESP_WIFI_ROAMING_PERIODIC_SCAN_MONITOR
uint8_t scan_interval;

View File

@@ -29,6 +29,18 @@ menu "Roaming triggers"
Setting 0 here may cause station to be flooded with low rssi events,
therefore that's not recommended to be kept.
config ESP_WIFI_ROAMING_LOW_RSSI_ROAM_DIFF
depends on ESP_WIFI_ROAMING_LOW_RSSI_ROAMING
int "RSSI difference b/w current AP and candidate AP for low RSSI roam"
range 1 99
default 5
help
Minimum RSSI improvement (in dB) required of a candidate AP before roaming
when triggered by the low RSSI event. A value of 1 keeps the previous behavior
(any strictly better AP). Higher values add hysteresis and reduce ping-pong
between nearby APs with similar RSSI. Prefer a small value here (e.g. 3-5);
use ESP_WIFI_ROAMING_SCAN_ROAM_RSSI_DIFF for larger proactive improvements.
config ESP_WIFI_ROAMING_PERIODIC_SCAN_MONITOR
bool "Conduct periodic scans to check if a better AP is available"
default y

View File

@@ -29,6 +29,7 @@ extern "C" {
#if LOW_RSSI_ROAMING_ENABLED
#define ROAMING_LOW_RSSI_THRESHOLD CONFIG_ESP_WIFI_ROAMING_LOW_RSSI_THRESHOLD
#define RSSI_THRESHOLD_REDUCTION_OFFSET CONFIG_ESP_WIFI_ROAMING_LOW_RSSI_OFFSET
#define LOW_RSSI_ROAM_DIFF CONFIG_ESP_WIFI_ROAMING_LOW_RSSI_ROAM_DIFF
#endif /*LOW_RSSI_ROAMING_ENABLED*/
#ifndef CONFIG_ESP_WIFI_ROAMING_PERIODIC_SCAN_MONITOR

View File

@@ -1342,7 +1342,7 @@ static void roaming_app_rssi_low_internal_handler(void *ctx, void *data)
if (!roaming_app_get_ap_info(&g_roaming_app.current_bss.ap)) {
g_roaming_app.current_bss.ap.rssi = event->rssi;
}
determine_best_ap(0);
determine_best_ap(g_roaming_app.config.low_rssi_roam_diff - 1);
int32_t next_threshold = g_roaming_app.current_low_rssi_threshold -
g_roaming_app.config.rssi_threshold_reduction_offset;
next_threshold = roaming_app_clamp_rssi_threshold(next_threshold);
@@ -2097,8 +2097,11 @@ static esp_err_t init_config_params(void)
g_roaming_app.config.backoff_time = ROAMING_BACKOFF_TIME;
g_roaming_app.config.low_rssi_roam_trigger = LOW_RSSI_ROAMING_ENABLED;
#if LOW_RSSI_ROAMING_ENABLED
g_roaming_app.config.low_rssi_threshold = ROAMING_LOW_RSSI_THRESHOLD;
g_roaming_app.config.rssi_threshold_reduction_offset = RSSI_THRESHOLD_REDUCTION_OFFSET;
g_roaming_app.config.low_rssi_roam_diff = LOW_RSSI_ROAM_DIFF;
#endif /* LOW_RSSI_ROAMING_ENABLED */
g_roaming_app.config.scan_monitor = PERIODIC_SCAN_MONITORING;
#if PERIODIC_SCAN_MONITORING
@@ -2117,9 +2120,10 @@ static esp_err_t init_config_params(void)
ESP_LOGD(ROAMING_TAG, "Roaming app config :");
ESP_LOGD(ROAMING_TAG, "backoff time=%d low_rssi_roam_trigger=%d low_rssi_threshold=%d rssi_threshold_reduction_offset=%d",
ESP_LOGD(ROAMING_TAG, "backoff time=%d low_rssi_roam_trigger=%d low_rssi_threshold=%d rssi_threshold_reduction_offset=%d low_rssi_roam_diff=%d",
g_roaming_app.config.backoff_time, g_roaming_app.config.low_rssi_roam_trigger,
g_roaming_app.config.low_rssi_threshold, g_roaming_app.config.rssi_threshold_reduction_offset);
g_roaming_app.config.low_rssi_threshold, g_roaming_app.config.rssi_threshold_reduction_offset,
g_roaming_app.config.low_rssi_roam_diff);
#if PERIODIC_SCAN_MONITORING
ESP_LOGD(ROAMING_TAG, "scan_monitor=%d scan_interval=%d scan_rssi_threshold=%d scan_rssi_diff=%d",
@@ -2421,9 +2425,10 @@ static int update_config_params(void *data)
ESP_LOGI(ROAMING_TAG, "Updated Roaming app config :");
ESP_LOGI(ROAMING_TAG, "backoff time=%d low_rssi_roam_trigger=%d low_rssi_threshold=%d rssi_threshold_reduction_offset=%d",
ESP_LOGI(ROAMING_TAG, "backoff time=%d low_rssi_roam_trigger=%d low_rssi_threshold=%d rssi_threshold_reduction_offset=%d low_rssi_roam_diff=%d",
g_roaming_app.config.backoff_time, g_roaming_app.config.low_rssi_roam_trigger,
g_roaming_app.config.low_rssi_threshold, g_roaming_app.config.rssi_threshold_reduction_offset);
g_roaming_app.config.low_rssi_threshold, g_roaming_app.config.rssi_threshold_reduction_offset,
g_roaming_app.config.low_rssi_roam_diff);
#if PERIODIC_SCAN_MONITORING
ESP_LOGI(ROAMING_TAG, "scan_monitor=%d scan_interval=%d scan_rssi_threshold=%d scan_rssi_diff=%d",