esp_wifi_he.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /*
  2. * SPDX-FileCopyrightText: 2022-2023 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdint.h>
  8. #include <stdbool.h>
  9. #include "esp_err.h"
  10. #include "esp_wifi_he_types.h"
  11. #ifdef __cplusplus
  12. extern "C" {
  13. #endif
  14. /**
  15. * @brief Set up an individual TWT agreement (NegotiationType=0) or change TWT parameters of the existing TWT agreement
  16. * - TWT Wake Interval = TWT Wake Interval Mantissa * (2 ^ TWT Wake Interval Exponent), unit: us
  17. * - e.g. TWT Wake Interval Mantissa = 512, TWT Wake Interval Exponent = 12, then TWT Wake Interval is 2097.152 ms
  18. * Nominal Minimum Wake Duration = 255, then TWT Wake Duration is 65.28 ms
  19. *
  20. * @attention Support at most 8 TWT agreements, otherwise ESP_ERR_WIFI_TWT_FULL will be returned.
  21. * Support sleep time up to (1 << 35) us.
  22. *
  23. * @param[in,out] setup_config pointer to itwt setup config structure.
  24. *
  25. * @return
  26. * - ESP_OK: succeed
  27. * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
  28. * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
  29. * - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
  30. * - ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status
  31. * - ESP_ERR_WIFI_TWT_FULL: no available flow id
  32. * - ESP_ERR_INVALID_ARG: invalid argument
  33. */
  34. esp_err_t esp_wifi_sta_itwt_setup(wifi_twt_setup_config_t *setup_config);
  35. /**
  36. * @brief Tear down individual TWT agreements
  37. *
  38. * @param[in] flow_id The value range is [0, 7].
  39. * FLOW_ID_ALL indicates tear down all individual TWT agreements.
  40. *
  41. * @return
  42. * - ESP_OK: succeed
  43. * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
  44. * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
  45. * - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
  46. * - ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status
  47. * - ESP_ERR_INVALID_ARG: invalid argument
  48. */
  49. esp_err_t esp_wifi_sta_itwt_teardown(int flow_id);
  50. /**
  51. * @brief Send a TWT Information frame to AP for suspending/resuming established iTWT agreements.
  52. *
  53. * @param[in] flow_id The value range is [0, 7].
  54. * FLOW_ID_ALL indicates suspend all individual TWT agreements
  55. * @param[in] suspend_time_ms If the value is 0, indicates the specified flow_id or all established agreements will be suspended until resume by users.
  56. * If the value is greater than 0, indicates the specified flow_id or all established agreements will be suspended until suspend_time_ms timeout, unit: ms.
  57. *
  58. * @return
  59. * - ESP_OK: succeed
  60. * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
  61. * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
  62. * - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
  63. * - ESP_ERR_WIFI_NOT_ASSOC: WiFi is not associated
  64. * - ESP_ERR_INVALID_ARG: invalid argument
  65. */
  66. esp_err_t esp_wifi_sta_itwt_suspend(int flow_id, int suspend_time_ms);
  67. /**
  68. * @brief Get flow id status
  69. *
  70. * @param[in] flow_id_bitmap Flow id status bitmap with 8 bit. Each bit represents that whether the corresponding flow id is setup.
  71. * 1: setup, 0: not setup.
  72. *
  73. * @return
  74. * - ESP_OK: succeed
  75. * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
  76. * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
  77. * - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
  78. * - ESP_ERR_WIFI_NOT_CONNECT: The station is in disconnect status
  79. * - ESP_ERR_INVALID_ARG: invalid argument
  80. */
  81. esp_err_t esp_wifi_sta_itwt_get_flow_id_status(int *flow_id_bitmap);
  82. /**
  83. * @brief Send probe to update TSF time
  84. *
  85. * @attention In bad network, timeout_ms is variable with the network
  86. *
  87. * @param[in] timeout_ms The estimated time includes sending probe request and receiving probe response, unit: ms.
  88. *
  89. * @return
  90. * - ESP_OK: succeed
  91. * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
  92. * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
  93. * - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
  94. * - ESP_ERR_WIFI_NOT_ASSOC: WiFi is not associated
  95. */
  96. esp_err_t esp_wifi_sta_itwt_send_probe_req(int timeout_ms);
  97. /**
  98. * @brief Set time offset with TBTT of target wake time field in itwt setup request frame.
  99. *
  100. * @param[in] offset_us Offset with TBTT of target wake time field in itwt setup request frame, range is [0, 102400], unit microseconds.
  101. *
  102. * @return
  103. * - ESP_OK: succeed
  104. * - ESP_ERR_WIFI_NOT_INIT: WiFi is not initialized by esp_wifi_init
  105. * - ESP_ERR_WIFI_NOT_STARTED: WiFi is not started by esp_wifi_start
  106. * - ESP_ERR_WIFI_CONN: WiFi internal error, station or soft-AP control block wrong
  107. * - ESP_ERR_WIFI_NOT_ASSOC: WiFi is not associated
  108. * - ESP_ERR_INVALID_ARG: invalid argument
  109. */
  110. esp_err_t esp_wifi_sta_itwt_set_target_wake_time_offset(int offset_us);
  111. /**
  112. * @brief Enable the reception statistics.
  113. *
  114. * @param[in] rx_stats indicate whether enable the reception statistics for HT, HE SU, HE ER SU and legacy
  115. * @param[in] rx_mu_stats indicate whether enable the reception statistics for DL MU-MIMO and DL OFDMA
  116. *
  117. * @return
  118. * - ESP_OK: succeed
  119. * - ESP_ERR_NO_MEM: out of memory
  120. */
  121. esp_err_t esp_wifi_enable_rx_statistics(bool rx_stats, bool rx_mu_stats);
  122. /**
  123. * @brief Enable the transmission statistics.
  124. *
  125. * @param[in] aci access category of the transmission
  126. * @param[in] tx_stats indicate whether enable the transmission statistics
  127. *
  128. * @return
  129. * - ESP_OK: succeed
  130. * - ESP_ERR_NO_MEM: out of memory
  131. */
  132. esp_err_t esp_wifi_enable_tx_statistics(esp_wifi_aci_t aci, bool tx_stats);
  133. #ifdef __cplusplus
  134. }
  135. #endif