mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
feat(wifi):wifi support broadcast twt
This commit is contained in:
parent
5a65712325
commit
bfe3fb0993
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
|
||||
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
@ -142,6 +142,66 @@ esp_err_t esp_wifi_enable_rx_statistics(bool rx_stats, bool rx_mu_stats);
|
||||
*/
|
||||
esp_err_t esp_wifi_enable_tx_statistics(esp_wifi_aci_t aci, bool tx_stats);
|
||||
|
||||
/**
|
||||
* @brief Set up an broadcast TWT agreement (NegotiationType=3) or change TWT parameters of the existing TWT agreement
|
||||
* - TWT Wake Interval = TWT Wake Interval Mantissa * (2 ^ TWT Wake Interval Exponent), unit: us
|
||||
* - e.g. TWT Wake Interval Mantissa = 512, TWT Wake Interval Exponent = 12, then TWT Wake Interval is 2097.152 ms
|
||||
* Nominal Minimum Wake Duration = 255, then TWT Wake Duration is 65.28 ms
|
||||
*
|
||||
* @attention Support at most 32 TWT agreements, otherwise ESP_ERR_WIFI_TWT_FULL will be returned.
|
||||
* Support sleep time up to (1 << 35) us.
|
||||
*
|
||||
* @param[in,out] setup_config pointer to btwt setup config structure.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
||||
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
|
||||
* - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
|
||||
* - ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status
|
||||
* - ESP_ERR_WIFI_TWT_FULL: no available flow id
|
||||
* - ESP_ERR_INVALID_ARG: invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_btwt_setup(wifi_btwt_setup_config_t *config);
|
||||
|
||||
/**
|
||||
* @brief Tear down broadcast TWT agreements
|
||||
*
|
||||
* @param[in] btwt_id The value range is [0, 31].
|
||||
* BTWT_ID_ALL indicates tear down all broadcast TWT agreements.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
|
||||
* - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
|
||||
* - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
|
||||
* - ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status
|
||||
* - ESP_ERR_INVALID_ARG: invalid argument
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_btwt_teardown(uint8_t btwt_id);
|
||||
|
||||
/**
|
||||
* @brief Get broadcast TWT information
|
||||
*
|
||||
* @param[in] btwt_info pointer to bTWT information structure.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
* - ESP_FAIL: fail
|
||||
* - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_btwt_get_info(esp_wifi_btwt_info_t *btwt_info);
|
||||
|
||||
/**
|
||||
* @brief Set wifi TWT config
|
||||
*
|
||||
* @param[in] config pointer to the wifi TWT configure structure.
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: succeed
|
||||
*/
|
||||
esp_err_t esp_wifi_sta_twt_config(wifi_twt_config_t *config);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -15,6 +15,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#define FLOW_ID_ALL (8)
|
||||
#define BTWT_ID_ALL (32)
|
||||
#define BSS_MAX_COLOR (63)
|
||||
|
||||
/**
|
||||
@ -111,6 +112,17 @@ typedef enum {
|
||||
TWT_REJECT, /**< indicate that the negotiation has ended in failure to create a new TWT agreement */
|
||||
} wifi_twt_setup_cmds_t;
|
||||
|
||||
/**
|
||||
* @brief broadcast TWT setup config
|
||||
*/
|
||||
typedef struct {
|
||||
wifi_twt_setup_cmds_t setup_cmd; /**< Indicates the type of TWT command*/
|
||||
uint8_t btwt_id; /**< When set up an broadcast TWT agreement, the broadcast twt id will be assigned by AP after a successful agreement setup.
|
||||
broadcast twt id could be specified to a value in the range of [1, 31], but it might be change by AP in the response.
|
||||
When change TWT parameters of the existing TWT agreement, broadcast twt id should be an existing one. The value range is [1, 31].*/
|
||||
uint16_t timeout_time_ms; /**< Timeout times of receving setup action frame response, default 5s*/
|
||||
} wifi_btwt_setup_config_t;
|
||||
|
||||
/**
|
||||
* @brief TWT setup config
|
||||
*/
|
||||
@ -294,6 +306,18 @@ typedef struct {
|
||||
} __attribute__((packed)) esp_wifi_rxctrl_t;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief bTWT setup status
|
||||
*/
|
||||
typedef enum {
|
||||
BTWT_SETUP_TXFAIL, /**< station sends btwt setup request frame fail */
|
||||
BTWT_SETUP_SUCCESS, /**< station receives btwt setup response frame and setup btwt sucessfully */
|
||||
BTWT_SETUP_TIMEOUT, /**< timeout of receiving btwt setup response frame */
|
||||
BTWT_SETUP_FULL, /**< indicate there is no avaliable btwt id */
|
||||
BTWT_SETUP_INVALID_ARG, /**< indicate invalid argument to setup btwt */
|
||||
BTWT_SETUP_INTERNAL_ERR, /**< indicate internal error to setup btwt */
|
||||
} wifi_btwt_setup_status_t;
|
||||
|
||||
/** Argument structure for WIFI_EVENT_TWT_SET_UP event */
|
||||
typedef struct {
|
||||
wifi_twt_setup_config_t config; /**< itwt setup config, this value is determined by the AP */
|
||||
@ -316,6 +340,34 @@ typedef struct {
|
||||
wifi_itwt_teardown_status_t status; /**< itwt teardown status */
|
||||
} wifi_event_sta_itwt_teardown_t;
|
||||
|
||||
/** Argument structure for WIFI_EVENT_BTWT_SET_UP event */
|
||||
typedef struct {
|
||||
wifi_btwt_setup_status_t status; /**< indicate btwt setup status */
|
||||
wifi_twt_setup_cmds_t setup_cmd; /**< indicate the type of TWT command */
|
||||
uint8_t btwt_id; /**< indicate btwt id */
|
||||
uint8_t min_wake_dura; /**< Nominal Minimum Wake Duration, indicates the minimum amount of time, in unit of 256 us, that the TWT requesting STA expects that it needs to be awake. The value range is [1, 255]. */
|
||||
uint8_t wake_invl_expn; /**< TWT Wake Interval Exponent. The value range is [0, 31]. */
|
||||
uint16_t wake_invl_mant; /**< TWT Wake Interval Mantissa. The value range is [1, 65535]. */
|
||||
bool trigger; /**< 1: a trigger-enabled TWT, 0: a non-trigger-enabled TWT */
|
||||
uint8_t flow_type; /**< 0: an announced TWT, 1: an unannounced TWT */
|
||||
uint8_t reason; /**< btwt setup frame tx fail reason */
|
||||
uint64_t target_wake_time; /**< TWT SP start time */
|
||||
} wifi_event_sta_btwt_setup_t;
|
||||
|
||||
/**
|
||||
* @brief BTWT teardown status
|
||||
*/
|
||||
typedef enum {
|
||||
BTWT_TEARDOWN_FAIL, /**< station sends teardown frame fail */
|
||||
BTWT_TEARDOWN_SUCCESS, /**< 1) station successfully sends teardown frame to AP; 2) station receives teardown frame from AP */
|
||||
} wifi_btwt_teardown_status_t;
|
||||
|
||||
/** Argument structure for WIFI_EVENT_TWT_TEARDOWN event */
|
||||
typedef struct {
|
||||
uint8_t btwt_id; /**< btwt id */
|
||||
wifi_btwt_teardown_status_t status; /**< btwt teardown status */
|
||||
} wifi_event_sta_btwt_teardown_t;
|
||||
|
||||
/**
|
||||
* @brief iTWT probe status
|
||||
*/
|
||||
@ -360,6 +412,20 @@ typedef struct {
|
||||
uint8_t flow_id; /**< flow id */
|
||||
} wifi_event_sta_twt_wakeup_t;
|
||||
|
||||
typedef struct {
|
||||
bool btwt_id_in_use; /**< indicate whether the btwt id is in use or not */
|
||||
uint16_t btwt_trigger : 1; /**< 1: a trigger-enabled TWT, 0: a non-trigger-enabled TWT */
|
||||
uint16_t btwt_flow_type : 1; /**< 0: an announced TWT, 1: an unannounced TWT */
|
||||
uint16_t btwt_recommendation : 3; /**< indicate recommendations on the types of frames. 0: no constraints, [1, 3], [4, 7] reserved */
|
||||
uint16_t btwt_wake_interval_exponent : 5; /**< TWT Wake Interval Exponent. The value range is [0, 31]. */
|
||||
uint16_t btwt_rsvd : 6; /**< reserved */
|
||||
uint8_t btwt_wake_duration; /**< TWT Wake duration unit, 0: 256us 1: TU (TU = 1024us) */
|
||||
uint16_t btwt_wake_interval_mantissa; /**< TWT Wake Interval Mantissa. The value range is [1, 65535]. */
|
||||
uint16_t btwt_info_id : 5; /**< btwt id */
|
||||
uint16_t btwt_info_persistence : 8; /**< indicate the number of TBTTs during which the Broadcast TWT SPs corresponding to this broadcast TWT parameters set are present */
|
||||
uint16_t btwt_info_rsvd : 3; /**< reserved */
|
||||
} esp_wifi_btwt_info_t;
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -818,6 +818,8 @@ typedef enum {
|
||||
WIFI_EVENT_ITWT_PROBE, /**< iTWT probe */
|
||||
WIFI_EVENT_ITWT_SUSPEND, /**< iTWT suspend */
|
||||
WIFI_EVENT_TWT_WAKEUP, /**< TWT wakeup */
|
||||
WIFI_EVENT_BTWT_SETUP, /**< bTWT setup */
|
||||
WIFI_EVENT_BTWT_TEARDOWN, /**< bTWT teardown*/
|
||||
|
||||
WIFI_EVENT_NAN_STARTED, /**< NAN Discovery has started */
|
||||
WIFI_EVENT_NAN_STOPPED, /**< NAN Discovery has stopped */
|
||||
|
Loading…
x
Reference in New Issue
Block a user