|
Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
|
Go to the source code of this file.
Data Structures | |
| struct | cobs_encoder |
| COBS streaming encoder state. More... | |
| struct | cobs_decoder |
| COBS streaming decoder state. More... | |
Macros | |
COBS Encoder/Decoder Flags | |
| #define | COBS_DEFAULT_DELIMITER 0x00 |
| Default COBS delimiter value. | |
| #define | COBS_FLAG_TRAILING_DELIMITER BIT(8) |
| Flag indicating that encode or decode should include a trailing delimiter. | |
| #define | COBS_FLAG_CUSTOM_DELIMITER(x) |
| Macro for setting a custom delimiter in flags. | |
Typedefs | |
| typedef int(* | cobs_stream_cb) (const uint8_t *buf, size_t len, void *user_data) |
| Callback function type for streaming COBS encoder/decoder. | |
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) |
| COBS encoding. | |
| int | cobs_decode (struct net_buf *src, struct net_buf *dst, uint32_t flags) |
| COBS decoding. | |
| int | cobs_encoder_init (struct cobs_encoder *enc, cobs_stream_cb cb, void *user_data, uint32_t flags) |
| Initialize COBS streaming encoder. | |
| int | cobs_encoder_close (struct cobs_encoder *enc) |
| Finalize COBS streaming encoder. | |
| int | cobs_encoder_write (struct cobs_encoder *enc, const uint8_t *buf, size_t len) |
| Write data to COBS streaming encoder. | |
| int | cobs_decoder_init (struct cobs_decoder *dec, cobs_stream_cb cb, void *user_data, uint32_t flags) |
| Initialize COBS streaming decoder. | |
| int | cobs_decoder_close (struct cobs_decoder *dec) |
| Finalize COBS streaming decoder. | |
| int | cobs_decoder_write (struct cobs_decoder *dec, const uint8_t *buf, size_t len) |
| Write data to COBS streaming decoder. | |
| #define COBS_DEFAULT_DELIMITER 0x00 |
Default COBS delimiter value.
The standard COBS delimiter is zero (0x00). This is the delimiter value used when COBS_FLAG_CUSTOM_DELIMITER is not specified.
| #define COBS_FLAG_CUSTOM_DELIMITER | ( | x | ) |
Macro for setting a custom delimiter in flags.
The 8 LSB of "flags" is used for the delimiter value. When a custom delimiter is configured, the implementation applies an XOR operation with the delimiter value on the encoded data after encoding and before decoding. This allows COBS to work with delimiters other than zero.
| x | Custom delimiter value (0-255) |
Example usage:
| #define COBS_FLAG_TRAILING_DELIMITER BIT(8) |
Flag indicating that encode or decode should include a trailing delimiter.
When set, the encoder will append a delimiter byte after the encoded data, and the decoder will accept a delimiter byte at the end of the encoded data.