CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
Ardupilot

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: Ardupilot/ardupilot
Path: blob/master/libraries/AP_Beacon/AP_Beacon_Pozyx.h
Views: 1798
1
#pragma once
2
3
#include "AP_Beacon_Backend.h"
4
5
#if AP_BEACON_POZYX_ENABLED
6
7
#define AP_BEACON_POZYX_MSG_LEN_MAX 20 // messages from uno/pozyx are no more than 20bytes
8
#define AP_BEACON_POZYX_HEADER 0x01 // messages start with this character
9
#define AP_BEACON_POZYX_MSGID_BEACON_CONFIG 0x02 // message contains anchor config information
10
#define AP_BEACON_POZYX_MSGID_BEACON_DIST 0x03 // message contains individual beacon distance
11
#define AP_BEACON_POZYX_MSGID_POSITION 0x04 // message contains vehicle position information
12
#define AP_BEACON_DISTANCE_MAX 200.0f // sanity check beacon and vehicle messages to be within this distance from origin
13
14
class AP_Beacon_Pozyx : public AP_Beacon_Backend
15
{
16
17
public:
18
// constructor
19
using AP_Beacon_Backend::AP_Beacon_Backend;
20
21
// return true if sensor is basically healthy (we are receiving data)
22
bool healthy() override;
23
24
// update
25
void update() override;
26
27
private:
28
29
enum ParseState{
30
ParseState_WaitingForHeader = 0,
31
ParseState_WaitingForMsgId = 1,
32
ParseState_WaitingForLen = 2,
33
ParseState_WaitingForContents = 3
34
} parse_state;
35
36
// parse buffer
37
void parse_buffer();
38
39
uint8_t parse_msg_id;
40
uint8_t parse_msg_len;
41
42
uint8_t linebuf[AP_BEACON_POZYX_MSG_LEN_MAX];
43
uint8_t linebuf_len = 0;
44
uint32_t last_update_ms = 0;
45
};
46
47
#endif // AP_BEACON_POZYX_ENABLED
48
49