From 1e2ddc4c929d981e0382a90670d4dd38aa2f9ed4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jani=20Hirsim=C3=A4ki?= Date: Wed, 27 Nov 2024 13:55:17 +0200 Subject: [PATCH] samples: dect_phy: dect_shell: sett: band 4 support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Doing PHY API initialization when changing from/to band 4. Additionally, removing free-ISM support. Note: band #4 support only with nRF9151 and modem mfw 1.0.2. Jira: MOSH-622 Signed-off-by: Jani Hirsimäki --- .../releases/release-notes-changelog.rst | 1 + samples/dect/dect_phy/dect_shell/README.rst | 7 ++++- .../dect_shell/src/dect/common/dect_common.h | 7 ----- .../src/dect/common/dect_common_utils.c | 7 ----- .../dect_shell/src/dect/dect_phy_ctrl.c | 18 ++++++++++-- .../dect_shell/src/dect/dect_phy_shell.c | 28 +++++++++++++------ .../src/dect/mac/dect_phy_mac_shell.c | 12 ++++---- 7 files changed, 49 insertions(+), 31 deletions(-) diff --git a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst index 6d1ffb3963d1..821344d3ad08 100644 --- a/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst +++ b/doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst @@ -309,6 +309,7 @@ DECT NR+ samples This is not a full MAC implementation and not fully compliant with DECT NR+ MAC specification (`ETSI TS 103 636-4`_). * The ``startup_cmd`` command. This command is used to store shell commands to be run sequentially after bootup. + * Band 4 support for nRF9151 with modem firmware v1.0.2. * Updated: diff --git a/samples/dect/dect_phy/dect_shell/README.rst b/samples/dect/dect_phy/dect_shell/README.rst index 2da9d0620c6e..ae4bbff8df75 100644 --- a/samples/dect/dect_phy/dect_shell/README.rst +++ b/samples/dect/dect_phy/dect_shell/README.rst @@ -84,12 +84,17 @@ Examples dect sett --tx_pwr -16 -* Change the default band to ``2`` (has impact when automatic channel selection is used, in other words, the set channel is zero in ``dect rssi_scan`` or in ``dect mac beacon_start`` command): +* Change the default band to ``2`` (has impact when automatic channel selection is used, in other words, when the set channel is zero in ``dect rssi_scan`` or in ``dect mac beacon_start`` command): .. code-block:: console dect sett -b 2 +.. caution:: + There might be region-specific limitations for radio channel usage. + See Regulations and Channel frequency sections of the :ref:`nrfxlib:nrf_modem_dect_phy` page for using different DECT NR+ radio bands and channels in different regions. + Make sure to always measure the channel with the ``dect rssi_scan`` command before accessing the band. + RSSI measurement ================ diff --git a/samples/dect/dect_phy/dect_shell/src/dect/common/dect_common.h b/samples/dect/dect_phy/dect_shell/src/dect/common/dect_common.h index 4f13bf526a71..b3fa1e57ed36 100644 --- a/samples/dect/dect_phy/dect_shell/src/dect/common/dect_common.h +++ b/samples/dect/dect_phy/dect_shell/src/dect/common/dect_common.h @@ -196,10 +196,6 @@ typedef struct { /************************************************************************************************/ -/* Not in dect specs. This sub GHz band only with custom modem */ -#define DECT_PHY_SUPPORTED_CHANNEL_BAND_868_FREE_ISM_MIN 479 -#define DECT_PHY_SUPPORTED_CHANNEL_BAND_868_FREE_ISM_MAX 485 - /* Supported DECT bands. See ETSI TS 103 636-2 v1.3.1 Table 5.4.2-1. (3rd column) */ #define DECT_PHY_SUPPORTED_CHANNEL_BAND1_MIN 1657 @@ -208,7 +204,6 @@ typedef struct { #define DECT_PHY_SUPPORTED_CHANNEL_BAND2_MIN 1680 #define DECT_PHY_SUPPORTED_CHANNEL_BAND2_MAX 1700 -/* This sub GHz band only with custom modem */ #define DECT_PHY_SUPPORTED_CHANNEL_BAND4_MIN 524 #define DECT_PHY_SUPPORTED_CHANNEL_BAND4_MAX 552 @@ -218,8 +213,6 @@ typedef struct { #define DECT_PHY_SUPPORTED_CHANNEL_BAND22_MIN 1691 #define DECT_PHY_SUPPORTED_CHANNEL_BAND22_MAX 1711 -#define DECT_PHY_BAND_IS_CUSTOM_LOW(x) (x == 4 || x == 868) - /************************************************************************************************/ #define US_TO_MODEM_TICKS(x) ((uint64_t)(((x) * NRF_MODEM_DECT_MODEM_TIME_TICK_RATE_KHZ) / 1000)) diff --git a/samples/dect/dect_phy/dect_shell/src/dect/common/dect_common_utils.c b/samples/dect/dect_phy/dect_shell/src/dect/common/dect_common_utils.c index 55f2fcad466c..f762ea5e1c30 100644 --- a/samples/dect/dect_phy/dect_shell/src/dect/common/dect_common_utils.c +++ b/samples/dect/dect_phy/dect_shell/src/dect/common/dect_common_utils.c @@ -355,9 +355,6 @@ bool dect_common_utils_channel_is_supported(uint16_t band_nbr, uint16_t channel, } else if (band_nbr == 22) { return (channel >= DECT_PHY_SUPPORTED_CHANNEL_BAND22_MIN && channel <= DECT_PHY_SUPPORTED_CHANNEL_BAND22_MAX); - } else if (band_nbr == 868) { - return (channel >= DECT_PHY_SUPPORTED_CHANNEL_BAND_868_FREE_ISM_MIN && - channel <= DECT_PHY_SUPPORTED_CHANNEL_BAND_868_FREE_ISM_MAX); } else { return false; } @@ -375,8 +372,6 @@ uint16_t dect_common_utils_channel_max_on_band(uint16_t band_nbr) return DECT_PHY_SUPPORTED_CHANNEL_BAND9_MAX; } else if (band_nbr == 22) { return DECT_PHY_SUPPORTED_CHANNEL_BAND22_MAX; - } else if (band_nbr == 868) { - return DECT_PHY_SUPPORTED_CHANNEL_BAND_868_FREE_ISM_MAX; } else { return 0; } @@ -394,8 +389,6 @@ uint16_t dect_common_utils_channel_min_on_band(uint16_t band_nbr) return DECT_PHY_SUPPORTED_CHANNEL_BAND9_MIN; } else if (band_nbr == 22) { return DECT_PHY_SUPPORTED_CHANNEL_BAND22_MIN; - } else if (band_nbr == 868) { - return DECT_PHY_SUPPORTED_CHANNEL_BAND_868_FREE_ISM_MIN; } else { return 0; } diff --git a/samples/dect/dect_phy/dect_shell/src/dect/dect_phy_ctrl.c b/samples/dect/dect_phy/dect_shell/src/dect/dect_phy_ctrl.c index e0460b853b92..920b0452a71f 100644 --- a/samples/dect/dect_phy/dect_shell/src/dect/dect_phy_ctrl.c +++ b/samples/dect/dect_phy/dect_shell/src/dect/dect_phy_ctrl.c @@ -185,6 +185,11 @@ static void dect_phy_ctrl_msgq_thread_handler(void) break; } case DECT_PHY_CTRL_OP_SETTINGS_UPDATED: { + bool phy_api_reinit_needed = *((bool *)event.data); + + if (phy_api_reinit_needed) { + dect_phy_ctrl_phy_reinit(); + } if (ctrl_data.ext_cmd.sett_changed_cb != NULL) { ctrl_data.ext_cmd.sett_changed_cb(); } @@ -193,17 +198,21 @@ static void dect_phy_ctrl_msgq_thread_handler(void) case DECT_PHY_CTRL_OP_PHY_API_MDM_INITIALIZED: { struct dect_phy_common_op_initialized_params *params = (struct dect_phy_common_op_initialized_params *)event.data; + char tmp_str[128] = {0}; if (params->temperature != NRF_MODEM_DECT_PHY_TEMP_NOT_MEASURED) { ctrl_data.last_valid_temperature = params->temperature; } if (params->status) { + dect_common_utils_modem_phy_err_to_string( + params->status, params->temperature, tmp_str); + desh_error("(%s): init failed (time %llu, temperature %d, " - "temp_limit %d): %d", + "temp_limit %d): %d (%s)", (__func__), params->time, params->temperature, params->modem_configuration.temperature_limit, - params->status); + params->status, tmp_str); } else { if (ctrl_data.phy_api_init_count <= 1) { desh_print("DECT modem initialized:"); @@ -739,8 +748,13 @@ static void dect_phy_ctrl_phy_init(void) ctrl_data.dect_phy_init_params.harq_rx_expiry_time_us = current_settings->harq.mdm_init_harq_expiry_time_us; + ctrl_data.dect_phy_init_params.harq_rx_process_count = current_settings->harq.mdm_init_harq_process_count; + ctrl_data.dect_phy_init_params.reserved = 0; + ctrl_data.dect_phy_init_params.band4_support = + ((current_settings->common.band_nbr == 4) ? 1 : 0); + if (ret) { printk("nrf_modem_dect_phy_callback_set returned: %i\n", ret); } else { diff --git a/samples/dect/dect_phy/dect_shell/src/dect/dect_phy_shell.c b/samples/dect/dect_phy/dect_shell/src/dect/dect_phy_shell.c index 8f350bcaeecc..265b923420af 100644 --- a/samples/dect/dect_phy/dect_shell/src/dect/dect_phy_shell.c +++ b/samples/dect/dect_phy/dect_shell/src/dect/dect_phy_shell.c @@ -405,7 +405,8 @@ static const char dect_phy_rf_tool_cmd_usage_str[] = " -c, --channel , Channel. Default 1665.\n" " Ranges: band #1: 1657-1677 (only odd numbers as per\n" " ETSI EN 301 406-2, ch 4.3.2.3),\n" - " band #2 1680-1700, band #9 1691-1711.\n" + " band #2 1680-1700, band #4 524-552,\n" + " band #9 1703-1711, band #22 1691-1711.\n" " -e --rx_exp_rssi_level , Set expected RSSI level on RX (dBm).\n" " Default: from common rx settings.\n" " -p --tx_pwr , TX power (dBm),\n" @@ -1334,7 +1335,8 @@ static const char dect_phy_sett_cmd_usage_str[] = " -b, --band_nbr <#>, Set used band.\n" " Impacted on when a channel is set as zero\n" " (e.g. in rssi_scan).\n" - " Default: band #1. Other supported bands are: 2, 9 and 22.\n" + " Default: band #1. Other supported bands are:\n" + " 2, 4, 9 and 22.\n" " -d, --sche_delay , Estimated scheduling delay (us).\n" "RSSI measurement settings:\n" " --rssi_scan_time , Channel access: set the time (msec) that is used for\n" @@ -1470,6 +1472,7 @@ static int dect_phy_sett_cmd(const struct shell *shell, size_t argc, char **argv int long_index = 0; int opt, tmp_value; + bool phy_api_reinit_needed = false; if (argc < 2) { goto show_usage; @@ -1510,16 +1513,18 @@ static int dect_phy_sett_cmd(const struct shell *shell, size_t argc, char **argv case 'b': { tmp_value = atoi(optarg); if (tmp_value == 1 || tmp_value == 2 || tmp_value == 4 || tmp_value == 9 || - tmp_value == 22 || tmp_value == 868) { + tmp_value == 22) { newsettings.common.band_nbr = tmp_value; } else { desh_error("Band #%d is not supported.", tmp_value); return -EINVAL; } - if (newsettings.common.band_nbr == 4 || - newsettings.common.band_nbr == 868) { - desh_print("Custom low band chosen: " - "custom modem fw is needed to get it working."); + if ((newsettings.common.band_nbr == 4 && + current_settings.common.band_nbr != 4) || + (current_settings.common.band_nbr == 4 && + newsettings.common.band_nbr != 4)) { + /* If changing to/from 4, we need dto reinit PHY API */ + phy_api_reinit_needed = true; } break; } @@ -1604,7 +1609,8 @@ static int dect_phy_sett_cmd(const struct shell *shell, size_t argc, char **argv } case DECT_SHELL_SETT_RESET_ALL: { dect_common_settings_defaults_set(); - return 0; + phy_api_reinit_needed = true; + goto settings_updated; } case 'h': goto show_usage; @@ -1620,7 +1626,11 @@ static int dect_phy_sett_cmd(const struct shell *shell, size_t argc, char **argv } dect_common_settings_write(&newsettings); - dect_phy_ctrl_msgq_non_data_op_add(DECT_PHY_CTRL_OP_SETTINGS_UPDATED); +settings_updated: + dect_phy_ctrl_msgq_data_op_add( + DECT_PHY_CTRL_OP_SETTINGS_UPDATED, + (void *)&phy_api_reinit_needed, + sizeof(bool)); return 0; show_usage: diff --git a/samples/dect/dect_phy/dect_shell/src/dect/mac/dect_phy_mac_shell.c b/samples/dect/dect_phy/dect_shell/src/dect/mac/dect_phy_mac_shell.c index 1b8ad7a17a93..d454e2fd6f8c 100644 --- a/samples/dect/dect_phy/dect_shell/src/dect/mac/dect_phy_mac_shell.c +++ b/samples/dect/dect_phy/dect_shell/src/dect/mac/dect_phy_mac_shell.c @@ -55,7 +55,8 @@ static const char dect_phy_mac_beacon_scan_usage_str[] = "Options:\n" " -c , Channel nbr to be scanned for a beacon.\n" " Ranges: band #1: 1657-1677, band #2 1680-1700,\n" - " band #9 1691-1711. Zero value: all in a set band.\n" + " band #4 524-552, band #9 1703-1711,\n" + " band #22 1691-1711. Zero value: all in a set band.\n" " Default: 1665.\n" " -t, --scan_time , Scanning duration in seconds (default: 4 " "seconds).\n" @@ -186,7 +187,8 @@ static const char dect_phy_mac_beacon_start_cmd_usage_str[] = "Options:\n" " -c , Used channel for a beacon.\n" " Ranges: band #1: 1657-1677 (only odd numbers),\n" - " band #2 1680-1700, band #9 1691-1711.\n" + " band #2 1680-1700, band #4 524-552, band #9 1703-1711,\n" + " band #22 1691-1711.\n" " Default: 0, i.e. automatic selection of\n" " free/possible channel on a set band.\n" " -p, --tx_pwr , Set beacon broadcast power (dBm), default: -16.\n" @@ -273,7 +275,7 @@ static const char dect_phy_mac_associate_cmd_usage_str[] = " -m, --tx_mcs , TX MCS (integer). Default: 0.\n" "Note: LBT (Listen Before Talk) is enabled as a default for a min period,\n" " but the LBT max RSSI threshold can be configured in settings\n" - " (dect sett ----rssi_scan_busy_th ).\n"; + " (dect sett --rssi_scan_busy_th ).\n"; /* Specifying the expected options (both long and short): */ static struct option long_options_associate[] = {{"tx_pwr", required_argument, 0, 'p'}, @@ -356,7 +358,7 @@ static const char dect_phy_mac_dissociate_cmd_usage_str[] = " -m, --tx_mcs , TX MCS (integer). Default: 0.\n" "Note: LBT (Listen Before Talk) is enabled as a default for a min period,\n" " but the LBT max RSSI threshold can be configured in settings\n" - " (dect sett ----rssi_scan_busy_th ).\n"; + " (dect sett --rssi_scan_busy_th ).\n"; /* Specifying the expected options (both long and short): */ static struct option long_options_dissociate[] = { @@ -443,7 +445,7 @@ static const char dect_phy_mac_rach_tx_cmd_usage_str[] = " is encoded in JSON.\n" "Note: LBT (Listen Before Talk) is enabled as a default for a min period,\n" " but the LBT max RSSI threshold can be configured in settings\n" - " (dect sett ----rssi_scan_busy_th ).\n"; + " (dect sett --rssi_scan_busy_th ).\n"; #define DECT_PHY_MAC_RACH_TX_DATA_JSON_OVERHEAD 30