Skip to content

Commit

Permalink
samples: dect_phy: dect_shell: modem 1.1 support
Browse files Browse the repository at this point in the history
Major modem/libmodem api update. Also did related changes:
- new commands: activate/deactivate, radio_mode
- new setting: startup radio mode for activation
- pcc/pdc rx includes handle but not carrier/channel,
thus keeping up to date information for that.
- ping/perf/rf_tool: still own callbacks but no reinit of phy api,
doing cancel(all) instead.
- rf_tool: decreased --frame_repeat_count default to 15.
- rf_tool: "rf_tool command done" print at the end.
- radio mode query is used.
- latency info usage is added.
Jira: MOSH-621

Signed-off-by: Jani Hirsimäki <[email protected]>
  • Loading branch information
jhirsi committed Jan 22, 2025
1 parent 1107269 commit 1af4135
Show file tree
Hide file tree
Showing 28 changed files with 1,582 additions and 1,019 deletions.
34 changes: 14 additions & 20 deletions samples/dect/dect_phy/dect_shell/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ Main command structure:
.. code-block:: console
dect
activate
deactivate
sett
radio_mode
rssi_scan
ping
perf
Expand Down Expand Up @@ -286,15 +289,6 @@ Example 2: HARQ
dect perf -c --c_gap_subslots 4 --c_tx_mcs 4 --c_slots 4 --s_tx_id 39 -t 12 --c_harq_feedback_rx_delay_subslots 2 --c_harq_feedback_rx_subslots 3 --c_harq_process_nbr_max 7 -a --channel 1671
* Client side: Decrease default scheduler delay and rerun the previous step:

.. code-block:: console
dect sett -d 5000
.. note::
Set the delay back to default to avoid scheduler problems on other use cases.

RX/TX testing with RF tool
==========================

Expand Down Expand Up @@ -329,13 +323,13 @@ Example 1: bi-directional testing
.. code-block:: console
dect sett -t 39
dect rf_tool -m rx_tx --rx_find_sync --frame_repeat_count 50 --frame_repeat_count_intervals 10 -c 1677
dect rf_tool -m rx_tx --rx_find_sync --frame_repeat_count 15 --frame_repeat_count_intervals 10 -c 1677
* Client side: Trigger to start operation:

.. code-block:: console
dect rf_tool -m rx_tx --frame_repeat_count 50 --frame_repeat_count_intervals 10 -t 39 -c 1677
dect rf_tool -m rx_tx --frame_repeat_count 15 --frame_repeat_count_intervals 10 -t 39 -c 1677
Example 2: unidirectional testing
---------------------------------
Expand All @@ -346,7 +340,7 @@ Example 2: unidirectional testing
.. code-block:: console
dect sett -t 39
dect rf_tool -m rx --rx_find_sync --frame_repeat_count 50 -c 1677
dect rf_tool -m rx --rx_find_sync --frame_repeat_count 15 -c 1677
* RX device option 2: RX device on ``rx_cont`` mode:

Expand All @@ -360,13 +354,13 @@ Example 2: unidirectional testing
.. code-block:: console
dect sett -t 39
dect rf_tool -m rx_cont --rf_mode_peer tx --frame_repeat_count 50 --rx_find_sync -c 1677
dect rf_tool -m rx_cont --rf_mode_peer tx --frame_repeat_count 15 --rx_find_sync -c 1677
* TX device: Trigger to start operation:

.. code-block:: console
dect rf_tool -m tx --frame_repeat_count 50 -c 1677 -t 39
dect rf_tool -m tx --frame_repeat_count 15 -c 1677 -t 39
* RX device with option 2: Stop continuous RX to give a report:

Expand All @@ -388,20 +382,20 @@ Example 3: duty cycle (RX+TX) testing
.. code-block:: console
server:
dect rf_tool -m rx_tx --rx_find_sync --rx_subslot_count 9 --rx_idle_subslot_count 3 --tx_subslot_count 8 --tx_idle_subslot_count 3 --frame_repeat_count 50 -c 1677
dect rf_tool -m rx_tx --rx_find_sync --rx_subslot_count 9 --rx_idle_subslot_count 3 --tx_subslot_count 8 --tx_idle_subslot_count 3 --frame_repeat_count 15 -c 1677
client:
dect rf_tool -m rx_tx --rx_subslot_count 9 --rx_idle_subslot_count 3 --tx_subslot_count 8 --tx_idle_subslot_count 3 --frame_repeat_count 50 -c 1677 -t 39
dect rf_tool -m rx_tx --rx_subslot_count 9 --rx_idle_subslot_count 3 --tx_subslot_count 8 --tx_idle_subslot_count 3 --frame_repeat_count 15 -c 1677 -t 39
RX/TX duty cycle percentage 82.50%:

.. code-block:: console
server:
dect rf_tool -m rx_tx --rx_find_sync --rx_subslot_count 17 --rx_idle_subslot_count 3 --tx_subslot_count 16 --tx_idle_subslot_count 4 --frame_repeat_count 50 -c 1677
dect rf_tool -m rx_tx --rx_find_sync --rx_subslot_count 17 --rx_idle_subslot_count 3 --tx_subslot_count 16 --tx_idle_subslot_count 4 --frame_repeat_count 15 -c 1677
client:
dect rf_tool -m rx_tx --rx_subslot_count 17 --rx_idle_subslot_count 3 --tx_subslot_count 16 --tx_idle_subslot_count 4 --frame_repeat_count 50 -c 1677 -t 39
dect rf_tool -m rx_tx --rx_subslot_count 17 --rx_idle_subslot_count 3 --tx_subslot_count 16 --tx_idle_subslot_count 4 --frame_repeat_count 15 -c 1677 -t 39
* TX/RX testing on separate devices:

Expand Down Expand Up @@ -433,10 +427,10 @@ Example 4: Bi-directional testing with more data
.. code-block:: console
server:
dect rf_tool -m rx_tx --rx_find_sync --rx_subslot_count 9 --rx_idle_subslot_count 4 --tx_subslot_count 8 --tx_idle_subslot_count 4 --tx_mcs 4 --frame_repeat_count 50 -c 1677
dect rf_tool -m rx_tx --rx_find_sync --rx_subslot_count 9 --rx_idle_subslot_count 4 --tx_subslot_count 8 --tx_idle_subslot_count 4 --tx_mcs 4 --frame_repeat_count 15 -c 1677
client:
dect rf_tool -m rx_tx --rx_subslot_count 9 --rx_idle_subslot_count 4 --tx_subslot_count 8 --tx_idle_subslot_count 4 --tx_mcs 4 --frame_repeat_count 50 -c 1677 --tx_pwr 15 -t 39
dect rf_tool -m rx_tx --rx_subslot_count 9 --rx_idle_subslot_count 4 --tx_subslot_count 8 --tx_idle_subslot_count 4 --tx_mcs 4 --frame_repeat_count 15 -c 1677 --tx_pwr 15 -t 39
Dect NR+ PHY MAC
================
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,15 @@ typedef struct {
#define DECT_PHY_SUPPORTED_CHANNEL_BAND22_MIN 1691
#define DECT_PHY_SUPPORTED_CHANNEL_BAND22_MAX 1711

#define DESH_DECT_PHY_SUPPORTED_BAND_COUNT 5

/************************************************************************************************/

#define DECT_PHY_CLASS_1_MAX_TX_POWER_DBM 23
#define DECT_PHY_CLASS_2_MAX_TX_POWER_DBM 21
#define DECT_PHY_CLASS_3_MAX_TX_POWER_DBM 19
#define DECT_PHY_CLASS_4_MAX_TX_POWER_DBM 10

/************************************************************************************************/

#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 @@ -53,6 +53,8 @@ static const struct dect_phy_settings_common phy_common_settings_data = {
.network_id = DECT_PHY_DEFAULT_NETWORK_ID,
.transmitter_id = DECT_PHY_DEFAULT_TRANSMITTER_LONG_RD_ID,
.band_nbr = 1,
.activate_at_startup = true,
.startup_radio_mode = NRF_MODEM_DECT_PHY_RADIO_MODE_LOW_LATENCY,
};

static const struct dect_phy_settings phy_settings_data_defaults = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#define DECT_PHY_DEFAULT_NETWORK_ID 0x12345678
#define DECT_PHY_DEFAULT_TRANSMITTER_LONG_RD_ID 38
#define DECT_PHY_API_SCHEDULER_OFFSET_US (10000)
#define DECT_PHY_API_SCHEDULER_OFFSET_US (5000)

#define DECT_PHY_SETT_DEFAULT_BEACON_TX_INTERVAL_SECS 2

Expand Down Expand Up @@ -109,6 +109,8 @@ struct dect_phy_settings_common {
uint32_t network_id;
uint32_t transmitter_id;
uint16_t band_nbr;
bool activate_at_startup;
enum nrf_modem_dect_phy_radio_mode startup_radio_mode;
uint16_t short_rd_id; /* Generated random value, cannot be set */
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ const char *dect_common_utils_modem_phy_err_to_string(enum nrf_modem_dect_phy_er
{NRF_MODEM_DECT_PHY_SUCCESS, "NRF_MODEM_DECT_PHY_SUCCESS"},
{NRF_MODEM_DECT_PHY_ERR_LBT_CHANNEL_BUSY, "ERR_LBT_CHANNEL_BUSY"},
{NRF_MODEM_DECT_PHY_ERR_UNSUPPORTED_OP, "ERR_UNSUPPORTED_OP"},
{NRF_MODEM_DECT_PHY_ERR_NO_ONGOING_OP, "ERR_NO_ONGOING_OP"},
{NRF_MODEM_DECT_PHY_ERR_NOT_FOUND, "ERR_NOT_FOUND"},
{NRF_MODEM_DECT_PHY_ERR_NO_MEMORY, "ERR_NO_MEMORY"},
{NRF_MODEM_DECT_PHY_ERR_NOT_ALLOWED, "ERR_NOT_ALLOWED"},
{NRF_MODEM_DECT_PHY_OK_WITH_HARQ_RESET, "PHY_OK_WITH_HARQ_RESET"},
Expand All @@ -244,15 +244,18 @@ const char *dect_common_utils_modem_phy_err_to_string(enum nrf_modem_dect_phy_er
{NRF_MODEM_DECT_PHY_ERR_PAYLOAD_UNAVAILABLE, "ERR_PAYLOAD_UNAVAILABLE"},
{NRF_MODEM_DECT_PHY_ERR_OP_CANCELED, "PHY_ERR_OP_CANCELED"},
{NRF_MODEM_DECT_PHY_ERR_COMBINED_OP_FAILED, "ERR_COMBINED_OP_FAILED"},
{NRF_MODEM_DECT_PHY_ERR_RADIO_MODE_CONFLICT, "ERR_RADIO_MODE_CONFLICT"},
{NRF_MODEM_DECT_PHY_ERR_UNSUPPORTED_CARRIER, "ERR_UNSUPPORTED_CARRIER"},
{NRF_MODEM_DECT_PHY_ERR_UNSUPPORTED_DATA_SIZE, "ERR_UNSUPPORTED_DATA_SIZE"},
{NRF_MODEM_DECT_PHY_ERR_INVALID_NETWORK_ID, "ERR_INVALID_NETWORK_ID"},
{NRF_MODEM_DECT_PHY_ERR_INVALID_PHY_HEADER, "ERR_INVALID_PHY_HEADER"},
{NRF_MODEM_DECT_PHY_ERR_INVALID_DURATION, "ERR_INVALID_DURATION"},
{NRF_MODEM_DECT_PHY_ERR_INVALID_PARAMETER, "ERR_INVALID_PARAMETER"},
{NRF_MODEM_DECT_PHY_ERR_TX_POWER_OVER_MAX_LIMIT, "ERR_TX_POWER_OVER_MAX_LIMIT"},
{NRF_MODEM_DECT_PHY_ERR_MODEM_ERROR, "ERR_MODEM_ERROR"},
{NRF_MODEM_DECT_PHY_ERR_MODEM_ERROR_RF_STATE, "ERR_MODEM_ERROR_RF_STATE"},
{NRF_MODEM_DECT_PHY_ERR_TEMP_HIGH, "ERR_TEMP_HIGH"},
{NRF_MODEM_DECT_PHY_ERR_PROD_LOCK, "ERR_PROD_LOCK"},
/* Specific internal errors: */
{DECT_SCHEDULER_DELAYED_ERROR, "DECT_SCHEDULER_DELAYED_ERROR"},
{DECT_SCHEDULER_SCHEDULER_FATAL_MEM_ALLOC_ERROR,
Expand Down Expand Up @@ -489,3 +492,33 @@ bool dect_common_utils_mdm_ticks_is_in_range(uint64_t time, uint64_t start, uint
{
return (time >= start && time <= end);
}

/**************************************************************************************************/

const char *dect_common_utils_radio_mode_to_string(int mode, char *out_str_buff)
{
struct mapping_tbl_item const mapping_table[] = {
{NRF_MODEM_DECT_PHY_RADIO_MODE_LOW_LATENCY, "Low latency"},
{NRF_MODEM_DECT_PHY_RADIO_MODE_LOW_LATENCY_WITH_STANDBY,
"Low latency with standby"},
{NRF_MODEM_DECT_PHY_RADIO_MODE_NON_LBT_WITH_STANDBY, "LBT disabled, with standby"},
{-1, NULL}};

return dect_common_utils_map_to_string(mapping_table, mode, out_str_buff);
}

/**************************************************************************************************/

int8_t dect_common_utils_max_tx_pwr_dbm_by_pwr_class(uint8_t power_class)
{
if (power_class == 1) {
return DECT_PHY_CLASS_1_MAX_TX_POWER_DBM;
} else if (power_class == 2) {
return DECT_PHY_CLASS_2_MAX_TX_POWER_DBM;
} else if (power_class == 3) {
return DECT_PHY_CLASS_3_MAX_TX_POWER_DBM;
} else {
return DECT_PHY_CLASS_4_MAX_TX_POWER_DBM;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,12 @@ bool dect_common_utils_32bit_network_id_validate(uint32_t network_id);

bool dect_common_utils_mdm_ticks_is_in_range(uint64_t time, uint64_t start, uint64_t end);

/******************************************************************************/

const char *dect_common_utils_radio_mode_to_string(int mode, char *out_str_buff);

/******************************************************************************/

int8_t dect_common_utils_max_tx_pwr_dbm_by_pwr_class(uint8_t power_class);

#endif /* DECT_COMMON_UTILS_H */
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
#include "dect_common_settings.h"
#include "dect_phy_common_rx.h"

#include "dect_phy_ctrl.h"

#include "dect_phy_api_scheduler_integration.h"
#include "dect_phy_api_scheduler.h"

Expand Down Expand Up @@ -64,7 +66,6 @@ static void dect_phy_api_scheduler_led_off_timer_handler(struct k_timer *timer_i

static bool dect_phy_api_scheduler_list_remove_from_tail(void);
static void dect_phy_api_scheduler_list_purge(void);
static bool dect_phy_api_scheduler_list_is_empty(void);

static struct dect_phy_api_scheduler_list_item *
dect_phy_api_scheduler_done_list_item_add(struct dect_phy_api_scheduler_list_item *new_list_item);
Expand Down Expand Up @@ -212,7 +213,7 @@ static bool dect_phy_api_scheduler_list_remove_from_tail(void)
return return_value;
}

static bool dect_phy_api_scheduler_list_is_empty(void)
bool dect_phy_api_scheduler_list_is_empty(void)
{
return sys_dlist_is_empty(&to_be_sheduled_list);
}
Expand Down Expand Up @@ -476,11 +477,12 @@ struct dect_phy_api_scheduler_list_item *
dect_phy_api_scheduler_list_item_add(struct dect_phy_api_scheduler_list_item *new_list_item)
{
struct dect_phy_api_scheduler_list_item *iterator = NULL;
const uint32_t scheduler_offset = DECT_PHY_TX_RX_SCHEDULING_OFFSET_MDM_TICKS;

if (new_list_item == NULL) {
return NULL;
}
uint32_t scheduler_offset = dect_phy_ctrl_modem_latency_min_margin_between_ops_get();

const uint64_t new_frame_time = new_list_item->sched_config.frame_time;
const uint64_t next_frame_time = new_frame_time + DECT_RADIO_FRAME_DURATION_IN_MODEM_TICKS;
const uint64_t new_length_mdm_ticks =
Expand Down Expand Up @@ -888,18 +890,6 @@ dect_phy_api_scheduler_done_list_item_find_by_phy_handle(uint32_t handle)
return iterator;
}

static void dect_phy_api_scheduler_done_list_items_stop_in_modem(void)
{
struct dect_phy_api_scheduler_list_item *iterator = NULL;

SYS_DLIST_FOR_EACH_CONTAINER(&done_sheduled_list, iterator, dnode) {
if (!iterator->stop_requested) {
(void)nrf_modem_dect_phy_rx_stop(iterator->phy_op_handle);
iterator->stop_requested = true;
}
}
}

static void dect_phy_api_scheduler_done_list_mdm_op_complete(
struct dect_phy_common_op_completed_params *params,
struct dect_phy_api_scheduler_list_item *list_item)
Expand Down Expand Up @@ -1499,7 +1489,6 @@ static void dect_phy_api_scheduler_th_handler(void)
}
case DECT_PHY_API_EVENT_SCHEDULER_OP_SUSPEND: {
scheduler_data.state = SCHEDULER_STATE_SUSPENDED;
dect_phy_api_scheduler_done_list_items_stop_in_modem();
dect_phy_api_scheduler_suspended_evt_send();
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

/* Following defines the time how much in advance is scheduled to modem */
#define DECT_PHY_API_SCHEDULER_OP_TIME_WINDOW_MS 500
#define DECT_PHY_API_SCHEDULER_OP_MAX_COUNT 20
#define DECT_PHY_API_SCHEDULER_OP_MAX_COUNT 30

#define DECT_SCHEDULER_DELAYED_ERROR 6666
#define DECT_SCHEDULER_SCHEDULER_FATAL_MEM_ALLOC_ERROR 6667
Expand Down Expand Up @@ -217,6 +217,8 @@ void dect_phy_api_scheduler_list_delete_all_items(void); /* purge */

uint64_t dect_phy_api_scheduler_list_item_last_scheduled_modem_frame_time_get(void);

bool dect_phy_api_scheduler_list_is_empty(void);

/**************************************************************************************************/

/* Scheduler done list API */
Expand Down
19 changes: 5 additions & 14 deletions samples/dect/dect_phy/dect_shell/src/dect/common/dect_phy_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

/******************************************************************************/

#define DECT_PHY_MAX_TX_PWR_DBM 23

#define DECT_PHY_LBT_PERIOD_MAX_SYM (NRF_MODEM_DECT_LBT_PERIOD_MAX / NRF_MODEM_DECT_SYMBOL_DURATION)
#define DECT_PHY_LBT_PERIOD_MIN_SYM (NRF_MODEM_DECT_LBT_PERIOD_MIN / NRF_MODEM_DECT_SYMBOL_DURATION)

Expand All @@ -35,17 +33,10 @@ struct dect_phy_common_harq_feedback_data {
uint8_t encoded_data_to_send[DECT_DATA_MAX_LEN]; /* DECT_MAC_MESSAGE_TYPE_HARQ_FEEDBACK */
};

struct dect_phy_common_op_initialized_params {
uint64_t time;
int16_t temperature;
struct nrf_modem_dect_phy_modem_cfg modem_configuration;
enum nrf_modem_dect_phy_err status;
};

struct dect_phy_common_op_pcc_rcv_params {
uint64_t time;
uint64_t stf_start_time;
struct nrf_modem_dect_phy_rx_pcc_status pcc_status;
struct nrf_modem_dect_phy_pcc_event pcc_status;

uint8_t phy_len;
enum dect_phy_packet_length_type phy_len_type;
Expand All @@ -60,17 +51,17 @@ struct dect_phy_common_op_pcc_rcv_params {

struct dect_phy_common_op_pcc_crc_fail_params {
uint64_t time;
struct nrf_modem_dect_phy_rx_pcc_crc_failure crc_failure;
struct nrf_modem_dect_phy_pcc_crc_failure_event crc_failure;
};
struct dect_phy_common_op_pdc_crc_fail_params {
uint64_t time;
struct nrf_modem_dect_phy_rx_pdc_crc_failure crc_failure;
struct nrf_modem_dect_phy_pdc_crc_failure_event crc_failure;
};

struct dect_phy_commmon_op_pdc_rcv_params {
struct nrf_modem_dect_phy_rx_pdc_status rx_status;
struct nrf_modem_dect_phy_pdc_event rx_status;

uint16_t last_rx_op_channel;
uint16_t rx_channel;

uint8_t last_received_pcc_short_nw_id;
uint16_t last_received_pcc_transmitter_short_rd_id;
Expand Down
Loading

0 comments on commit 1af4135

Please sign in to comment.