15#ifndef ARES_SERIAL_FRAME_H
16#define ARES_SERIAL_FRAME_H
18#include <zephyr/kernel.h>
23#define ARES_FRAME_HEADER '^'
28#define ARES_FRAME_FOOTER '@'
33#define ARES_FRAME_HEADER_OVERHEAD UINT32_C(1)
38#define ARES_FRAME_TYPE_OVERHEAD UINT32_C(1)
43#define ARES_FRAME_LEN_OVERHEAD UINT32_C(2)
48#define ARES_FRAME_FOOTER_OVERHEAD UINT32_C(1)
53#define ARES_FRAME_OVERHEAD \
54 (uint64_t)(ARES_FRAME_HEADER_OVERHEAD + ARES_FRAME_TYPE_OVERHEAD + \
55 ARES_FRAME_LEN_OVERHEAD + ARES_FRAME_FOOTER_OVERHEAD)
121 uint16_t preamble_len;
127 uint8_t cad_symbol_num;
128 uint8_t cad_detection_peak;
129 uint8_t cad_detection_min;
135 uint8_t broadcast : 1;
ares_frame_error
Frame related errors.
Definition frame.h:61
@ ARES_FRAME_ERROR_BAD_FRAME
Frame could not be deserialized.
Definition frame.h:62
@ ARES_FRAME_ERROR_NOT_IMPLEMENTED
Frame handler not implemented.
Definition frame.h:64
@ ARES_FRAME_ERROR_BAD_TYPE
Frame type not valid for reception.
Definition frame.h:63
int ares_serialize_frame(uint8_t *buf, size_t len, const struct ares_frame *frame)
Function to serialize an ares frame into a buffer.
ares_frame_type
Frame types.
Definition frame.h:71
@ ARES_FRAME_LORA_CONFIG
LoRa configuration frame.
Definition frame.h:74
@ ARES_FRAME_DBG
Debug frames, TX only.
Definition frame.h:83
@ ARES_FRAME_START
Start time frame.
Definition frame.h:73
@ ARES_FRAME_SETTING
SETTING frame.
Definition frame.h:72
@ ARES_FRAME_LOG_ACK
Log message ACK from LoRa.
Definition frame.h:79
@ ARES_FRAME_PKT_RX
Packet received, TX only.
Definition frame.h:84
@ ARES_FRAME_FRAMING_ERROR
Framing error frame. TX only.
Definition frame.h:82
@ ARES_FRAME_CLAIM
LoRa host claim frame.
Definition frame.h:77
@ ARES_FRAME_VERSION
Version information.
Definition frame.h:80
@ ARES_FRAME_LOG
Log message.
Definition frame.h:78
@ ARES_FRAME_ACK
ACK frame.
Definition frame.h:81
@ ARES_FRAME_PKT_TX
Packet transmitted, TX only.
Definition frame.h:85
@ ARES_FRAME_TYPE_INVALID
Invalid frame.
Definition frame.h:87
@ ARES_FRAME_HEARTBEAT
LoRa Heart Beat frame.
Definition frame.h:76
@ ARES_FRAME_LED
Control LED state.
Definition frame.h:75
int ares_deserialize_frame(struct ares_frame *frame, const uint8_t *buf, size_t len)
Function to deserialize an ares frame from a buffer.
bool ares_check_if_frame(const uint8_t *buf, size_t len)
Check if the frame in the buffer is valid.
int ares_serial_frame_present(const uint8_t *buf, size_t len, struct ares_frame_info *info)
Function to check if there is an ares frame in the buffer.
Serial buffer metadata that describes the location of a frame in a buffer, the size of the frame,...
Definition frame.h:196
int frame_size
Definition frame.h:209
int start_index
Definition frame.h:202
int bytes_left
Definition frame.h:216
Structured representation of an ares frame.
Definition frame.h:94
struct ares_frame::@374352004270334174265237346140161256060261362272::@203254315067334021223073267021150040075101067065 HEARTBEAT
ARES_FRAME_HEARTBEAT.
enum ares_frame_error FRAMING_ERROR
ARES_FRAME_FRAMING_ERROR.
Definition frame.h:176
union ares_frame::@374352004270334174265237346140161256060261362272 payload
struct ares_frame::@374352004270334174265237346140161256060261362272::@123345237273217274012176272225135172074343367026 LORA_CONFIG
ARES_FRAME_LORA_CONFIG.
uint16_t CLAIM
ARES_FRAME_CLAIM.
Definition frame.h:147
struct ares_frame::@374352004270334174265237346140161256060261362272::@377363006262176051154052201263065200317013100346 SETTING
ARES_FRAME_SETTING.
struct ares_frame::@374352004270334174265237346140161256060261362272::@007202216350257264046200241060160134244122065363 LED
ARES_FRAME_LED.
int DBG
ARES_FRAME_DBG.
Definition frame.h:178
struct ares_frame::@374352004270334174265237346140161256060261362272::@342113245354176232372045362126071211103100144265 LOG
ARES_FRAME_LOG.
struct ares_frame::@374352004270334174265237346140161256060261362272::@104121142016223002303203034052024051250074302166 PKT_RX
ARES_FRAME_PKT_RX.
struct ares_frame::@374352004270334174265237346140161256060261362272::@075365105005327057272274234253154326200364245040 VERSION
ARES_FRAME_VERSION.
int ACK
ARES_FRAME_ACK.
Definition frame.h:174
uint32_t PKT_TX
ARES_FRAME_PKT_TX.
Definition frame.h:186
struct ares_frame::@374352004270334174265237346140161256060261362272::@123205165062376031253055366322112146373000060341 LOG_ACK
ARES_FRAME_LOG_ACK.
enum ares_frame_type type
Definition frame.h:98
struct ares_frame::@374352004270334174265237346140161256060261362272::@371051361254270065332050147031327021305323146131 START
ARES_FRAME_START.