YAPB
Loading...
Searching...
No Matches
Lifecycle

Functions

YAPB_Result_t YAPB_initialize (YAPB_Packet_t *pkt, uint8_t *buffer, size_t size)
 Initialize a packet for writing.
YAPB_Result_t YAPB_finalize (YAPB_Packet_t *pkt, size_t *out_len)
 Finalize the packet, writing the total length into the header.
YAPB_Result_t YAPB_load (YAPB_Packet_t *pkt, const uint8_t *data, size_t size)
 Load a packet for reading from raw data.

Detailed Description

Packet creation, finalization, and loading.

Function Documentation

◆ YAPB_finalize()

YAPB_Result_t YAPB_finalize ( YAPB_Packet_t * pkt,
size_t * out_len )

Finalize the packet, writing the total length into the header.

Must be called after all push operations are complete. The packet data in the buffer is ready to transmit after this call.

Parameters
pktPacket in write mode.
out_lenOutput: total packet length including header. May be NULL.
Returns
YAPB_OK on success, error code otherwise.

◆ YAPB_initialize()

YAPB_Result_t YAPB_initialize ( YAPB_Packet_t * pkt,
uint8_t * buffer,
size_t size )

Initialize a packet for writing.

Sets up the packet in write mode. The caller provides the backing buffer. The header is zeroed as a safety measure in case YAPB_finalize() is forgotten.

Parameters
pktPacket structure to initialize.
bufferBuffer to write packet data into.
sizeSize of the buffer (must be >= YAPB_HEADER_SIZE).
Returns
YAPB_OK on success, error code otherwise.

◆ YAPB_load()

YAPB_Result_t YAPB_load ( YAPB_Packet_t * pkt,
const uint8_t * data,
size_t size )

Load a packet for reading from raw data.

Validates the header length field and sets up the packet in read mode. The data buffer must remain valid for the lifetime of all pop operations.

Parameters
pktPacket structure to initialize.
dataRaw packet data (including header).
sizeSize of the data buffer.
Returns
YAPB_OK on success, error code otherwise.