#include <MIDI_Interfaces/BLEMIDI/BLERingBuf.hpp>
Circular FIFO buffer for buffering BLE packet data.
It supports both complete BLE packets and packets split over multiple chunks. Full packets that are added to the FIFO might be split up over multiple chunks.
Capacity | Buffer size (bytes). Note that the actual maximum data size may be up to 6 bytes less because of data structure overhead. |
SizeT | The type to use for the size of tbe buffer. Should be atomic if this buffer is to be used as a SPSC queue between two threads. See NonatomicBLERingBufSize for an example. |
Definition at line 34 of file BLERingBuf.hpp.
Classes | |
struct | Header |
Public Member Functions | |
BLERingBuf () | |
bool | push (BLEDataView data, BLEDataType type=BLEDataType::Packet) |
Copy the given data into the buffer. | |
BLEDataType | pop (BLEDataView &data) |
Get a view to the next chunk of data. | |
Static Private Member Functions | |
static constexpr uint_fast16_t | ceil_h (uint_fast16_t i) |
Private Attributes | |
unsigned char | buffer [capacity] |
uint_fast16_t | read_p = 0 |
uint_fast16_t | write_p = header_size |
SizeT | size {header_size} |
Static Private Attributes | |
static constexpr uint_fast16_t | header_size = sizeof(Header) |
static constexpr uint_fast16_t | capacity = Capacity |
|
inline |
Definition at line 58 of file BLERingBuf.hpp.
|
inlinestaticconstexprprivate |
Definition at line 53 of file BLERingBuf.hpp.
|
inline |
Copy the given data into the buffer.
May be split up into two chunks, in which case the type will be set to BLEDataType::Continuation for the second chunk.
false | The buffer is full, nothing added to the buffer. |
Definition at line 68 of file BLERingBuf.hpp.
|
inline |
Get a view to the next chunk of data.
The view remains valid until the next call to pop.
BLEDataType::None | No data available. |
BLEDataType::Packet | The data output parameter points to the first chunk of a packet. |
BLEDataType::Continuation | The data output parameter points to a chunk of continuation data of the same packet. |
Definition at line 127 of file BLERingBuf.hpp.
|
staticconstexprprivate |
Definition at line 44 of file BLERingBuf.hpp.
|
staticconstexprprivate |
Definition at line 47 of file BLERingBuf.hpp.
|
private |
Definition at line 48 of file BLERingBuf.hpp.
|
private |
Definition at line 49 of file BLERingBuf.hpp.
|
private |
Definition at line 50 of file BLERingBuf.hpp.
|
private |
Definition at line 51 of file BLERingBuf.hpp.