BlueToe
an alternative GATT/BLE implementation
|
structure, able to store variable sized link layer PDUs in a fixed size ring. More...
#include <bluetoe/link_layer/include/bluetoe/ring_buffer.hpp>
Public Member Functions | |
pdu_ring_buffer (std::uint8_t *buffer) | |
sets up the ring to be empty | |
void | reset (std::uint8_t *buffer) |
resets the ring to be empty | |
Buffer | alloc_front (std::uint8_t *buffer, std::size_t size) const |
return a writeable PDU buffer of at least size bytes at the front of the ring | |
void | push_front (std::uint8_t *buffer, const Buffer &pdu) |
stores the allocated PDU in the ring. | |
Buffer | next_end () const |
returns the next PDU from the ring. | |
void | pop_end (std::uint8_t *buffer) |
frees the last PDU at the end of the ring | |
bool | more_than_one () const |
returns true, if the buffer contains at least 2 elements | |
Static Public Attributes | |
static constexpr std::size_t | size = Size |
the size of the buffer in bytes | |
structure, able to store variable sized link layer PDUs in a fixed size ring.
The buffer uses the size field of the stored PDUs as pointers to the next PDU stored in the buffer.
Elements are inserted at the front and removed from the end. When the ring buffer is empty it is garantied that the buffer can store one elemente of at least Size - 1 in size.
The Layout is used to access the header field of the PDU and to determin the in memory length of stored PDUs.
|
explicit |
sets up the ring to be empty
Buffer bluetoe::link_layer::pdu_ring_buffer< Size, Buffer, Layout >::alloc_front | ( | std::uint8_t * | buffer, |
std::size_t | size | ||
) | const |
return a writeable PDU buffer of at least size bytes at the front of the ring
The function is idempotent and will yield the same results as long as the state of the buffer is not changed and the parameters are the same.
If there is not enough room for size bytes in the ring buffer, the function will return an empty read_buffer.
Buffer bluetoe::link_layer::pdu_ring_buffer< Size, Buffer, Layout >::next_end |
returns the next PDU from the ring.
If no PDU is stored in the ring, the function will return an empty write_buffer.
void bluetoe::link_layer::pdu_ring_buffer< Size, Buffer, Layout >::pop_end | ( | std::uint8_t * | buffer | ) |
frees the last PDU at the end of the ring
void bluetoe::link_layer::pdu_ring_buffer< Size, Buffer, Layout >::push_front | ( | std::uint8_t * | buffer, |
const Buffer & | pdu | ||
) |
stores the allocated PDU in the ring.
The length field of the PDU must contain the actual size of the PDU - 2. Now the stored PDU can be read through the ring.
void bluetoe::link_layer::pdu_ring_buffer< Size, Buffer, Layout >::reset | ( | std::uint8_t * | buffer | ) |
resets the ring to be empty