Skip to content

Commit b7a776f

Browse files
jhirsinordicjm
authored andcommitted
samples: dect_phy: dect_shell: mac: last minute scan
Instead of LBT, support for Last Minute Scan (LMS) before beacon TX and the 1st random access resource. Jira: MOSH-592 Signed-off-by: Jani Hirsimäki <[email protected]>
1 parent 74690d2 commit b7a776f

15 files changed

+296
-41
lines changed

samples/dect/dect_phy/dect_shell/README.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,9 @@ DeSh command: ``dect mac``
427427

428428
This command demostrates basic sample of DECT NR+ MAC layer on top of PHY API based on ETSI TS 103 636-4 V1.4.8 (2024-01).
429429
With this command you can start a cluster beacon, scan for beacons, associate/dissociate, and send data to beacon random access RX window.
430-
Note: this is just a basic sample and not a full MAC implementation.
430+
431+
Disclaimer: this is just a basic sample for initials and not a full MAC implementation, it does not support all the features of the DECT NR+ MAC layer and is not fully compliant with the MAC specification.
432+
For example cluster beaconing with RA allocation, and LMS implementations overall are not what is required by the MAC specification.
431433

432434
Example: starting of cluster beacon and sending RA data to it
433435
-------------------------------------------------------------

samples/dect/dect_phy/dect_shell/src/dect/common/dect_common.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,7 @@ typedef struct {
233233

234234
#define DECT_RADIO_FRAME_SUBSLOT_COUNT_IN_SLOT (2)
235235
#define DECT_RADIO_FRAME_SLOT_COUNT (24)
236+
236237
#define DECT_RADIO_FRAME_SUBSLOT_COUNT \
237238
(DECT_RADIO_FRAME_SUBSLOT_COUNT_IN_SLOT * DECT_RADIO_FRAME_SLOT_COUNT)
238239
#define DECT_RADIO_FRAME_DURATION_US (10000)
@@ -247,5 +248,10 @@ typedef struct {
247248

248249
#define MS_TO_SUBSLOTS(x) (((x) / 10) * 48)
249250

251+
#define DECT_RADIO_SLOT_SYMBOL_COUNT (10)
252+
#define DECT_RADIO_SUBSLOT_SYMBOL_COUNT (5)
253+
254+
#define DECT_RADIO_FRAME_SYMBOL_COUNT (DECT_RADIO_FRAME_SLOT_COUNT * DECT_RADIO_SLOT_SYMBOL_COUNT)
255+
250256
/******************************************************************************/
251257
#endif /* DECT_COMMON_H */

samples/dect/dect_phy/dect_shell/src/dect/common/dect_phy_api_scheduler.c

Lines changed: 60 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@
2020
/* Internals */
2121

2222
/* Internal events to scheduler thread */
23-
#define DECT_PHY_API_EVENT_SCHEDULER_NEXT_FRAME 1
24-
#define DECT_PHY_API_EVENT_SCHEDULER_OP_COMPLETED 2
25-
#define DECT_PHY_API_EVENT_SCHEDULER_OP_PDC_DATA_RECEIVED 3
26-
#define DECT_PHY_API_EVENT_SCHEDULER_OP_LIST_PURGE 4
27-
#define DECT_PHY_API_EVENT_SCHEDULER_LED_TX_ON 5
28-
#define DECT_PHY_API_EVENT_SCHEDULER_LED_TX_OFF 6
29-
#define DECT_PHY_API_EVENT_SCHEDULER_OP_SUSPEND 7
30-
#define DECT_PHY_API_EVENT_SCHEDULER_OP_RESUME 8
31-
#define DECT_PHY_API_EVENT_SCHEDULER_OP_RECONFIG_ON 9
32-
#define DECT_PHY_API_EVENT_SCHEDULER_OP_RECONFIG_OFF 10
23+
#define DECT_PHY_API_EVENT_SCHEDULER_NEXT_FRAME 1
24+
#define DECT_PHY_API_EVENT_SCHEDULER_OP_COMPLETED 2
25+
#define DECT_PHY_API_EVENT_SCHEDULER_OP_PDC_DATA_RECEIVED 3
26+
#define DECT_PHY_API_EVENT_SCHEDULER_OP_LIST_PURGE 4
27+
#define DECT_PHY_API_EVENT_SCHEDULER_OP_LIST_ITEM_RM_DEALLOC 5
28+
#define DECT_PHY_API_EVENT_SCHEDULER_LED_TX_ON 6
29+
#define DECT_PHY_API_EVENT_SCHEDULER_LED_TX_OFF 7
30+
#define DECT_PHY_API_EVENT_SCHEDULER_OP_SUSPEND 8
31+
#define DECT_PHY_API_EVENT_SCHEDULER_OP_RESUME 9
32+
#define DECT_PHY_API_EVENT_SCHEDULER_OP_RECONFIG_ON 10
33+
#define DECT_PHY_API_EVENT_SCHEDULER_OP_RECONFIG_OFF 11
3334

3435
/* Scheduler states */
3536
enum dect_phy_api_scheduler_state {
@@ -278,6 +279,13 @@ dect_phy_api_scheduler_list_item_remove_by_phy_op_handle(uint16_t handle)
278279
return iterator;
279280
}
280281

282+
void dect_phy_api_scheduler_th_list_item_remove_dealloc_by_phy_op_handle(uint16_t handle)
283+
{
284+
(void)dect_phy_api_scheduler_raise_event_with_data(
285+
DECT_PHY_API_EVENT_SCHEDULER_OP_LIST_ITEM_RM_DEALLOC, (void *)&handle,
286+
sizeof(uint16_t));
287+
}
288+
281289
void dect_phy_api_scheduler_list_item_remove_dealloc_by_phy_op_handle(uint16_t handle)
282290
{
283291
struct dect_phy_api_scheduler_list_item *iterator = NULL;
@@ -687,6 +695,24 @@ struct dect_phy_api_scheduler_list_item *dect_phy_api_scheduler_list_item_alloc_
687695
return p_elem;
688696
}
689697

698+
struct dect_phy_api_scheduler_list_item *dect_phy_api_scheduler_list_item_alloc_rssi_element(
699+
struct dect_phy_api_scheduler_list_item_config **item_conf)
700+
{
701+
struct dect_phy_api_scheduler_list_item *p_elem =
702+
k_calloc(1, sizeof(struct dect_phy_api_scheduler_list_item));
703+
704+
if (p_elem == NULL) {
705+
printk("%s: cannot allocate memory for scheduler list item\n", (__func__));
706+
return NULL;
707+
}
708+
p_elem->priority = DECT_PRIORITY1_RX_RSSI;
709+
p_elem->sched_config.tx.encoded_payload_pdu = NULL;
710+
p_elem->silent_fail = false;
711+
*item_conf = &p_elem->sched_config;
712+
713+
return p_elem;
714+
}
715+
690716
void dect_phy_api_scheduler_list_item_dealloc(struct dect_phy_api_scheduler_list_item *list_item)
691717
{
692718
if (list_item != NULL) {
@@ -1033,6 +1059,15 @@ dect_phy_api_scheduler_core_mdm_phy_op(struct dect_phy_api_scheduler_list_item *
10331059
DECT_PHY_API_EVENT_SCHEDULER_LED_TX_ON);
10341060
#endif
10351061
}
1062+
} else if (list_item->priority == DECT_PRIORITY1_RX_RSSI) {
1063+
struct nrf_modem_dect_phy_rssi_params rssi_params =
1064+
list_item->sched_config.rssi.rssi_op_params;
1065+
1066+
err = nrf_modem_dect_phy_rssi(&rssi_params);
1067+
if (err) {
1068+
desh_error("(%s): nrf_modem_dect_phy_rssi failed %d",
1069+
(__func__), err);
1070+
}
10361071
} else {
10371072
struct nrf_modem_dect_phy_rx_params rx_op = {
10381073
.rssi_interval = NRF_MODEM_DECT_PHY_RSSI_INTERVAL_OFF,
@@ -1155,6 +1190,10 @@ static void dect_phy_api_scheduler_core_tick_th_schedule_next_frame(void)
11551190
}
11561191
iterator->phy_op_handle = next_handle;
11571192
}
1193+
if (iterator->priority == DECT_PRIORITY1_RX_RSSI) {
1194+
iterator->sched_config.rssi.rssi_op_params.start_time =
1195+
new_frame_time;
1196+
}
11581197

11591198
if (!dect_phy_api_scheduler_list_item_add(iterator)) {
11601199
printk("(%s)/1: dect_phy_api_scheduler_list_item_add for "
@@ -1274,6 +1313,10 @@ static void dect_phy_api_scheduler_core_tick_th_schedule_next_frame(void)
12741313
}
12751314
iterator->phy_op_handle = next_handle;
12761315
}
1316+
if (iterator->priority == DECT_PRIORITY1_RX_RSSI) {
1317+
iterator->sched_config.rssi.rssi_op_params.start_time =
1318+
new_frame_time;
1319+
}
12771320

12781321
if (!dect_phy_api_scheduler_list_item_add(iterator)) {
12791322
desh_error("(%s): dect_phy_api_scheduler_list_item_add "
@@ -1406,6 +1449,13 @@ static void dect_phy_api_scheduler_th_handler(void)
14061449
dect_phy_api_scheduler_done_list_purge();
14071450
break;
14081451
}
1452+
case DECT_PHY_API_EVENT_SCHEDULER_OP_LIST_ITEM_RM_DEALLOC: {
1453+
uint16_t *phy_handle = (uint16_t *)event.data;
1454+
1455+
dect_phy_api_scheduler_list_item_remove_dealloc_by_phy_op_handle(
1456+
*phy_handle);
1457+
break;
1458+
}
14091459
case DECT_PHY_API_EVENT_SCHEDULER_OP_SUSPEND: {
14101460
scheduler_data.state = SCHEDULER_STATE_SUSPENDED;
14111461
dect_phy_api_scheduler_done_list_items_stop_in_modem();

samples/dect/dect_phy/dect_shell/src/dect/common/dect_phy_api_scheduler.h

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ typedef enum {
5959
DECT_PRIORITY0_FORCE_RX, /* Possible to schedule past of the scheduler mdm RX window */
6060
DECT_PRIORITY1_TX,
6161
DECT_PRIORITY1_RX,
62+
DECT_PRIORITY1_RX_RSSI,
6263
DECT_PRIORITY2_TX,
6364
DECT_PRIORITY2_RX,
6465
DECT_PRIORITY_LOWEST_RX
@@ -104,6 +105,10 @@ struct dect_phy_api_scheduler_list_item_config_rx {
104105
enum nrf_modem_dect_phy_rx_mode mode;
105106
};
106107

108+
struct dect_phy_api_scheduler_list_item_config_rx_rssi {
109+
struct nrf_modem_dect_phy_rssi_params rssi_op_params;
110+
};
111+
107112
struct dect_phy_api_scheduler_list_item_config {
108113
dect_mac_address_info_t address_info;
109114

@@ -139,8 +144,9 @@ struct dect_phy_api_scheduler_list_item_config {
139144
uint16_t length_slots;
140145
uint16_t length_subslots;
141146

142-
struct dect_phy_api_scheduler_list_item_config_rx rx; /* RX specifics */
143-
struct dect_phy_api_scheduler_list_item_config_tx tx; /* TX specifics */
147+
struct dect_phy_api_scheduler_list_item_config_rx rx; /* RX specifics */
148+
struct dect_phy_api_scheduler_list_item_config_tx tx; /* TX specifics */
149+
struct dect_phy_api_scheduler_list_item_config_rx_rssi rssi; /* RSSI specifics */
144150
};
145151

146152
struct dect_phy_api_scheduler_list_item {
@@ -166,6 +172,8 @@ struct dect_phy_api_scheduler_list_item *dect_phy_api_scheduler_list_item_alloc_
166172
struct dect_phy_api_scheduler_list_item_config **item_conf);
167173
struct dect_phy_api_scheduler_list_item *dect_phy_api_scheduler_list_item_alloc_rx_element(
168174
struct dect_phy_api_scheduler_list_item_config **item_conf);
175+
struct dect_phy_api_scheduler_list_item *dect_phy_api_scheduler_list_item_alloc_rssi_element(
176+
struct dect_phy_api_scheduler_list_item_config **item_conf);
169177
void dect_phy_api_scheduler_list_item_dealloc(struct dect_phy_api_scheduler_list_item *list_item);
170178
struct dect_phy_api_scheduler_list_item *dect_phy_api_scheduler_list_item_create_new_copy(
171179
struct dect_phy_api_scheduler_list_item *item_to_be_copied, uint64_t new_frame_time,
@@ -183,6 +191,8 @@ void dect_phy_api_scheduler_list_item_remove_dealloc_by_phy_op_handle(uint16_t h
183191
void dect_phy_api_scheduler_list_item_remove_dealloc_by_phy_op_handle_range(uint16_t range_start,
184192
uint16_t range_end);
185193

194+
void dect_phy_api_scheduler_th_list_item_remove_dealloc_by_phy_op_handle(uint16_t handle);
195+
186196
void dect_phy_api_scheduler_list_item_pdu_payload_update_by_phy_handle(
187197
uint16_t handle, uint8_t *new_encoded_payload_pdu, uint16_t size);
188198

samples/dect/dect_phy/dect_shell/src/dect/dect_phy_ctrl.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,12 @@ static void dect_phy_ctrl_mdm_on_rssi_cb(const uint64_t *time,
612612
const struct nrf_modem_dect_phy_rssi_meas *p_result)
613613
{
614614
dect_app_modem_time_save(time);
615-
dect_phy_scan_rssi_cb_handle(NRF_MODEM_DECT_PHY_SUCCESS, p_result);
615+
616+
if (ctrl_data.rssi_scan_on_going) {
617+
dect_phy_scan_rssi_cb_handle(NRF_MODEM_DECT_PHY_SUCCESS, p_result);
618+
} else if (ctrl_data.ext_cmd.direct_rssi_cb != NULL) {
619+
ctrl_data.ext_cmd.direct_rssi_cb(p_result);
620+
}
616621
}
617622

618623
static void dect_phy_ctrl_mdm_on_link_configuration_cb(uint64_t const *time,

samples/dect/dect_phy/dect_shell/src/dect/dect_phy_ctrl.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,10 @@ typedef bool (*dect_phy_ctrl_ext_phy_api_pdc_rx_cb_t)(
106106
int dect_phy_ctrl_th_register_default_phy_api_pdc_rcv_cb(
107107
dect_phy_ctrl_ext_phy_api_pdc_rx_cb_t default_pdc_rcv_cb);
108108

109+
/* Callback for receiving RSSI measurement results */
110+
typedef void (*dect_phy_ctrl_ext_phy_api_direct_rssi_cb_t)(
111+
const struct nrf_modem_dect_phy_rssi_meas *meas_results);
112+
109113
/* Callback for receiving modem operation complete events */
110114
typedef void (*dect_phy_ctrl_ext_phy_api_mdm_op_complete_cb_t)(
111115
struct dect_phy_common_op_completed_params *params);
@@ -130,6 +134,7 @@ struct dect_phy_ctrl_ext_callbacks {
130134
dect_phy_ctrl_ext_phy_api_pcc_rx_cb_t direct_pcc_rcv_cb;
131135
dect_phy_ctrl_ext_phy_api_pcc_rx_cb_t pcc_rcv_cb;
132136
dect_phy_ctrl_ext_phy_api_direct_pdc_rx_cb_t direct_pdc_rcv_cb;
137+
dect_phy_ctrl_ext_phy_api_direct_rssi_cb_t direct_rssi_cb;
133138
dect_phy_ctrl_ext_phy_api_pdc_rx_cb_t pdc_rcv_cb;
134139
dect_phy_ctrl_ext_phy_api_mdm_op_complete_cb_t op_complete_cb;
135140
dect_phy_ctrl_ext_settings_changed_cb_t sett_changed_cb;

samples/dect/dect_phy/dect_shell/src/dect/dect_phy_scan.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,6 @@
2222
#include "dect_phy_scan.h"
2323
#include "dect_phy_rx.h"
2424

25-
enum dect_phy_rssi_scan_data_result_verdict {
26-
DECT_PHY_RSSI_SCAN_VERDICT_FREE,
27-
DECT_PHY_RSSI_SCAN_VERDICT_POSSIBLE,
28-
DECT_PHY_RSSI_SCAN_VERDICT_BUSY,
29-
};
3025
struct dect_phy_rssi_scan_data_result {
3126
uint16_t channel;
3227
enum dect_phy_rssi_scan_data_result_verdict result;

samples/dect/dect_phy/dect_shell/src/dect/dect_phy_scan.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@
88
#define DECT_PHY_SCAN_H
99
#include <zephyr/kernel.h>
1010

11+
enum dect_phy_rssi_scan_data_result_verdict {
12+
DECT_PHY_RSSI_SCAN_VERDICT_FREE,
13+
DECT_PHY_RSSI_SCAN_VERDICT_POSSIBLE,
14+
DECT_PHY_RSSI_SCAN_VERDICT_BUSY,
15+
};
16+
1117
struct dect_phy_rssi_channel_scan_result_t {
1218
enum nrf_modem_dect_phy_err phy_status;
1319

samples/dect/dect_phy/dect_shell/src/dect/dect_phy_shell.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,8 @@ struct dect_phy_common_op_event_msgq_item {
166166
#define DECT_PHY_COMMON_RX_CMD_HANDLE 50
167167
#define DECT_PHY_COMMON_RSSI_SCAN_HANDLE 60
168168

169+
#define DECT_PHY_MAC_BEACON_LMS_RSSI_SCAN_HANDLE 99
170+
169171
#define DECT_PHY_MAC_BEACON_TX_HANDLE 100
170172
#define DECT_PHY_MAC_BEACON_RX_RACH_HANDLE_START 101
171173
#define DECT_PHY_MAC_BEACON_RX_RACH_HANDLE_END 999
@@ -180,6 +182,7 @@ struct dect_phy_common_op_event_msgq_item {
180182
#define DECT_PHY_MAC_CLIENT_ASSOCIATION_RX_HANDLE 1003
181183
#define DECT_PHY_MAC_CLIENT_ASSOCIATION_REL_TX_HANDLE 1004
182184

185+
183186
#define DECT_PHY_PERF_TX_HANDLE_START 10000
184187
#define DECT_PHY_PERF_TX_HANDLE_END 10049
185188
#define DECT_PHY_PERF_TX_HANDLE_IN_RANGE(x) \

samples/dect/dect_phy/dect_shell/src/dect/mac/dect_phy_mac.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ bool dect_phy_mac_handle(struct dect_phy_commmon_op_pdc_rcv_params *rcv_params)
371371
beacon_msg = &sdu_list_item->message.cluster_beacon;
372372
} else if (sdu_list_item->message_type ==
373373
DECT_PHY_MAC_MESSAGE_RANDOM_ACCESS_RESOURCE_IE) {
374+
/* Note: there could be many of these, this takes only the last */
374375
ra_ie = &sdu_list_item->message.rach_ie;
375376
}
376377
}

0 commit comments

Comments
 (0)