docs: seperate multiple antennas from Wi-Fi to PHY

pull/13550/head
alanmaxwell 2024-03-21 19:31:30 +08:00
rodzic 0f73cf50fb
commit a6cc70e6e7
6 zmienionych plików z 141 dodań i 125 usunięć

Wyświetl plik

@ -44,3 +44,4 @@ API Guides
:SOC_WIFI_SUPPORTED: wifi
:SOC_WIFI_SUPPORTED: wifi-security
low-power-mode
:SOC_WIFI_SUPPORTED or SOC_BT_SUPPORTED or SOC_IEEE802154_SUPPORTED: phy

Wyświetl plik

@ -0,0 +1,68 @@
PHY
==================
:link_to_translation:`zh_CN:[中文]`
Multiple Antennas
--------------------------
The multiple antennas selecting can be depicted as following picture::
__________
|Enabled |
___|Antenna 0 |\\ _________
|__________| \\ GPIO[0] <----> antenna_select[0] ---| | --- antenna 0
RX/TX ___ \\____\ GPIO[1] <----> antenna_select[1] ---| Antenna | --- antenna 1
\ __________ // / GPIO[2] <----> antenna_select[2] ---| Switch | ... ...
\ ___|Enabled | // GPIO[3] <----> antenna_select[3] ---|_________| --- antenna 15
\ |Antenna 1 |//
|__________|
{IDF_TARGET_NAME} supports up to sixteen antennas through external antenna switch. The antenna switch can be controlled by up to four address pins - antenna_select[0:3]. Different input value of antenna_select[0:3] means selecting different antenna. For example, the value '0b1011' means the antenna 11 is selected. The default value of antenna_select[3:0] is '0b0000', which means the antenna 0 is selected by default.
Up to four GPIOs are connected to the four active high antenna_select pins. {IDF_TARGET_NAME} can select the antenna by control the GPIO[0:3]. The API :cpp:func:`esp_phy_set_ant_gpio()` is used to configure which GPIOs are connected to antenna_selects. If GPIO[x] is connected to antenna_select[x], then gpio_config->gpio_cfg[x].gpio_select should be set to 1 and gpio_config->gpio_cfg[x].gpio_num should be provided.
For the specific implementation of the antenna switch, there may be illegal values in `antenna_select[0:3]`. It means that {IDF_TARGET_NAME} may support less than sixteen antennas through the switch. For example, ESP32-WROOM-DA which uses RTC6603SP as the antenna switch, supports two antennas. Two GPIOs are connected to two active high antenna selection inputs. The value '0b01' means the antenna 0 is selected, the value '0b10' means the antenna 1 is selected. Values '0b00' and '0b11' are illegal.
Although up to sixteen antennas are supported, only one or two antennas can be simultaneously enabled for RX/TX. The API :cpp:func:`esp_phy_set_ant()` is used to configure which antennas are enabled.
The enabled antennas selecting algorithm is also configured by :cpp:func:`esp_phy_set_ant()`. The RX/TX antenna mode can be :cpp:enumerator:`ESP_PHY_ANT_MODE_ANT0`, :cpp:enumerator:`ESP_PHY_ANT_MODE_ANT1`, or :cpp:enumerator:`ESP_PHY_ANT_MODE_AUTO`. If the antenna mode is :cpp:enumerator:`ESP_PHY_ANT_MODE_ANT0`, the enabled antenna 0 is selected for RX/TX data. If the antenna mode is :cpp:enumerator:`ESP_PHY_ANT_MODE_ANT1`, the enabled antenna 1 is selected for RX/TX data. Otherwise, Wi-Fi automatically selects the enabled antenna that has better signal.
If the RX antenna mode is :cpp:enumerator:`ESP_PHY_ANT_MODE_AUTO`, the default antenna mode also needs to be set, because the RX antenna switching only happens when some conditions are met. For example, the RX antenna starts to switch if the RSSI is lower than -65 dBm or another antenna has better signal. RX uses the default antenna if the conditions are not met. If the default antenna mode is :cpp:enumerator:`ESP_PHY_ANT_MODE_ANT1`, the enabled antenna 1 is used as the default RX antenna, otherwise the enabled antenna 0 is used.
Some limitations need to be considered:
- The TX antenna can be set to :cpp:enumerator:`ESP_PHY_ANT_MODE_AUTO` only if the RX antenna mode is :cpp:enumerator:`ESP_PHY_ANT_MODE_AUTO`, because TX antenna selecting algorithm is based on RX antenna in :cpp:enumerator:`ESP_PHY_ANT_MODE_AUTO` type.
- When the TX antenna mode or RX antenna mode is configured to :cpp:enumerator:`ESP_PHY_ANT_MODE_AUTO` the switching mode will easily trigger the switching phase, as long as there is deterioration of the RF signal. So in situations where the RF signal is not stable, the antenna switching will occur frequently, resulting in an RF performance that may not meet expectations.
Following is the recommended scenarios to use the multiple antennas:
- The applications can always choose to select a specified antenna or implement their own antenna selecting algorithm, e.g., selecting the antenna mode based on the information collected by the application. Refer to ESP-IDF example :idf_file:`examples/phy/antenna/README.md` for the antenna selecting algorithm design.
- Both RX/TX antenna modes are configured to ESP_PHY_ANT_MODE_ANT0 or ESP_PHY_ANT_MODE_ANT1.
Multiple Antennas Configuration
+++++++++++++++++++++++++++++++++++++
Generally, following steps can be taken to configure the multiple antennas:
- Configure which GPIOs are connected to the antenna_selects. For example, if four antennas are supported and GPIO20/GPIO21 are connected to antenna_select[0]/antenna_select[1], the configurations look like:
.. code-block:: c
esp_phy_ant_gpio_config_t ant_gpio_config = {
.gpio_cfg[0] = { .gpio_select = 1, .gpio_num = 20 },
.gpio_cfg[1] = { .gpio_select = 1, .gpio_num = 21 }
};
- Configure which antennas are enabled and how RX/TX use the enabled antennas. For example, if antenna1 and antenna3 are enabled, the RX needs to select the better antenna automatically and uses antenna1 as its default antenna, the TX always selects the antenna3. The configuration looks like:
.. code-block:: c
esp_phy_ant_config_t config = {
.rx_ant_mode = ESP_PHY_ANT_MODE_AUTO,
.rx_ant_default = ESP_PHY_ANT_ANT0,
.tx_ant_mode = ESP_PHY_ANT_MODE_ANT1,
.enabled_ant0 = 1,
.enabled_ant1 = 3
};

Wyświetl plik

@ -2175,69 +2175,8 @@ The Wi-Fi sniffer mode can be enabled in the Wi-Fi mode of :cpp:enumerator:`WIFI
Another noteworthy issue about the sniffer is the callback :cpp:type:`wifi_promiscuous_cb_t`. The callback will be called directly in the Wi-Fi driver task, so if the application has a lot of work to do for each filtered packet, the recommendation is to post an event to the application task in the callback and defer the real work to the application task.
Wi-Fi Multiple Antennas
--------------------------
The Wi-Fi multiple antennas selecting can be depicted as following picture::
__________
|Enabled |
___|Antenna 0 |\\ _________
|__________| \\ GPIO[0] <----> antenna_select[0] ---| | --- antenna 0
RX/TX ___ \\____\ GPIO[1] <----> antenna_select[1] ---| Antenna | --- antenna 1
\ __________ // / GPIO[2] <----> antenna_select[2] ---| Switch | ... ...
\ ___|Enabled | // GPIO[3] <----> antenna_select[3] ---|_________| --- antenna 15
\ |Antenna 1 |//
|__________|
{IDF_TARGET_NAME} supports up to sixteen antennas through external antenna switch. The antenna switch can be controlled by up to four address pins - antenna_select[0:3]. Different input value of antenna_select[0:3] means selecting different antenna. For example, the value '0b1011' means the antenna 11 is selected. The default value of antenna_select[3:0] is '0b0000', which means the antenna 0 is selected by default.
Up to four GPIOs are connected to the four active high antenna_select pins. {IDF_TARGET_NAME} can select the antenna by control the GPIO[0:3]. The API :cpp:func:`esp_wifi_set_ant_gpio()` is used to configure which GPIOs are connected to antenna_selects. If GPIO[x] is connected to antenna_select[x], then gpio_config->gpio_cfg[x].gpio_select should be set to 1 and gpio_config->gpio_cfg[x].gpio_num should be provided.
For the specific implementation of the antenna switch, there may be illegal values in `antenna_select[0:3]`. It means that {IDF_TARGET_NAME} may support less than sixteen antennas through the switch. For example, ESP32-WROOM-DA which uses RTC6603SP as the antenna switch, supports two antennas. Two GPIOs are connected to two active high antenna selection inputs. The value '0b01' means the antenna 0 is selected, the value '0b10' means the antenna 1 is selected. Values '0b00' and '0b11' are illegal.
Although up to sixteen antennas are supported, only one or two antennas can be simultaneously enabled for RX/TX. The API :cpp:func:`esp_wifi_set_ant()` is used to configure which antennas are enabled.
The enabled antennas selecting algorithm is also configured by :cpp:func:`esp_wifi_set_ant()`. The RX/TX antenna mode can be :cpp:enumerator:`WIFI_ANT_MODE_ANT0`, :cpp:enumerator:`WIFI_ANT_MODE_ANT1`, or :cpp:enumerator:`WIFI_ANT_MODE_AUTO`. If the antenna mode is :cpp:enumerator:`WIFI_ANT_MODE_ANT0`, the enabled antenna 0 is selected for RX/TX data. If the antenna mode is :cpp:enumerator:`WIFI_ANT_MODE_ANT1`, the enabled antenna 1 is selected for RX/TX data. Otherwise, Wi-Fi automatically selects the enabled antenna that has better signal.
If the RX antenna mode is :cpp:enumerator:`WIFI_ANT_MODE_AUTO`, the default antenna mode also needs to be set, because the RX antenna switching only happens when some conditions are met. For example, the RX antenna starts to switch if the RSSI is lower than -65 dBm or another antenna has better signal. RX uses the default antenna if the conditions are not met. If the default antenna mode is :cpp:enumerator:`WIFI_ANT_MODE_ANT1`, the enabled antenna 1 is used as the default RX antenna, otherwise the enabled antenna 0 is used.
Some limitations need to be considered:
- The TX antenna can be set to :cpp:enumerator:`WIFI_ANT_MODE_AUTO` only if the RX antenna mode is :cpp:enumerator:`WIFI_ANT_MODE_AUTO`, because TX antenna selecting algorithm is based on RX antenna in :cpp:enumerator:`WIFI_ANT_MODE_AUTO` type.
- When the TX antenna mode or RX antenna mode is configured to :cpp:enumerator:`WIFI_ANT_MODE_AUTO` the switching mode will easily trigger the switching phase, as long as there is deterioration of the RF signal. So in situations where the RF signal is not stable, the antenna switching will occur frequently, resulting in an RF performance that may not meet expectations.
- Currently, Bluetooth® does not support the multiple antennas feature, so please do not use multiple antennas related APIs.
Following is the recommended scenarios to use the multiple antennas:
- The applications can always choose to select a specified antenna or implement their own antenna selecting algorithm, e.g., selecting the antenna mode based on the information collected by the application. Refer to ESP-IDF example :idf_file:`examples/wifi/antenna/README.md` for the antenna selecting algorithm design.
- Both RX/TX antenna modes are configured to WIFI_ANT_MODE_ANT0 or WIFI_ANT_MODE_ANT1.
Wi-Fi Multiple Antennas Configuration
+++++++++++++++++++++++++++++++++++++
Generally, following steps can be taken to configure the multiple antennas:
- Configure which GPIOs are connected to the antenna_selects. For example, if four antennas are supported and GPIO20/GPIO21 are connected to antenna_select[0]/antenna_select[1], the configurations look like:
.. code-block:: c
wifi_ant_gpio_config_t ant_gpio_config = {
.gpio_cfg[0] = { .gpio_select = 1, .gpio_num = 20 },
.gpio_cfg[1] = { .gpio_select = 1, .gpio_num = 21 }
};
- Configure which antennas are enabled and how RX/TX use the enabled antennas. For example, if antenna1 and antenna3 are enabled, the RX needs to select the better antenna automatically and uses antenna1 as its default antenna, the TX always selects the antenna3. The configuration looks like:
.. code-block:: c
wifi_ant_config_t config = {
.rx_ant_mode = WIFI_ANT_MODE_AUTO,
.rx_ant_default = WIFI_ANT_ANT0,
.tx_ant_mode = WIFI_ANT_MODE_ANT1,
.enabled_ant0 = 1,
.enabled_ant1 = 3
};
---------------------------
Please refer to the :doc:`PHY <../api-guides/phy>`
.. only:: SOC_WIFI_CSI_SUPPORT

Wyświetl plik

@ -44,3 +44,4 @@ API 指南
:SOC_WIFI_SUPPORTED: wifi
:SOC_WIFI_SUPPORTED: wifi-security
low-power-mode
:SOC_WIFI_SUPPORTED or SOC_BT_SUPPORTED or SOC_IEEE802154_SUPPORTED: phy

Wyświetl plik

@ -0,0 +1,68 @@
PHY
==================
:link_to_translation:`en:[English]`
多根天线
-------------------
下图描述多根天线的选择过程::
__________
|Enabled |
___|Antenna 0 |\\ _________
|__________| \\ GPIO[0] <----> antenna_select[0] ---| | --- antenna 0
RX/TX ___ \\____\ GPIO[1] <----> antenna_select[1] ---| Antenna | --- antenna 1
\ __________ // / GPIO[2] <----> antenna_select[2] ---| Switch | ... ...
\ ___|Enabled | // GPIO[3] <----> antenna_select[3] ---|_________| --- antenna 15
\ |Antenna 1 |//
|__________|
{IDF_TARGET_NAME} 通过外部天线开关,最多支持 16 根天线。天线开关最多可由四个地址管脚控制 - antenna_select[0:3]。向 antenna_select[0:3] 输入不同的值,以选择不同的天线。例如,输入值 '0b1011' 表示选中天线 11。antenna_select[3:0] 的默认值为 "0b0000",表示默认选择了天线 0。
四个高电平有效 antenna_select 管脚有多达四个 GPIO 连接。{IDF_TARGET_NAME} 可以通过控制 GPIO[0:3] 选择天线。API :cpp:func:`esp_phy_set_ant_gpio()` 用于配置 antenna_selects 连接哪些 GPIO。如果 GPIO[x] 连接到 antenna_select[x]gpio_config->gpio_cfg[x].gpio_select 应设置为 1且要提供 gpio_config->gpio_cfg[x].gpio_num 的值。
天线开关的具体实现不同,`antenna_select[0:3]` 的输入值中可能存在非法值,即 {IDF_TARGET_NAME} 通过外部天线开关支持的天线数可能小于 16 根。例如ESP32-WROOM-DA 使用 RTC6603SP 作为天线开关,仅支持 2 根天线。两个天线选择输入管脚为高电平有效,连接到两个 GPIO。'0b01' 表示选中天线 0'0b10' 表示选中天线 1。输入值 '0b00' 和 '0b11' 为非法值。
尽管最多支持 16 根天线发送和接收数据时最多仅能同时使能两根天线。API :cpp:func:`esp_phy_set_ant()` 用于配置使能哪些天线。
使能天线后,选择算法的过程同样可由 :cpp:func:`esp_phy_set_ant()` 配置。接收/发送数据源的天线模式可以是 ESP_PHY_ANT_MODE_ANT0、ESP_PHY_ANT_MODE_ANT1 或 ESP_PHY_ANT_MODE_AUTO。如果天线模式为 ESP_PHY_ANT_MODE_AUTO使能的天线 0 用于接收/发送数据。如果天线模式为 ESP_PHY_ANT_MODE_ANT1使能天线 1 用于接收/发送数据。否则,会自动选择使能天线中信号较好的天线。
如果接收数据的天线模式为 ESP_PHY_ANT_MODE_AUTO还需要设置默认天线模式。只有在满足某些条件时接收数据天线才会切换例如如果 RSSI 低于 -65 dBm或另一根天线信号更好。如果条件不满足接收数据使用默认天线。如果默认天线模式为 ESP_PHY_ANT_MODE_ANT1则使能的天线 1 是默认接收数据天线,否则是使能的天线 0。
有一些限制情况需要考虑:
- 因为发送数据天线基于 ESP_PHY_ANT_MODE_AUTO 类型的接收数据天线选择算法,只有接收数据的天线模式为 ESP_PHY_ANT_MODE_AUTO 时,发送数据天线才能设置为 ESP_PHY_ANT_MODE_AUTO。
- 接收或者发送天线模式配置为 ESP_PHY_ANT_MODE_AUTO 时,只要存在 RF 信号的恶化,很容易触发天线切换。如果射频信号不稳定,天线会频繁切换,使得总的射频性能无法达到预期效果。
推荐在以下场景中使用多根天线:
- 应用程序可以始终选择指定的天线,也可以执行自身天线选择算法,如根据应用程序收集的信息来选择天线模式等。请参考 IDF 示例 :idf_file:`examples/phy/antenna/README.md` 来设计天线选择算法。
- 接收/发送数据的天线模式均配置为 ESP_PHY_ANT_MODE_ANT0 或 ESP_PHY_ANT_MODE_ANT1。
多根天线配置
++++++++++++++++++++++++++++
通常,可以执行以下步骤来配置多根天线:
- 配置 antenna_selects 连接哪些 GPIOs例如如果支持四根天线且 GPIO20/GPIO21 连接到 antenna_select[0]/antenna_select[1],配置如下所示:
.. code-block:: c
esp_phy_ant_gpio_config_t ant_gpio_config = {
.gpio_cfg[0] = { .gpio_select = 1, .gpio_num = 20 },
.gpio_cfg[1] = { .gpio_select = 1, .gpio_num = 21 }
};
- 配置使能哪些天线、以及接收/发送数据如何使用使能的天线,例如,如果使能了天线 1 和天线 3接收数据需要自动选择较好的天线并将天线 1 作为默认天线,发送数据始终选择天线 3。配置如下所示:
.. code-block:: c
esp_phy_ant_config_t config = {
.rx_ant_mode = ESP_PHY_ANT_MODE_AUTO,
.rx_ant_default = ESP_PHY_ANT_ANT0,
.tx_ant_mode = ESP_PHY_ANT_MODE_ANT1,
.enabled_ant0 = 1,
.enabled_ant1 = 3
};

Wyświetl plik

@ -2144,68 +2144,7 @@ Wi-Fi Sniffer 模式可以通过 :cpp:func:`esp_wifi_set_promiscuous()` 使能
Wi-Fi 多根天线
--------------------------
下图描述 Wi-Fi 多根天线的选择过程::
__________
|Enabled |
___|Antenna 0 |\\ _________
|__________| \\ GPIO[0] <----> antenna_select[0] ---| | --- antenna 0
RX/TX ___ \\____\ GPIO[1] <----> antenna_select[1] ---| Antenna | --- antenna 1
\ __________ // / GPIO[2] <----> antenna_select[2] ---| Switch | ... ...
\ ___|Enabled | // GPIO[3] <----> antenna_select[3] ---|_________| --- antenna 15
\ |Antenna 1 |//
|__________|
{IDF_TARGET_NAME} 通过外部天线开关,最多支持 16 根天线。天线开关最多可由四个地址管脚控制 - antenna_select[0:3]。向 antenna_select[0:3] 输入不同的值,以选择不同的天线。例如,输入值 '0b1011' 表示选中天线 11。antenna_select[3:0] 的默认值为 "0b0000",表示默认选择了天线 0。
四个高电平有效 antenna_select 管脚有多达四个 GPIO 连接。{IDF_TARGET_NAME} 可以通过控制 GPIO[0:3] 选择天线。API :cpp:func:`esp_wifi_set_ant_gpio()` 用于配置 antenna_selects 连接哪些 GPIO。如果 GPIO[x] 连接到 antenna_select[x]gpio_config->gpio_cfg[x].gpio_select 应设置为 1且要提供 gpio_config->gpio_cfg[x].gpio_num 的值。
天线开关的具体实现不同,`antenna_select[0:3]` 的输入值中可能存在非法值,即 {IDF_TARGET_NAME} 通过外部天线开关支持的天线数可能小于 16 根。例如ESP32-WROOM-DA 使用 RTC6603SP 作为天线开关,仅支持 2 根天线。两个天线选择输入管脚为高电平有效,连接到两个 GPIO。'0b01' 表示选中天线 0'0b10' 表示选中天线 1。输入值 '0b00' 和 '0b11' 为非法值。
尽管最多支持 16 根天线发送和接收数据时最多仅能同时使能两根天线。API :cpp:func:`esp_wifi_set_ant()` 用于配置使能哪些天线。
使能天线后,选择算法的过程同样可由 :cpp:func:`esp_wifi_set_ant()` 配置。接收/发送数据源的天线模式可以是 WIFI_ANT_MODE_ANT0、WIFI_ANT_MODE_ANT1 或 WIFI_ANT_MODE_AUTO。如果天线模式为 WIFI_ANT_MODE_ANT0使能的天线 0 用于接收/发送数据。如果天线模式为 WIFI_ANT_MODE_ANT1使能天线 1 用于接收/发送数据。否则Wi-Fi 会自动选择使能天线中信号较好的天线。
如果接收数据的天线模式为 WIFI_ANT_MODE_AUTO还需要设置默认天线模式。只有在满足某些条件时接收数据天线才会切换例如如果 RSSI 低于 -65 dBm或另一根天线信号更好。如果条件不满足接收数据使用默认天线。如果默认天线模式为 WIFI_ANT_MODE_ANT1则使能的天线 1 是默认接收数据天线,否则是使能的天线 0。
有一些限制情况需要考虑:
- 因为发送数据天线基于 WIFI_ANT_MODE_AUTO 类型的接收数据天线选择算法,只有接收数据的天线模式为 WIFI_ANT_MODE_AUTO 时,发送数据天线才能设置为 WIFI_ANT_MODE_AUTO。
- 接收或者发送天线模式配置为 WIFI_ANT_MODE_AUTO 时,只要存在 RF 信号的恶化,很容易触发天线切换。如果射频信号不稳定,天线会频繁切换,使得总的射频性能无法达到预期效果。
- 目前Bluetooth® 不支持多根天线功能,请不要使用与多根天线有关的 API。
推荐在以下场景中使用多根天线:
- 应用程序可以始终选择指定的天线,也可以执行自身天线选择算法,如根据应用程序收集的信息来选择天线模式等。请参考 IDF 示例 :idf_file:`examples/wifi/antenna/README.md` 来设计天线选择算法。
- 接收/发送数据的天线模式均配置为 WIFI_ANT_MODE_ANT0 或 WIFI_ANT_MODE_ANT1。
Wi-Fi 多根天线配置
+++++++++++++++++++++++++++++++++++++
通常,可以执行以下步骤来配置多根天线:
- 配置 antenna_selects 连接哪些 GPIOs例如如果支持四根天线且 GPIO20/GPIO21 连接到 antenna_select[0]/antenna_select[1],配置如下所示:
.. code-block:: c
wifi_ant_gpio_config_t ant_gpio_config = {
.gpio_cfg[0] = { .gpio_select = 1, .gpio_num = 20 },
.gpio_cfg[1] = { .gpio_select = 1, .gpio_num = 21 }
};
- 配置使能哪些天线、以及接收/发送数据如何使用使能的天线,例如,如果使能了天线 1 和天线 3接收数据需要自动选择较好的天线并将天线 1 作为默认天线,发送数据始终选择天线 3。配置如下所示:
.. code-block:: c
wifi_ant_config_t config = {
.rx_ant_mode = WIFI_ANT_MODE_AUTO,
.rx_ant_default = WIFI_ANT_ANT0,
.tx_ant_mode = WIFI_ANT_MODE_ANT1,
.enabled_ant0 = 1,
.enabled_ant1 = 3
};
具体请参考 :doc:`PHY <../api-guides/phy>`
.. only:: SOC_WIFI_CSI_SUPPORT