Hello Everyone,
I have been using DWM1001 and I have connected it with a Raspberry Pi 3 (model B). I’m trying to set the node as an anchor by modifying the examples/ex1_TWR_2Hosts/anchor/anchor_cfg.c source file, using UART generic mode. I have configured it once , and saw the instant change from tag to anchor using the Decawave DRTLS manager application , but since then I always had TLV response errors and the node just stays in the same mode. I have printed them, to see what was going wrong :
SET anchor
07
01
9e
ret_val[0] 40
ret_val[1] 1
ret_val[2] 3, RV_OK = 0
ret_val[3] 0
ret_val[4] 40
ret_val[5] 1
ret_val[6] 0
HAL_UART: ERROR: DWM1001_RV_ERR: 3
The code I’ve been using is this , and I have created a new function, dwm_cfg_set_Anchor(&cfg_node); , that is like dwm_cfg_anchor_set , just modified it to get a dwm_cfg_t variable instead of a dwm_cfg_anchor_t .
#include “dwm_api.h”
#include “hal.h”
#define DWM_ERR_PERM (-5)
int main(void)
{
//dwm_cfg_anchor_t cfg_node;
dwm_cfg_t cfg_node;
int wait_period = 2000;
HAL_Print(“dwm_init(): dev%d\n”, HAL_DevNum());
dwm_init();
HAL_Print(“Wait 2s for node to reset\n”);
HAL_Delay(2000);
dwm_cfg_get(&cfg_node);
/* Before configuration */
HAL_Print("\nBefore Configuration \n");
HAL_Print(“initiator %u \n”, cfg_node.initiator);
HAL_Print(“bridge %u \n”, cfg_node.bridge);
HAL_Print(“LED enabled %u \n”, cfg_node.common.led_en);
HAL_Print(“BLE enabled %u \n”, cfg_node.common.ble_en);
HAL_Print(“firmware update enabled %u \n”, cfg_node.common.fw_update_en);
HAL_Print(“UWB mode %u \n\n\n”, cfg_node.common.uwb_mode);
/***********************/
//configuration of the node → anchor
cfg_node.initiator = 1;
cfg_node.bridge = 0;
cfg_node.common.led_en = 1;
cfg_node.common.ble_en = 1; //dwm-api-test
cfg_node.common.fw_update_en = 1;
cfg_node.common.uwb_mode = DWM_UWB_MODE_ACTIVE;
HAL_Print(“SET anchor \n”);
dwm_cfg_set_Anchor(&cfg_node);
HAL_Delay(2000); // set delay before reset
dwm_reset();
/***********************/
dwm_pos_t pos;
pos.qf = 100;
pos.x = 800;
pos.y = 0;
pos.z = 0;
dwm_pos_set(&pos);
dwm_pos_t node_pos;
dwm_loc_data_t loc;
dwm_pos_get(&node_pos);
loc.p_pos = &node_pos;
dwm_reset();
/*********************/
HAL_Print("\n");
HAL_Print(“initiator %u \n”, cfg_node.initiator);
HAL_Print(“bridge %u \n”, cfg_node.bridge);
HAL_Print(“LED enabled %u \n”, cfg_node.common.led_en);
HAL_Print(“BLE enabled %u \n”, cfg_node.common.ble_en);
HAL_Print(“firmware update enabled %u \n”, cfg_node.common.fw_update_en);
HAL_Print(“UWB mode %u \n\n\n”, cfg_node.common.uwb_mode);
/**************************************/
dwm_cfg_get(&cfg_node);
HAL_Print("\n\n");
HAL_Print(“initiator %u \n”, cfg_node.initiator);
HAL_Print(“bridge %u \n”, cfg_node.bridge);
HAL_Print(“LED enabled %u \n”, cfg_node.common.led_en);
HAL_Print(“BLE enabled %u \n”, cfg_node.common.ble_en);
HAL_Print(“firmware update enabled %u \n”, cfg_node.common.fw_update_en);
HAL_Print(“UWB mode %u \n\n”, cfg_node.common.uwb_mode);
HAL_Print("********* \n\n", cfg_node.common.uwb_mode);
while(1)
{
HAL_Print(“Wait %d ms…\n”, wait_period);
HAL_Delay(2000);
dwm_cfg_get(&cfg_node);
HAL_Print("\n\n");
HAL_Print("initiator %u \n", cfg_node.initiator);
HAL_Print("bridge %u \n", cfg_node.bridge);
HAL_Print("LED enabled %u \n", cfg_node.common.led_en);
HAL_Print("BLE enabled %u \n", cfg_node.common.ble_en);
HAL_Print("firmware update enabled %u \n", cfg_node.common.fw_update_en);
HAL_Print("UWB mode %u \n\n", cfg_node.common.uwb_mode);
HAL_Print("********* \n\n", cfg_node.common.uwb_mode);
if(dwm_loc_get(&loc) == RV_OK)
{
HAL_Print("\t[%d,%d,%d,%u]\n", node_pos.x, node_pos.y, node_pos.z,
node_pos.qf);
HAL_Print("initiator %u \n", cfg_node.initiator);
HAL_Print("\t[%d,%d,%d,%u]\n", loc.p_pos->x, loc.p_pos->y, loc.p_pos->z,
loc.p_pos->qf);
}
}
return 0;
}