diff --git a/samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c b/samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c index 72e3f5b..04f5f52 100644 --- a/samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c +++ b/samples/radio_test_bm/src/nrf_wifi_radio_test_shell.c @@ -196,6 +196,55 @@ static int check_channel_settings(unsigned char tput_mode, return 0; } +static int nrf_wifi_init(size_t argc, const char *argv[]) +{ + int ret = 0; + struct nrf70_bm_regulatory_info reg_info = { 0 }; + + ARG_UNUSED(argc); + ARG_UNUSED(argv); + + memcpy(reg_info.country_code, CONFIG_WIFI_RT_REG_DOMAIN, 2); + reg_info.force = true; + + /* Initialize the Wi-Fi module */ + ret = nrf70_bm_rt_init(®_info); + if (ret) { + printf("Failed to initialize WiFi module\n"); + goto cleanup; + } + printf("Initialized WiFi module, ready for radio test\n"); + +cleanup: + if (ret) { + nrf70_bm_rt_deinit(); + printf("Exiting WiFi radio test sample application with error: %d\n", ret); + } + return ret; +} + +static int nrf_wifi_deinit(size_t argc, const char *argv[]) +{ + int ret; + + ARG_UNUSED(argc); + ARG_UNUSED(argv); + + ret = nrf70_bm_rt_deinit(); + if (ret) { + printf("Failed to deinitialize WiFi module\n"); + return ret; + } + + memset(&ctx->conf_params, 0, sizeof(ctx->conf_params)); + ctx->rf_test_run = false; + + printf("Deinitialized WiFi module\n"); + + return 0; +} + + enum nrf_wifi_status nrf_wifi_radio_test_conf_init(struct rpu_conf_params *conf_params) { enum nrf_wifi_status status = NRF_WIFI_STATUS_FAIL; @@ -861,26 +910,22 @@ static int nrf_wifi_radio_test_init(size_t argc, const char *argv[]) { if (ctx->conf_params.rx) { RT_SHELL_PRINTF_INFO("Disabling ongoing RX test\n"); - ctx->conf_params.rx = 0; - status = nrf_wifi_rt_fmac_prog_rx(ctx->rpu_ctx, &ctx->conf_params); - if (status != NRF_WIFI_STATUS_SUCCESS) { RT_SHELL_PRINTF_ERROR("Disabling RX failed\n"); + ctx->conf_params.rx = 1; return -ENOEXEC; } } if (ctx->conf_params.tx) { RT_SHELL_PRINTF_INFO("Disabling ongoing TX test\n"); - ctx->conf_params.tx = 0; - status = nrf_wifi_rt_fmac_prog_tx(ctx->rpu_ctx, &ctx->conf_params); - if (status != NRF_WIFI_STATUS_SUCCESS) { RT_SHELL_PRINTF_ERROR("Disabling TX failed\n"); + ctx->conf_params.tx = 1; return -ENOEXEC; } } @@ -888,16 +933,13 @@ static int nrf_wifi_radio_test_init(size_t argc, const char *argv[]) { if (ctx->rf_test_run) { if (ctx->rf_test != NRF_WIFI_RF_TEST_TX_TONE) { RT_SHELL_PRINTF_ERROR("Unexpected: RF Test (%d) running\n", ctx->rf_test); - return -ENOEXEC; } RT_SHELL_PRINTF_INFO("Disabling ongoing TX tone test\n"); - status = nrf_wifi_rt_fmac_rf_test_tx_tone(ctx->rpu_ctx, 0, ctx->conf_params.tx_tone_freq, - ctx->conf_params.tx_power); - + ctx->conf_params.tx_power); if (status != NRF_WIFI_STATUS_SUCCESS) { RT_SHELL_PRINTF_ERROR("Disabling TX tone test failed\n"); return -ENOEXEC; @@ -996,6 +1038,7 @@ static int nrf_wifi_radio_test_set_tx(size_t argc, const char *argv[]) { if (status != NRF_WIFI_STATUS_SUCCESS) { RT_SHELL_PRINTF_ERROR("Programming TX failed\n"); + ctx->conf_params.tx = !val; return -ENOEXEC; } @@ -1027,6 +1070,7 @@ static int nrf_wifi_radio_test_set_rx(size_t argc, const char *argv[]) { if (status != NRF_WIFI_STATUS_SUCCESS) { RT_SHELL_PRINTF_ERROR("Programming RX failed\n"); + ctx->conf_params.rx = !val; return -ENOEXEC; } @@ -1674,6 +1718,8 @@ DEFINE_CMD_HANDLER(nrf_wifi_radio_test_set_tx_power) DEFINE_CMD_HANDLER(nrf_wifi_radio_test_set_ru_tone) DEFINE_CMD_HANDLER(nrf_wifi_radio_test_set_ru_index) DEFINE_CMD_HANDLER(nrf_wifi_radio_test_init) +DEFINE_CMD_HANDLER(nrf_wifi_init); +DEFINE_CMD_HANDLER(nrf_wifi_deinit); DEFINE_CMD_HANDLER(nrf_wifi_radio_test_set_tx) DEFINE_CMD_HANDLER(nrf_wifi_radio_test_set_rx) #ifdef CONFIG_NRF70_SR_COEX_RF_SWITCH @@ -1791,6 +1837,10 @@ SHELL_STATIC_SUBCMD_SET_CREATE( RTSH(nrf_wifi_radio_test_set_ru_index), 2, 0), SHELL_CMD_ARG(init, NULL, "<val> - Primary channel number", RTSH(nrf_wifi_radio_test_init), 2, 0), + SHELL_CMD_ARG(nrf70_init, NULL, "Initialize nRF70", + RTSH(nrf_wifi_init), 0, 0), + SHELL_CMD_ARG(nrf70_deinit, NULL, "Deinitialize nRF70", + RTSH(nrf_wifi_deinit), 0, 0), SHELL_CMD_ARG(tx, NULL, "0 - Disable TX\n" "1 - Enable TX",