Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/libraries/AP_Beacon/AP_Beacon_Nooploop.h
Views: 1798
#pragma once12#include "AP_Beacon_Backend.h"34#if AP_BEACON_NOOPLOOP_ENABLED56#define NOOPLOOP_MSG_BUF_MAX 25678class AP_Beacon_Nooploop : public AP_Beacon_Backend9{1011public:12// constructor13using AP_Beacon_Backend::AP_Beacon_Backend;1415// return true if sensor is basically healthy (we are receiving data)16bool healthy() override;1718// update the state of the sensor19void update() override;2021private:22enum class MsgType : uint8_t {23INVALID = 0,24NODE_FRAME2,25SETTING_FRAME026};2728// process one byte received on serial port29// message is stored in _msgbuf30MsgType parse_byte(uint8_t b);3132// send setting_frame0 to tag. tag will ack setting_frame0 with anchor position filled33void request_setting();3435// parse node_frame2 to get tag position and distance36void parse_node_frame2();3738// parse setting_frame0 to get anchor position39void parse_setting_frame0();4041enum class ParseState : uint8_t {42HEADER = 0, // waiting for header43H55_FUNCTION_MARK, // waiting for function mark44H54_FUNCTION_MARK, // waiting for function mark45LEN_L, // waiting for low byte of length46LEN_H, // waiting for high byte of length47NF2_PAYLOAD, // receiving payload bytes48SF0_PAYLOAD, // receiving payload bytes49} _state = ParseState::HEADER;5051// members52uint8_t _msgbuf[NOOPLOOP_MSG_BUF_MAX]; // buffer to hold most recent message from tag53uint16_t _msg_len; // number of bytes received from the current message (may be larger than size of _msgbuf)54uint16_t _frame_len; // message supplied frame length55uint8_t _crc_expected; // calculated crc which is compared against actual received crc56uint32_t _last_update_ms; // last time we receive data from tag57bool _anchor_pos_avail; // flag indicates if we got anchor position or not58uint32_t _last_request_setting_ms; // last time we sent request_setting0 packet to tag59};6061#endif // AP_BEACON_NOOPLOOP_ENABLED626364