1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-15 01:23:49 +01:00

examples/twr_aloha: default print rng result only on initiator

This commit is contained in:
Francisco Molina 2022-03-24 13:44:02 +01:00
parent f5a4a486f6
commit a5f54b5a03
2 changed files with 19 additions and 2 deletions

View File

@ -149,6 +149,7 @@ static bool _complete_cb(struct uwb_dev *inst, struct uwb_mac_interface *cbs)
event_post(uwb_core_get_eventq(), &_rng_listen_event.super);
return false;
}
/* get received frame */
struct uwb_rng_instance *rng = (struct uwb_rng_instance *)cbs->inst_ptr;
@ -157,6 +158,15 @@ static bool _complete_cb(struct uwb_dev *inst, struct uwb_mac_interface *cbs)
/* parse data*/
uwb_core_rng_data_t data;
/* with ss twr, the last frame will hold the initiator as the src address,
with ds twr, it will hold the responder address */
if (IS_ACTIVE(CONFIG_TWR_PRINTF_INITIATOR_ONLY) &&
((frame->code < UWB_DATA_CODE_DS_TWR && frame->src_address != _udev->uid) ||
(frame->code >= UWB_DATA_CODE_DS_TWR && frame->dst_address != _udev->uid))) {
event_post(uwb_core_get_eventq(), &_rng_listen_event.super);
return true;
}
data.src = frame->src_address;
data.dest = frame->dst_address;
data.time = ztimer_now(ZTIMER_MSEC);

View File

@ -31,14 +31,21 @@ extern "C" {
* @brief Block after a request is sent
*/
#ifndef CONFIG_TWR_SHELL_BLOCKING
#define CONFIG_TWR_SHELL_BLOCKING 1
#define CONFIG_TWR_SHELL_BLOCKING 1
#endif
/**
* @brief Minimum idle time to enable putting the radio to sleep
*/
#ifndef CONFIG_TWR_MIN_IDLE_SLEEP_MS
#define CONFIG_TWR_MIN_IDLE_SLEEP_MS 20
#define CONFIG_TWR_MIN_IDLE_SLEEP_MS 20
#endif
/*
* @brief Block after a request is sent
*/
#ifndef CONFIG_TWR_PRINTF_INITIATOR_ONLY
#define CONFIG_TWR_PRINTF_INITIATOR_ONLY 1
#endif
/**