Skip to content

Commit

Permalink
samples: dect_phy: dect_shell: sett: band 4 support
Browse files Browse the repository at this point in the history
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 <jani.hirsimaki@nordicsemi.no>
  • Loading branch information
jhirsi authored and rlubos committed Nov 28, 2024
1 parent d1c785a commit 1e2ddc4
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
7 changes: 6 additions & 1 deletion samples/dect/dect_phy/dect_shell/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
================

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand All @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down
18 changes: 16 additions & 2 deletions samples/dect/dect_phy/dect_shell/src/dect/dect_phy_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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:");
Expand Down Expand Up @@ -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 {
Expand Down
28 changes: 19 additions & 9 deletions samples/dect/dect_phy/dect_shell/src/dect/dect_phy_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,8 @@ static const char dect_phy_rf_tool_cmd_usage_str[] =
" -c, --channel <int>, 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 <int>, Set expected RSSI level on RX (dBm).\n"
" Default: from common rx settings.\n"
" -p --tx_pwr <int>, TX power (dBm),\n"
Expand Down Expand Up @@ -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 <usecs>, Estimated scheduling delay (us).\n"
"RSSI measurement settings:\n"
" --rssi_scan_time <msecs>, Channel access: set the time (msec) that is used for\n"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
Expand All @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@ static const char dect_phy_mac_beacon_scan_usage_str[] =
"Options:\n"
" -c <integer>, 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 <integer>, Scanning duration in seconds (default: 4 "
"seconds).\n"
Expand Down Expand Up @@ -186,7 +187,8 @@ static const char dect_phy_mac_beacon_start_cmd_usage_str[] =
"Options:\n"
" -c <integer>, 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 <dbm>, Set beacon broadcast power (dBm), default: -16.\n"
Expand Down Expand Up @@ -273,7 +275,7 @@ static const char dect_phy_mac_associate_cmd_usage_str[] =
" -m, --tx_mcs <integer>, 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 <dbm>).\n";
" (dect sett --rssi_scan_busy_th <dbm>).\n";

/* Specifying the expected options (both long and short): */
static struct option long_options_associate[] = {{"tx_pwr", required_argument, 0, 'p'},
Expand Down Expand Up @@ -356,7 +358,7 @@ static const char dect_phy_mac_dissociate_cmd_usage_str[] =
" -m, --tx_mcs <integer>, 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 <dbm>).\n";
" (dect sett --rssi_scan_busy_th <dbm>).\n";

/* Specifying the expected options (both long and short): */
static struct option long_options_dissociate[] = {
Expand Down Expand Up @@ -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 <dbm>).\n";
" (dect sett --rssi_scan_busy_th <dbm>).\n";

#define DECT_PHY_MAC_RACH_TX_DATA_JSON_OVERHEAD 30

Expand Down

0 comments on commit 1e2ddc4

Please sign in to comment.