OpenThread_app
Loading...
Searching...
No Matches
ot_app_buffer.h File Reference

Thread-safe shared buffer management for the OpenThread Application Framework. More...

#include "stdint.h"

Go to the source code of this file.

Classes

struct  bufferConfig_t
 Buffer configuration structure. More...

Macros

#define OTAPP_BUF_SIZE   (OTAPP_BUF_KEY_1_SIZE + OTAPP_BUF_KEY_2_SIZE + OTAPP_BUF_KEY_3_SIZE)
 Total size of the buffer pool.
Return Codes
#define OTAPP_BUF_OK   (-1)
 Operation successful.
#define OTAPP_BUF_ERROR   (-2)
 Generic error (null ptr, init missing).
#define OTAPP_BUF_ERROR_OVERFLOW   (-3)
 Buffer is full or data exceeds slot size.
#define OTAPP_BUF_ERROR_KEY_NOT_FOUND   (-4)
 The provided key does not exist in config.
#define OTAPP_BUF_ERROR_WRITE_LOCK   (-5)
 The slot is currently locked for direct writing.
Buffer Configuration Keys
#define OTAPP_BUF_KEY_1   0x1001
 Key 1: General purpose buffer. Used by otapp_pair_uriParseMessage() and otapp_pair_uriResourcesCreate().
#define OTAPP_BUF_KEY_1_SIZE   256
#define OTAPP_BUF_KEY_2   0x1002
 Auxiliary buffer slot 2.
#define OTAPP_BUF_KEY_2_SIZE   64
#define OTAPP_BUF_KEY_3   0x1003
 Auxiliary buffer slot 3.
#define OTAPP_BUF_KEY_3_SIZE   64

Functions

int8_t otapp_buf_append (uint16_t key, const uint8_t *new_data, uint16_t len)
 Appends data to the buffer slot associated with the key.
int8_t otapp_buf_getData (uint16_t key, uint8_t *bufOut, uint16_t bufSize, uint16_t *lenBufOut)
 Retrieves data from a buffer slot into a user-provided buffer.
const uint8_t * otapp_buf_getReadOnly_ptr (uint16_t key, uint16_t *bufSize_out)
 Gets a read-only pointer to the buffer slot's payload.
uint8_t * otapp_buf_getWriteOnly_ptr (uint16_t key, uint16_t required_size)
 Requests a write-only pointer for direct memory access (Zero-Copy).
int8_t otapp_buff_clear (uint16_t key)
 Clears the data in a specific buffer slot.
uint16_t otapp_buf_getMaxSize (uint16_t key)
 Returns the maximum capacity of a slot.
uint16_t otapp_buf_getCurrentLenSize (uint16_t key)
 Returns the current length of data stored in a slot.
int8_t otapp_buf_writeUnlock (uint16_t key)
 Unlocks a slot previously locked by otapp_buf_getWriteOnly_ptr.
void otapp_buffer_init (void)
 Initializes the buffer module and creates the RTOS mutex.

Detailed Description

Thread-safe shared buffer management for the OpenThread Application Framework.

see more information in section: Shared Buffer Management