Ares LoRa Firmware
Loading...
Searching...
No Matches
frame.h File Reference

Ares frame library. More...

#include <zephyr/kernel.h>
Include dependency graph for frame.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ares_frame
 Structured representation of an ares frame. More...
struct  ares_frame_info
 Serial buffer metadata that describes the location of a frame in a buffer, the size of the frame, and how many bytes need to be read before deserialization is possible. More...

Macros

#define ARES_FRAME_HEADER   '^'
#define ARES_FRAME_FOOTER   '@'
#define ARES_FRAME_HEADER_OVERHEAD   UINT32_C(1)
#define ARES_FRAME_TYPE_OVERHEAD   UINT32_C(1)
#define ARES_FRAME_LEN_OVERHEAD   UINT32_C(2)
#define ARES_FRAME_FOOTER_OVERHEAD   UINT32_C(1)
#define ARES_FRAME_OVERHEAD

Enumerations

enum  ares_frame_error { ARES_FRAME_ERROR_BAD_FRAME = 0 , ARES_FRAME_ERROR_BAD_TYPE = 1 , ARES_FRAME_ERROR_NOT_IMPLEMENTED = 2 }
 Frame related errors. More...
enum  ares_frame_type {
  ARES_FRAME_SETTING , ARES_FRAME_START , ARES_FRAME_LORA_CONFIG , ARES_FRAME_LED ,
  ARES_FRAME_HEARTBEAT , ARES_FRAME_CLAIM , ARES_FRAME_LOG , ARES_FRAME_LOG_ACK ,
  ARES_FRAME_VERSION , ARES_FRAME_ACK , ARES_FRAME_FRAMING_ERROR , ARES_FRAME_DBG ,
  ARES_FRAME_PKT_RX , ARES_FRAME_PKT_TX , ARES_FRAME_TYPE_INVALID
}
 Frame types. More...

Functions

int ares_serialize_frame (uint8_t *buf, size_t len, const struct ares_frame *frame)
 Function to serialize an ares frame into a buffer.
int ares_deserialize_frame (struct ares_frame *frame, const uint8_t *buf, size_t len)
 Function to deserialize an ares frame from a buffer.
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.
bool ares_check_if_frame (const uint8_t *buf, size_t len)
 Check if the frame in the buffer is valid.

Detailed Description

Ares frame library.

| Field | Header | Length | Type | Payload | Footer | | Size | 1 byte | 2 bytes | 1 byte | 0-65535 bytes | 1 byte | | Value | ^ | | | | @ |

Date
3/19/26
Author
Tom Schmitz <tschm.nosp@m.itz@.nosp@m.andre.nosp@m.w.cm.nosp@m.u.edu>

Macro Definition Documentation

◆ ARES_FRAME_FOOTER

#define ARES_FRAME_FOOTER   '@'

Footer for Ares frames.

◆ ARES_FRAME_FOOTER_OVERHEAD

#define ARES_FRAME_FOOTER_OVERHEAD   UINT32_C(1)

Number of bytes needed for the footer field.

◆ ARES_FRAME_HEADER

#define ARES_FRAME_HEADER   '^'

Header for Ares frames.

◆ ARES_FRAME_HEADER_OVERHEAD

#define ARES_FRAME_HEADER_OVERHEAD   UINT32_C(1)

Number of bytes needed for the header field.

◆ ARES_FRAME_LEN_OVERHEAD

#define ARES_FRAME_LEN_OVERHEAD   UINT32_C(2)

Number of bytes needed for the length field.

◆ ARES_FRAME_OVERHEAD

#define ARES_FRAME_OVERHEAD
Value:
#define ARES_FRAME_FOOTER_OVERHEAD
Definition frame.h:48
#define ARES_FRAME_TYPE_OVERHEAD
Definition frame.h:38
#define ARES_FRAME_HEADER_OVERHEAD
Definition frame.h:33
#define ARES_FRAME_LEN_OVERHEAD
Definition frame.h:43

Number of bytes needed for an Ares frame.

◆ ARES_FRAME_TYPE_OVERHEAD

#define ARES_FRAME_TYPE_OVERHEAD   UINT32_C(1)

Number of bytes needed for the type field.

Enumeration Type Documentation

◆ ares_frame_error

Frame related errors.

Enumerator
ARES_FRAME_ERROR_BAD_FRAME 

Frame could not be deserialized.

ARES_FRAME_ERROR_BAD_TYPE 

Frame type not valid for reception.

ARES_FRAME_ERROR_NOT_IMPLEMENTED 

Frame handler not implemented.

◆ ares_frame_type

Frame types.

Enumerator
ARES_FRAME_SETTING 

SETTING frame.

ARES_FRAME_START 

Start time frame.

ARES_FRAME_LORA_CONFIG 

LoRa configuration frame.

ARES_FRAME_LED 

Control LED state.

ARES_FRAME_HEARTBEAT 

LoRa Heart Beat frame.

ARES_FRAME_CLAIM 

LoRa host claim frame.

ARES_FRAME_LOG 

Log message.

ARES_FRAME_LOG_ACK 

Log message ACK from LoRa.

ARES_FRAME_VERSION 

Version information.

ARES_FRAME_ACK 

ACK frame.

ARES_FRAME_FRAMING_ERROR 

Framing error frame. TX only.

ARES_FRAME_DBG 

Debug frames, TX only.

ARES_FRAME_PKT_RX 

Packet received, TX only.

ARES_FRAME_PKT_TX 

Packet transmitted, TX only.

ARES_FRAME_TYPE_INVALID 

Invalid frame.

Function Documentation

◆ ares_check_if_frame()

bool ares_check_if_frame ( const uint8_t * buf,
size_t len )

Check if the frame in the buffer is valid.

Parameters
[in]bufPointer to source buffer.
[in]lenThe length of the serialized frame.
Returns
true if the frame is valid.
false otherwise.

◆ ares_deserialize_frame()

int ares_deserialize_frame ( struct ares_frame * frame,
const uint8_t * buf,
size_t len )

Function to deserialize an ares frame from a buffer.

Parameters
[out]framePointer to the destination frame.
[in]bufPointer to the start of the buffered frame.
[in]lenThe length of the buffered frame.
Returns
0 on success.
-EBADMSG if frame is not valid.
-EINVAL on invalid parameters.

◆ ares_serial_frame_present()

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.

Parameters
[in]bufPointer to source buffer.
[in]lenThe number of valid bytes in the buffer.
[out]infoThe metadata for finding the frame in the buffer.
Returns
1 if frame was found.
0 if no frame was found.
-EINVAL if parameters are invalid.

◆ ares_serialize_frame()

int ares_serialize_frame ( uint8_t * buf,
size_t len,
const struct ares_frame * frame )

Function to serialize an ares frame into a buffer.

Parameters
[out]bufPointer to the destination buffer.
[in]lenThe length of the destination buffer.
[in]framePointer to the source frame.
Returns
The number of bytes written to the buffer.
-EINVAL if invalid parameters.
-ENOBUFS buffer size is too small.