Sorry, made an error in my previous replies, so correcting here. I’ve made progress, but still not ranging properly. Here is what I’ve uncovered.
I’m using two DWM3001CDK to work toward Two-Way Ranging TWR. My starting point is the code for the tag to be used with the provided iPhone app.
I deleted the ble
and niq
initializations in main.c
. I finally realized that the main_uwb.c
function called _defaultTask
is not properly setting up the controllER versus controllEE. With the current code, it was always setting the unit as “controlEE”. So, to make it work, I added a variable ranging_role
that I could set to 0/1 for Responder/Initiator (same as the value set in ACCESSORY_RANGING_ROLE). See snippet of code below. You will also need to create a:
static uint32_t ranging_role = 1; /**< Responder 0, Initiator 1 */
[Note: I struggled for a bit since I first tried using AppSetFiRaRole
and AppGetFiRaRole
, but I can’t seem to make sense about what they are doing. I try setting with a value and then I read back a different value (that’s strange). These two functions are also used in construct_fira_param_from_config
so they may require additional scrutiny in that function too.]
Current behavior is still not providing measurements, but at least there is some back and forth communications.
-
If I plug in Responder alone, there is no report printed, it just waits. D13 flashes Red
-
If I plug in Initiator alone, there is a string of ERR ranging reports printed, with increasing Block Index. D13 flashes Yellow and Red:
report_cb ->
report_cb <-
{"TWR": {"R":54,"a16":"0x0001","S":"ERR","D cm":0}}
report_cb ->
report_cb <-
{"TWR": {"R":55,"a16":"0x0001","S":"ERR","D cm":0}}
report_cb ->
report_cb <-
{"TWR": {"R":56,"a16":"0x0001","S":"ERR","D cm":0}}
report_cb ->
report_cb <-
{"TWR": {"R":57,"a16":"0x0001","S":"ERR","D cm":0}}
report_cb ->
- If I plug in the Responder, and subsequently plug in the Initiator and watch the response on the responder, I start start to see a string of ERR ranging reports, all with a Block Index = 1. Responder D13 flashes Red, Initiator D13 flashes Yellow and Red.
report_cb ->
report_cb <-
{"TWR": {"R":1,"a16":"0x0001","S":"ERR","D cm":0}}
report_cb ->
report_cb <-
{"TWR": {"R":1,"a16":"0x0001","S":"ERR","D cm":0}}
report_cb ->
report_cb <-
{"TWR": {"R":1,"a16":"0x0001","S":"ERR","D cm":0}}
report_cb ->
report_cb <-
{"TWR": {"R":1,"a16":"0x0001","S":"ERR","D cm":0}}
report_cb ->
report_cb <-
{"TWR": {"R":1,"a16":"0x0001","S":"ERR","D cm":0}}
/*
* This task will start an Accessory as a UWB Initiator or UWB Responder
*
*/
static void _defaultTask(const void *arg)
{
char str[256];
osEvent evt;
fira_param_t *fira_param = get_fira_config();
param_block_t* app_config = AppConfigGet();
char result[256];
snprintf(result, sizeof(result), "_defaultTask ->\n");
port_tx_msg(result, strlen(result));
int Signal = SIGNAL_START_INIT | SIGNAL_START_RESP | SIGNAL_STOP_ALL;
while(1)
{
osMutexRelease(defaultTask.MutexId);
evt = osSignalWait(Signal, 10000);
osMutexWait(defaultTask.MutexId, 0);
nrfx_wdt_feed();
if(evt.status == osEventTimeout)
{
display_threads_heap_usage();
continue;
}
fira_terminate();
disable_dw3000_irq();
/**/
snprintf(result, sizeof(result), "ResumeUWBTasks: evt.value_signals %d\n", evt.value.signals);
port_tx_msg(result, strlen(result));
snprintf(result, sizeof(result), "_defaultTask - AppGetFiraRole: %d\n", AppGetFiRaRole());
port_tx_msg(result, strlen(result));
if (ranging_role == 1) {
construct_fira_param_from_config(fira_param, (void*)&AppConfigGet()->s.fira_config, 1);
fira_helper_controller((void const *)fira_param);
} else {
construct_fira_param_from_config(fira_param, (void*)&AppConfigGet()->s.fira_config, 0);
fira_helper_controlee((void const *)fira_param);
}
}
snprintf(result, sizeof(result), "_defaultTask <-\n");
port_tx_msg(result, strlen(result));
}