From c8d7c9bd712fa71609c8b0e7d441ceffb4ab938f Mon Sep 17 00:00:00 2001 From: xiehang Date: Thu, 16 Feb 2023 15:31:32 +0800 Subject: [PATCH] Add the output RX result command --- .../esp_phy/include/esp_phy_cert_test.h | 27 +++++++++++++++++++ examples/phy/cert_test/README.md | 10 +++++-- examples/phy/cert_test/main/cert_test.c | 2 -- examples/phy/cert_test/main/cmd_phy.c | 26 ++++++++++++++++++ examples/phy/cert_test/sdkconfig.defaults | 1 - 5 files changed, 61 insertions(+), 5 deletions(-) diff --git a/components/esp_phy/include/esp_phy_cert_test.h b/components/esp_phy/include/esp_phy_cert_test.h index 868b06c48c..461295683c 100644 --- a/components/esp_phy/include/esp_phy_cert_test.h +++ b/components/esp_phy/include/esp_phy_cert_test.h @@ -56,6 +56,26 @@ typedef enum { PHY_BLE_TYPE_MAX } esp_phy_ble_type_t; +/** + * @brief Structure holding PHY RX result + */ +typedef struct { + uint32_t phy_rx_correct_count; /*!< The number of desired packets received */ + int phy_rx_rssi; /*!< Average RSSI of desired packets */ + uint32_t phy_rx_total_count; /*!< The number of total packets received */ + uint32_t phy_rx_result_flag; /*!< 0 means no RX info; 1 means the lastest Wi-Fi RX info; 2 means the lastest BLE RX info. */ +} esp_phy_rx_result_t; + +/** + * @brief Wifi power domain power on + */ +void esp_wifi_power_domain_on(void); + +/** + * @brief Wifi power domain power off + */ +void esp_wifi_power_domain_off(void); + /** * @brief Environment variable configuration * @@ -161,6 +181,13 @@ void esp_phy_ble_rx(uint32_t chan, uint32_t syncw, esp_phy_ble_rate_t rate); */ void esp_phy_bt_tx_tone(uint32_t start, uint32_t chan, uint32_t power); +/** + * @brief Get some RX information + * + * @param rx_result: This struct for storing RX information; + */ +void esp_phy_get_rx_result(esp_phy_rx_result_t *rx_result); + #ifdef __cplusplus } #endif diff --git a/examples/phy/cert_test/README.md b/examples/phy/cert_test/README.md index 86cedd5931..b5ff530578 100644 --- a/examples/phy/cert_test/README.md +++ b/examples/phy/cert_test/README.md @@ -78,7 +78,10 @@ phy> esp_rx -n 1 -r 0 I (19348) phy: wifi rx start: channel is 1, rate is 0x0 phy> phy> cmdstop -I (24248) phy: Correct: 1112 Desired: 773 RSSI: -633 noise: -960 gain: 629 para1: 12198 para2 +I (142881) phy: Total: 535 Correct: 474 RSSI: -650 noise: -960 gain: 531 para1: 5759 para2: 3 +phy> +phy> get_rx_result +I (145991) cmd_phy: Total: 535, Correct: 474, RSSI: -650, flag: 1 phy> phy> wifiscwout -e 1 -c 1 -p 0 I (98308) phy: wifi single carrier tx out, single carrier is in 1 channel, power is about (2 @@ -93,7 +96,10 @@ phy> esp_ble_rx -n 1 -s 0x71764129 -r 0 I (2898) phy: RW LE V9 RX PER phy> phy> cmdstop -I (7678) phy: 144 0 0 5 13f 0 0 0 0 0 p 0 0 0 0 0 0 +I (381241) phy: 3 0 0 0 3 0 0 0 0 0 p -263 -86 -279 a8 -100 -77 +phy> +phy> get_rx_result +I (383871) cmd_phy: Total: 3, Correct: 0, RSSI: 0, flag: 2 phy> phy> bt_tx_tone -e 1 -n 1 -p 0 I (56008) phy: BT TX TONE START! diff --git a/examples/phy/cert_test/main/cert_test.c b/examples/phy/cert_test/main/cert_test.c index f3027cc28f..4e8e3c0405 100644 --- a/examples/phy/cert_test/main/cert_test.c +++ b/examples/phy/cert_test/main/cert_test.c @@ -12,8 +12,6 @@ #include "cmd_phy.h" #include "esp_phy_cert_test.h" -#include "esp_private/wifi.h" - void app_main(void) { ESP_ERROR_CHECK(nvs_flash_init()); diff --git a/examples/phy/cert_test/main/cmd_phy.c b/examples/phy/cert_test/main/cmd_phy.c index 391ec25287..4672a866ae 100644 --- a/examples/phy/cert_test/main/cmd_phy.c +++ b/examples/phy/cert_test/main/cmd_phy.c @@ -56,6 +56,23 @@ static int esp_phy_cmdstop_func(int argc, char **argv) return 0; } +static int esp_phy_get_rx_result_func(int argc, char **argv) +{ + esp_phy_rx_result_t rx_result; + int nerrors = arg_parse(argc, argv, (void **) &phy_args); + if (nerrors != 0) { + arg_print_errors(stderr, phy_args.end, argv[0]); + return 1; + } + + esp_phy_get_rx_result(&rx_result); + + ESP_LOGI(TAG, "Total: %lu, Correct: %lu, RSSI: %d, flag: %lu", rx_result.phy_rx_total_count, + rx_result.phy_rx_correct_count, rx_result.phy_rx_rssi, rx_result.phy_rx_result_flag); + + return 0; +} + #if SOC_WIFI_SUPPORTED void cert_wifi_tx(void *arg) { @@ -393,6 +410,15 @@ void register_phy_cmd(void) }; ESP_ERROR_CHECK( esp_console_cmd_register(&cmdstop_cmd) ); + const esp_console_cmd_t get_rx_result = { + .command = "get_rx_result", + .help = "Get RX information", + .hint = NULL, + .func = &esp_phy_get_rx_result_func, + .argtable = NULL + }; + ESP_ERROR_CHECK( esp_console_cmd_register(&get_rx_result) ); + #if SOC_WIFI_SUPPORTED const esp_console_cmd_t cbw40m_cmd = { .command = "cbw40m_en", diff --git a/examples/phy/cert_test/sdkconfig.defaults b/examples/phy/cert_test/sdkconfig.defaults index 905254449c..b0ce7b5c29 100644 --- a/examples/phy/cert_test/sdkconfig.defaults +++ b/examples/phy/cert_test/sdkconfig.defaults @@ -1,4 +1,3 @@ -CONFIG_ESP_INT_WDT=n CONFIG_ESP_TASK_WDT_EN=n CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION=y