MBot Software Library  v1.0
An API documentation to mbot_firmware repository
Functions
Listener
Collaboration diagram for Listener:

Functions

void comms_listener_loop (void)
 Main loop for the communication listener. More...
 
int read_header (uint8_t *header_data)
 Read the header data from the communication interface. More...
 
int validate_header (uint8_t *header_data)
 Validate the integrity of the header data. More...
 
int read_message (uint8_t *header_data, uint8_t *msg_data_serialized, uint16_t message_len, char *topic_msg_data_checksum)
 Read a message from the communication interface. More...
 
int validate_message (uint8_t *header_data, uint8_t *msg_data_serialized, uint16_t message_len, char topic_msg_data_checksum)
 Validate the integrity of the message data. More...
 

Detailed Description

<comms/listener.h>

Function Documentation

◆ comms_listener_loop()

void comms_listener_loop ( void  )

Main loop for the communication listener.

This function continuously reads and validates headers and messages from the communication interface. If the header and message are valid, it processes the message and calls the appropriate callback function.

◆ read_header()

int read_header ( uint8_t *  header_data)

Read the header data from the communication interface.

Parameters
header_dataPointer to the array where the header data will be stored.
Returns
1 if the header data was read successfully, 0 otherwise.

◆ read_message()

int read_message ( uint8_t *  header_data,
uint8_t *  msg_data_serialized,
uint16_t  message_len,
char *  topic_msg_data_checksum 
)

Read a message from the communication interface.

Parameters
header_dataPointer to the array containing the header data.
msg_data_serializedPointer to the array where the serialized message data will be stored.
message_lenLength of the message to read, as specified in the header data.
topic_msg_data_checksumPointer to a char where the checksum of the message data will be stored.
Returns
1 if the message was read successfully, 0 otherwise.

◆ validate_header()

int validate_header ( uint8_t *  header_data)

Validate the integrity of the header data.

Parameters
header_dataPointer to the array containing the header data to validate.
Returns
1 if the header data is valid, 0 otherwise.

◆ validate_message()

int validate_message ( uint8_t *  header_data,
uint8_t *  msg_data_serialized,
uint16_t  message_len,
char  topic_msg_data_checksum 
)

Validate the integrity of the message data.

Parameters
header_dataPointer to the array containing the header data.
msg_data_serializedPointer to the array containing the serialized message data.
message_lenLength of the message, as specified in the header data.
topic_msg_data_checksumChecksum of the message data.
Returns
1 if the message data is valid, 0 otherwise.