|
Zephyr API Documentation 4.3.99
A Scalable Open Source RTOS
|
COBS encoding and decoding functions with custom delimiter support. More...
Data Structures | |
| struct | cobs_encoder |
| COBS streaming encoder state. More... | |
| struct | cobs_decoder |
| COBS streaming decoder state. More... | |
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. | |
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.
#include <zephyr/data/cobs.h>
Callback function type for streaming COBS encoder/decoder.
This callback is invoked by the streaming encoder/decoder to output processed data chunks. A decoder that allows trailing delimiters and encounters one will invoke this callback with a NULL pointer and zero length indicating a completed frame.
When this callback function returns a negative error value, the encoder or decoder stream is aborted and the error will be propagated.
| buf | Buffer containing processed data |
| len | Length of data in buffer |
| user_data | User-provided context pointer |
#include <zephyr/data/cobs.h>
COBS decoding.
Decodes COBS-encoded data from source buffer to destination buffer.
| src | Source buffer to decode |
| dst | Destination buffer for decoded data |
| flags | Decoding flags COBS_FLAGS |
| 0 | Success |
| -ENOMEM | Insufficient destination space |
| -EINVAL | Invalid COBS structure or parameters |
| int cobs_decoder_close | ( | struct cobs_decoder * | dec | ) |
#include <zephyr/data/cobs.h>
Finalize COBS streaming decoder.
Completes the decoding process and verifies that the stream ended properly. Should be called after all data has been written to the decoder.
The decoder state will be reset.
| dec | Pointer to decoder structure |
| 0 | Success |
| -EINVAL | More data was expected before closing |
| int cobs_decoder_init | ( | struct cobs_decoder * | dec, |
| cobs_stream_cb | cb, | ||
| void * | user_data, | ||
| uint32_t | flags ) |
#include <zephyr/data/cobs.h>
Initialize COBS streaming decoder.
Initializes a COBS decoder for streaming operation. The decoder will call the provided callback function to output decoded data chunks as they become available.
| dec | Pointer to decoder structure to initialize |
| cb | Callback function for output data |
| user_data | User data pointer passed to callback |
| flags | Decoding flags COBS_FLAGS |
| int cobs_decoder_write | ( | struct cobs_decoder * | dec, |
| const uint8_t * | buf, | ||
| size_t | len ) |
#include <zephyr/data/cobs.h>
Write data to COBS streaming decoder.
Decodes the provided encoded data and outputs decoded chunks via the registered callback function. This function can be called multiple times to decode data incrementally.
In case an error is returned, the decoder state will be reset.
| dec | Pointer to decoder structure |
| buf | Buffer containing encoded data |
| len | Length of data in buffer |
buf on success, negative errno code on failure #include <zephyr/data/cobs.h>
COBS encoding.
Encodes data from source buffer to destination buffer using COBS encoding.
| src | Source buffer to encode |
| dst | Destination buffer for encoded data |
| flags | Encoding flags COBS_FLAGS |
| 0 | Success |
| -ENOMEM | Insufficient destination space |
| -EINVAL | Invalid COBS structure or parameters |
| int cobs_encoder_close | ( | struct cobs_encoder * | enc | ) |
#include <zephyr/data/cobs.h>
Finalize COBS streaming encoder.
Flushes any remaining data and optionally writes trailing delimiter if COBS_FLAG_TRAILING_DELIMITER was set during initialization.
The encoder state will be reset.
| enc | Pointer to encoder structure |
| int cobs_encoder_init | ( | struct cobs_encoder * | enc, |
| cobs_stream_cb | cb, | ||
| void * | user_data, | ||
| uint32_t | flags ) |
#include <zephyr/data/cobs.h>
Initialize COBS streaming encoder.
Initializes a COBS encoder for streaming operation. The encoder will call the provided callback function to output encoded data chunks as they become available.
| enc | Pointer to encoder structure to initialize |
| cb | Callback function for output data |
| user_data | User data pointer passed to callback |
| flags | Encoding flags COBS_FLAGS |
| int cobs_encoder_write | ( | struct cobs_encoder * | enc, |
| const uint8_t * | buf, | ||
| size_t | len ) |
#include <zephyr/data/cobs.h>
Write data to COBS streaming encoder.
Encodes the provided data and outputs encoded chunks via the registered callback function. This function can be called multiple times to encode data incrementally.
In case an error is returned, the encoder state will be reset.
| enc | Pointer to encoder structure |
| buf | Buffer containing data to encode |
| len | Length of data in buffer |
buf on success, negative errno code on failure #include <zephyr/data/cobs.h>
Calculate maximum encoded buffer size.
| decoded_size | Size of input data to be encoded |
| flags | Encoding flags COBS_FLAGS |