mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
feat(wifi): itwt support itwt wake duration unit
This commit is contained in:
parent
320f8ebe7d
commit
395ad3edc0
@ -401,6 +401,12 @@ static const esp_err_msg_t esp_err_msg_table[] = {
|
||||
ERR_TBL_IT(ESP_ERR_WIFI_TWT_SETUP_TIMEOUT), /* 12312 0x3018 Timeout of receiving twt setup response
|
||||
frame, timeout times can be set during
|
||||
twt setup */
|
||||
# endif
|
||||
# ifdef ESP_ERR_WIFI_TWT_SETUP_TXFAIL
|
||||
ERR_TBL_IT(ESP_ERR_WIFI_TWT_SETUP_TXFAIL), /* 12313 0x3019 TWT setup frame tx failed */
|
||||
# endif
|
||||
# ifdef ESP_ERR_WIFI_TWT_SETUP_REJECT
|
||||
ERR_TBL_IT(ESP_ERR_WIFI_TWT_SETUP_REJECT), /* 12314 0x301a The twt setup request was rejected by the AP */
|
||||
# endif
|
||||
// components/wpa_supplicant/esp_supplicant/include/esp_wps.h
|
||||
# ifdef ESP_ERR_WIFI_REGISTRAR
|
||||
|
@ -162,7 +162,7 @@ hal_mac_is_dma_enable = 0x40000e00;
|
||||
//wdevProcessRxSucDataAll = 0x40000e0c;
|
||||
wdev_csi_len_align = 0x40000e10;
|
||||
ppDequeueTxDone_Locked = 0x40000e14;
|
||||
ppProcTxDone = 0x40000e18;
|
||||
//ppProcTxDone = 0x40000e18;
|
||||
//pm_tx_data_done_process = 0x40000e1c;
|
||||
config_is_cache_tx_buf_enabled = 0x40000e20;
|
||||
ppMapWaitTxq = 0x40000e24;
|
||||
@ -297,16 +297,16 @@ tsf_hal_unmap_tbtt_target_to_rx_frame = 0x40001024;
|
||||
//ppSelectTxFormat = 0x40001028;
|
||||
//ppCertSetRate = 0x4000102c;
|
||||
//ppHEAMPDU2Normal = 0x40001030;
|
||||
ppCalTxHEAMPDULength = 0x40001034;
|
||||
ppCalTxHESMPDULength = 0x40001038;
|
||||
//ppCalTxHEAMPDULength = 0x40001034;
|
||||
//ppCalTxHESMPDULength = 0x40001038;
|
||||
rcGetRate = 0x4000103c;
|
||||
rcGetDCMMaxRate = 0x40001040;
|
||||
//rcGetSMPDURate = 0x40001044;
|
||||
ppDirectRecycleAmpdu = 0x40001048;
|
||||
ppCheckTxHEAMPDUlength = 0x4000104c;
|
||||
rx11AXRate2AMPDULimit = 0x40001050;
|
||||
//ppCheckTxHEAMPDUlength = 0x4000104c;
|
||||
//rx11AXRate2AMPDULimit = 0x40001050;
|
||||
//ppRegressAmpdu = 0x40001054;
|
||||
ppCalDeliNum = 0x40001058;
|
||||
//ppCalDeliNum = 0x40001058;
|
||||
ppAdd2AMPDUTail = 0x4000105c;
|
||||
esp_test_disable_tx_statistics = 0x40001060;
|
||||
esp_test_enable_tx_statistics = 0x40001064;
|
||||
|
@ -85,6 +85,8 @@ extern "C" {
|
||||
|
||||
#define ESP_ERR_WIFI_TWT_FULL (ESP_ERR_WIFI_BASE + 23) /*!< no available flow id */
|
||||
#define ESP_ERR_WIFI_TWT_SETUP_TIMEOUT (ESP_ERR_WIFI_BASE + 24) /*!< Timeout of receiving twt setup response frame, timeout times can be set during twt setup */
|
||||
#define ESP_ERR_WIFI_TWT_SETUP_TXFAIL (ESP_ERR_WIFI_BASE + 25) /*!< TWT setup frame tx failed */
|
||||
#define ESP_ERR_WIFI_TWT_SETUP_REJECT (ESP_ERR_WIFI_BASE + 26) /*!< The twt setup request was rejected by the AP */
|
||||
|
||||
/**
|
||||
* @brief WiFi stack configuration parameters passed to esp_wifi_init call.
|
||||
|
@ -103,7 +103,8 @@ typedef struct
|
||||
flow_id could be specified to a value in the range of [0, 7], but it might be changed by AP in the response.
|
||||
When change TWT parameters of the existing TWT agreement, flow_id should be an existing one. The value range is [0, 7]. */
|
||||
uint16_t wake_invl_expn :5; /**< TWT Wake Interval Exponent. The value range is [0, 31]. */
|
||||
uint16_t reserved :6; /**< bit: 10.15 reserved */
|
||||
uint16_t wake_duration_unit :1; /**< TWT Wake duration unit, 0: 256us 1: TU (TU = 1024us)*/
|
||||
uint16_t reserved :5; /**< bit: 11.15 reserved */
|
||||
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]. */
|
||||
uint16_t wake_invl_mant; /**< TWT Wake Interval Mantissa. The value range is [1, 65535]. */
|
||||
uint16_t twt_id; /**< TWT connection id, the value range is [0, 32767]. */
|
||||
@ -204,8 +205,10 @@ typedef struct {
|
||||
|
||||
/** Argument structure for WIFI_EVENT_TWT_SET_UP event */
|
||||
typedef struct {
|
||||
wifi_twt_setup_config_t config; /**< itwt setup config*/
|
||||
esp_err_t status; /**< 1: indicate tx success, others : indicate tx fail */
|
||||
wifi_twt_setup_config_t config; /**< itwt setup config, this value is determined by the AP */
|
||||
esp_err_t status; /**< itwt setup status, 1: indicate setup success, others : indicate setup fail */
|
||||
uint8_t reason; /**< itwt setup frame tx fail reason */
|
||||
uint64_t target_wake_time; /**< TWT SP start time */
|
||||
} wifi_event_sta_itwt_setup_t;
|
||||
|
||||
/** Argument structure for WIFI_EVENT_TWT_TEARDOWN event */
|
||||
|
@ -969,6 +969,7 @@ typedef struct {
|
||||
uint8_t mac[6]; /**< MAC address of the station disconnects to soft-AP */
|
||||
uint8_t aid; /**< the aid that soft-AP gave to the station disconnects to */
|
||||
bool is_mesh_child; /**< flag to identify mesh child */
|
||||
uint8_t reason; /**< reason of disconnection */
|
||||
} wifi_event_ap_stadisconnected_t;
|
||||
|
||||
/** Argument structure for WIFI_EVENT_AP_PROBEREQRECVED event */
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 82dd9020a46f8603c60c33e5af87a80a256f4f8f
|
||||
Subproject commit b9d885520d29081530681e45b256f63a09779efa
|
@ -31,12 +31,13 @@ typedef struct {
|
||||
struct arg_int *setup;
|
||||
struct arg_int *teardown;
|
||||
struct arg_int *suspend;
|
||||
struct arg_int *trigger; //1-trigger-enabled, 0-non-trigger-enabled, setup
|
||||
struct arg_int *flowtype; //1-unannounced, 0-announced, setup
|
||||
struct arg_int *trigger; //1-trigger-enabled, 0-non-trigger-enabled, setup
|
||||
struct arg_int *flowtype; //1-unannounced, 0-announced, setup
|
||||
struct arg_int *negtype;
|
||||
struct arg_int *wakeinvlexp; //setup
|
||||
struct arg_int *wakeinvlman; //setup
|
||||
struct arg_int *minwakedur; //setup
|
||||
struct arg_int *wakeinvlexp; //setup
|
||||
struct arg_int *wakeduraunit; //1-TU, 0-256us
|
||||
struct arg_int *wakeinvlman; //setup
|
||||
struct arg_int *minwakedur; //setup
|
||||
struct arg_int *flowid;
|
||||
struct arg_int *twtid;
|
||||
struct arg_int *setup_timeout_time_ms;
|
||||
@ -91,6 +92,12 @@ static int wifi_cmd_itwt(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (itwt_args.wakeduraunit->count) {
|
||||
if (itwt_args.wakeduraunit->ival[0] < 0 || itwt_args.wakeduraunit->ival[0] > 1) {
|
||||
ESP_LOGE(TAG, "(itwt)expect [0, 1], wake duration unit: %d", itwt_args.wakeduraunit->ival[0]);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
if (itwt_args.twtid->count) {
|
||||
if (itwt_args.twtid->ival[0] < 0 || itwt_args.twtid->ival[0] > 32767) {
|
||||
ESP_LOGE(TAG, "(itwt)expect [0, 32767], twt id: %d", itwt_args.twtid->ival[0]);
|
||||
@ -109,6 +116,7 @@ static int wifi_cmd_itwt(int argc, char **argv)
|
||||
.twt_id = itwt_args.twtid->count ? itwt_args.twtid->ival[0] : 0,
|
||||
.flow_type = itwt_args.flowtype->count ? ((itwt_args.flowtype->ival[0] == 0) ? 0 : 1) : 0,
|
||||
.min_wake_dura = itwt_args.minwakedur->count ? itwt_args.minwakedur->ival[0] : 255,
|
||||
.wake_duration_unit = itwt_args.wakeduraunit->count ? itwt_args.wakeduraunit->ival[0] : 0,
|
||||
.wake_invl_expn = itwt_args.wakeinvlexp->count ? itwt_args.wakeinvlexp->ival[0] : 10,
|
||||
.wake_invl_mant = itwt_args.wakeinvlman->count ? itwt_args.wakeinvlman->ival[0] : 512,
|
||||
.trigger = itwt_args.trigger->count ? (itwt_args.trigger->ival[0] ? 1 : 0) : 1,
|
||||
@ -178,6 +186,7 @@ void register_wifi_itwt(void)
|
||||
itwt_args.flowtype = arg_int0("f", NULL, "<flow_type>", "flow type: 0-announced, 1-unannounced");
|
||||
itwt_args.negtype = arg_int0("n", NULL, "<neg_type>", "negotiate type");
|
||||
itwt_args.minwakedur = arg_int0("d", NULL, "<minwakedur>", "Norminal Min. Wake Duration");
|
||||
itwt_args.wakeduraunit = arg_int0("u", NULL, "<wakeduraunit>", "wake duration unit 0-256us, 1-TU (TU = 1024us)");
|
||||
itwt_args.wakeinvlexp = arg_int0("e", NULL, "<wakeinvlexp>", "Wake Interval Exponent");
|
||||
itwt_args.wakeinvlman = arg_int0("m", NULL, "<wakeinvlman>", "Wake Interval Mantissa");
|
||||
itwt_args.flowid = arg_int0("i", NULL, "<flow_id>", "Flow ID");
|
||||
|
@ -44,11 +44,13 @@ menu "Example Configuration"
|
||||
default y
|
||||
help
|
||||
0- a non-trigger-enabled TWT, 1-a trigger-enabled TWT
|
||||
|
||||
config EXAMPLE_ITWT_ANNOUNCED
|
||||
bool "announced"
|
||||
default y
|
||||
help
|
||||
0- an unannounced TWT, 1-an announced TWT
|
||||
|
||||
config EXAMPLE_ITWT_MIN_WAKE_DURA
|
||||
int "itwt minimum wake duration"
|
||||
range 1 255
|
||||
@ -56,30 +58,42 @@ menu "Example Configuration"
|
||||
help
|
||||
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].
|
||||
|
||||
config EXAMPLE_ITWT_WAKE_DURATION_UNIT
|
||||
int "itwt wake duration unit"
|
||||
range 0 1
|
||||
default 0
|
||||
help
|
||||
TWT wake duration unit, 0: 256us 1: TU (TU = 1024us)
|
||||
|
||||
config EXAMPLE_ITWT_WAKE_INVL_EXPN
|
||||
int "itwt wake interval exponent"
|
||||
range 0 31
|
||||
default 10
|
||||
help
|
||||
TWT Wake Interval Exponent, in microseconds. The value range is [0, 31].
|
||||
|
||||
config EXAMPLE_ITWT_WAKE_INVL_MANT
|
||||
int "itwt wake interval mantissa"
|
||||
range 1 65535
|
||||
default 512
|
||||
help
|
||||
TWT Wake Interval Mantissa, in microseconds. The value range is [1, 65535].
|
||||
|
||||
config EXAMPLE_ITWT_ID
|
||||
int "itwt connection id"
|
||||
range 0 32767
|
||||
default 0
|
||||
help
|
||||
TWT Connection id. The value range is [0, 32767].
|
||||
|
||||
config EXAMPLE_ITWT_SETUP_TIMEOUT_TIME_MS
|
||||
int "itwt wake interval mantissa"
|
||||
int "itwt setup timeout times"
|
||||
range 100 65535
|
||||
default 5000
|
||||
help
|
||||
TWT setup timeout time, in microseconds. The value range is [100, 65535].
|
||||
|
||||
endmenu
|
||||
|
||||
choice EXAMPLE_MAX_CPU_FREQ
|
||||
|
@ -46,6 +46,7 @@ static const char *TAG = "itwt";
|
||||
/*set the ssid and password via "idf.py menuconfig"*/
|
||||
#define DEFAULT_SSID CONFIG_EXAMPLE_WIFI_SSID
|
||||
#define DEFAULT_PWD CONFIG_EXAMPLE_WIFI_PASSWORD
|
||||
#define ITWT_SETUP_SUCCESS 1
|
||||
|
||||
#if CONFIG_EXAMPLE_ITWT_TRIGGER_ENABLE
|
||||
uint8_t trigger_enabled = 1;
|
||||
@ -123,6 +124,7 @@ static void got_ip_handler(void *arg, esp_event_base_t event_base,
|
||||
.twt_id = CONFIG_EXAMPLE_ITWT_ID,
|
||||
.flow_type = flow_type_announced ? 0 : 1,
|
||||
.min_wake_dura = CONFIG_EXAMPLE_ITWT_MIN_WAKE_DURA,
|
||||
.wake_duration_unit = CONFIG_EXAMPLE_ITWT_WAKE_DURATION_UNIT,
|
||||
.wake_invl_expn = CONFIG_EXAMPLE_ITWT_WAKE_INVL_EXPN,
|
||||
.wake_invl_mant = CONFIG_EXAMPLE_ITWT_WAKE_INVL_MANT,
|
||||
.trigger = trigger_enabled,
|
||||
@ -156,14 +158,23 @@ static void itwt_setup_handler(void *arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void *event_data)
|
||||
{
|
||||
wifi_event_sta_itwt_setup_t *setup = (wifi_event_sta_itwt_setup_t *) event_data;
|
||||
if (setup->config.setup_cmd == TWT_ACCEPT) {
|
||||
if (setup->status == ITWT_SETUP_SUCCESS) {
|
||||
/* TWT Wake Interval = TWT Wake Interval Mantissa * (2 ^ TWT Wake Interval Exponent) */
|
||||
ESP_LOGI(TAG, "<WIFI_EVENT_ITWT_SETUP>twt_id:%d, flow_id:%d, %s, %s, wake_dura:%d, wake_invl_e:%d, wake_invl_m:%d", setup->config.twt_id,
|
||||
ESP_LOGI(TAG, "<WIFI_EVENT_ITWT_SETUP>twt_id:%d, flow_id:%d, %s, %s, wake_dura:%d, wake_dura_unit:%d, wake_invl_e:%d, wake_invl_m:%d", setup->config.twt_id,
|
||||
setup->config.flow_id, setup->config.trigger ? "trigger-enabled" : "non-trigger-enabled", setup->config.flow_type ? "unannounced" : "announced",
|
||||
setup->config.min_wake_dura, setup->config.wake_invl_expn, setup->config.wake_invl_mant);
|
||||
ESP_LOGI(TAG, "<WIFI_EVENT_ITWT_SETUP>wake duration:%d us, service period:%d us", setup->config.min_wake_dura << 8, setup->config.wake_invl_mant << setup->config.wake_invl_expn);
|
||||
setup->config.min_wake_dura, setup->config.wake_duration_unit, setup->config.wake_invl_expn, setup->config.wake_invl_mant);
|
||||
ESP_LOGI(TAG, "<WIFI_EVENT_ITWT_SETUP>target wake time:%lld, wake duration:%d us, service period:%d us", setup->target_wake_time, setup->config.min_wake_dura << (setup->config.wake_duration_unit == 1 ? 10 : 8),
|
||||
setup->config.wake_invl_mant << setup->config.wake_invl_expn);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "<WIFI_EVENT_ITWT_SETUP>twt_id:%d, unexpected setup command:%d", setup->config.twt_id, setup->config.setup_cmd);
|
||||
if (setup->status == ESP_ERR_WIFI_TWT_SETUP_TIMEOUT) {
|
||||
ESP_LOGE(TAG, "<WIFI_EVENT_ITWT_SETUP>twt_id:%d, timeout of receiving twt setup response frame", setup->config.twt_id);
|
||||
} else if (setup->status == ESP_ERR_WIFI_TWT_SETUP_TXFAIL) {
|
||||
ESP_LOGE(TAG, "<WIFI_EVENT_ITWT_SETUP>twt_id:%d, twt setup frame tx failed, reason: %d", setup->config.twt_id, setup->reason);
|
||||
} else if (setup->status == ESP_ERR_WIFI_TWT_SETUP_REJECT) {
|
||||
ESP_LOGE(TAG, "<WIFI_EVENT_ITWT_SETUP>twt_id:%d, twt setup request was rejected, setup cmd: %d", setup->config.twt_id, setup->config.setup_cmd);
|
||||
} else {
|
||||
ESP_LOGE(TAG, "<WIFI_EVENT_ITWT_SETUP>twt_id:%d, twt setup failed, status: %d", setup->config.twt_id, setup->status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user