Zephyr Project API 4.1.99
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
COBS (Consistent Overhead Byte Stuffing)

COBS encoding and decoding functions with custom delimiter support. More...

Functions

static size_t cobs_max_encoded_len (size_t decoded_size, uint32_t flags)
 Calculate maximum encoded buffer size.
 
int cobs_encode (struct net_buf *src, struct net_buf *dst, uint32_t flags)
 Standard COBS encoding.
 
int cobs_decode (struct net_buf *src, struct net_buf *dst, uint32_t flags)
 Standard COBS decoding.
 

Detailed Description

COBS encoding and decoding functions with custom delimiter support.

Provides functions for COBS encoding/decoding with configurable delimiters. The implementation handles both standard zero-delimited COBS and custom delimiter variants.

Function Documentation

◆ cobs_decode()

int cobs_decode ( struct net_buf src,
struct net_buf dst,
uint32_t  flags 
)

#include <include/zephyr/data/cobs.h>

Standard COBS decoding.

Parameters
srcSource buffer to decode
dstDestination buffer for decoded data
flagsDecoding flags (reserved)
Return values
0Success
-ENOMEMInsufficient destination space
-EINVALInvalid COBS structure or parameters

◆ cobs_encode()

int cobs_encode ( struct net_buf src,
struct net_buf dst,
uint32_t  flags 
)

#include <include/zephyr/data/cobs.h>

Standard COBS encoding.

Parameters
srcSource buffer to decode
dstDestination buffer for decoded data
flagsDecoding flags (reserved)
Return values
0Success
-ENOMEMInsufficient destination space
-EINVALInvalid COBS structure or parameters

◆ cobs_max_encoded_len()

static size_t cobs_max_encoded_len ( size_t  decoded_size,
uint32_t  flags 
)
inlinestatic

#include <include/zephyr/data/cobs.h>

Calculate maximum encoded buffer size.

Parameters
decoded_sizeSize of input data to be encoded
flagsCOBS_FLAG_TRAILING_DELIMITER to include termination byte in calculation
Returns
Required buffer size for worst-case encoding scenario