feat(esp_wifi): Adds a new API to set default scan parameters

- esp_wifi_set_scan_parameters() : Used to set the default scan parameters to be used
while scanning. These parameters will be used for all scans conducted by station
including connect scan. Parameters provided through esp_wifi_scan_start() override the
default parameters for that scan only
- esp_wifi_get_scan_parameters(): Used to get the current default scan parameters.
pull/13557/merge
jgujarathi 2024-04-17 16:05:49 +05:30 zatwierdzone przez BOT
rodzic 64a1ed07d9
commit 770162d76c
3 zmienionych plików z 61 dodań i 1 usunięć

Wyświetl plik

@ -469,6 +469,7 @@ esp_err_t esp_wifi_deauth_sta(uint16_t aid);
* @param config configuration settings for scanning, if set to NULL default settings will be used
* of which default values are show_hidden:false, scan_type:active, scan_time.active.min:0,
* scan_time.active.max:120 milliseconds, scan_time.passive:360 milliseconds
* home_chan_dwell_time:30ms
*
* @param block if block is true, this API will block the caller until the scan is done, otherwise
* it will return immediately
@ -483,6 +484,47 @@ esp_err_t esp_wifi_deauth_sta(uint16_t aid);
*/
esp_err_t esp_wifi_scan_start(const wifi_scan_config_t *config, bool block);
/**
* @brief Set default parameters used for scanning by station.
*
* @attention The values set using this API are also used for scans used while connecting.
*
* @attention The values of maximum active scan time and passive scan time per channel are limited to 1500 milliseconds.
*
* @attention The home_chan_dwell_time needs to be a minimum of 30ms and a maximum of 150ms.
*
* @attention Set any of the parameters to 0 to indicate using the default parameters -
* scan_time.active.min : 0ms, scan_time.active.max : 120ms home_chan_dwell_time : 30ms
* scan_time.passive : 360ms
*
* @attention Default values can be retrieved using the macro WIFI_SCAN_PARAMS_DEFAULT_CONFIG()
*
* @attention Set the config parameter to NULL to reset previously set scan parameters to their default values.
*
* @param config default configuration settings for all scans by stations
*
* @return
* - ESP_OK: succeed
* - ESP_FAIL: failed as station mode has not been started yet
* - ESP_ERR_INVALID_ARG: values provided do not satisfy the requirements
* - ESP_ERR_NOT_SUPPORTED: This API is not supported in AP mode yet
* - ESP_ERR_INVALID_STATE: a scan/connect is in progress right now, cannot change scan parameters
* - others: refer to error code in esp_err.h
*/
esp_err_t esp_wifi_set_scan_parameters(const wifi_scan_default_params_t *config);
/**
* @brief Get default parameters used for scanning by station.
*
* @param config structure variable within which scan default params will be stored
*
* @return
* - ESP_OK: succeed
* - ESP_ERR_INVALID_ARG: passed parameter does not point to a valid memory
* - others: refer to error code in esp_err.h
*/
esp_err_t esp_wifi_get_scan_parameters(wifi_scan_default_params_t *config);
/**
* @brief Stop the scan in process
*

Wyświetl plik

@ -144,6 +144,18 @@ typedef enum {
WIFI_SECOND_CHAN_BELOW, /**< the channel width is HT40 and the secondary channel is below the primary channel */
} wifi_second_chan_t;
#define WIFI_ACTIVE_SCAN_MIN_DEFAULT_TIME 0
#define WIFI_ACTIVE_SCAN_MAX_DEFAULT_TIME 120
#define WIFI_PASSIVE_SCAN_DEFAULT_TIME 360
#define WIFI_SCAN_HOME_CHANNEL_DWELL_DEFAULT_TIME 30
#define WIFI_SCAN_PARAMS_DEFAULT_CONFIG() { \
.scan_time.active.min = WIFI_ACTIVE_SCAN_MIN_DEFAULT_TIME, \
.scan_time.active.max = WIFI_ACTIVE_SCAN_MAX_DEFAULT_TIME, \
.scan_time.passive = WIFI_PASSIVE_SCAN_DEFAULT_TIME, \
.home_chan_dwell_time = WIFI_SCAN_HOME_CHANNEL_DWELL_DEFAULT_TIME\
}
typedef enum {
WIFI_SCAN_TYPE_ACTIVE = 0, /**< active scan */
WIFI_SCAN_TYPE_PASSIVE, /**< passive scan */
@ -180,6 +192,12 @@ typedef struct {
wifi_scan_channel_bitmap_t channel_bitmap; /**< Channel bitmap for setting specific channels to be scanned. For 2.4ghz channels set ghz_2_channels from BIT(1) to BIT(14) from LSB to MSB order to indicate channels to be scanned. Currently scanning in 5ghz channels is not supported. Please note that the 'channel' parameter above needs to be set to 0 to allow scanning by bitmap. */
} wifi_scan_config_t;
/** @brief Parameters default scan configurations. */
typedef struct {
wifi_scan_time_t scan_time; /**< scan time per channel */
uint8_t home_chan_dwell_time;/**< time spent at home channel between scanning consecutive channels.*/
} wifi_scan_default_params_t;
typedef enum {
WIFI_CIPHER_TYPE_NONE = 0, /**< the cipher type is none */
WIFI_CIPHER_TYPE_WEP40, /**< the cipher type is WEP40 */

@ -1 +1 @@
Subproject commit d935da0725203542585ba981faa6d69f35480e9e
Subproject commit d3325558c6e97a2b255e3ee1b562e2d269709adf