Telemetry Linux - Message Parsing APIs

Note

These APIs are used internally in the Linux implementation of Telemetry for message parsing

bool telemetry_parse_msg_type(const uint8_t *buffer, uint32_t buffer_size, telemetry_message_type *msg_type)

Parses out the message type from an encoded message.

Return
bool true if successful, otherwise false
Parameters
  • buffer: buffer with encoded message
  • buffer_size: size of buffer
  • msg_type: parsed out type of message

int telemetry_encode_packet_msg(uint8_t *buffer, const telemetry_packet *pkt)

Attempts to encode a telemetry_packet.

Return
int 0 if successful, otherwise negative error code
Parameters
  • buffer: buffer to store encoded packet in
  • pkt: telemetry_packet to encode

bool telemetry_parse_packet_msg(const uint8_t *buffer, uint32_t buffer_size, telemetry_packet *packet)

Attempt to parse telemetry_packet from buffer.

Return
bool true if successful, otherwise false
Parameters
  • buffer: buffer storing packet data
  • buffer_size: size of buffer
  • packet: telemetry_packet to store data in

int telemetry_encode_subscribe_msg(uint8_t *buffer, const uint16_t *topic_id)

Attempts to encode a subscribe message.

Return
int 0 if successful, otherwise negative error code
Parameters
  • buffer: buffer to store encoded packet in
  • topic_id: topic ID for subscribing

bool telemetry_parse_subscribe_msg(const uint8_t *buffer, uint32_t buffer_size, uint16_t *topic_id)

Attempt to parse a subscribe message.

Return
bool true if successful, otherwise false
Parameters
  • buffer: buffer storing packet data
  • buffer_size: size of buffer
  • topic_id: topic ID read from message

int telemetry_encode_unsubscribe_msg(uint8_t *buffer, const uint16_t *topic_id)

Attempts to encode an unsubscribe message.

Return
int 0 if successful, otherwise negative error code
Parameters
  • buffer: buffer to store encoded packet in
  • topic_id: topic ID to encode in message

bool telemetry_parse_unsubscribe_msg(const uint8_t *buffer, uint32_t buffer_size, uint16_t *topic_id)

Attempt to parse an unsubscribe message.

Return
bool true if successful, otherwise false
Parameters
  • buffer: buffer storing packet data
  • buffer_size: size of buffer
  • topic_id: topic ID read from message

int telemetry_encode_disconnect_msg(uint8_t *buffer)

Attempts to encode disconnect message.

Return
int 0 if successful, otherwise negative error code
Parameters
  • buffer: buffer to store encoded packet in

int start_encode_msg(CborEncoder *encoder, CborEncoder *container, uint8_t *buffer, uint32_t buffer_size, uint8_t num_elements, telemetry_message_type message_type)

Sets up the structures for encoding a message.

Return
int 0 if successful, otherwise negative error
Parameters
  • encoder: Master CBOR encoder
  • container: CBOR container for map
  • buffer: buffer to store end data in
  • buffer_size: size of buffer
  • num_elements: number of elements in the message map
  • message_type: message type to be encoded

int end_encode_msg(uint8_t *buffer, CborEncoder *encoder, CborEncoder *container)

Finishing the CBOR encoding process.

Return
int 0 if successful, otherwise negative error code
Parameters
  • buffer: buffer for storing serialized data
  • encoder: CBOR encoder
  • container: CBOR map container