esp32 漫游

/** @brief STA configuration settings for the ESP32 */
typedef struct {
    uint8_t ssid[32];      /**< SSID of target AP. */
    uint8_t password[64];  /**< Password of target AP. */
    wifi_scan_method_t scan_method;    /**< do all channel scan or fast scan */
    bool bssid_set;        /**< whether set MAC address of target AP or not. Generally, station_config.bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP.*/
    uint8_t bssid[6];     /**< MAC address of target AP*/
    uint8_t channel;       /**< channel of target AP. Set to 1~13 to scan starting from the specified channel before connecting to AP. If the channel of AP is unknown, set it to 0.*/
    uint16_t listen_interval;   /**< Listen interval for ESP32 station to receive beacon when WIFI_PS_MAX_MODEM is set. Units: AP beacon intervals. Defaults to 3 if set to 0. */
    wifi_sort_method_t sort_method;    /**< sort the connect AP in the list by rssi or security mode */
    wifi_scan_threshold_t  threshold;     /**< When sort_method is set, only APs which have an auth mode that is more secure than the selected auth mode and a signal stronger than the minimum RSSI will be used. */
    wifi_pmf_config_t pmf_cfg;    /**< Configuration for Protected Management Frame. Will be advertized in RSN Capabilities in RSN IE. */
    uint32_t rm_enabled:1;        /**< Whether Radio Measurements are enabled for the connection */
    uint32_t btm_enabled:1;       /**< Whether BSS Transition Management is enabled for the connection */
    uint32_t mbo_enabled:1;       /**< Whether MBO is enabled for the connection */
    uint32_t ft_enabled:1;        /**< Whether FT is enabled for the connection */
    uint32_t owe_enabled:1;       /**< Whether OWE is enabled for the connection */
    uint32_t reserved:27;         /**< Reserved for future feature set */
    wifi_sae_pwe_method_t sae_pwe_h2e;     /**< Whether SAE hash to element is enabled */
} wifi_sta_config_t;

	wifi_config_t wifi_config = {
		.sta = {
			.ssid = EXAMPLE_WIFI_SSID,
			.password = EXAMPLE_WIFI_PASSWORD,
			.rm_enabled =1,
			.btm_enabled =1,
			.mbo_enabled =1,
			.pmf_cfg.capable = 1,
			.ft_enabled =1,
		},
	};

This comment is to indicate that only one event will come after calling esp_wifi_set_rssi_threshold(), for getting a second event esp_wifi_set_rssi_threshold() needs to be called again.

esp_err_t esp_wifi_set_rssi_threshold(int32_t rssi)

Parameters

rssi – threshold value in dbm between -100 to 0

Returns

  • ESP_OK: succeed

  • ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init

  • ESP_ERR_WIFI_ARG: invalid argument

esp_event_handler_register(WIFI_EVENT, WIFI_EVENT_STA_BSS_RSSI_LOW,
				&esp_bss_rssi_low_handler, NULL)

ref:

Wi-Fi 库 - ESP32 - — ESP-IDF 编程指南 v5.0.1 文档

Wi-Fi — ESP-FAQ 文档

https://github.com/espressif/esp-idf/tree/master/examples/wifi/roaming

猜你喜欢

转载自blog.csdn.net/wwwlyj123321/article/details/130090306