We’re developing a custom API layer for the DWM3001CDK for inter-operability between our Raspberry Pi and an Arduino/STM32 module, which the existing APIs did not provide a simple nor straightforward approach for.
I’ve essentially tried to port the Python SDK (which didn’t even detect our boards via tty, btw) to C. I’ve gotten everything mostly working (ie; get_device_info shows DECA something), the only problem being the notification receiving part, in which I’m getting random, garbage data. Any help?
Here’s the link to the repo, and a snippet of how I send commands and receive notifications:
// commands.c
int start_uwb_ranging_session(int tty_fd, uint32_t sid)
{
uint8_t payload[SID_SIZE];
size_t payload_len = sizeof(payload) / sizeof(payload[0]);
init_payload(payload, payload_len, sid);
Packet sent_pkt = create_packet(CommandHeader, RANGING, RANGE_START, payload, payload_len);
Packet rcvd_pkt;
return send_n_receive(tty_fd, sent_pkt, &rcvd_pkt);
}
void receive_process_notif(int tty_fd)
{
while (1)
{
sleep(1);
printf("\n\n\n");
Packet rcvd_packet;
rcv_packet(tty_fd, &rcvd_packet);
print_packet_header(rcvd_packet.header);
printf(" pkt: GID: %s (0x%04X)\n", gid_t_s(rcvd_packet.gid), rcvd_packet.gid);
printf(" pkt: OID: %s (0x%04X)\n", oid_t_s(rcvd_packet.gid, rcvd_packet.oid), rcvd_packet.oid);
}
}
// main.c
printf("\n -- Starting UWB 1 ranging... -- \n");
if (start_uwb_ranging_session(tty_fd_1, SESSION_ID) < 0)
{
printf("\n**ERROR: FAILED TO START UWB RANGING**\n");
gtfo(tty_fd_1, SESSION_ID);
return -5;
}
sleep(3);
printf("\n -- Starting UWB 2 ranging... -- \n");
if (start_uwb_ranging_session(tty_fd_2, SESSION_ID) < 0)
{
printf("\n**ERROR: FAILED TO START UWB RANGING**\n");
gtfo(tty_fd_2, SESSION_ID);
return -5;
}
sleep(3);
printf("\n -- Receiving UWB notifications... -- \n");
receive_process_notif(tty_fd_2); // also tried tty_fd_1, same data
Any help or hints in the right direction are greatly appreciated - thanks!