Ring Buffer#

API and Callbacks for the Ring Buffer Component.

This component manages a ring buffer of binary entries. Each entry has a 1- or 2-byte length field that is recorded to manage the buffer. This ring buffer can be used by multiple entities as the buffer space for the ring buffer is allocated by the caller.

Modules#

sl_zigbee_ring_buffer_t

API#

sl_zigbee_af_ring_buffer_init_struct(sl_zigbee_ring_buffer_t *ringBufferStruct, bool wideLengthField, sl_zigbee_af_plugin_ring_buffer_delete_function_t *deleteCallback, uint8_t *dataPtr)

Initialize the ring buffer struct based on data passed. widLengthField determines whether the ring buffer uses 1 or 2 byte length fields for entry. wideLengthField = false uses 1 byte length, wideLengthField = true uses 2 byte lengths. All entries in the same ring buffer utilze the same size length field. Different ring buffers may use differnt sizes.

sl_zigbee_af_ring_buffer_add_entry(sl_zigbee_ring_buffer_t *ring, uint8_t *dataToAdd, uint16_t dataToAddSize)

Add an entry in the ring buffer.

sl_zigbee_af_ring_buffer_get_entry_by_entry_number(sl_zigbee_ring_buffer_t *ring, uint16_t entryNumber, uint16_t dataIndexInEntry, uint16_t *returnEntryTotalSize, uint16_t maxReturnSize, uint16_t *returnDataSize, uint8_t *returnData)

Retrieve data from the specified entry. Returns the entry's total size in value pointed to by returnEntryTotalSize. The amount of data returned is written to the pointer returnDataSize. This allows for the caller to get the entry's total size at the same time they are able to grab a chunk of the entry up to some limit.

sl_zigbee_af_ring_buffer_get_last_entry(sl_zigbee_ring_buffer_t *ring, uint16_t dataIndexInEntry, uint16_t *returnEntryTotalSize, uint16_t maxReturnSize, uint16_t *returnDataSize, uint8_t *returnData)

Get the last entry of the ring buffer.

sl_zigbee_af_ring_buffer_init_iterator(sl_zigbee_ring_buffer_t *ring)

Initialize the iterator to the first entry in the ring buffer. You may immediately call sl_zigbee_af_ring_buffer_get_entry_by_iterator() after this function is called.

sl_zigbee_af_ring_buffer_iterator_next_entry(sl_zigbee_ring_buffer_t *ring)

Iterate to next entry in ring buffer.

sl_zigbee_af_ring_buffer_get_entry_by_iterator(sl_zigbee_ring_buffer_t *ring, uint16_t dataIndexInEntry, uint16_t *returnEntryTotalSize, uint16_t maxReturnSize, uint16_t *returnDataSize, uint8_t *returnData)
sl_zigbee_af_ring_buffer_update_entry_by_iterator(sl_zigbee_ring_buffer_t *ring, uint16_t dataIndexInEntry, uint8_t *updatedData, uint16_t updatedDataLength)

Update a ring buffer entry by passing in the iterator.

sl_zigbee_af_ring_buffer_append_last_entry(sl_zigbee_ring_buffer_t *ring, uint8_t *dataToAdd, uint16_t dataToAddSize)

Append an entry to end of the ring buffer.

Typedefs#

typedef void()
sl_zigbee_af_plugin_ring_buffer_delete_function_t(uint16_t entryNumber, uint16_t entrySize)

API Documentation#

sl_zigbee_af_ring_buffer_init_struct#

sl_status_t sl_zigbee_af_ring_buffer_init_struct (sl_zigbee_ring_buffer_t * ringBufferStruct, bool wideLengthField, sl_zigbee_af_plugin_ring_buffer_delete_function_t * deleteCallback, uint8_t * dataPtr)

Initialize the ring buffer struct based on data passed. widLengthField determines whether the ring buffer uses 1 or 2 byte length fields for entry. wideLengthField = false uses 1 byte length, wideLengthField = true uses 2 byte lengths. All entries in the same ring buffer utilze the same size length field. Different ring buffers may use differnt sizes.

Parameters
N/AringBufferStruct

Ver.: always

N/AwideLengthField

Ver.: always

N/AdeleteCallback

Ver.: always

N/AdataPtr

Ver.: always

Returns

  • sl_status_t status code


Definition at line 82 of file app/framework/plugin/ring-buffer/ring-buffer.h

sl_zigbee_af_ring_buffer_add_entry#

sl_status_t sl_zigbee_af_ring_buffer_add_entry (sl_zigbee_ring_buffer_t * ring, uint8_t * dataToAdd, uint16_t dataToAddSize)

Add an entry in the ring buffer.

Parameters
N/Aring

Ver.: always

N/AdataToAdd

Ver.: always

N/AdataToAddSize

Ver.: always

Returns

  • sl_status_t status code


Definition at line 96 of file app/framework/plugin/ring-buffer/ring-buffer.h

sl_zigbee_af_ring_buffer_get_entry_by_entry_number#

sl_status_t sl_zigbee_af_ring_buffer_get_entry_by_entry_number (sl_zigbee_ring_buffer_t * ring, uint16_t entryNumber, uint16_t dataIndexInEntry, uint16_t * returnEntryTotalSize, uint16_t maxReturnSize, uint16_t * returnDataSize, uint8_t * returnData)

Retrieve data from the specified entry. Returns the entry's total size in value pointed to by returnEntryTotalSize. The amount of data returned is written to the pointer returnDataSize. This allows for the caller to get the entry's total size at the same time they are able to grab a chunk of the entry up to some limit.

Parameters
N/Aring

numbering starts from 0

N/AentryNumber

may be set to NULL, in which case no return data is written.

N/AdataIndexInEntry

does not include the entry's length overhead, which the caller shouldn't care about anyway.

N/AreturnEntryTotalSize
N/AmaxReturnSize
N/AreturnDataSize
N/AreturnData

Returns

  • sl_status_t status code


Definition at line 115 of file app/framework/plugin/ring-buffer/ring-buffer.h

sl_zigbee_af_ring_buffer_get_last_entry#

sl_status_t sl_zigbee_af_ring_buffer_get_last_entry (sl_zigbee_ring_buffer_t * ring, uint16_t dataIndexInEntry, uint16_t * returnEntryTotalSize, uint16_t maxReturnSize, uint16_t * returnDataSize, uint8_t * returnData)

Get the last entry of the ring buffer.

Parameters
N/Aring

Ver.: always

N/AdataIndexInEntry

Ver.: always

N/AreturnEntryTotalSize

Ver.: always

N/AmaxReturnSize

Ver.: always

N/AreturnDataSize

Ver.: always

N/AreturnData

Ver.: always

Returns

  • sl_status_t status code


Definition at line 134 of file app/framework/plugin/ring-buffer/ring-buffer.h

sl_zigbee_af_ring_buffer_init_iterator#

sl_status_t sl_zigbee_af_ring_buffer_init_iterator (sl_zigbee_ring_buffer_t * ring)

Initialize the iterator to the first entry in the ring buffer. You may immediately call sl_zigbee_af_ring_buffer_get_entry_by_iterator() after this function is called.

Parameters
N/Aring

Ver.: always

Returns

  • sl_status_t status code


Definition at line 150 of file app/framework/plugin/ring-buffer/ring-buffer.h

sl_zigbee_af_ring_buffer_iterator_next_entry#

sl_status_t sl_zigbee_af_ring_buffer_iterator_next_entry (sl_zigbee_ring_buffer_t * ring)

Iterate to next entry in ring buffer.

Parameters
N/Aring

Ver.: always

Returns

  • sl_status_t status code

Note

  • Return SL_STATUS_IN_PROGRESS if there are more items left to iterate through. Returns SL_STATUS_OK on reaching the last item, and the iterator is marked invalid (needs to be initialized again). Returns SL_STATUS_INVALID_STATE if the iterator has not been initialized. An iterator can also be marked invalid if the ring buffer has deleted the entry that the iterator was currently on.


Definition at line 166 of file app/framework/plugin/ring-buffer/ring-buffer.h

sl_zigbee_af_ring_buffer_get_entry_by_iterator#

sl_status_t sl_zigbee_af_ring_buffer_get_entry_by_iterator (sl_zigbee_ring_buffer_t * ring, uint16_t dataIndexInEntry, uint16_t * returnEntryTotalSize, uint16_t maxReturnSize, uint16_t * returnDataSize, uint8_t * returnData)

Similar to sl_zigbee_af_ring_buffer_get_entry_by_entry_number().

Parameters
N/Aring

Ver.: always

N/AdataIndexInEntry

Ver.: always

N/AreturnEntryTotalSize

Ver.: always

N/AmaxReturnSize

Ver.: always

N/AreturnDataSize

Ver.: always

N/AreturnData

Ver.: always

Returns

  • sl_status_t status code

Note

  • The iterator must have already been initialized


Definition at line 182 of file app/framework/plugin/ring-buffer/ring-buffer.h

sl_zigbee_af_ring_buffer_update_entry_by_iterator#

sl_status_t sl_zigbee_af_ring_buffer_update_entry_by_iterator (sl_zigbee_ring_buffer_t * ring, uint16_t dataIndexInEntry, uint8_t * updatedData, uint16_t updatedDataLength)

Update a ring buffer entry by passing in the iterator.

Parameters
N/Aring

Ver.: always

N/AdataIndexInEntry

Ver.: always

N/AupdatedData

Ver.: always

N/AupdatedDataLength

Ver.: always

Returns

  • sl_status_t status code


Definition at line 199 of file app/framework/plugin/ring-buffer/ring-buffer.h

sl_zigbee_af_ring_buffer_append_last_entry#

sl_status_t sl_zigbee_af_ring_buffer_append_last_entry (sl_zigbee_ring_buffer_t * ring, uint8_t * dataToAdd, uint16_t dataToAddSize)

Append an entry to end of the ring buffer.

Parameters
N/Aring

Ver.: always

N/AdataToAdd

Ver.: always

N/AdataToAddSize

Ver.: always

Returns

  • sl_status_t status code


Definition at line 213 of file app/framework/plugin/ring-buffer/ring-buffer.h

Typedef Documentation#

sl_zigbee_af_plugin_ring_buffer_delete_function_t#

typedef void() sl_zigbee_af_plugin_ring_buffer_delete_function_t(uint16_t entryNumber, uint16_t entrySize) (uint16_t entryNumber, uint16_t entrySize)

Definition at line 41 of file app/framework/plugin/ring-buffer/ring-buffer.h

Macro Definition Documentation#

SL_ZIGBEE_AF_PLUGIN_RING_BUFFER_WIDE_LENGTH_ENTRY_OVERHEAD#

#define SL_ZIGBEE_AF_PLUGIN_RING_BUFFER_WIDE_LENGTH_ENTRY_OVERHEAD
Value:
2

Definition at line 35 of file app/framework/plugin/ring-buffer/ring-buffer.h

SL_ZIGBEE_AF_PLUGIN_RING_BUFFER_NARROW_LENGTH_ENTRY_OVERHEAD#

#define SL_ZIGBEE_AF_PLUGIN_RING_BUFFER_NARROW_LENGTH_ENTRY_OVERHEAD
Value:
1

Definition at line 36 of file app/framework/plugin/ring-buffer/ring-buffer.h

SL_ZIGBEE_AF_PLUGIN_RING_BUFFER_MAX_LENGTH_ENTRY_OVERHEAD#

#define SL_ZIGBEE_AF_PLUGIN_RING_BUFFER_MAX_LENGTH_ENTRY_OVERHEAD
Value:
SL_ZIGBEE_AF_PLUGIN_RING_BUFFER_WIDE_LENGTH_ENTRY_OVERHEAD

Definition at line 38 of file app/framework/plugin/ring-buffer/ring-buffer.h