mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-29 18:27:20 +02:00
fix(esp_wifi): moving around roaming app code a bit
This commit is contained in:
@ -16,87 +16,6 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SUPPLICANT_CANDIDATE_LIST_EXPIRY 10
|
||||
|
||||
/* Global Roaming Configuration */
|
||||
#define ROAMING_BACKOFF_TIME CONFIG_ESP_WIFI_ROAMING_BACKOFF_TIME
|
||||
|
||||
/* Low RSSI based roaming configuration */
|
||||
#define LOW_RSSI_ROAMING_ENABLED CONFIG_ESP_WIFI_ROAMING_LOW_RSSI_ROAMING
|
||||
#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
|
||||
#endif /*LOW_RSSI_ROAMING_ENABLED*/
|
||||
|
||||
/* Periodic Scan based Roaming configuration */
|
||||
#define PERIODIC_SCAN_MONITORING CONFIG_ESP_WIFI_ROAMING_PERIODIC_SCAN_MONITOR
|
||||
#if PERIODIC_SCAN_MONITORING
|
||||
#define SCAN_MONITOR_INTERVAL CONFIG_ESP_WIFI_ROAMING_SCAN_MONITOR_INTERVAL
|
||||
#define SCAN_MONITOR_RSSI_THRESHOLD CONFIG_ESP_WIFI_ROAMING_PERIODIC_SCAN_THRESHOLD
|
||||
#define SCAN_ROAM_RSSI_DIFF CONFIG_ESP_WIFI_ROAMING_SCAN_ROAM_RSSI_DIFF
|
||||
#endif /* PERIODIC_SCAN_MONITORING */
|
||||
|
||||
/* Scan configuration */
|
||||
#define SCAN_TIME_MIN_DURATION CONFIG_ESP_WIFI_ROAMING_SCAN_MIN_SCAN_TIME
|
||||
#define SCAN_TIME_MAX_DURATION CONFIG_ESP_WIFI_ROAMING_SCAN_MAX_SCAN_TIME
|
||||
#define HOME_CHANNEL_DWELL_TIME CONFIG_ESP_WIFI_ROAMING_HOME_CHANNEL_DWELL_TIME
|
||||
#define SCAN_PREFERRED_CHAN_LIST CONFIG_ESP_WIFI_ROAMING_SCAN_CHAN_LIST
|
||||
#define DEFAULT_PREFERRED_SCAN_CHAN_LIST "None"
|
||||
#define SCAN_RESULTS_USABILITY_WINDOW CONFIG_ESP_WIFI_ROAMING_SCAN_EXPIRY_WINDOW
|
||||
#define MAX_CANDIDATE_COUNT CONFIG_ESP_WIFI_ROAMING_MAX_CANDIDATES
|
||||
|
||||
/* Legacy roaming configuration */
|
||||
#ifdef CONFIG_ESP_WIFI_ROAMING_LEGACY_ROAMING
|
||||
#define LEGACY_ROAM_ENABLED CONFIG_ESP_WIFI_ROAMING_LEGACY_ROAMING
|
||||
#else
|
||||
#define LEGACY_ROAM_ENABLED 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_WIFI_NETWORK_ASSISTED_ROAMING_RETRY_COUNT
|
||||
#define BSS_TM_RETRY_COUNT CONFIG_ESP_WIFI_NETWORK_ASSISTED_ROAMING_RETRY_COUNT
|
||||
#else
|
||||
#define BSS_TM_RETRY_COUNT 0
|
||||
#endif
|
||||
|
||||
/* Network Assisted Roaming */
|
||||
#ifdef CONFIG_ESP_WIFI_ROAMING_NETWORK_ASSISTED_ROAM
|
||||
#define NETWORK_ASSISTED_ROAMING_ENABLED CONFIG_ESP_WIFI_ROAMING_NETWORK_ASSISTED_ROAM
|
||||
#else
|
||||
#define NETWORK_ASSISTED_ROAMING_ENABLED 0
|
||||
#endif
|
||||
|
||||
/* Periodic RRM configuration */
|
||||
#define PERIODIC_RRM_MONITORING CONFIG_ESP_WIFI_ROAMING_PERIODIC_RRM_MONITORING
|
||||
#if PERIODIC_RRM_MONITORING
|
||||
#define RRM_MONITOR_TIME CONFIG_ESP_WIFI_ROAMING_RRM_MONITOR_TIME
|
||||
#define RRM_MONITOR_RSSI_THRESHOLD CONFIG_ESP_WIFI_ROAMING_RRM_MONITOR_THRESHOLD
|
||||
#endif /*PERIODIC_RRM_MONITORING*/
|
||||
|
||||
#define MAX_SCAN_CHAN_LIST_COUNT 14
|
||||
|
||||
#define MAX_NEIGHBOR_LEN 512
|
||||
|
||||
#define IS_PSK(authmode) \
|
||||
(((authmode == WIFI_AUTH_WPA_PSK) || (authmode == WIFI_AUTH_WPA2_PSK) || \
|
||||
(authmode == WIFI_AUTH_WPA_WPA2_PSK) || (authmode == WIFI_AUTH_WPA3_PSK) || \
|
||||
(authmode == WIFI_AUTH_WPA2_WPA3_PSK) || (authmode == WIFI_AUTH_WAPI_PSK) ? 1 : 0))
|
||||
|
||||
#define OWE_COMPATIBLE(curr_auth, cand_auth) \
|
||||
((((curr_auth == WIFI_AUTH_OPEN) || (curr_auth == WIFI_AUTH_OWE)) && ((cand_auth == WIFI_AUTH_OPEN) || (cand_auth == WIFI_AUTH_OWE)))? 1 : 0)
|
||||
|
||||
#define PSK_COMPATIBLE(curr_auth, cand_auth) \
|
||||
((IS_PSK(curr_auth) && IS_PSK(cand_auth)) ? 1 : 0)
|
||||
|
||||
struct scanned_ap_info {
|
||||
uint16_t current_count;
|
||||
struct timeval time;
|
||||
wifi_ap_record_t ap_records[MAX_CANDIDATE_COUNT];
|
||||
};
|
||||
struct cand_bss {
|
||||
uint8_t channel;
|
||||
uint8_t bssid[ETH_ALEN];
|
||||
};
|
||||
|
||||
struct roam_config {
|
||||
uint8_t backoff_time;
|
||||
bool low_rssi_roam_trigger;
|
||||
@ -112,54 +31,14 @@ struct roam_config {
|
||||
bool rrm_monitor;
|
||||
uint8_t rrm_monitor_time;
|
||||
uint8_t rrm_monitor_rssi_threshold;
|
||||
};
|
||||
|
||||
struct roaming_app {
|
||||
wifi_scan_config_t scan_params;
|
||||
struct roam_config config;
|
||||
bool scan_ongoing;
|
||||
int8_t current_rssi_threshold;
|
||||
char *btm_neighbor_list;
|
||||
struct timeval last_roamed_time;
|
||||
wifi_ap_record_t ap_info;
|
||||
struct scanned_ap_info scanned_aps;
|
||||
bool btm_support;
|
||||
bool rrm_support;
|
||||
|
||||
#if LOW_RSSI_ROAMING_ENABLED
|
||||
int8_t current_low_rssi_threshold;
|
||||
#endif
|
||||
#if LEGACY_ROAM_ENABLED && NETWORK_ASSISTED_ROAMING_ENABLED
|
||||
uint8_t btm_attempt;
|
||||
#endif
|
||||
#if LEGACY_ROAM_ENABLED
|
||||
bool force_roam_ongoing;
|
||||
#endif
|
||||
#if PERIODIC_RRM_MONITORING
|
||||
bool periodic_rrm_active;
|
||||
bool rrm_request_active;
|
||||
#endif
|
||||
#if PERIODIC_SCAN_MONITORING
|
||||
bool periodic_scan_active;
|
||||
#endif
|
||||
bool allow_reconnect;
|
||||
wifi_scan_config_t scan_config;
|
||||
};
|
||||
|
||||
void init_roaming_app(void);
|
||||
void deinit_roaming_app(void);
|
||||
|
||||
#if PERIODIC_RRM_MONITORING
|
||||
void roaming_app_periodic_rrm_internal_handler(void *data, void *ctx);
|
||||
#endif /*PERIODIC_RRM_MONITORING*/
|
||||
|
||||
#if PERIODIC_SCAN_MONITORING
|
||||
void roaming_app_periodic_scan_internal_handler(void *data, void *ctx);
|
||||
#endif /*PERIODIC_SCAN_ROAM_MONITORING*/
|
||||
|
||||
void roaming_app_trigger_roam_internal_handler(void *data, void *ctx);
|
||||
|
||||
void roaming_app_disable_reconnect(void);
|
||||
void roaming_app_enable_reconnect(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
136
components/esp_wifi/wifi_apps/roaming_app/src/esp_roaming_i.h
Normal file
136
components/esp_wifi/wifi_apps/roaming_app/src/esp_roaming_i.h
Normal file
@ -0,0 +1,136 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_log.h"
|
||||
#include "esp_err.h"
|
||||
#include "esp_wifi_types.h"
|
||||
#include "utils/common.h"
|
||||
#include <sys/time.h>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SUPPLICANT_CANDIDATE_LIST_EXPIRY 10
|
||||
|
||||
/* Global Roaming Configuration */
|
||||
#define ROAMING_BACKOFF_TIME CONFIG_ESP_WIFI_ROAMING_BACKOFF_TIME
|
||||
|
||||
/* Low RSSI based roaming configuration */
|
||||
#define LOW_RSSI_ROAMING_ENABLED CONFIG_ESP_WIFI_ROAMING_LOW_RSSI_ROAMING
|
||||
#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
|
||||
#endif /*LOW_RSSI_ROAMING_ENABLED*/
|
||||
|
||||
/* Periodic Scan based Roaming configuration */
|
||||
#define PERIODIC_SCAN_MONITORING CONFIG_ESP_WIFI_ROAMING_PERIODIC_SCAN_MONITOR
|
||||
#if PERIODIC_SCAN_MONITORING
|
||||
#define SCAN_MONITOR_INTERVAL CONFIG_ESP_WIFI_ROAMING_SCAN_MONITOR_INTERVAL
|
||||
#define SCAN_MONITOR_RSSI_THRESHOLD CONFIG_ESP_WIFI_ROAMING_PERIODIC_SCAN_THRESHOLD
|
||||
#define SCAN_ROAM_RSSI_DIFF CONFIG_ESP_WIFI_ROAMING_SCAN_ROAM_RSSI_DIFF
|
||||
#endif /* PERIODIC_SCAN_MONITORING */
|
||||
|
||||
/* Scan configuration */
|
||||
#define SCAN_TIME_MIN_DURATION CONFIG_ESP_WIFI_ROAMING_SCAN_MIN_SCAN_TIME
|
||||
#define SCAN_TIME_MAX_DURATION CONFIG_ESP_WIFI_ROAMING_SCAN_MAX_SCAN_TIME
|
||||
#define HOME_CHANNEL_DWELL_TIME CONFIG_ESP_WIFI_ROAMING_HOME_CHANNEL_DWELL_TIME
|
||||
#define SCAN_PREFERRED_CHAN_LIST CONFIG_ESP_WIFI_ROAMING_SCAN_CHAN_LIST
|
||||
#define DEFAULT_PREFERRED_SCAN_CHAN_LIST "None"
|
||||
#define SCAN_RESULTS_USABILITY_WINDOW CONFIG_ESP_WIFI_ROAMING_SCAN_EXPIRY_WINDOW
|
||||
#define MAX_CANDIDATE_COUNT CONFIG_ESP_WIFI_ROAMING_MAX_CANDIDATES
|
||||
|
||||
/* Legacy roaming configuration */
|
||||
#ifdef CONFIG_ESP_WIFI_ROAMING_LEGACY_ROAMING
|
||||
#define LEGACY_ROAM_ENABLED CONFIG_ESP_WIFI_ROAMING_LEGACY_ROAMING
|
||||
#else
|
||||
#define LEGACY_ROAM_ENABLED 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_ESP_WIFI_NETWORK_ASSISTED_ROAMING_RETRY_COUNT
|
||||
#define BSS_TM_RETRY_COUNT CONFIG_ESP_WIFI_NETWORK_ASSISTED_ROAMING_RETRY_COUNT
|
||||
#else
|
||||
#define BSS_TM_RETRY_COUNT 0
|
||||
#endif
|
||||
|
||||
/* Network Assisted Roaming */
|
||||
#ifdef CONFIG_ESP_WIFI_ROAMING_NETWORK_ASSISTED_ROAM
|
||||
#define NETWORK_ASSISTED_ROAMING_ENABLED CONFIG_ESP_WIFI_ROAMING_NETWORK_ASSISTED_ROAM
|
||||
#else
|
||||
#define NETWORK_ASSISTED_ROAMING_ENABLED 0
|
||||
#endif
|
||||
|
||||
/* Periodic RRM configuration */
|
||||
#define PERIODIC_RRM_MONITORING CONFIG_ESP_WIFI_ROAMING_PERIODIC_RRM_MONITORING
|
||||
#if PERIODIC_RRM_MONITORING
|
||||
#define RRM_MONITOR_TIME CONFIG_ESP_WIFI_ROAMING_RRM_MONITOR_TIME
|
||||
#define RRM_MONITOR_RSSI_THRESHOLD CONFIG_ESP_WIFI_ROAMING_RRM_MONITOR_THRESHOLD
|
||||
#endif /*PERIODIC_RRM_MONITORING*/
|
||||
|
||||
#define MAX_SCAN_CHAN_LIST_COUNT 14
|
||||
|
||||
#define MAX_NEIGHBOR_LEN 512
|
||||
|
||||
#define IS_PSK(authmode) \
|
||||
(((authmode == WIFI_AUTH_WPA_PSK) || (authmode == WIFI_AUTH_WPA2_PSK) || \
|
||||
(authmode == WIFI_AUTH_WPA_WPA2_PSK) || (authmode == WIFI_AUTH_WPA3_PSK) || \
|
||||
(authmode == WIFI_AUTH_WPA2_WPA3_PSK) || (authmode == WIFI_AUTH_WAPI_PSK) ? 1 : 0))
|
||||
|
||||
#define OWE_COMPATIBLE(curr_auth, cand_auth) \
|
||||
((((curr_auth == WIFI_AUTH_OPEN) || (curr_auth == WIFI_AUTH_OWE)) && ((cand_auth == WIFI_AUTH_OPEN) || (cand_auth == WIFI_AUTH_OWE)))? 1 : 0)
|
||||
|
||||
#define PSK_COMPATIBLE(curr_auth, cand_auth) \
|
||||
((IS_PSK(curr_auth) && IS_PSK(cand_auth)) ? 1 : 0)
|
||||
|
||||
struct scanned_ap_info {
|
||||
uint16_t current_count;
|
||||
struct timeval time;
|
||||
wifi_ap_record_t ap_records[MAX_CANDIDATE_COUNT];
|
||||
};
|
||||
struct cand_bss {
|
||||
uint8_t channel;
|
||||
uint8_t bssid[ETH_ALEN];
|
||||
};
|
||||
|
||||
struct roam_bss_info {
|
||||
wifi_ap_record_t ap;
|
||||
bool btm_support;
|
||||
bool rrm_support;
|
||||
};
|
||||
|
||||
struct roaming_app {
|
||||
struct roam_config config;
|
||||
bool scan_ongoing;
|
||||
int8_t current_rssi_threshold;
|
||||
char *btm_neighbor_list;
|
||||
struct timeval last_roamed_time;
|
||||
struct scanned_ap_info scanned_aps;
|
||||
struct roam_bss_info current_bss;
|
||||
|
||||
#if LOW_RSSI_ROAMING_ENABLED
|
||||
int8_t current_low_rssi_threshold;
|
||||
#endif
|
||||
#if LEGACY_ROAM_ENABLED && NETWORK_ASSISTED_ROAMING_ENABLED
|
||||
uint8_t btm_attempt;
|
||||
#endif
|
||||
#if LEGACY_ROAM_ENABLED
|
||||
bool force_roam_ongoing;
|
||||
#endif
|
||||
#if PERIODIC_RRM_MONITORING
|
||||
bool periodic_rrm_active;
|
||||
bool rrm_request_active;
|
||||
#endif
|
||||
#if PERIODIC_SCAN_MONITORING
|
||||
bool periodic_scan_active;
|
||||
#endif
|
||||
bool allow_reconnect;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
@ -22,6 +22,7 @@
|
||||
#include "regex.h"
|
||||
#include <stdio.h>
|
||||
#include "esp_roaming.h"
|
||||
#include "esp_roaming_i.h"
|
||||
#include "utils/common.h"
|
||||
#include "esp_wifi_driver.h"
|
||||
#include "utils/eloop.h"
|
||||
@ -43,6 +44,8 @@ static void *neighbor_list_lock = NULL;
|
||||
|
||||
static int wifi_post_roam_event(struct cand_bss *bss);
|
||||
static void determine_best_ap(int8_t rssi_threshold);
|
||||
static void roaming_app_periodic_rrm_internal_handler(void *data, void *ctx);
|
||||
static void roaming_app_periodic_scan_internal_handler(void *data, void *ctx);
|
||||
|
||||
static const char *ROAMING_TAG = "ROAM";
|
||||
|
||||
@ -193,28 +196,28 @@ static void roaming_app_sta_stop_event_handler(void* arg, esp_event_base_t event
|
||||
static void roaming_app_connected_event_handler(void* arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void* event_data)
|
||||
{
|
||||
roaming_app_get_ap_info(&g_roaming_app.ap_info);
|
||||
g_roaming_app.scan_params.ssid = g_roaming_app.ap_info.ssid;
|
||||
roaming_app_get_ap_info(&g_roaming_app.current_bss.ap);
|
||||
g_roaming_app.config.scan_config.ssid = g_roaming_app.current_bss.ap.ssid;
|
||||
#if LOW_RSSI_ROAMING_ENABLED
|
||||
if (g_roaming_app.ap_info.rssi < g_roaming_app.config.low_rssi_threshold) {
|
||||
if (g_roaming_app.current_bss.ap.rssi < g_roaming_app.config.low_rssi_threshold) {
|
||||
/* To ensure that the threshold is set to one offset below the current AP RSSI
|
||||
* in case, the AP is already below the RSSI threshold */
|
||||
g_roaming_app.current_low_rssi_threshold = g_roaming_app.ap_info.rssi - g_roaming_app.config.rssi_threshold_reduction_offset;
|
||||
g_roaming_app.current_low_rssi_threshold = g_roaming_app.current_bss.ap.rssi - g_roaming_app.config.rssi_threshold_reduction_offset;
|
||||
} else {
|
||||
g_roaming_app.current_low_rssi_threshold = g_roaming_app.config.low_rssi_threshold;
|
||||
}
|
||||
ESP_LOGD(ROAMING_TAG, "setting rssi threshold as %d", g_roaming_app.current_low_rssi_threshold);
|
||||
esp_wifi_set_rssi_threshold(g_roaming_app.current_low_rssi_threshold);
|
||||
#endif /*LOW_RSSI_ROAMING_ENABLED*/
|
||||
g_roaming_app.rrm_support = esp_rrm_is_rrm_supported_connection();
|
||||
g_roaming_app.btm_support = esp_wnm_is_btm_supported_connection();
|
||||
g_roaming_app.current_bss.rrm_support = esp_rrm_is_rrm_supported_connection();
|
||||
g_roaming_app.current_bss.btm_support = esp_wnm_is_btm_supported_connection();
|
||||
ESP_LOGD(ROAMING_TAG, "Station connected, RRM %ssupported, BTM %ssupported",
|
||||
g_roaming_app.rrm_support ? " " : "not ",
|
||||
g_roaming_app.btm_support ? " " : "not ");
|
||||
g_roaming_app.current_bss.rrm_support ? " " : "not ",
|
||||
g_roaming_app.current_bss.btm_support ? " " : "not ");
|
||||
gettimeofday(&g_roaming_app.last_roamed_time, NULL);
|
||||
if (!initialize_roaming_event()) {
|
||||
#if PERIODIC_RRM_MONITORING
|
||||
if (g_roaming_app.rrm_support) {
|
||||
if (g_roaming_app.current_bss.rrm_support) {
|
||||
init_periodic_rrm_event();
|
||||
}
|
||||
#endif /*PERIODIC_RRM_MONITORING*/
|
||||
@ -374,7 +377,7 @@ static void roaming_app_rssi_low_handler(void* arg, esp_event_base_t event_base,
|
||||
wifi_event_bss_rssi_low_t *event = event_data;
|
||||
ESP_LOGI(ROAMING_TAG, "%s:bss rssi is=%ld", __func__, event->rssi);
|
||||
|
||||
roaming_app_get_ap_info(&g_roaming_app.ap_info);
|
||||
roaming_app_get_ap_info(&g_roaming_app.current_bss.ap);
|
||||
determine_best_ap(0);
|
||||
g_roaming_app.current_low_rssi_threshold -= g_roaming_app.config.rssi_threshold_reduction_offset;
|
||||
ESP_LOGD(ROAMING_TAG, "Resetting RSSI Threshold to %d", g_roaming_app.current_low_rssi_threshold);
|
||||
@ -430,7 +433,7 @@ void roaming_app_trigger_roam(struct cand_bss *bss)
|
||||
goto free_bss;
|
||||
}
|
||||
#if NETWORK_ASSISTED_ROAMING_ENABLED
|
||||
if (g_roaming_app.config.btm_roaming_enabled && g_roaming_app.btm_support) {
|
||||
if (g_roaming_app.config.btm_roaming_enabled && g_roaming_app.current_bss.btm_support) {
|
||||
#if LEGACY_ROAM_ENABLED && NETWORK_ASSISTED_ROAMING_ENABLED
|
||||
if (g_roaming_app.btm_attempt <= g_roaming_app.config.btm_retry_cnt) {
|
||||
#endif
|
||||
@ -501,8 +504,8 @@ void print_ap_records(struct scanned_ap_info *ap_info)
|
||||
#if PERIODIC_RRM_MONITORING
|
||||
static void periodic_rrm_request(struct timeval *now)
|
||||
{
|
||||
roaming_app_get_ap_info(&g_roaming_app.ap_info);
|
||||
if (esp_rrm_is_rrm_supported_connection() && (g_roaming_app.ap_info.rssi < g_roaming_app.config.rrm_monitor_rssi_threshold)) {
|
||||
roaming_app_get_ap_info(&g_roaming_app.current_bss.ap);
|
||||
if (esp_rrm_is_rrm_supported_connection() && (g_roaming_app.current_bss.ap.rssi < g_roaming_app.config.rrm_monitor_rssi_threshold)) {
|
||||
if (esp_rrm_send_neighbor_report_request() < 0) {
|
||||
ESP_LOGE(ROAMING_TAG, "failed to send neighbor report request");
|
||||
return;
|
||||
@ -514,7 +517,7 @@ static void periodic_rrm_request(struct timeval *now)
|
||||
|
||||
static bool candidate_security_match(wifi_ap_record_t candidate)
|
||||
{
|
||||
wifi_auth_mode_t curr_auth = g_roaming_app.ap_info.authmode;
|
||||
wifi_auth_mode_t curr_auth = g_roaming_app.current_bss.ap.authmode;
|
||||
wifi_auth_mode_t cand_auth = candidate.authmode;
|
||||
ESP_LOGV(ROAMING_TAG, "Cand authmode : %d, Current Authmode : %d", cand_auth, curr_auth);
|
||||
if (cand_auth == curr_auth) {
|
||||
@ -618,7 +621,7 @@ static void conduct_scan(void)
|
||||
gettimeofday(&g_roaming_app.scanned_aps.time, NULL);
|
||||
/* Issue scan */
|
||||
os_memset(&g_roaming_app.scanned_aps, 0, sizeof(struct scanned_ap_info));
|
||||
if (esp_wifi_promiscuous_scan_start(&g_roaming_app.scan_params, scan_done_event_handler) < 0) {
|
||||
if (esp_wifi_promiscuous_scan_start(&g_roaming_app.config.scan_config, scan_done_event_handler) < 0) {
|
||||
ESP_LOGE(ROAMING_TAG, "failed to issue scan");
|
||||
return;
|
||||
}
|
||||
@ -661,9 +664,9 @@ static void periodic_scan_roam(struct timeval *now)
|
||||
#endif /*NETWORK_ASSISTED_ROAMING_ENABLED && !LEGACY_ROAM_ENABLED*/
|
||||
/* If the current RSSI is not worse than the configured threshold
|
||||
* for station initiated roam, then do not trigger roam */
|
||||
roaming_app_get_ap_info(&g_roaming_app.ap_info);
|
||||
ESP_LOGD(ROAMING_TAG, "Connected AP's RSSI=%d", g_roaming_app.ap_info.rssi);
|
||||
if (g_roaming_app.ap_info.rssi > g_roaming_app.config.scan_rssi_threshold) {
|
||||
roaming_app_get_ap_info(&g_roaming_app.current_bss.ap);
|
||||
ESP_LOGD(ROAMING_TAG, "Connected AP's RSSI=%d", g_roaming_app.current_bss.ap.rssi);
|
||||
if (g_roaming_app.current_bss.ap.rssi > g_roaming_app.config.scan_rssi_threshold) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -672,7 +675,7 @@ static void periodic_scan_roam(struct timeval *now)
|
||||
#endif /*PERIODIC_SCAN_MONITORING*/
|
||||
|
||||
#if PERIODIC_RRM_MONITORING
|
||||
void roaming_app_periodic_rrm_internal_handler(void *data, void *ctx)
|
||||
static void roaming_app_periodic_rrm_internal_handler(void *data, void *ctx)
|
||||
{
|
||||
struct timeval now;
|
||||
|
||||
@ -695,7 +698,7 @@ void roaming_app_periodic_rrm_internal_handler(void *data, void *ctx)
|
||||
#endif /*PERIODIC_RRM_MONITORING*/
|
||||
|
||||
#if PERIODIC_SCAN_MONITORING
|
||||
void roaming_app_periodic_scan_internal_handler(void *data, void *ctx)
|
||||
static void roaming_app_periodic_scan_internal_handler(void *data, void *ctx)
|
||||
{
|
||||
struct timeval now;
|
||||
|
||||
@ -761,14 +764,14 @@ static int8_t parse_scan_chan_list(void)
|
||||
char* token;
|
||||
token = strsep(&scan_chan_string, ",");
|
||||
|
||||
g_roaming_app.scan_params.channel_bitmap.ghz_2_channels = 0;
|
||||
g_roaming_app.config.scan_config.channel_bitmap.ghz_2_channels = 0;
|
||||
|
||||
while (token != NULL) {
|
||||
uint8_t channel = atoi(token);
|
||||
/* Check if the number is within the required range */
|
||||
if (channel >= 1 && channel <= 14) {
|
||||
/* Check if the number is already present in the array */
|
||||
g_roaming_app.scan_params.channel_bitmap.ghz_2_channels |= (1 << channel);
|
||||
g_roaming_app.config.scan_config.channel_bitmap.ghz_2_channels |= (1 << channel);
|
||||
} else {
|
||||
ESP_LOGE(ROAMING_TAG, "Channel out of range: %d", channel);
|
||||
ret = -1;
|
||||
@ -828,7 +831,7 @@ static esp_err_t init_config_params(void)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
static esp_err_t init_scan_params(void)
|
||||
static esp_err_t init_scan_config(void)
|
||||
{
|
||||
if (!scan_results_lock) {
|
||||
scan_results_lock = os_recursive_mutex_create();
|
||||
@ -842,10 +845,10 @@ static esp_err_t init_scan_params(void)
|
||||
ESP_ERROR_CHECK(parse_scan_chan_list());
|
||||
}
|
||||
|
||||
g_roaming_app.scan_params.scan_type = 0;
|
||||
g_roaming_app.scan_params.scan_time.active.min = SCAN_TIME_MIN_DURATION;
|
||||
g_roaming_app.scan_params.scan_time.active.max = SCAN_TIME_MAX_DURATION;
|
||||
g_roaming_app.scan_params.home_chan_dwell_time = HOME_CHANNEL_DWELL_TIME;
|
||||
g_roaming_app.config.scan_config.scan_type = 0;
|
||||
g_roaming_app.config.scan_config.scan_time.active.min = SCAN_TIME_MIN_DURATION;
|
||||
g_roaming_app.config.scan_config.scan_time.active.max = SCAN_TIME_MAX_DURATION;
|
||||
g_roaming_app.config.scan_config.home_chan_dwell_time = HOME_CHANNEL_DWELL_TIME;
|
||||
gettimeofday(&g_roaming_app.scanned_aps.time, NULL);
|
||||
return ESP_OK;
|
||||
}
|
||||
@ -868,7 +871,7 @@ void init_roaming_app(void)
|
||||
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_BSS_RSSI_LOW,
|
||||
&roaming_app_rssi_low_handler, NULL));
|
||||
#endif /*LOW_RSSI_ROAMING_ENABLED*/
|
||||
ESP_ERROR_CHECK(init_scan_params());
|
||||
ESP_ERROR_CHECK(init_scan_config());
|
||||
ESP_ERROR_CHECK(init_config_params());
|
||||
#if PERIODIC_RRM_MONITORING
|
||||
ESP_ERROR_CHECK(esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_NEIGHBOR_REP,
|
||||
@ -943,6 +946,7 @@ esp_err_t roam_set_config_params(struct roam_config *config)
|
||||
g_roaming_app.config.rrm_monitor = config->rrm_monitor;
|
||||
g_roaming_app.config.rrm_monitor_time = config->rrm_monitor_time;
|
||||
g_roaming_app.config.rrm_monitor_rssi_threshold = config->rrm_monitor_rssi_threshold;
|
||||
g_roaming_app.config.scan_config = config->scan_config;
|
||||
|
||||
ESP_LOGD(ROAMING_TAG, "Updated Roaming app config :");
|
||||
|
||||
|
Reference in New Issue
Block a user