mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
Merge branch 'bugfix/multiple_wifi_fixes_v5.0' into 'release/v5.0'
esp_wifi: update wifi lib See merge request espressif/esp-idf!21425
This commit is contained in:
commit
b2396cee86
@ -49,6 +49,8 @@ typedef enum {
|
||||
typedef enum {
|
||||
ESP_BLUFI_STA_CONN_SUCCESS = 0x00,
|
||||
ESP_BLUFI_STA_CONN_FAIL = 0x01,
|
||||
ESP_BLUFI_STA_CONNECTING = 0x02,
|
||||
ESP_BLUFI_STA_NO_IP = 0x03,
|
||||
} esp_blufi_sta_conn_state_t;
|
||||
|
||||
/// BLUFI init status
|
||||
@ -75,6 +77,7 @@ typedef enum {
|
||||
ESP_BLUFI_MAKE_PUBLIC_ERROR,
|
||||
ESP_BLUFI_DATA_FORMAT_ERROR,
|
||||
ESP_BLUFI_CALC_MD5_ERROR,
|
||||
ESP_BLUFI_WIFI_SCAN_FAIL,
|
||||
} esp_blufi_error_state_t;
|
||||
|
||||
/**
|
||||
@ -98,6 +101,12 @@ typedef struct {
|
||||
bool softap_max_conn_num_set; /*!< is max connection number of softap interface set */
|
||||
uint8_t softap_channel; /*!< channel of softap interface */
|
||||
bool softap_channel_set; /*!< is channel of softap interface set */
|
||||
uint8_t sta_max_conn_retry; /*!< max retry of sta establish connection */
|
||||
bool sta_max_conn_retry_set; /*!< is max retry of sta establish connection set */
|
||||
uint8_t sta_conn_end_reason; /*!< reason of sta connection end */
|
||||
bool sta_conn_end_reason_set; /*!< is reason of sta connection end set */
|
||||
int8_t sta_conn_rssi; /*!< rssi of sta connection */
|
||||
bool sta_conn_rssi_set; /*!< is rssi of sta connection set */
|
||||
} esp_blufi_extra_info_t;
|
||||
|
||||
/** @brief Description of an WiFi AP */
|
||||
|
@ -313,6 +313,21 @@ static void btc_blufi_wifi_conn_report(uint8_t opmode, uint8_t sta_conn_state, u
|
||||
*p++ = 1;
|
||||
*p++ = info->softap_channel;
|
||||
}
|
||||
if (info->sta_max_conn_retry_set) {
|
||||
*p++ = BLUFI_TYPE_DATA_SUBTYPE_STA_MAX_CONN_RETRY;
|
||||
*p++ = 1;
|
||||
*p++ = info->sta_max_conn_retry;
|
||||
}
|
||||
if (info->sta_conn_end_reason_set) {
|
||||
*p++ = BLUFI_TYPE_DATA_SUBTYPE_STA_CONN_END_REASON;
|
||||
*p++ = 1;
|
||||
*p++ = info->sta_conn_end_reason;
|
||||
}
|
||||
if (info->sta_conn_rssi_set) {
|
||||
*p++ = BLUFI_TYPE_DATA_SUBTYPE_STA_CONN_RSSI;
|
||||
*p++ = 1;
|
||||
*p++ = info->sta_conn_rssi;
|
||||
}
|
||||
}
|
||||
if (p - data > data_len) {
|
||||
BTC_TRACE_ERROR("%s len error %d %d\n", __func__, (int)(p - data), data_len);
|
||||
@ -706,6 +721,21 @@ void btc_blufi_call_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
dst->wifi_conn_report.extra_info->softap_channel = src_info->softap_channel;
|
||||
dst->wifi_conn_report.extra_info_len += (1 + 2);
|
||||
}
|
||||
if (src_info->sta_max_conn_retry_set) {
|
||||
dst->wifi_conn_report.extra_info->sta_max_conn_retry_set = src_info->sta_max_conn_retry_set;
|
||||
dst->wifi_conn_report.extra_info->sta_max_conn_retry = src_info->sta_max_conn_retry;
|
||||
dst->wifi_conn_report.extra_info_len += (1 + 2);
|
||||
}
|
||||
if (src_info->sta_conn_end_reason_set) {
|
||||
dst->wifi_conn_report.extra_info->sta_conn_end_reason_set = src_info->sta_conn_end_reason_set;
|
||||
dst->wifi_conn_report.extra_info->sta_conn_end_reason = src_info->sta_conn_end_reason;
|
||||
dst->wifi_conn_report.extra_info_len += (1 + 2);
|
||||
}
|
||||
if (src_info->sta_conn_rssi_set) {
|
||||
dst->wifi_conn_report.extra_info->sta_conn_rssi_set = src_info->sta_conn_rssi_set;
|
||||
dst->wifi_conn_report.extra_info->sta_conn_rssi = src_info->sta_conn_rssi;
|
||||
dst->wifi_conn_report.extra_info_len += (1 + 2);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_BLUFI_ACT_SEND_WIFI_LIST:{
|
||||
|
@ -12,7 +12,7 @@
|
||||
#if (BLUFI_INCLUDED == TRUE)
|
||||
|
||||
#define BTC_BLUFI_GREAT_VER 0x01 //Version + Subversion
|
||||
#define BTC_BLUFI_SUB_VER 0x02 //Version + Subversion
|
||||
#define BTC_BLUFI_SUB_VER 0x03 //Version + Subversion
|
||||
#define BTC_BLUFI_VERSION ((BTC_BLUFI_GREAT_VER<<8)|BTC_BLUFI_SUB_VER) //Version + Subversion
|
||||
|
||||
typedef UINT8 tGATT_IF;
|
||||
@ -121,6 +121,9 @@ extern tBLUFI_ENV *blufi_env_ptr;
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_WIFI_LIST 0x11
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_ERROR_INFO 0x12
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_CUSTOM_DATA 0x13
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_STA_MAX_CONN_RETRY 0x14
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_STA_CONN_END_REASON 0x15
|
||||
#define BLUFI_TYPE_DATA_SUBTYPE_STA_CONN_RSSI 0x16
|
||||
#define BLUFI_TYPE_IS_CTRL(type) (BLUFI_GET_TYPE((type)) == BLUFI_TYPE_CTRL)
|
||||
#define BLUFI_TYPE_IS_DATA(type) (BLUFI_GET_TYPE((type)) == BLUFI_TYPE_DATA)
|
||||
|
||||
|
@ -1983,7 +1983,7 @@ ieee80211_raw_frame_sanity_check = 0x400020fc;
|
||||
ieee80211_crypto_aes_128_cmac_encrypt = 0x40002100;
|
||||
ieee80211_alloc_tx_buf = 0x40002108;
|
||||
ieee80211_output_do = 0x4000210c;
|
||||
ieee80211_send_nulldata = 0x40002110;
|
||||
/* ieee80211_send_nulldata = 0x40002110; */
|
||||
ieee80211_setup_robust_mgmtframe = 0x40002114;
|
||||
ieee80211_encap_null_data = 0x4000211c;
|
||||
ieee80211_send_deauth = 0x40002120;
|
||||
|
@ -1732,7 +1732,7 @@ ieee80211_recycle_cache_eb = 0x4000188c;
|
||||
ieee80211_search_node = 0x40001890;
|
||||
roundup2 = 0x40001894;
|
||||
ieee80211_crypto_encap = 0x40001898;
|
||||
ieee80211_crypto_decap = 0x4000189c;
|
||||
/* ieee80211_crypto_decap = 0x4000189c; */
|
||||
/* ieee80211_decap = 0x400018a0; */
|
||||
ieee80211_set_tx_pti = 0x400018a4;
|
||||
wifi_is_started = 0x400018a8;
|
||||
|
@ -2043,7 +2043,7 @@ ieee80211_recycle_cache_eb = 0x40005afc;
|
||||
ieee80211_search_node = 0x40005b08;
|
||||
roundup2 = 0x40005b14;
|
||||
ieee80211_crypto_encap = 0x40005b20;
|
||||
ieee80211_crypto_decap = 0x40005b2c;
|
||||
/* ieee80211_crypto_decap = 0x40005b2c; */
|
||||
/* ieee80211_decap = 0x40005b38; */
|
||||
ieee80211_set_tx_pti = 0x40005b44;
|
||||
wifi_is_started = 0x40005b50;
|
||||
|
@ -10,6 +10,7 @@ menu "Wi-Fi"
|
||||
bool "Software controls WiFi/Bluetooth coexistence"
|
||||
depends on ESP32_WIFI_ENABLED && BT_ENABLED
|
||||
default y
|
||||
select ESP_WIFI_STA_DISCONNECTED_PM_ENABLE
|
||||
help
|
||||
If enabled, WiFi & Bluetooth coexistence is controlled by software rather than hardware.
|
||||
Recommended for heavy traffic scenarios. Both coexistence configuration options are
|
||||
@ -307,6 +308,7 @@ menu "Wi-Fi"
|
||||
|
||||
config ESP_WIFI_STA_DISCONNECTED_PM_ENABLE
|
||||
bool "Power Management for station at disconnected"
|
||||
default y
|
||||
help
|
||||
Select this option to enable power_management for station when disconnected.
|
||||
Chip will do modem-sleep when rf module is not in use any more.
|
||||
|
@ -580,6 +580,8 @@ esp_err_t esp_wifi_get_bandwidth(wifi_interface_t ifx, wifi_bandwidth_t *bw);
|
||||
* @attention 2. When ESP32 is in STA mode, this API should not be called when STA is scanning or connecting to an external AP
|
||||
* @attention 3. When ESP32 is in softAP mode, this API should not be called when softAP has connected to external STAs
|
||||
* @attention 4. When ESP32 is in STA+softAP mode, this API should not be called when in the scenarios described above
|
||||
* @attention 5. The channel info set by this API will not be stored in NVS. So If you want to remeber the channel used before wifi stop,
|
||||
* you need to call this API again after wifi start, or you can call `esp_wifi_set_config()` to store the channel info in NVS.
|
||||
*
|
||||
* @param primary for HT20, primary is the channel number, for HT40, primary is the primary channel
|
||||
* @param second for HT20, second is ignored, for HT40, second is the second channel
|
||||
@ -789,6 +791,7 @@ esp_err_t esp_wifi_get_promiscuous_ctrl_filter(wifi_promiscuous_filter_t *filter
|
||||
* @attention 2. For station configuration, bssid_set needs to be 0; and it needs to be 1 only when users need to check the MAC address of the AP.
|
||||
* @attention 3. ESP32 is limited to only one channel, so when in the soft-AP+station mode, the soft-AP will adjust its channel automatically to be the same as
|
||||
* the channel of the ESP32 station.
|
||||
* @attention 4. The configuration will be stored in NVS
|
||||
*
|
||||
* @param interface interface
|
||||
* @param conf station or soft-AP configuration
|
||||
@ -1224,6 +1227,7 @@ esp_err_t esp_wifi_ftm_resp_set_offset(int16_t offset_cm);
|
||||
*/
|
||||
esp_err_t esp_wifi_config_11b_rate(wifi_interface_t ifx, bool disable);
|
||||
|
||||
#define ESP_WIFI_CONNECTIONLESS_INTERVAL_DEFAULT_MODE 0
|
||||
/**
|
||||
* @brief Set wake interval for connectionless modules to wake up periodically.
|
||||
*
|
||||
@ -1232,6 +1236,7 @@ esp_err_t esp_wifi_config_11b_rate(wifi_interface_t ifx, bool disable);
|
||||
* When ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is enabled, this configuration could work at disconnected status.
|
||||
* @attention 3. Event WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START would be posted each time wake interval starts.
|
||||
* @attention 4. Recommend to configure interval in multiples of hundred. (e.g. 100ms)
|
||||
* @attention 5. Recommend to configure interval to ESP_WIFI_CONNECTIONLESS_INTERVAL_DEFAULT_MODE to get stable performance at coexistence mode.
|
||||
*
|
||||
* @param wake_interval Milliseconds after would the chip wake up, from 1 to 65535.
|
||||
*/
|
||||
|
@ -64,41 +64,62 @@ typedef enum {
|
||||
} wifi_auth_mode_t;
|
||||
|
||||
typedef enum {
|
||||
WIFI_REASON_UNSPECIFIED = 1,
|
||||
WIFI_REASON_AUTH_EXPIRE = 2,
|
||||
WIFI_REASON_AUTH_LEAVE = 3,
|
||||
WIFI_REASON_ASSOC_EXPIRE = 4,
|
||||
WIFI_REASON_ASSOC_TOOMANY = 5,
|
||||
WIFI_REASON_NOT_AUTHED = 6,
|
||||
WIFI_REASON_NOT_ASSOCED = 7,
|
||||
WIFI_REASON_ASSOC_LEAVE = 8,
|
||||
WIFI_REASON_ASSOC_NOT_AUTHED = 9,
|
||||
WIFI_REASON_DISASSOC_PWRCAP_BAD = 10,
|
||||
WIFI_REASON_DISASSOC_SUPCHAN_BAD = 11,
|
||||
WIFI_REASON_BSS_TRANSITION_DISASSOC = 12,
|
||||
WIFI_REASON_IE_INVALID = 13,
|
||||
WIFI_REASON_MIC_FAILURE = 14,
|
||||
WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
|
||||
WIFI_REASON_GROUP_KEY_UPDATE_TIMEOUT = 16,
|
||||
WIFI_REASON_IE_IN_4WAY_DIFFERS = 17,
|
||||
WIFI_REASON_GROUP_CIPHER_INVALID = 18,
|
||||
WIFI_REASON_PAIRWISE_CIPHER_INVALID = 19,
|
||||
WIFI_REASON_AKMP_INVALID = 20,
|
||||
WIFI_REASON_UNSUPP_RSN_IE_VERSION = 21,
|
||||
WIFI_REASON_INVALID_RSN_IE_CAP = 22,
|
||||
WIFI_REASON_802_1X_AUTH_FAILED = 23,
|
||||
WIFI_REASON_CIPHER_SUITE_REJECTED = 24,
|
||||
WIFI_REASON_UNSPECIFIED = 1,
|
||||
WIFI_REASON_AUTH_EXPIRE = 2,
|
||||
WIFI_REASON_AUTH_LEAVE = 3,
|
||||
WIFI_REASON_ASSOC_EXPIRE = 4,
|
||||
WIFI_REASON_ASSOC_TOOMANY = 5,
|
||||
WIFI_REASON_NOT_AUTHED = 6,
|
||||
WIFI_REASON_NOT_ASSOCED = 7,
|
||||
WIFI_REASON_ASSOC_LEAVE = 8,
|
||||
WIFI_REASON_ASSOC_NOT_AUTHED = 9,
|
||||
WIFI_REASON_DISASSOC_PWRCAP_BAD = 10,
|
||||
WIFI_REASON_DISASSOC_SUPCHAN_BAD = 11,
|
||||
WIFI_REASON_BSS_TRANSITION_DISASSOC = 12,
|
||||
WIFI_REASON_IE_INVALID = 13,
|
||||
WIFI_REASON_MIC_FAILURE = 14,
|
||||
WIFI_REASON_4WAY_HANDSHAKE_TIMEOUT = 15,
|
||||
WIFI_REASON_GROUP_KEY_UPDATE_TIMEOUT = 16,
|
||||
WIFI_REASON_IE_IN_4WAY_DIFFERS = 17,
|
||||
WIFI_REASON_GROUP_CIPHER_INVALID = 18,
|
||||
WIFI_REASON_PAIRWISE_CIPHER_INVALID = 19,
|
||||
WIFI_REASON_AKMP_INVALID = 20,
|
||||
WIFI_REASON_UNSUPP_RSN_IE_VERSION = 21,
|
||||
WIFI_REASON_INVALID_RSN_IE_CAP = 22,
|
||||
WIFI_REASON_802_1X_AUTH_FAILED = 23,
|
||||
WIFI_REASON_CIPHER_SUITE_REJECTED = 24,
|
||||
WIFI_REASON_TDLS_PEER_UNREACHABLE = 25,
|
||||
WIFI_REASON_TDLS_UNSPECIFIED = 26,
|
||||
WIFI_REASON_SSP_REQUESTED_DISASSOC = 27,
|
||||
WIFI_REASON_NO_SSP_ROAMING_AGREEMENT = 28,
|
||||
WIFI_REASON_BAD_CIPHER_OR_AKM = 29,
|
||||
WIFI_REASON_NOT_AUTHORIZED_THIS_LOCATION = 30,
|
||||
WIFI_REASON_SERVICE_CHANGE_PERCLUDES_TS = 31,
|
||||
WIFI_REASON_UNSPECIFIED_QOS = 32,
|
||||
WIFI_REASON_NOT_ENOUGH_BANDWIDTH = 33,
|
||||
WIFI_REASON_MISSING_ACKS = 34,
|
||||
WIFI_REASON_EXCEEDED_TXOP = 35,
|
||||
WIFI_REASON_STA_LEAVING = 36,
|
||||
WIFI_REASON_END_BA = 37,
|
||||
WIFI_REASON_UNKNOWN_BA = 38,
|
||||
WIFI_REASON_TIMEOUT = 39,
|
||||
WIFI_REASON_PEER_INITIATED = 46,
|
||||
WIFI_REASON_AP_INITIATED = 47,
|
||||
WIFI_REASON_INVALID_FT_ACTION_FRAME_COUNT = 48,
|
||||
WIFI_REASON_INVALID_PMKID = 49,
|
||||
WIFI_REASON_INVALID_MDE = 50,
|
||||
WIFI_REASON_INVALID_FTE = 51,
|
||||
WIFI_REASON_TRANSMISSION_LINK_ESTABLISH_FAILED = 67,
|
||||
WIFI_REASON_ALTERATIVE_CHANNEL_OCCUPIED = 68,
|
||||
|
||||
WIFI_REASON_INVALID_PMKID = 53,
|
||||
|
||||
WIFI_REASON_BEACON_TIMEOUT = 200,
|
||||
WIFI_REASON_NO_AP_FOUND = 201,
|
||||
WIFI_REASON_AUTH_FAIL = 202,
|
||||
WIFI_REASON_ASSOC_FAIL = 203,
|
||||
WIFI_REASON_HANDSHAKE_TIMEOUT = 204,
|
||||
WIFI_REASON_CONNECTION_FAIL = 205,
|
||||
WIFI_REASON_AP_TSF_RESET = 206,
|
||||
WIFI_REASON_ROAMING = 207,
|
||||
WIFI_REASON_BEACON_TIMEOUT = 200,
|
||||
WIFI_REASON_NO_AP_FOUND = 201,
|
||||
WIFI_REASON_AUTH_FAIL = 202,
|
||||
WIFI_REASON_ASSOC_FAIL = 203,
|
||||
WIFI_REASON_HANDSHAKE_TIMEOUT = 204,
|
||||
WIFI_REASON_CONNECTION_FAIL = 205,
|
||||
WIFI_REASON_AP_TSF_RESET = 206,
|
||||
WIFI_REASON_ROAMING = 207,
|
||||
} wifi_err_reason_t;
|
||||
|
||||
typedef enum {
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit a0aaa5ae6bd26caea68175a3d5e4dbe2cef8a35d
|
||||
Subproject commit b10fa11471b69b82f9599aa2941e1c353bd517c1
|
@ -321,11 +321,11 @@ The format of ACK Frame:
|
||||
* 0x02: SoftAP
|
||||
* 0x03: SoftAP & STA
|
||||
|
||||
data[1]: connection state of the STA device. 0x0 indicates a connection state, and others represent a disconnected state;
|
||||
data[1]: connection state of the STA device. 0x0 indicates a connection state with IP address, 0x1 represent a disconnected state, 0x2 indicates a connecting state, and 0x3 indicates a connection state but no IP address.
|
||||
|
||||
data[2]: connection state of SoftAP. That is, how many STA devices have been connected.
|
||||
|
||||
data[3] and the subsequent is in accordance with the format of SSID/BSSID information.
|
||||
data[3] and the subsequent is in accordance with the format of SSID/BSSID information. If device is in connecting state, maximum Wi-Fi reconnecting time would be included here. If device is in disconnected state, Wi-Fi connection end reason and RSSI would be included here.
|
||||
* - 0x10 (b’010000)
|
||||
- Version
|
||||
-
|
||||
@ -347,10 +347,25 @@ The format of ACK Frame:
|
||||
* 0x06: dh param error
|
||||
* 0x07: read param error
|
||||
* 0x08: make public error
|
||||
* 0x09: data format error
|
||||
* 0x0a: calculate MD5 error
|
||||
* 0x0b: Wi-Fi scan error
|
||||
* - 0x13 (b’010011)
|
||||
- Custom Data
|
||||
- To send or receive custom data.
|
||||
- The data frame supports to be sent into fragments if the data length is too long.
|
||||
* - 0x14 (b’010100)
|
||||
- Set the maximum Wi-Fi reconnecting time.
|
||||
-
|
||||
- data[0] represents the maximum Wi-Fi reconnecting time.
|
||||
* - 0x15 (b’010101)
|
||||
- Set the Wi-Fi connection end reason.
|
||||
-
|
||||
- data[0] represents the Wi-Fi connection end reason, whose type shall be same with struct `wifi_err_reason_t`.
|
||||
* - 0x16 (b’010110)
|
||||
- Set the RSSI at Wi-Fi connection end.
|
||||
-
|
||||
- data[0] represents the RSSI at Wi-Fi connection end. If there is no meaningful RSSI in the connection end, this value shall be the meaningless one, which is `-128`.
|
||||
|
||||
.. note::
|
||||
|
||||
|
@ -27,13 +27,13 @@ Supported Coexistence Scenario for {IDF_TARGET_NAME}
|
||||
+ +--------+-----------+-----+------------+-----------+----------+
|
||||
| |SOFTAP |TX Beacon |Y |Y |Y |Y |
|
||||
+ + +-----------+-----+------------+-----------+----------+
|
||||
| | |Connecting |Y |Y |Y |Y |
|
||||
| | |Connecting |C1 |C1 |C1 |C1 |
|
||||
+ + +-----------+-----+------------+-----------+----------+
|
||||
| | |Connected |C1 |C1 |C1 |C1 |
|
||||
+ +--------+-----------+-----+------------+-----------+----------+
|
||||
| |Sniffer |RX |C2 |C2 |C2 |C2 |
|
||||
| |Sniffer |RX |C1 |C1 |C1 |C1 |
|
||||
+ +--------+-----------+-----+------------+-----------+----------+
|
||||
| |ESP-NOW |RX |X |X |X |X |
|
||||
| |ESP-NOW |RX |S |S |S |S |
|
||||
+ + +-----------+-----+------------+-----------+----------+
|
||||
| | |TX |Y |Y |Y |Y |
|
||||
+-------+--------+-----------+-----+------------+-----------+----------+
|
||||
@ -56,13 +56,13 @@ Supported Coexistence Scenario for {IDF_TARGET_NAME}
|
||||
+ +--------+-----------+--------+-------------+-----+----------+-----------+
|
||||
| |SOFTAP |TX Beacon |Y |Y |Y |Y |Y |
|
||||
+ + +-----------+--------+-------------+-----+----------+-----------+
|
||||
| | |Connecting |Y |Y |Y |Y |Y |
|
||||
| | |Connecting |C1 |C1 |C1 |C1 |C1 |
|
||||
+ + +-----------+--------+-------------+-----+----------+-----------+
|
||||
| | |Connected |C1 |C1 |C1 |C1 |C1 |
|
||||
+ +--------+-----------+--------+-------------+-----+----------+-----------+
|
||||
| |Sniffer |RX |C2 |C2 |C2 |C2 |C2 |
|
||||
| |Sniffer |RX |C1 |C1 |C1 |C1 |C1 |
|
||||
+ +--------+-----------+--------+-------------+-----+----------+-----------+
|
||||
| |ESP-NOW |RX |X |X |X |X |X |
|
||||
| |ESP-NOW |RX |S |S |S |S |S |
|
||||
+ + +-----------+--------+-------------+-----+----------+-----------+
|
||||
| | |TX |Y |Y |Y |Y |Y |
|
||||
+-------+--------+-----------+--------+-------------+-----+----------+-----------+
|
||||
@ -72,9 +72,8 @@ Supported Coexistence Scenario for {IDF_TARGET_NAME}
|
||||
|
||||
Y: supported and performance is stable
|
||||
C1: supported but the performance is unstable
|
||||
C2: supported but the packet loss rate of Sniffer is unstable
|
||||
X: not supported
|
||||
|
||||
S: supported and performance is stable in STA mode, otherwise not supported
|
||||
|
||||
Coexistence Mechanism and Policy
|
||||
------------------------------------------------
|
||||
@ -152,6 +151,16 @@ Dynamic Priority
|
||||
|
||||
The coexistence module assigns different priorities to different status of Wi-Fi and Bluetooth. And the priority for each status is dynamic. For example, in every N BLE Advertising events, there is always one event with high priority. If a high-priority BLE Advertising event occurs within the Wi-Fi time slice, the right to use the RF may be preempted by BLE.
|
||||
|
||||
.. only:: SOC_WIFI_SUPPORTED
|
||||
|
||||
Wi-Fi Connectionless Modules Coexistence
|
||||
""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
To some extent, some combinations of connectionless power-saving parameters `Window` and `Interval` would lead to extra Wi-Fi priority request out of Wi-Fi time slice. It`s for obtaining RF resources at coexistence for customized parameters, while leading to impact on Bluetooth performance.
|
||||
|
||||
If connectionless power-saving parameters are configured with default values, the coexistence module would perform in stable mode and the behaviour above would not happen. So please configure Wi-Fi connectionless power-saving parameters to default values unless you have plenty of coexistence performance tests for customized parameters.
|
||||
|
||||
Please refer to :ref:`connectionless module power save <connectionless-module-power-save>` to get more detail.
|
||||
|
||||
How to Use the Coexistence Feature
|
||||
--------------------------------------
|
||||
|
@ -266,6 +266,11 @@ WIFI_EVENT_STA_BEACON_TIMEOUT
|
||||
|
||||
If the station does not receive the beacon of the connected AP within the inactive time, the beacon timeout happens, the `WIFI_EVENT_STA_BEACON_TIMEOUT`_ will arise. The application can set inactive time via API :cpp:func:`esp_wifi_set_inactive_time()`.
|
||||
|
||||
WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START
|
||||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
The `WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START`_ will arise at the start of connectionless module `Interval`. See :ref:`connectionless module power save <connectionless-module-power-save>`.
|
||||
|
||||
{IDF_TARGET_NAME} Wi-Fi Station General Scenario
|
||||
------------------------------------------------
|
||||
Below is a "big scenario" which describes some small scenarios in station mode:
|
||||
@ -767,7 +772,7 @@ Four-way Handshake Phase
|
||||
Wi-Fi Reason Code
|
||||
+++++++++++++++++++++
|
||||
|
||||
The table below shows the reason code defined in {IDF_TARGET_NAME}. The first column is the macro name defined in esp_wifi_types.h. The common prefix *WIFI_REASON* is removed, which means that *UNSPECIFIED* actually stands for *WIFI_REASON_UNSPECIFIED* and so on. The second column is the value of the reason. The third column is the standard value to which this reason is mapped in section 8.4.1.7 of IEEE 802.11-2012 (For more information, refer to the standard mentioned above). The last column describes the reason.
|
||||
The table below shows the reason-code defined in {IDF_TARGET_NAME}. The first column is the macro name defined in esp_wifi_types.h. The common prefix *WIFI_REASON* is removed, which means that *UNSPECIFIED* actually stands for *WIFI_REASON_UNSPECIFIED* and so on. The second column is the value of the reason. The third column is the standard value to which this reason is mapped in section 9.4.1.7 of IEEE 802.11-2020. (For more information, refer to the standard mentioned above.) The last column describes the reason.
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
@ -996,6 +1001,102 @@ The table below shows the reason code defined in {IDF_TARGET_NAME}. The first co
|
||||
For the ESP station, this reason is reported when:
|
||||
|
||||
- it is received from the AP.
|
||||
* - TDLS_PEER_UNREACHABLE
|
||||
- 25
|
||||
- 25
|
||||
- TDLS direct-link teardown due to TDLS peer STA unreachable via the TDLS direct link.
|
||||
* - TDLS_UNSPECIFIED
|
||||
- 26
|
||||
- 26
|
||||
- TDLS direct-link teardown for unspecified reason.
|
||||
* - SSP_REQUESTED_DISASSOC
|
||||
- 27
|
||||
- 27
|
||||
- Disassociated because session terminated by SSP request.
|
||||
* - NO_SSP_ROAMING_AGREEMENT
|
||||
- 28
|
||||
- 28
|
||||
- Disassociated because of lack of SSP roaming agreement.
|
||||
* - BAD_CIPHER_OR_AKM
|
||||
- 29
|
||||
- 29
|
||||
- Requested service rejected because of SSP cipher suite or AKM requirement.
|
||||
* - NOT_AUTHORIZED_THIS_LOCATION
|
||||
- 30
|
||||
- 30
|
||||
- Requested service not authorized in this location.
|
||||
* - SERVICE_CHANGE_PRECLUDES_TS
|
||||
- 31
|
||||
- 31
|
||||
- TS deleted because QoS AP lacks sufficient bandwidth for this QoS STA due to a change in BSS service characteristics or operational mode (e.g., an HT BSS change from 40 MHz channel to 20 MHz channel).
|
||||
* - UNSPECIFIED_QOS
|
||||
- 32
|
||||
- 32
|
||||
- Disassociated for unspecified, QoS-related reason.
|
||||
* - NOT_ENOUGH_BANDWIDTH
|
||||
- 33
|
||||
- 33
|
||||
- Disassociated because QoS AP lacks sufficient bandwidth for this QoS STA.
|
||||
* - MISSING_ACKS
|
||||
- 34
|
||||
- 34
|
||||
- Disassociated because excessive number of frames need to be acknowledged, but are not acknowledged due to AP transmissions and/or poor channel conditions.
|
||||
* - EXCEEDED_TXOP
|
||||
- 35
|
||||
- 35
|
||||
- Disassociated because STA is transmitting outside the limits of its TXOPs.
|
||||
* - STA_LEAVING
|
||||
- 36
|
||||
- 36
|
||||
- Requesting STA is leaving the BSS (or resetting).
|
||||
* - END_BA
|
||||
- 37
|
||||
- 37
|
||||
- Requesting STA is no longer using the stream or session.
|
||||
* - UNKNOWN_BA
|
||||
- 38
|
||||
- 38
|
||||
- Requesting STA received frames using a mechanism for which a setup has not been completed.
|
||||
* - TIMEOUT
|
||||
- 39
|
||||
- 39
|
||||
- Requested from peer STA due to timeout
|
||||
* - Reserved
|
||||
- 40 ~ 45
|
||||
- 40 ~ 45
|
||||
-
|
||||
* - PEER_INITIATED
|
||||
- 46
|
||||
- 46
|
||||
- In a Disassociation frame: Disassociated because authorized access limit reached.
|
||||
* - AP_INITIATED
|
||||
- 47
|
||||
- 47
|
||||
- In a Disassociation frame: Disassociated due to external service requirements.
|
||||
* - INVALID_FT_ACTION_FRAME_COUNT
|
||||
- 48
|
||||
- 48
|
||||
- Invalid FT Action frame count.
|
||||
* - INVALID_PMKID
|
||||
- 49
|
||||
- 49
|
||||
- Invalid pairwise master key identifier (PMKID).
|
||||
* - INVALID_MDE
|
||||
- 50
|
||||
- 50
|
||||
- Invalid MDE.
|
||||
* - INVALID_FTE
|
||||
- 51
|
||||
- 51
|
||||
- Invalid FTE
|
||||
* - TRANSMISSION_LINK_ESTABLISHMENT_FAILED
|
||||
- 67
|
||||
- 67
|
||||
- Transmission link establishment in alternative channel failed.
|
||||
* - ALTERATIVE_CHANNEL_OCCUPIED
|
||||
- 68
|
||||
- 68
|
||||
- The alternative channel is occupied.
|
||||
* - BEACON_TIMEOUT
|
||||
- 200
|
||||
- reserved
|
||||
@ -1022,6 +1123,51 @@ The table below shows the reason code defined in {IDF_TARGET_NAME}. The first co
|
||||
- Espressif-specific Wi-Fi reason code: the connection to the AP has failed.
|
||||
|
||||
|
||||
Wi-Fi Reason code related to wrong password
|
||||
++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
The table below shows the Wi-Fi reason-code may related to wrong password.
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
:widths: 5 10 40
|
||||
|
||||
* - Reason code
|
||||
- Value
|
||||
- Description
|
||||
* - 4WAY_HANDSHAKE_TIMEOUT
|
||||
- 15
|
||||
- Four-way handshake times out. Setting wrong password when STA connecting to an encrpyted AP.
|
||||
* - NO_AP_FOUND
|
||||
- 201
|
||||
- This may related to wrong password in the two scenarios:
|
||||
|
||||
- Setting password when STA connecting to an unencrypted AP.
|
||||
- Doesn't setting password when STA connecting to an encrypted AP.
|
||||
* - HANDSHAKE_TIMEOUT
|
||||
- 204
|
||||
- Four-way handshake fails.
|
||||
|
||||
Wi-Fi Reason code related to low RSSI
|
||||
++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
The table below shows the Wi-Fi reason-code may related to low RSSI.
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
:widths: 5 10 40
|
||||
|
||||
* - Reason code
|
||||
- Value
|
||||
- Description
|
||||
* - NO_AP_FOUND
|
||||
- 201
|
||||
- The station fails to scan the target AP due to low RSSI
|
||||
* - HANDSHAKE_TIMEOUT
|
||||
- 204
|
||||
- Four-way handshake fails.
|
||||
|
||||
|
||||
{IDF_TARGET_NAME} Wi-Fi Station Connecting When Multiple APs Are Found
|
||||
----------------------------------------------------------------------
|
||||
|
||||
@ -1076,7 +1222,7 @@ Call :cpp:func:`esp_wifi_set_mode()` to set the Wi-Fi mode.
|
||||
Station Basic Configuration
|
||||
+++++++++++++++++++++++++++++++++++++
|
||||
|
||||
API esp_wifi_set_config() can be used to configure the station. The table below describes the fields in detail.
|
||||
API :cpp:func:`esp_wifi_set_config()` can be used to configure the station. And the configuration will be stored in NVS. The table below describes the fields in detail.
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
@ -1115,7 +1261,7 @@ API esp_wifi_set_config() can be used to configure the station. The table below
|
||||
AP Basic Configuration
|
||||
+++++++++++++++++++++++++++++++++++++
|
||||
|
||||
API esp_wifi_set_config() can be used to configure the AP. The table below describes the fields in detail.
|
||||
API :cpp:func:`esp_wifi_set_config()` can be used to configure the AP. And the configuration will be stored in NVS. The table below describes the fields in detail.
|
||||
|
||||
.. only:: esp32 or esp32s2 or esp32c3 or esp32s3
|
||||
|
||||
@ -1496,6 +1642,81 @@ Currently, {IDF_TARGET_NAME} AP does not support all of the power-saving feature
|
||||
|
||||
In the future, all power-saving features will be supported on {IDF_TARGET_NAME} AP.
|
||||
|
||||
Disconnected State Sleep
|
||||
+++++++++++++++++++++++++++++++
|
||||
|
||||
Disconnected state is the duration without Wi-Fi connection between :cpp:func:`esp_wifi_start` to :cpp:func:`esp_wifi_stop`.
|
||||
|
||||
Currently, {IDF_TARGET_NAME} Wi-Fi supports sleep mode in disconnected state if running at station mode. This feature could be configured by Menuconfig choice :ref:`CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE`.
|
||||
|
||||
If :ref:`CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE` is enabled, RF, PHY and BB would be turned off in disconnected state when IDLE. The current would be same with current at modem-sleep.
|
||||
|
||||
The choice :ref:`CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE` would be selected by default, while it would be selected forcefully in Menuconfig at coexistence mode.
|
||||
|
||||
.. _connectionless-module-power-save:
|
||||
|
||||
Connectionless Modules Power-saving
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
Connectionless modules are those Wi-Fi modules not relying on Wi-Fi connection, e.g ESP-NOW, DPP, FTM. These modules start from :cpp:func:`esp_wifi_start`, working until :cpp:func:`esp_wifi_stop`.
|
||||
|
||||
Currently, if ESP-NOW works at station mode, its supported to sleep at both connected state and disconnected state.
|
||||
|
||||
Connectionless Modules TX
|
||||
*******************************
|
||||
|
||||
For each connectionless module, its supported to TX at any sleeping time without any extra configuration.
|
||||
|
||||
Meanwhile, :cpp:func:`esp_wifi_80211_tx` is supported at sleep as well.
|
||||
|
||||
Connectionless Modules RX
|
||||
*******************************
|
||||
|
||||
For each connectionless module, two parameters shall be configured to RX at sleep, which are `Window` and `Interval`.
|
||||
|
||||
At the start of `Interval` time, RF, PHY, BB would be turned on and kept for `Window` time. Connectionless Module could RX in the duration.
|
||||
|
||||
**Interval**
|
||||
|
||||
- There is only one `Interval`. Its configured by :cpp:func:`esp_wifi_set_connectionless_interval`. The unit is milliseconds.
|
||||
|
||||
- The default value of `Interval` is `ESP_WIFI_CONNECTIONLESS_INTERVAL_DEFAULT_MODE`.
|
||||
|
||||
- Event `WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START`_ would be posted at the start of `Interval`. Since `Window` also starts at that momemt, its recommended to TX in that event.
|
||||
|
||||
- At connected state, the start of `Interval` would be aliged with TBTT.
|
||||
|
||||
**Window**
|
||||
|
||||
- Each connectionless module has its own `Window` after start. Connectionless Modules Power-saving would work with the max one among them.
|
||||
|
||||
- `Window` is configured by :cpp:func:`module_name_set_wake_window`. The unit is milliseconds.
|
||||
|
||||
- The default value of `Window` is the maximum.
|
||||
|
||||
.. table:: RF, PHY and BB usage under different circumstances
|
||||
|
||||
+----------------------+-------------------------------------------------+---------------------------------------------------------------------------+
|
||||
| | Interval |
|
||||
+ +-------------------------------------------------+---------------------------------------------------------------------------+
|
||||
| | ESP_WIFI_CONNECTIONLESS_INTERVAL_DEFAULT_MODE | 1 - maximum |
|
||||
+--------+-------------+-------------------------------------------------+---------------------------------------------------------------------------+
|
||||
| Window | 0 | not used |
|
||||
+ +-------------+-------------------------------------------------+---------------------------------------------------------------------------+
|
||||
| | 1 - maximum | default mode | used periodically (Window < Interval) / used all time (Window ≥ Interval) |
|
||||
+--------+-------------+-------------------------------------------------+---------------------------------------------------------------------------+
|
||||
|
||||
Default mode
|
||||
*******************************
|
||||
|
||||
If `Interval` is `ESP_WIFI_CONNECTIONLESS_INTERVAL_DEFAULT_MODE` with non-zero `Window`, Connectionless Modules Power-saving would work in default mode.
|
||||
|
||||
In default mode, RF, PHY, BB would be kept on if no coexistence with non-Wi-Fi protocol.
|
||||
|
||||
With coexistence, RF, PHY, BB resources are allocated by coexistence module to Wi-Fi connectionless module and non-Wi-Fi module, using time-division method. In default mode, Wi-Fi connectionless module is allowed to use RF, BB, PHY periodically under a stable performance.
|
||||
|
||||
Its recommended to configure Connectionless Modules Power-saving to default mode if there is Wi-Fi connectionless module coexists with non-Wi-Fi module.
|
||||
|
||||
{IDF_TARGET_NAME} Wi-Fi Throughput
|
||||
-----------------------------------
|
||||
|
||||
|
@ -98,6 +98,19 @@ Config ESP-NOW Rate
|
||||
|
||||
Call :cpp:func:`esp_wifi_config_espnow_rate()` to config ESPNOW rate of specified interface. Make sure that the interface is enabled before config rate. This API should be called after :cpp:func:`esp_wifi_start()`.
|
||||
|
||||
Config ESP-NOW Power-saving Parameter
|
||||
--------------------------------------------
|
||||
|
||||
Sleep is supported only when {IDF_TARGET_NAME} is configured as station.
|
||||
|
||||
Call :cpp:func:`esp_now_set_wake_window()` to configure Window for ESP-NOW RX at sleep. The default value is the maximum, which allowing RX all the time.
|
||||
|
||||
If Power-saving is needed for ESP-NOW, call :cpp:func:`esp_wifi_connectionless_module_set_wake_interval()` to configure Interval as well.
|
||||
|
||||
.. only:: SOC_WIFI_SUPPORTED
|
||||
|
||||
Please refer to :ref:`connectionless module power save <connectionless-module-power-save>` to get more detail.
|
||||
|
||||
Application Examples
|
||||
--------------------
|
||||
|
||||
|
@ -321,11 +321,11 @@ ACK 帧格式(8 bit):
|
||||
* 0x02: SoftAP
|
||||
* 0x03: SoftAP & STA
|
||||
|
||||
data[1]:STA 设备的连接状态。0x0 表示处于连接状态,其他表示处于非连接状态;
|
||||
data[1]:STA 设备的连接状态。0x0 表示处于连接状态且获得 IP 地址,0x1 表示处于非连接状态, 0x2 表示处于正在连接状态,0x3 表示处于连接状态但未获得 IP 地址。
|
||||
|
||||
data[2]:SoftAP 的连接状态,即表示有多少 STA 设备已经连接。
|
||||
|
||||
data[3]及后面的数据是按照 SSID/BSSID 格式提供的信息。
|
||||
data[3]及后面的数据是按照 SSID/BSSID 格式提供的信息。 如果 Wi-Fi 处于正在连接状态,这里将会包含最大重连次数;如果 Wi-Fi 处于非连接状态,这里将会包含 Wi-Fi 断开连接原因和 RSSI 信息。
|
||||
* - 0x10 (b’010000)
|
||||
- 版本
|
||||
-
|
||||
@ -347,10 +347,25 @@ ACK 帧格式(8 bit):
|
||||
* 0x06: dh param error
|
||||
* 0x07: read param error
|
||||
* 0x08: make public error
|
||||
* 0x09: data format error
|
||||
* 0x0a: calculate MD5 error
|
||||
* 0x0b: Wi-Fi scan error
|
||||
* - 0x13 (b’010011)
|
||||
- 自定义数据
|
||||
- 用户发送或者接收自定义数据。
|
||||
- 数据较长时可分片发送。
|
||||
* - 0x14 (b’010100)
|
||||
- 设置最大 Wi-Fi 重连次数。
|
||||
-
|
||||
- data[0] 表示 Wi-Fi 最大重连次数。
|
||||
* - 0x15 (b’010101)
|
||||
- 设置 Wi-Fi 连接失败原因。
|
||||
-
|
||||
- data[0] 表示 Wi-Fi 连接失败原因,它的类型应该和 `wifi_err_reason_t` 一致。
|
||||
* - 0x16 (b’010110)
|
||||
- 设置 Wi-Fi 连接失败的 RSSI 。
|
||||
-
|
||||
- data[0] 表示在 Wi-Fi 连接失败时的 RSSI。 如果在连接结束时没有有意义的 RSSI , 这个值应该为一个无意义值 `-128`。
|
||||
|
||||
.. note::
|
||||
|
||||
|
@ -27,13 +27,13 @@ RF 共存
|
||||
+ +--------+-----------+-----+------------+-----------+----------+
|
||||
| |SOFTAP |TX Beacon |Y |Y |Y |Y |
|
||||
+ + +-----------+-----+------------+-----------+----------+
|
||||
| | |Connecting |Y |Y |Y |Y |
|
||||
| | |Connecting |C1 |C1 |C1 |C1 |
|
||||
+ + +-----------+-----+------------+-----------+----------+
|
||||
| | |Connected |C1 |C1 |C1 |C1 |
|
||||
+ +--------+-----------+-----+------------+-----------+----------+
|
||||
| |Sniffer |RX |C2 |C2 |C2 |C2 |
|
||||
| |Sniffer |RX |C1 |C1 |C1 |C1 |
|
||||
+ +--------+-----------+-----+------------+-----------+----------+
|
||||
| |ESP-NOW |RX |X |X |X |X |
|
||||
| |ESP-NOW |RX |S |S |S |S |
|
||||
+ + +-----------+-----+------------+-----------+----------+
|
||||
| | |TX |Y |Y |Y |Y |
|
||||
+-------+--------+-----------+-----+------------+-----------+----------+
|
||||
@ -56,13 +56,13 @@ RF 共存
|
||||
+ +--------+-----------+--------+-------------+-----+----------+-----------+
|
||||
| |SOFTAP |TX Beacon |Y |Y |Y |Y |Y |
|
||||
+ + +-----------+--------+-------------+-----+----------+-----------+
|
||||
| | |Connecting |Y |Y |Y |Y |Y |
|
||||
| | |Connecting |C1 |C1 |C1 |C1 |C1 |
|
||||
+ + +-----------+--------+-------------+-----+----------+-----------+
|
||||
| | |Connected |C1 |C1 |C1 |C1 |C1 |
|
||||
+ +--------+-----------+--------+-------------+-----+----------+-----------+
|
||||
| |Sniffer |RX |C2 |C2 |C2 |C2 |C2 |
|
||||
| |Sniffer |RX |C1 |C1 |C1 |C1 |C1 |
|
||||
+ +--------+-----------+--------+-------------+-----+----------+-----------+
|
||||
| |ESP-NOW |RX |X |X |X |X |X |
|
||||
| |ESP-NOW |RX |S |S |S |S |S |
|
||||
+ + +-----------+--------+-------------+-----+----------+-----------+
|
||||
| | |TX |Y |Y |Y |Y |Y |
|
||||
+-------+--------+-----------+--------+-------------+-----+----------+-----------+
|
||||
@ -72,8 +72,8 @@ RF 共存
|
||||
|
||||
Y:支持且性能稳定。
|
||||
C1:不能保证性能处于稳定状态。
|
||||
C2:sniffer 无法保证丢包率。
|
||||
X:不支持。
|
||||
S:在STA模式下支持且性能稳定,否则不支持。
|
||||
|
||||
|
||||
共存机制与策略
|
||||
@ -152,6 +152,16 @@ RF 共存
|
||||
|
||||
共存模块对 Wi-Fi 和 Bluetooth 不同的状态赋予其不同的优先级。每种状态下的优先级并不是一成不变的,例如每 N 个广播事件 (Advertising event) 中会有一个广播事件使用高优先级。如果高优先级的广播事件发生在 Wi-Fi 时间片内,RF 的使用权可能会被 BLE 抢占。
|
||||
|
||||
.. only:: SOC_WIFI_SUPPORTED
|
||||
|
||||
Wi-Fi 非连接模块的共存
|
||||
""""""""""""""""""""""""""""
|
||||
|
||||
在一定程度上,某些 Wi-Fi 非连接模块功耗参数 Window 与 Interval 的组合会导致共存模块在 Wi-Fi 时间片外申请共存优先级。这是为了按设定的功耗参数在共存时获取 RF 资源,但这会影响既定的蓝牙性能。
|
||||
|
||||
如果 Wi-Fi 非连接模块功耗参数为默认值时,上述动作不会发生,共存模块会按照性能稳定的模式运行。因此,除非您对特定非连接功耗参数下的共存性能有足够的测试,请在共存场景下将 Wi-Fi 非连接模块功耗参数配置为默认参数。
|
||||
|
||||
请参考 :ref:`非连接模块功耗管理 <connectionless-module-power-save-cn>` 获取更多信息。
|
||||
|
||||
如何使用共存功能
|
||||
----------------------------------
|
||||
|
@ -266,6 +266,11 @@ WIFI_EVENT_STA_BEACON_TIMEOUT
|
||||
|
||||
如果 station 在 inactive 时间内未收到所连接 AP 的 beacon,将发生 beacon 超时,将引发此事件。inactive 时间通过调用函数 :cpp:func:`esp_wifi_set_inactive_time()` 设置。
|
||||
|
||||
WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START
|
||||
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
非连接模块在 `Interval` 开始时触发此事件。 请参考 :ref:`非连接模块功耗管理 <connectionless-module-power-save-cn>` 。
|
||||
|
||||
{IDF_TARGET_NAME} Wi-Fi station 一般情况
|
||||
------------------------------------------------
|
||||
下图为 station 模式下的宏观场景,其中包含不同阶段的具体描述:
|
||||
@ -767,7 +772,7 @@ Wi-Fi 驱动程序内部扫描阶段
|
||||
Wi-Fi 原因代码
|
||||
+++++++++++++++++++++
|
||||
|
||||
下表罗列了 {IDF_TARGET_NAME} 中定义的原因代码。其中,第一列为 esp_wifi_types.h 中定义的宏名称。名称中省去了前缀 *WIFI_REASON*,也就是说,名称 *UNSPECIFIED* 实际应为 *WIFI_REASON_UNSPECIFIED*,以此类推。第二列为原因代码的相应数值。第三列为该原因映射到 IEEE 802.11-2012 中 8.4.1.7 段的标准值。(更多详细信息,请参阅前文描述。)最后一列为这一原因的描述。
|
||||
下表罗列了 {IDF_TARGET_NAME} 中定义的原因代码。其中,第一列为 esp_wifi_types.h 中定义的宏名称。名称中省去了前缀 *WIFI_REASON*,也就是说,名称 *UNSPECIFIED* 实际应为 *WIFI_REASON_UNSPECIFIED*,以此类推。第二列为原因代码的相应数值。第三列为该原因映射到 IEEE 802.11-2020 中 9.4.1.7 段的标准值。(更多详细信息,请参阅前文描述。)最后一列为这一原因的描述。
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
@ -996,6 +1001,102 @@ Wi-Fi 原因代码
|
||||
对于 ESP station,出现以下情况时报告该代码:
|
||||
|
||||
- 从 AP 接收到该代码。
|
||||
* - TDLS_PEER_UNREACHABLE
|
||||
- 25
|
||||
- 25
|
||||
- 通过 TDLS 直连无法到达TDLS 对端 STA,导致 TDLS 直连中断。
|
||||
* - TDLS_UNSPECIFIED
|
||||
- 26
|
||||
- 26
|
||||
- 不明原因的 TDLS 直连中断。
|
||||
* - SSP_REQUESTED_DISASSOC
|
||||
- 27
|
||||
- 27
|
||||
- association 取消,由于会话被 SSP request 终止。
|
||||
* - NO_SSP_ROAMING_AGREEMENT
|
||||
- 28
|
||||
- 28
|
||||
- association 取消,由于缺乏 SSP 漫游认证。
|
||||
* - BAD_CIPHER_OR_AKM
|
||||
- 29
|
||||
- 29
|
||||
- 请求的服务被拒绝,由于 SSP 密码套件或者 AKM 的需求。
|
||||
* - NOT_AUTHORIZED_THIS_LO CATION
|
||||
- 30
|
||||
- 30
|
||||
- 请求的服务在此位置未得到授权。
|
||||
* - SERVICE_CHANGE_PRECLUDES_TS
|
||||
- 31
|
||||
- 31
|
||||
- TS 被删除,原因是:BSS 服务特性或者运行模式改变导致 Qos AP 缺少足够的带宽给 Qos STA 使用(例如:一个HT BSS 从 40 MHz 的信道切换到 20 MHz 的信道)。
|
||||
* - UNSPECIFIED_QOS
|
||||
- 32
|
||||
- 32
|
||||
- association 取消,由于不明确的 QoS 相关原因。
|
||||
* - NOT_ENOUGH_BANDWIDTH
|
||||
- 33
|
||||
- 33
|
||||
- association 取消,由于QoS AP 缺少足够的带宽给该 QoS STA 使用。
|
||||
* - MISSING_ACKS
|
||||
- 34
|
||||
- 34
|
||||
- association 取消,原因是:大量的帧需要被确认,但由于 AP 传输或者糟糕的信道条件而没有被确认。
|
||||
* - EXCEEDED_TXOP
|
||||
- 35
|
||||
- 35
|
||||
- association 取消,由于 STA 的传输超过了 TXOPs 的限制。
|
||||
* - STA_LEAVING
|
||||
- 36
|
||||
- 36
|
||||
- 请求 STA 离开了 BSS 或者重置了。
|
||||
* - END_BA
|
||||
- 37
|
||||
- 37
|
||||
- 请求 STA 不再使用该流或者会话。
|
||||
* - UNKNOWN_BA
|
||||
- 38
|
||||
- 38
|
||||
- 请求 STA 使用一种尚未完成的机制接收帧。
|
||||
* - TIMEOUT
|
||||
- 39
|
||||
- 39
|
||||
- 对端 STA 的请求超时。
|
||||
* - Reserved
|
||||
- 40 ~ 45
|
||||
- 40 ~ 45
|
||||
- 保留
|
||||
* - PEER_INITIATED
|
||||
- 46
|
||||
- 46
|
||||
- 在 Disassociation 帧中:已达到授权访问限制。
|
||||
* - AP_INITIATED
|
||||
- 47
|
||||
- 47
|
||||
- 在 Disassociation 帧中:外部服务需求。
|
||||
* - INVALID_FT_ACTION_FRAME_COUNT
|
||||
- 48
|
||||
- 48
|
||||
- 无效的 FT Action 帧计数。
|
||||
* - INVALID_PMKID
|
||||
- 49
|
||||
- 49
|
||||
- 无效的成对主密钥标识符(PMKID)。
|
||||
* - INVALID_MDE
|
||||
- 50
|
||||
- 50
|
||||
- 无效的 MDE。
|
||||
* - INVALID_FTE
|
||||
- 51
|
||||
- 51
|
||||
- 无效的 FTE。
|
||||
* - TRANSMISSION_LINK_ESTABLISHMENT_FAILED
|
||||
- 67
|
||||
- 67
|
||||
- 在备用信道中建立传输链路失败。
|
||||
* - ALTERATIVE_CHANNEL_OCCUPIED
|
||||
- 68
|
||||
- 68
|
||||
- 备用信道被占用。
|
||||
* - BEACON_TIMEOUT
|
||||
- 200
|
||||
- 保留
|
||||
@ -1022,6 +1123,52 @@ Wi-Fi 原因代码
|
||||
- 乐鑫特有的 Wi-Fi 原因代码: AP 连接失败。
|
||||
|
||||
|
||||
与密码错误有关的 Wi-Fi 原因代码
|
||||
+++++++++++++++++++++++++++++++++
|
||||
|
||||
下表罗列了与密码错误相关的 Wi-Fi 原因代码。
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
:widths: 5 10 40
|
||||
|
||||
* - 原因代码
|
||||
- 数值
|
||||
- 描述
|
||||
* - 4WAY_HANDSHAKE_TIMEOUT
|
||||
- 15
|
||||
- 四次握手超时。STA 在连接加密的 AP 的时候输入了错误的密码
|
||||
* - NO_AP_FOUND
|
||||
- 201
|
||||
- 密码错误会出现这个原因代码的场景有如下两个:
|
||||
|
||||
- STA 在连接加密的 AP 的时候没有输入密码
|
||||
- STA 在连接非加密的 AP 的时候输入了密码
|
||||
* - HANDSHAKE_TIMEOUT
|
||||
- 204
|
||||
- 握手超时。
|
||||
|
||||
|
||||
与低 RSSI 有关的 Wi-Fi 原因代码
|
||||
+++++++++++++++++++++++++++++++++
|
||||
|
||||
下表罗列了与低 RSSI 相关的 Wi-Fi 原因代码。
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
:widths: 5 10 40
|
||||
|
||||
* - 原因代码
|
||||
- 数值
|
||||
- 描述
|
||||
* - NO_AP_FOUND
|
||||
- 201
|
||||
- 低 RSSI 导致 station 无法扫描到目标 AP
|
||||
* - HANDSHAKE_TIMEOUT
|
||||
- 204
|
||||
- 握手超时。
|
||||
|
||||
|
||||
找到多个 AP 时的 {IDF_TARGET_NAME} Wi-Fi station 连接
|
||||
----------------------------------------------------------------------
|
||||
|
||||
@ -1076,7 +1223,7 @@ Wi-Fi 模式
|
||||
station 基本配置
|
||||
+++++++++++++++++++++++++++++++++++++
|
||||
|
||||
API esp_wifi_set_config() 可用于配置 station。下表详细介绍了各个字段。
|
||||
API :cpp:func:`esp_wifi_set_config()` 可用于配置 station。配置的参数信息会保存到 NVS 中。下表详细介绍了各个字段。
|
||||
|
||||
.. list-table::
|
||||
:header-rows: 1
|
||||
@ -1115,7 +1262,7 @@ API esp_wifi_set_config() 可用于配置 station。下表详细介绍了各个
|
||||
AP 基本配置
|
||||
+++++++++++++++++++++++++++++++++++++
|
||||
|
||||
API esp_wifi_set_config() 可用于配置 AP。下表详细介绍了各个字段。
|
||||
API :cpp:func:`esp_wifi_set_config()` 可用于配置 AP。配置的参数信息会保存到 NVS 中。下表详细介绍了各个字段。
|
||||
|
||||
.. only:: esp32 or esp32s2 or esp32c3 or esp32s3
|
||||
|
||||
@ -1495,6 +1642,81 @@ AP 睡眠
|
||||
|
||||
未来,{IDF_TARGET_NAME} AP 将支持所有节能功能。
|
||||
|
||||
非连接状态下的休眠
|
||||
+++++++++++++++++++++++++++++++
|
||||
|
||||
非连接状态指的是 :cpp:func:`esp_wifi_start` 至 :cpp:func:`esp_wifi_stop` 期间内,没有建立 Wi-Fi 连接的阶段。
|
||||
|
||||
目前, {IDF_TARGET_NAME} Wi-Fi 支持以 station 模式运行时,在非连接状态下休眠。可以通过选项 :ref:`CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE` 配置该功能。
|
||||
|
||||
如果打开配置选项 :ref:`CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE`,则在该阶段内,RF, PHY and BB 将在空闲时被关闭,电流将会等同于 Modem-sleep 模式下的休眠电流。
|
||||
|
||||
配置选项 :ref:`CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE` 默认情况下将会被打开,共存模式下被 Menuconfig 强制打开。
|
||||
|
||||
.. _connectionless-module-power-save-cn:
|
||||
|
||||
非连接模块功耗管理
|
||||
+++++++++++++++++++++++++++++++
|
||||
|
||||
非连接模块指的是一些不依赖于 Wi-Fi 连接的 Wi-Fi 模块,例如 ESP-NOW, DPP, FTM。这些模块从 :cpp:func:`esp_wifi_start` 开始工作至 :cpp:func:`esp_wifi_stop` 结束。
|
||||
|
||||
目前,ESP-NOW 以 station 模式工作时,既支持在连接状态下休眠,也支持在非连接状态下休眠。
|
||||
|
||||
非连接模块发包
|
||||
*******************************
|
||||
|
||||
对于任何非连接模块,在开启了休眠的任何时间点都可以发包,不需要进行任何额外的配置。
|
||||
|
||||
此外,:cpp:func:`esp_wifi_80211_tx` 也在休眠时被支持。
|
||||
|
||||
非连接模块收包
|
||||
*******************************
|
||||
|
||||
对于非连接模块,在开启休眠时如果需要进行收包,需要配置两个参数,分别为 `Window` 和 `Interval`。
|
||||
|
||||
在每个 `Interval` 开始时,RF, PHY and BB 将会被打开并保持 `Window` 的时间。非连接模块可以在此时间内收包。
|
||||
|
||||
**Interval**
|
||||
|
||||
- 全局只有一个 `Interval` 参数,所有非连接模块共享它。其数值由 API :cpp:func:`esp_wifi_set_connectionless_interval` 配置,单位为毫秒。
|
||||
|
||||
- `Interval` 的默认值为 `ESP_WIFI_CONNECTIONLESS_INTERVAL_DEFAULT_MODE` 。
|
||||
|
||||
- 在 `Interval` 开始时,将会给出 `WIFI_EVENT_CONNECTIONLESS_MODULE_WAKE_INTERVAL_START`_ 事件,由于 `Window` 将在此时开始,可以在此事件内布置发包动作。
|
||||
|
||||
- 在连接状态下,`Interval` 开始的时间点将会与 TBTT 时间点对齐。
|
||||
|
||||
**Window**
|
||||
|
||||
- 每个非连接模块在启动后都有其自身的 `Window` 参数,休眠模块将取所有模块 `Window` 的最大值运作。
|
||||
|
||||
- 其数值由 API :cpp:func:`module_name_set_wake_window` 配置,单位为毫秒。
|
||||
|
||||
- 模块 `Window` 的默认值为最大值。
|
||||
|
||||
.. table:: 不同 Window 与 Interval 组合下的 RF, PHY and BB 使用情况
|
||||
|
||||
+----------------------+-------------------------------------------------+---------------------------------------------------------------------------+
|
||||
| | Interval |
|
||||
+ +-------------------------------------------------+---------------------------------------------------------------------------+
|
||||
| | ESP_WIFI_CONNECTIONLESS_INTERVAL_DEFAULT_MODE | 1 - maximum |
|
||||
+--------+-------------+-------------------------------------------------+---------------------------------------------------------------------------+
|
||||
| Window | 0 | not used |
|
||||
+ +-------------+-------------------------------------------------+---------------------------------------------------------------------------+
|
||||
| | 1 - maximum | default mode | used periodically (Window < Interval) / used all time (Window ≥ Interval) |
|
||||
+--------+-------------+-------------------------------------------------+---------------------------------------------------------------------------+
|
||||
|
||||
默认模式
|
||||
*******************************
|
||||
|
||||
当 `Interval` 参数被配置为 `ESP_WIFI_CONNECTIONLESS_INTERVAL_DEFAULT_MODE` ,且有非零的 `Window` 参数时,非连接模块功耗管理将会按默认模式运行。
|
||||
|
||||
在没有与非 Wi-Fi 协议共存时,RF, PHY and BB 将会在默认模式下被一直打开。
|
||||
|
||||
在与非 Wi-Fi 协议共存时,RF, PHY and BB 资源被共存模块分时划给 Wi-Fi 非连接模块和非 Wi-Fi 协议使用。在默认模式下, Wi-Fi 非连接模块被允许周期性使用 RF, PHY and BB ,并且具有稳定性能。
|
||||
|
||||
推荐在与非 Wi-Fi 协议共存时将非连接模块功耗管理配置为默认模式。
|
||||
|
||||
{IDF_TARGET_NAME} Wi-Fi 吞吐量
|
||||
-----------------------------------
|
||||
|
||||
|
@ -98,6 +98,19 @@ ESP-NOW 采用 CCMP 方法保护供应商特定动作帧的安全,具体可参
|
||||
|
||||
调用 :cpp:func:`esp_wifi_config_espnow_rate()` 配置指定接口的 ESPNOW 速率。确保在配置速率之前使能接口。这个 API 应该在 :cpp:func:`esp_wifi_start()` 之后调用。
|
||||
|
||||
配置 ESP-NOW 功耗参数
|
||||
----------------------
|
||||
|
||||
当且仅当 {IDF_TARGET_NAME} 配置为 STA 模式时,允许其进行休眠。
|
||||
|
||||
进行休眠时,调用 :cpp:func:`esp_now_set_wake_window()` 为 ESP-NOW 收包配置 Window。默认情况下 Window 为最大值,将允许一直收包。
|
||||
|
||||
如果对 ESP-NOW 进功耗管理,也需要调用 :cpp:func:`esp_wifi_connectionless_module_set_wake_interval()`。
|
||||
|
||||
.. only:: SOC_WIFI_SUPPORTED
|
||||
|
||||
请参考 :ref:`非连接模块功耗管理 <connectionless-module-power-save-cn>` 获取更多信息。
|
||||
|
||||
应用示例
|
||||
----------
|
||||
|
||||
|
@ -38,7 +38,7 @@ examples/bluetooth/bluedroid/coex/gattc_gatts_coex:
|
||||
|
||||
examples/bluetooth/blufi:
|
||||
enable:
|
||||
- if: IDF_TARGET in ["esp32", "esp32c3"]
|
||||
- if: IDF_TARGET in ["esp32", "esp32c2", "esp32c3", "esp32s3"]
|
||||
temporary: true
|
||||
reason: the other targets are not tested yet
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
| Supported Targets | ESP32 | ESP32-C3 |
|
||||
| ----------------- | ----- | -------- |
|
||||
| Supported Targets | ESP32 | ESP32-C2 | ESP32-C3 | ESP32-S3 |
|
||||
| ----------------- | ----- | -------- | -------- | -------- |
|
||||
|
||||
# ESP-IDF Blufi Example
|
||||
|
||||
@ -27,7 +27,7 @@ Blufi is completely open source, here is the download link:
|
||||
|
||||
### Hardware Required
|
||||
|
||||
* A development board with ESP32/ESP32-C3 SoC (e.g., ESP32-DevKitC, ESP-WROVER-KIT, etc.)
|
||||
* A development board with ESP32/ESP32-C3/ESP32-S3/ESP32-C2 SoC (e.g., ESP32-DevKitC, ESP-WROVER-KIT, etc.)
|
||||
* A USB cable for Power supply and programming
|
||||
|
||||
See [Development Boards](https://www.espressif.com/en/products/devkits) for more information about it.
|
||||
|
10
examples/bluetooth/blufi/main/Kconfig.projbuild
Normal file
10
examples/bluetooth/blufi/main/Kconfig.projbuild
Normal file
@ -0,0 +1,10 @@
|
||||
menu "Example Configuration"
|
||||
|
||||
config EXAMPLE_WIFI_CONNECTION_MAXIMUM_RETRY
|
||||
int "WiFi connection maximum retry"
|
||||
range 0 255
|
||||
default 2
|
||||
help
|
||||
WiFi connection maximum retry, from 0 to 255.
|
||||
|
||||
endmenu
|
@ -31,6 +31,10 @@
|
||||
|
||||
#include "esp_blufi.h"
|
||||
|
||||
#define EXAMPLE_WIFI_CONNECTION_MAXIMUM_RETRY CONFIG_EXAMPLE_WIFI_CONNECTION_MAXIMUM_RETRY
|
||||
#define EXAMPLE_INVALID_REASON 255
|
||||
#define EXAMPLE_INVALID_RSSI -128
|
||||
|
||||
static void example_event_callback(esp_blufi_cb_event_t event, esp_blufi_cb_param_t *param);
|
||||
|
||||
#define WIFI_LIST_NUM 10
|
||||
@ -46,13 +50,53 @@ static EventGroupHandle_t wifi_event_group;
|
||||
to the AP with an IP? */
|
||||
const int CONNECTED_BIT = BIT0;
|
||||
|
||||
static uint8_t example_wifi_retry = 0;
|
||||
|
||||
/* store the station info for send back to phone */
|
||||
static bool gl_sta_connected = false;
|
||||
static bool gl_sta_got_ip = false;
|
||||
static bool ble_is_connected = false;
|
||||
static uint8_t gl_sta_bssid[6];
|
||||
static uint8_t gl_sta_ssid[32];
|
||||
static int gl_sta_ssid_len;
|
||||
static wifi_sta_list_t gl_sta_list;
|
||||
static bool gl_sta_is_connecting = false;
|
||||
static esp_blufi_extra_info_t gl_sta_conn_info;
|
||||
|
||||
static void example_record_wifi_conn_info(int rssi, uint8_t reason)
|
||||
{
|
||||
memset(&gl_sta_conn_info, 0, sizeof(esp_blufi_extra_info_t));
|
||||
if (gl_sta_is_connecting) {
|
||||
gl_sta_conn_info.sta_max_conn_retry_set = true;
|
||||
gl_sta_conn_info.sta_max_conn_retry = EXAMPLE_WIFI_CONNECTION_MAXIMUM_RETRY;
|
||||
} else {
|
||||
gl_sta_conn_info.sta_conn_rssi_set = true;
|
||||
gl_sta_conn_info.sta_conn_rssi = rssi;
|
||||
gl_sta_conn_info.sta_conn_end_reason_set = true;
|
||||
gl_sta_conn_info.sta_conn_end_reason = reason;
|
||||
}
|
||||
}
|
||||
|
||||
static void example_wifi_connect(void)
|
||||
{
|
||||
example_wifi_retry = 0;
|
||||
gl_sta_is_connecting = (esp_wifi_connect() == ESP_OK);
|
||||
example_record_wifi_conn_info(EXAMPLE_INVALID_RSSI, EXAMPLE_INVALID_REASON);
|
||||
}
|
||||
|
||||
static bool example_wifi_reconnect(void)
|
||||
{
|
||||
bool ret;
|
||||
if (gl_sta_is_connecting && example_wifi_retry++ < EXAMPLE_WIFI_CONNECTION_MAXIMUM_RETRY) {
|
||||
BLUFI_INFO("BLUFI WiFi starts reconnection\n");
|
||||
gl_sta_is_connecting = (esp_wifi_connect() == ESP_OK);
|
||||
example_record_wifi_conn_info(EXAMPLE_INVALID_RSSI, EXAMPLE_INVALID_REASON);
|
||||
ret = true;
|
||||
} else {
|
||||
ret = false;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int softap_get_current_connection_number(void)
|
||||
{
|
||||
@ -83,6 +127,7 @@ static void ip_event_handler(void* arg, esp_event_base_t event_base,
|
||||
info.sta_bssid_set = true;
|
||||
info.sta_ssid = gl_sta_ssid;
|
||||
info.sta_ssid_len = gl_sta_ssid_len;
|
||||
gl_sta_got_ip = true;
|
||||
if (ble_is_connected == true) {
|
||||
esp_blufi_send_wifi_conn_report(mode, ESP_BLUFI_STA_CONN_SUCCESS, softap_get_current_connection_number(), &info);
|
||||
} else {
|
||||
@ -100,27 +145,35 @@ static void wifi_event_handler(void* arg, esp_event_base_t event_base,
|
||||
int32_t event_id, void* event_data)
|
||||
{
|
||||
wifi_event_sta_connected_t *event;
|
||||
wifi_event_sta_disconnected_t *disconnected_event;
|
||||
wifi_mode_t mode;
|
||||
|
||||
switch (event_id) {
|
||||
case WIFI_EVENT_STA_START:
|
||||
esp_wifi_connect();
|
||||
example_wifi_connect();
|
||||
break;
|
||||
case WIFI_EVENT_STA_CONNECTED:
|
||||
gl_sta_connected = true;
|
||||
gl_sta_is_connecting = false;
|
||||
event = (wifi_event_sta_connected_t*) event_data;
|
||||
memcpy(gl_sta_bssid, event->bssid, 6);
|
||||
memcpy(gl_sta_ssid, event->ssid, event->ssid_len);
|
||||
gl_sta_ssid_len = event->ssid_len;
|
||||
break;
|
||||
case WIFI_EVENT_STA_DISCONNECTED:
|
||||
/* Only handle reconnection during connecting */
|
||||
if (gl_sta_connected == false && example_wifi_reconnect() == false) {
|
||||
gl_sta_is_connecting = false;
|
||||
disconnected_event = (wifi_event_sta_disconnected_t*) event_data;
|
||||
example_record_wifi_conn_info(disconnected_event->rssi, disconnected_event->reason);
|
||||
}
|
||||
/* This is a workaround as ESP32 WiFi libs don't currently
|
||||
auto-reassociate. */
|
||||
gl_sta_connected = false;
|
||||
gl_sta_got_ip = false;
|
||||
memset(gl_sta_ssid, 0, 32);
|
||||
memset(gl_sta_bssid, 0, 6);
|
||||
gl_sta_ssid_len = 0;
|
||||
esp_wifi_connect();
|
||||
xEventGroupClearBits(wifi_event_group, CONNECTED_BIT);
|
||||
break;
|
||||
case WIFI_EVENT_AP_START:
|
||||
@ -129,9 +182,17 @@ static void wifi_event_handler(void* arg, esp_event_base_t event_base,
|
||||
/* TODO: get config or information of softap, then set to report extra_info */
|
||||
if (ble_is_connected == true) {
|
||||
if (gl_sta_connected) {
|
||||
esp_blufi_send_wifi_conn_report(mode, ESP_BLUFI_STA_CONN_SUCCESS, softap_get_current_connection_number(), NULL);
|
||||
esp_blufi_extra_info_t info;
|
||||
memset(&info, 0, sizeof(esp_blufi_extra_info_t));
|
||||
memcpy(info.sta_bssid, gl_sta_bssid, 6);
|
||||
info.sta_bssid_set = true;
|
||||
info.sta_ssid = gl_sta_ssid;
|
||||
info.sta_ssid_len = gl_sta_ssid_len;
|
||||
esp_blufi_send_wifi_conn_report(mode, gl_sta_got_ip ? ESP_BLUFI_STA_CONN_SUCCESS : ESP_BLUFI_STA_NO_IP, softap_get_current_connection_number(), &info);
|
||||
} else if (gl_sta_is_connecting) {
|
||||
esp_blufi_send_wifi_conn_report(mode, ESP_BLUFI_STA_CONNECTING, softap_get_current_connection_number(), &gl_sta_conn_info);
|
||||
} else {
|
||||
esp_blufi_send_wifi_conn_report(mode, ESP_BLUFI_STA_CONN_FAIL, softap_get_current_connection_number(), NULL);
|
||||
esp_blufi_send_wifi_conn_report(mode, ESP_BLUFI_STA_CONN_FAIL, softap_get_current_connection_number(), &gl_sta_conn_info);
|
||||
}
|
||||
} else {
|
||||
BLUFI_INFO("BLUFI BLE is not connected yet\n");
|
||||
@ -207,6 +268,7 @@ static void initialise_wifi(void)
|
||||
wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
|
||||
ESP_ERROR_CHECK( esp_wifi_init(&cfg) );
|
||||
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
|
||||
example_record_wifi_conn_info(EXAMPLE_INVALID_RSSI, EXAMPLE_INVALID_REASON);
|
||||
ESP_ERROR_CHECK( esp_wifi_start() );
|
||||
}
|
||||
|
||||
@ -253,7 +315,7 @@ static void example_event_callback(esp_blufi_cb_event_t event, esp_blufi_cb_para
|
||||
so disconnect wifi before connection.
|
||||
*/
|
||||
esp_wifi_disconnect();
|
||||
esp_wifi_connect();
|
||||
example_wifi_connect();
|
||||
break;
|
||||
case ESP_BLUFI_EVENT_REQ_DISCONNECT_FROM_AP:
|
||||
BLUFI_INFO("BLUFI requset wifi disconnect from AP\n");
|
||||
@ -269,17 +331,17 @@ static void example_event_callback(esp_blufi_cb_event_t event, esp_blufi_cb_para
|
||||
|
||||
esp_wifi_get_mode(&mode);
|
||||
|
||||
|
||||
|
||||
if (gl_sta_connected) {
|
||||
memset(&info, 0, sizeof(esp_blufi_extra_info_t));
|
||||
memcpy(info.sta_bssid, gl_sta_bssid, 6);
|
||||
info.sta_bssid_set = true;
|
||||
info.sta_ssid = gl_sta_ssid;
|
||||
info.sta_ssid_len = gl_sta_ssid_len;
|
||||
esp_blufi_send_wifi_conn_report(mode, ESP_BLUFI_STA_CONN_SUCCESS, softap_get_current_connection_number(), &info);
|
||||
esp_blufi_send_wifi_conn_report(mode, gl_sta_got_ip ? ESP_BLUFI_STA_CONN_SUCCESS : ESP_BLUFI_STA_NO_IP, softap_get_current_connection_number(), &info);
|
||||
} else if (gl_sta_is_connecting) {
|
||||
esp_blufi_send_wifi_conn_report(mode, ESP_BLUFI_STA_CONNECTING, softap_get_current_connection_number(), &gl_sta_conn_info);
|
||||
} else {
|
||||
esp_blufi_send_wifi_conn_report(mode, ESP_BLUFI_STA_CONN_FAIL, softap_get_current_connection_number(), NULL);
|
||||
esp_blufi_send_wifi_conn_report(mode, ESP_BLUFI_STA_CONN_FAIL, softap_get_current_connection_number(), &gl_sta_conn_info);
|
||||
}
|
||||
BLUFI_INFO("BLUFI get wifi status from AP\n");
|
||||
|
||||
@ -354,7 +416,10 @@ static void example_event_callback(esp_blufi_cb_event_t event, esp_blufi_cb_para
|
||||
.channel = 0,
|
||||
.show_hidden = false
|
||||
};
|
||||
esp_wifi_scan_start(&scanConf, true);
|
||||
esp_err_t ret = esp_wifi_scan_start(&scanConf, true);
|
||||
if (ret != ESP_OK) {
|
||||
esp_blufi_send_error_info(ESP_BLUFI_WIFI_SCAN_FAIL);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ESP_BLUFI_EVENT_RECV_CUSTOM_DATA:
|
||||
|
Loading…
Reference in New Issue
Block a user