2016-10-24 02:46:07 -03:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "AP_Beacon_Backend.h"
|
|
|
|
|
2022-01-27 20:09:43 -04:00
|
|
|
#if AP_BEACON_POZYX_ENABLED
|
|
|
|
|
2016-10-24 02:46:07 -03:00
|
|
|
#define AP_BEACON_POZYX_MSG_LEN_MAX 20 // messages from uno/pozyx are no more than 20bytes
|
|
|
|
#define AP_BEACON_POZYX_HEADER 0x01 // messages start with this character
|
|
|
|
#define AP_BEACON_POZYX_MSGID_BEACON_CONFIG 0x02 // message contains anchor config information
|
|
|
|
#define AP_BEACON_POZYX_MSGID_BEACON_DIST 0x03 // message contains individual beacon distance
|
|
|
|
#define AP_BEACON_POZYX_MSGID_POSITION 0x04 // message contains vehicle position information
|
|
|
|
#define AP_BEACON_DISTANCE_MAX 200.0f // sanity check beacon and vehicle messages to be within this distance from origin
|
|
|
|
|
|
|
|
class AP_Beacon_Pozyx : public AP_Beacon_Backend
|
|
|
|
{
|
|
|
|
|
|
|
|
public:
|
|
|
|
// constructor
|
2020-04-01 04:59:40 -03:00
|
|
|
using AP_Beacon_Backend::AP_Beacon_Backend;
|
2016-10-24 02:46:07 -03:00
|
|
|
|
|
|
|
// return true if sensor is basically healthy (we are receiving data)
|
2018-11-07 08:11:40 -04:00
|
|
|
bool healthy() override;
|
2016-10-24 02:46:07 -03:00
|
|
|
|
|
|
|
// update
|
2018-11-07 08:11:40 -04:00
|
|
|
void update() override;
|
2016-10-24 02:46:07 -03:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
enum ParseState{
|
|
|
|
ParseState_WaitingForHeader = 0,
|
|
|
|
ParseState_WaitingForMsgId = 1,
|
|
|
|
ParseState_WaitingForLen = 2,
|
|
|
|
ParseState_WaitingForContents = 3
|
|
|
|
} parse_state;
|
|
|
|
|
|
|
|
// parse buffer
|
|
|
|
void parse_buffer();
|
|
|
|
|
|
|
|
uint8_t parse_msg_id;
|
|
|
|
uint8_t parse_msg_len;
|
|
|
|
|
|
|
|
uint8_t linebuf[AP_BEACON_POZYX_MSG_LEN_MAX];
|
|
|
|
uint8_t linebuf_len = 0;
|
|
|
|
uint32_t last_update_ms = 0;
|
|
|
|
};
|
2022-01-27 20:09:43 -04:00
|
|
|
|
|
|
|
#endif // AP_BEACON_POZYX_ENABLED
|