From 70cfbfbb3ee500f88a4ada76bc242aab8cef4756 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Mon, 29 Nov 2021 20:08:21 +0100 Subject: [PATCH] Preperations for dual antenna setups --- src/espwifistack.cpp | 28 ++++++++++++++++++++++++++++ src/espwifistackconfig.h | 6 ++++++ 2 files changed, 34 insertions(+) diff --git a/src/espwifistack.cpp b/src/espwifistack.cpp index 2f3f82d..479de2a 100644 --- a/src/espwifistack.cpp +++ b/src/espwifistack.cpp @@ -335,6 +335,34 @@ void init(const config &config) ESP_LOGE(TAG, "wifi_set_ap_config() failed with %s", esp_err_to_name(result)); } + if (config.dual_ant) + { + { + constexpr const wifi_ant_gpio_config_t config { + .gpio_cfg { + wifi_ant_gpio_t { .gpio_select = 1, .gpio_num = 2 }, + wifi_ant_gpio_t { .gpio_select = 1, .gpio_num = 25 } + } + }; + + if (const auto result = esp_wifi_set_ant_gpio(&config); result != ESP_OK) + ESP_LOGE(TAG, "esp_wifi_set_ant_gpio() failed with %s", esp_err_to_name(result)); + } + + { + wifi_ant_config_t config { + .rx_ant_mode = WIFI_ANT_MODE_AUTO, + .rx_ant_default = WIFI_ANT_ANT0, + .tx_ant_mode = WIFI_ANT_MODE_AUTO, + .enabled_ant0 = 0b0001, + .enabled_ant1 = 0b0010 + }; + + if (const auto result = esp_wifi_set_ant(&config); result != ESP_OK) + ESP_LOGE(TAG, "esp_wifi_set_ant() failed with %s", esp_err_to_name(result)); + } + } + last_ap_config = config.ap; _wifiState = WiFiState::None; diff --git a/src/espwifistackconfig.h b/src/espwifistackconfig.h index 348aab7..cdffada 100644 --- a/src/espwifistackconfig.h +++ b/src/espwifistackconfig.h @@ -131,6 +131,11 @@ struct sta_scan_config } }; +struct dual_ant_config +{ + +}; + struct sta_config { std::string hostname; @@ -211,6 +216,7 @@ struct eth_config struct config { std::optional base_mac_override; + std::optional dual_ant; std::optional sta; std::optional ap; #ifdef CONFIG_ETH_ENABLED