UWB-Tracking
Loading...
Searching...
No Matches
tof-device.h
Go to the documentation of this file.
1#pragma once
2
8#include <pin_config.h>
9#include <datatypes.h>
10#include "watchdog.h"
11#include <dw3000.h>
12#include <dw3000_mac_802_15_4.h>
13
14#define DEST_PAN_ID 0x4321
15#define START_RECEIVE_DATA_LOCATION 8 // index of MAC payload user data
16
17#define ALL_MSG_SN_IDX 2 // sequence number byte index in MHR
18#define RESP_MSG_POLL_RX_TS_IDX 0 // index in the MAC payload for Poll RX time
19#define RESP_MSG_RESP_TX_TS_IDX 4 // index in the MAC payload for Response TX time
20#define RESP_MSG_TS_LEN 4
21
22/* Note, the key index of 0 is forbidden to send as key index. Thus index 1 is the first.*/
23#define INITIATOR_KEY_INDEX 1
24#define RESPONDER_KEY_INDEX 2
25
26#define RX_BUF_LEN 127 /* The received frame cannot be bigger than 127 if STD PHR mode is used */
27
28#ifndef TX_ANT_DLY
29#define TX_ANT_DLY 16393
30#endif
31
32#ifndef RX_ANT_DLY
33#define RX_ANT_DLY 16393
34#endif
35
36/* Values for the PG_DELAY and TX_POWER registers reflect the bandwidth and power of the spectrum at the current
37 * temperature. These values can be calibrated prior to taking reference measurements.*/
38extern dwt_txconfig_t txconfig_options;
39
44{
45public:
51 TofDevice(uwb_addr src, unsigned long wdt_timeout);
52
57
61 virtual void setup();
62
66 void start_wdt();
67
71 void enable_leds();
72
76 virtual void loop();
77
82 char* get_type() {return const_cast<char*>(this->type.c_str());};
83
84protected:
86 /*defining the source and destination addresses*/
88
89 String type;
90
91 mac_frame_802_15_4_format_t mac_frame;
92 uint8_t poll_msg[4] = {'P', 'o', 'l', 'l'};
93 uint8_t resp_msg[16] = {0, 0, 0, 0, 0, 0, 0, 0, 'R', 'e', 's', 'p', 'o', 'n', 's', 'e'}; //first 8 bytes for timestamps
94
95 /* Buffer to store received response message.
96 * Its size is adjusted to longest frame that the code can handle. */
98
99 uint32_t status_reg;
100 dwt_aes_job_t aes_job_tx, aes_job_rx;
101 int8_t status;
102
103 dwt_aes_config_t aes_config;
104
105 dwt_config_t config;
106
107 /* Optional keys according to the key index - In AUX security header*/
108 dwt_aes_key_t keys_options[NUM_OF_KEY_OPTIONS];
109};
The base class for Time-of-Flight (TOF) devices.
Definition: tof-device.h:44
char * get_type()
Get the type of the TOF device.
Definition: tof-device.h:82
String type
Definition: tof-device.h:89
~TofDevice()
Destructor for the TofDevice class.
Definition: tof-device.h:56
uint8_t poll_msg[4]
Definition: tof-device.h:92
dwt_config_t config
Definition: tof-device.h:105
uwb_addr src_address
Definition: tof-device.h:87
uint8_t resp_msg[16]
Definition: tof-device.h:93
dwt_aes_job_t aes_job_tx
Definition: tof-device.h:100
Watchdog my_watchdog
Definition: tof-device.h:85
virtual void setup()
Initialize and configure the TOF device.
Definition: tof-device.cpp:69
int8_t status
Definition: tof-device.h:101
mac_frame_802_15_4_format_t mac_frame
Definition: tof-device.h:91
uint8_t rx_buffer[RX_BUF_LEN]
Definition: tof-device.h:97
dwt_aes_key_t keys_options[NUM_OF_KEY_OPTIONS]
Definition: tof-device.h:108
dwt_aes_job_t aes_job_rx
Definition: tof-device.h:100
uint32_t status_reg
Definition: tof-device.h:99
void start_wdt()
Start the WDT to handle failure events.
Definition: tof-device.cpp:90
void enable_leds()
Enable LEDs for debugging purposes.
Definition: tof-device.cpp:98
dwt_aes_config_t aes_config
Definition: tof-device.h:103
virtual void loop()
Main loop of the TOF device.
Definition: tof-device.cpp:110
Watchdog class for monitoring and resetting a timer.
Definition: watchdog.h:16
Defines custom data types used in the UWB device code.
long long uwb_addr
Definition: datatypes.h:11
Configuration of various pins used in the project.
#define RX_BUF_LEN
Definition: tof-device.h:26
dwt_txconfig_t txconfig_options
Library for creating a software watchdog timer with FreeRTOS.