Line data Source code
1 : #pragma once 2 : 3 : #include "AP_Frsky_MAVlite.h" 4 : 5 : #include <AP_Common/AP_Common.h> 6 : 7 : #include <stdint.h> 8 : 9 : #if HAL_WITH_FRSKY_TELEM_BIDIRECTIONAL 10 : class AP_Frsky_MAVlite_Message { 11 : public: 12 : // helpers 13 7 : bool get_float(float &value, const uint8_t offset) const WARN_IF_UNUSED { 14 7 : return get_bytes((uint8_t*)&value, offset, 4); 15 : } 16 2 : bool set_float(const float value, const uint8_t offset) WARN_IF_UNUSED { 17 2 : return set_bytes((uint8_t*)&value, offset, 4); 18 : } 19 : 20 : bool get_string(char* value, const uint8_t offset) const WARN_IF_UNUSED; 21 : bool set_string(const char* value, const uint8_t offset) WARN_IF_UNUSED; 22 : 23 4 : bool get_uint16(uint16_t &value, const uint8_t offset) const WARN_IF_UNUSED { 24 4 : return get_bytes((uint8_t*)&value, offset, 2); 25 : } 26 4 : bool set_uint16(const uint16_t value, const uint8_t offset) WARN_IF_UNUSED { 27 4 : return set_bytes((uint8_t*)&value, offset, 2); 28 : } 29 : 30 4 : bool get_uint8(uint8_t &value, const uint8_t offset) const WARN_IF_UNUSED { 31 4 : return get_bytes((uint8_t*)&value, offset, 1); 32 : } 33 4 : bool set_uint8(const uint8_t value, const uint8_t offset) WARN_IF_UNUSED { 34 4 : return set_bytes((uint8_t*)&value, offset, 1); 35 : } 36 : 37 : uint8_t msgid = 0; // ID of message in payload 38 : uint8_t len = 0; // Length of payload 39 : uint8_t payload[MAVLITE_MAX_PAYLOAD_LEN]; 40 : 41 : static void bit8_pack(uint8_t &value, const uint8_t bit_value, const uint8_t bit_count, const uint8_t bit_offset); 42 : static uint8_t bit8_unpack(const uint8_t value, const uint8_t bit_count, const uint8_t bit_offset); 43 : 44 : private: 45 : bool get_bytes(uint8_t *bytes, const uint8_t offset, const uint8_t count) const WARN_IF_UNUSED; 46 : bool set_bytes(const uint8_t *bytes, const uint8_t offset, const uint8_t count) WARN_IF_UNUSED; 47 : }; 48 : #endif