|
Ares LoRa Serial Driver Core
|
#include <ares_frame.hpp>
Classes | |
| struct | Setting |
| struct | Start |
| struct | LoraConfig |
| struct | Led |
| struct | Heartbeat |
| struct | Claim |
| struct | Log |
| struct | LogAck |
| struct | Version |
| struct | Dbg |
| struct | PktRx |
| struct | PktTx |
| struct | Decoded |
Public Types | |
| enum | AresFrameType : unsigned int { SETTING = 0 , START = 1 , LORA_CONFIG = 2 , LED = 3 , HEARTBEAT = 4 , CLAIM = 5 , LOG = 6 , LOG_ACK = 7 , VERSION = 8 , ACK = 9 , FRAMING_ERROR = 10 , DBG = 11 , PKT_RX = 12 , PKT_TX = 13 , UNKNOWN } |
| enum | FramingError : uint8_t { BAD_FRAME = 0 , BAD_TYPE = 1 , NOT_IMPLEMENTED = 2 } |
| using | AckErrorCode = int32_t |
| using | TxTypes |
| using | RxTypes |
| using | ResponseTypes |
Public Member Functions | |
| AresFrame (AresFrameType type, TxTypes payload) | |
| AresFrame (const std::vector< uint8_t > &bytearray) | |
| AresFrame () | |
| AresFrame (const AresFrame &other) | |
| ~AresFrame ()=default | |
| void | serialize (std::vector< uint8_t > &bytearray) |
| void | parse (const uint8_t *serial_data, size_t start_index, size_t len) |
| void | parse (const std::vector< uint8_t > &bytearray, size_t start_index) |
| Decoded | get_parsed_frame () const |
| bool | frame_available () const |
| size_t | total_frames () const |
Static Public Member Functions | |
| static std::tuple< ssize_t, ssize_t, ssize_t > | frame_present (const uint8_t *serial_data, size_t len, bool error_no_footer=true) |
| static std::tuple< ssize_t, ssize_t, ssize_t > | frame_present (const std::vector< uint8_t > &bytearray, bool error_no_footer=true) |
Framing class for Ares frames. These frames are used for communication with the Ares LoRa platform.
| using AresFrame::AckErrorCode = int32_t |
Data for AresFrame::ACK frames.
| using AresFrame::ResponseTypes |
A variant representing all the response frame types.
| using AresFrame::RxTypes |
A variant representing all the reception frame types.
| using AresFrame::TxTypes |
A variant representing all the transmission frame types.
| enum AresFrame::AresFrameType : unsigned int |
Frame types for communication with the LoRa module.
| Enumerator | |
|---|---|
| SETTING | Setting get/set (TX/RX). |
| START | Start time (TX/RX). |
| LORA_CONFIG | LoRa modem configuration (TX). |
| LED | LED state get/set (TX/RX). |
| HEARTBEAT | Send heartbeat (TX/RX). |
| CLAIM | Master claim (TX/RX). |
| LOG | Log message (TX/RX). |
| LOG_ACK | Log acknowledge (RX). |
| VERSION | Firmware version (TX/RX). |
| ACK | Command acknowledge (RX). |
| FRAMING_ERROR | Framing error (RX). |
| DBG | Debug message (RX). |
| PKT_RX | Packet Received (RX). |
| PKT_TX | Packet transmitted (RX). |
| UNKNOWN | Unknown frame. |
| enum AresFrame::FramingError : uint8_t |
Data for AresFrame::FRAMING_ERROR frames.
| Enumerator | |
|---|---|
| BAD_FRAME | Bad frame. |
| BAD_TYPE | Bad frame type. |
| NOT_IMPLEMENTED | Frame type not implemented. |
|
explicit |
Constructs a frame object from deserialized data.
| type | The type of the frame. |
| payload | The payload for the frame. |
|
explicit |
Constructs a frame object from serial data.
| bytearray | The serial data. |
| AresFrameError | if frame is not found in buffer. |
| AresFrame::AresFrame | ( | ) |
Default constructor.
| AresFrame::AresFrame | ( | const AresFrame & | other | ) |
Copy constructor.
| other | Other object to copy. |
|
default |
Destructor.
|
nodiscard |
Check if a new frame is available for serialization. Useful for messages split into multiple frames.
|
static |
Checks if there is a frame present in the given buffer.
| bytearray | The buffer to check. |
| error_no_footer | Return an error if there is no footer. |
|
static |
Checks if there is a frame present in the given buffer.
| serial_data | The serial data buffer to check. |
| len | The length of the serial data buffer. |
| error_no_footer | Return an error if there is no footer. |
|
nodiscard |
Retrieve the parsed frame.
| void AresFrame::parse | ( | const std::vector< uint8_t > & | bytearray, |
| size_t | start_index ) |
Parse a frame from the given buffer.
| bytearray | The buffer to parse a frame from |
| start_index | The start index of the frame. |
| AresFrameError | if frame type cannot be parsed (meant for transmission only). |
| void AresFrame::parse | ( | const uint8_t * | serial_data, |
| size_t | start_index, | ||
| size_t | len ) |
Parse a frame from the given buffer.
| serial_data | The buffer to parse a frame from. |
| start_index | The start index of the frame. |
| len | The length of the buffer. |
| AresFrameError | if frame type cannot be parsed (meant for transmission only). |
| void AresFrame::serialize | ( | std::vector< uint8_t > & | bytearray | ) |
Serialize the frame into a buffer. If a frame is split into chunks, then places the next frame into the buffer.
| bytearray | The buffer to store the serialized frame in. |
| AresFrameError | if frame type cannot be serialized (meant for reception only). |
| AresFrameError | if log message is empty. |
| AresFrameError | if log message is too long. |
| AresFrameError | if frame payload length cannot be calculated. |
|
nodiscard |
Retrieve the number of frames a message is split up into.