Control Surface main
MIDI Control Surface library for Arduino
Loading...
Searching...
No Matches
Classes | Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
BLERingBuf< Capacity, SizeT > Class Template Reference

#include <MIDI_Interfaces/BLEMIDI/BLERingBuf.hpp>

Detailed Description

template<uint_fast16_t Capacity, class SizeT = NonatomicBLERingBufSize<uint_fast16_t>>
class BLERingBuf< Capacity, SizeT >

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.

Template Parameters
CapacityBuffer size (bytes). Note that the actual maximum data size may be up to 6 bytes less because of data structure overhead.
SizeTThe 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.

+ Collaboration diagram for BLERingBuf< Capacity, SizeT >:

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
 

Constructor & Destructor Documentation

◆ BLERingBuf()

template<uint_fast16_t Capacity, class SizeT = NonatomicBLERingBufSize<uint_fast16_t>>
BLERingBuf ( )
inline

Definition at line 58 of file BLERingBuf.hpp.

Member Function Documentation

◆ ceil_h()

template<uint_fast16_t Capacity, class SizeT = NonatomicBLERingBufSize<uint_fast16_t>>
static constexpr uint_fast16_t ceil_h ( uint_fast16_t i)
inlinestaticconstexprprivate

Definition at line 53 of file BLERingBuf.hpp.

◆ push()

template<uint_fast16_t Capacity, class SizeT = NonatomicBLERingBufSize<uint_fast16_t>>
bool push ( BLEDataView data,
BLEDataType type = BLEDataType::Packet )
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.

Return values
falseThe buffer is full, nothing added to the buffer.

Definition at line 68 of file BLERingBuf.hpp.

◆ pop()

template<uint_fast16_t Capacity, class SizeT = NonatomicBLERingBufSize<uint_fast16_t>>
BLEDataType pop ( BLEDataView & data)
inline

Get a view to the next chunk of data.

The view remains valid until the next call to pop.

Return values
BLEDataType::NoneNo data available.
BLEDataType::PacketThe data output parameter points to the first chunk of a packet.
BLEDataType::ContinuationThe data output parameter points to a chunk of continuation data of the same packet.

Definition at line 127 of file BLERingBuf.hpp.

Member Data Documentation

◆ header_size

template<uint_fast16_t Capacity, class SizeT = NonatomicBLERingBufSize<uint_fast16_t>>
constexpr uint_fast16_t header_size = sizeof(Header)
staticconstexprprivate

Definition at line 44 of file BLERingBuf.hpp.

◆ capacity

template<uint_fast16_t Capacity, class SizeT = NonatomicBLERingBufSize<uint_fast16_t>>
constexpr uint_fast16_t capacity = Capacity
staticconstexprprivate

Definition at line 47 of file BLERingBuf.hpp.

◆ buffer

template<uint_fast16_t Capacity, class SizeT = NonatomicBLERingBufSize<uint_fast16_t>>
unsigned char buffer[capacity]
private

Definition at line 48 of file BLERingBuf.hpp.

◆ read_p

template<uint_fast16_t Capacity, class SizeT = NonatomicBLERingBufSize<uint_fast16_t>>
uint_fast16_t read_p = 0
private

Definition at line 49 of file BLERingBuf.hpp.

◆ write_p

template<uint_fast16_t Capacity, class SizeT = NonatomicBLERingBufSize<uint_fast16_t>>
uint_fast16_t write_p = header_size
private

Definition at line 50 of file BLERingBuf.hpp.

◆ size

template<uint_fast16_t Capacity, class SizeT = NonatomicBLERingBufSize<uint_fast16_t>>
SizeT size {header_size}
private

Definition at line 51 of file BLERingBuf.hpp.


The documentation for this class was generated from the following file: