Wi-Fi Vendor Features
ESP-WIFI-MESH
For details, see the ESP-WIFI-MESH.
Wi-Fi 80211 Packet Send
The esp_wifi_80211_tx() API can be used to:
Send the beacon, probe request, probe response, and action frame.
Send the non-QoS data frame.
It cannot be used for sending encrypted or QoS frames.
Preconditions of Using esp_wifi_80211_tx()
The Wi-Fi mode is station, or AP, or station/AP.
Either
esp_wifi_set_promiscuous(true), oresp_wifi_start(), or both of these APIs returnESP_OK. This is because Wi-Fi hardware must be initialized beforeesp_wifi_80211_tx()is called. In ESP32-C5, bothesp_wifi_set_promiscuous(true)andesp_wifi_start()can trigger the initialization of Wi-Fi hardware.The parameters of
esp_wifi_80211_tx()are hereby correctly provided.
Data Rate
The default data rate is 1 Mbps.
Can set any rate through
esp_wifi_config_80211_tx_rate()API.Can set any bandwidth through
esp_wifi_set_bandwidth()API.
Side-Effects to Avoid in Different Scenarios
Theoretically, if the side-effects the API imposes on the Wi-Fi driver or other stations/APs are not considered, a raw 802.11 packet can be sent over the air with any destination MAC, any source MAC, any BSSID, or any other types of packet. However, robust or useful applications should avoid such side-effects. The table below provides some tips and recommendations on how to avoid the side-effects of esp_wifi_80211_tx() in different scenarios.
Scenario |
Description |
|---|---|
No Wi-Fi connection |
In this scenario, no Wi-Fi connection is set up, so there are no side-effects on the Wi-Fi driver. If Theoretically, the MAC address can be any address. However, this may impact other stations/APs with the same MAC/BSSID. Side-effect example#1 The application calls To avoid the above-mentioned side-effects, it is recommended that:
The recommendations above are only for avoiding side-effects and can be ignored when there are good reasons. |
Have Wi-Fi connection |
When the Wi-Fi connection is already set up, and the sequence is controlled by the application, the latter may impact the sequence control of the Wi-Fi connection as a whole. So, the The MAC-address recommendations in the “No Wi-Fi connection” scenario also apply to this scenario. If the Wi-Fi mode is station mode, the MAC address1 is the MAC of AP to which the station is connected, and the MAC address2 is the MAC of station interface, it is said that the packet is sent from the station to AP. Otherwise, if the Wi-Fi is in AP mode, the MAC address1 is the MAC of the station that connects to this AP, and the MAC address2 is the MAC of AP interface, it is said that the packet is sent from the AP to station. To avoid conflicting with Wi-Fi connections, the following checks are applied:
|
Wi-Fi Vendor IE Configuration
By default, all Wi-Fi management frames are processed by the Wi-Fi driver, and the application can ignore them. However, some applications may have to handle the beacon, probe request, probe response, and other management frames. For example, if you insert some vendor-specific IE into the management frames, it is only the management frames which contain this vendor-specific IE that will be processed. In ESP32-C5, esp_wifi_set_vendor_ie() and esp_wifi_set_vendor_ie_cb() are responsible for this kind of tasks.
Wi-Fi Channel State Information
Channel state information (CSI) refers to the channel information of a Wi-Fi connection. In ESP32-C5, this information consists of channel frequency responses of sub-carriers and is estimated when packets are received from the transmitter. Each channel frequency response of sub-carrier is recorded by two bytes of signed characters. The first one is imaginary part and the second one is real part. Except for the IEEE 802.11g mode, all other modes have two LTF sequences (LLTF + HT/VHT/HE-LTF). ESP32-C5 can determine whether to include LLTF or HT/VHT/HE-LTF through acquire_csi_force_lltf field of wifi_csi_acquire_config_t. For different types of packets which are received on channels with different state, the sub-carrier index and total bytes of signed characters of CSI are shown in the following table.
channel |
secondary channel |
none |
below |
above |
||||||||||||
packet information |
signal mode |
non HT |
HT |
HE |
non HT |
HT |
non HT |
HT |
||||||||
channel bandwidth |
20 MHz |
20 MHz |
20 MHz |
20 MHz |
20 MHz |
40 MHz |
20 MHz |
20 MHz |
40 MHz |
|||||||
STBC |
non STBC |
non STBC |
STBC |
non STBC |
STBC |
non STBC |
non STBC |
STBC |
none STBC |
STBC |
non STBC |
non STBC |
STBC |
non STBC |
STBC |
|
sub-carrier index |
LLTF |
0~26, -26~-1 |
— |
— |
— |
— |
0~52 |
— |
— |
— |
— |
-53~-1 |
— |
— |
— |
— |
HT-LTF (HT-LTF1) |
— |
0~28, -28~-1 |
0~28, -28~-1 |
— |
— |
— |
0~56 |
0~56 |
0~58, -58~-1 |
0~58, -58~-1 |
— |
-57~-1 |
-57~-1 |
0~58, -58~-1 |
0~58, -58~-1 |
|
HT-LTF2 |
— |
— |
0~28, -28~-1 |
— |
— |
— |
— |
0~56 |
— |
0~58, -58~-1 |
— |
— |
-57~-1 |
— |
0~58, -58~-1 |
|
HE-LTF (HE-LTF1) |
— |
— |
— |
0~122, -122~1 |
Determined by wifi_csi_config_t |
— |
— |
— |
— |
— |
— |
— |
— |
— |
— |
|
HE-LTF2 |
— |
— |
— |
— |
— |
— |
— |
— |
— |
— |
— |
— |
— |
— |
||
total bytes |
106 |
114 |
228 |
490 |
490 |
106 |
114 |
228 |
234 |
468 |
106 |
114 |
228 |
234 |
468 |
|
Note
In HT/VHT/HE modes, there are two LTF sequences: LLTF + HT/VHT/HE-LTF. If the
acquire_csi_force_lltffield ofwifi_csi_acquire_config_tis set to false, the CSI data will only contain HT/VHT/HE-LTF (as shown in the table above); otherwise, the CSI data will only contain LLTF. The sub-carrier index and total bytes for LLTF in HT/VHT/HE modes are the same as those for LLTF in non-HT modes.In VHT mode, the sub-carrier index and total bytes are the same as those in HT mode.
All of the information in the table can be found in the structure wifi_csi_info_t.
Secondary channel refers to
secondfield ofrx_ctrlfield.signal mode of packet refers to
cur_bb_formatfield ofrx_ctrlfield.total bytes refers to
lenfieldThe CSI data corresponding to each Long Training Field (LTF) type is stored in a buffer starting from the buf field. Each item is stored as two bytes: imaginary part followed by real part. The order of each item is the same as the sub-carrier in the table.
If
first_word_invalidofwifi_csi_info_tis true, it means that the first four bytes of CSI data is invalid due to a hardware limitation in ESP32-C5.If
rx_channel_estimate_info_vldofrx_ctrlfield is 1, indicates that the CSI data is valid; otherwise, the CSI data is invalid.More information like RSSI, noise floor of RF, receiving time and antenna is in the
rx_ctrlfield.
For STBC packets, the subcarrier indices of HE-LTF1 and HE-LTF2 are determined by acquire_csi_he_stbc_mode field of wifi_csi_config_t. Please refer to the table below for details.
acquire_csi_he_stbc |
HE-LTF1 |
HE-LTF2 |
0 |
-122~-1, 0~122 |
— |
1 |
— |
-122~-1, 0~122 |
2 |
Sample evenly among the HE-LTF1 and HE-LTF2 |
|
When imaginary part and real part data of sub-carrier are used, please refer to the table below.
PHY standard |
Sub-carrier range |
Invalid sub-carrier |
Sub-carrier (total/data) |
|---|---|---|---|
802.11a/g |
-26 to +26 |
0 |
53 total, 52 usable |
802.11n, 20 MHz |
-28 to +28 |
0 |
57 total, 56 usable |
802.11n, 40 MHz |
-58 to +58 |
-1, 0, 1 |
117 total, 114 usable |
802.11ac, 20 MHz |
-28 to +28 |
0 |
57 total, 56 usable |
802.11ax, 20 MHz (SU) |
-122 to + 122 |
-1, 0, 1 |
245 total, 242 usable |
Note
When the PHY is 802.11ax, please refer to the protocol for sub-carrier range and invalid sub-carrier for MU packets.
Note
For STBC packet, CSI is provided for every space-time stream without CSD (cyclic shift delay). As each cyclic shift on the additional chains shall be -200 ns, only the CSD angle of first space-time stream is recorded in sub-carrier 0 of HT-LTF1 (HE-LTF1) and HT-LTF2 (HE-LTF2) for there is no channel frequency response in sub-carrier 0. CSD[10:0] is 11 bits, ranging from -pi to pi.
Wi-Fi Channel State Information Configure
To use Wi-Fi CSI, the following steps need to be done.
Select Wi-Fi CSI in menuconfig. Go to
Menuconfig>Components config>Wi-Fi>Wi-Fi CSI (Channel State Information).Set CSI receiving callback function by calling API
esp_wifi_set_csi_rx_cb().Configure CSI by calling API
esp_wifi_set_csi_config().Enable CSI by calling API
esp_wifi_set_csi().
The CSI receiving callback function runs from Wi-Fi task. So, do not do lengthy operations in the callback function. Instead, post necessary data to a queue and handle it from a lower priority task. Because station does not receive any packet when it is disconnected and only receives packets from AP when it is connected, it is suggested to enable sniffer mode to receive more CSI data by calling esp_wifi_set_promiscuous().
Wi-Fi Multiple Antennas
Please refer to the PHY.