3#include <Settings/NamespaceSettings.hpp>
6#include <condition_variable>
16template <
class Derived>
80 std::condition_variable
cv;
82 using lock_t = std::unique_lock<std::mutex>;
103#include "ThreadedBLEMIDISender.ipp"
Type definitions and callback interfaces for communication between the low-level BLE stacks and highe...
#define BEGIN_CS_NAMESPACE
Class for building MIDI over Bluetooth Low Energy packets.
Class that manages a background thread that sends BLE packets asynchronously.
BLEMIDIPacketBuilder packet
View of the data to send.
void sendData(BLEDataView)=delete
Actually perform the BLE notification with the given data.
std::condition_variable cv
Condition variable used by the background sender thread to wait for data to send, and for the main th...
uint16_t getMinMTU() const
Get the minimum MTU of all connected clients.
std::unique_lock< std::mutex > lock_t
Lock type used to lock the mutex.
struct ThreadedBLEMIDISender::@5 shared
std::chrono::milliseconds timeout
Timeout before the sender thread sends a packet.
void setTimeout(std::chrono::milliseconds timeout)
Set the timeout, the number of milliseconds to buffer the outgoing MIDI messages.
bool handleSendEvents()
Function that waits for BLE packets and sends them in the background.
void forceMinMTU(uint16_t mtu)
Force the MTU to an artificially small value (used for testing).
ThreadedBLEMIDISender & operator=(const ThreadedBLEMIDISender &)=delete
bool stop
Flag to stop the background thread.
std::atomic_uint_fast16_t force_min_mtu
Override the minimum MTU (0 means don't override, nonzero overrides if it's smaller than the minimum ...
ThreadedBLEMIDISender(const ThreadedBLEMIDISender &)=delete
ProtectedBuilder acquirePacket()
Acquire exclusive access to the buffer to be sent by the timer.
void begin()
Start the background thread.
void releasePacketAndNotify(ProtectedBuilder &lck)
Release exclusive access to the buffer and notify the sender thread that data is available.
ThreadedBLEMIDISender()=default
std::thread send_thread
The background thread responsible for sending the data.
std::mutex mtx
Lock to protect all shared data in this struct.
void updateMTU(uint16_t mtu)
Set the maximum transmission unit of the Bluetooth link.
std::atomic_uint_fast16_t min_mtu
The minimum MTU of all connected clients.
void sendNow(ProtectedBuilder &lck)
Sends the data immediately without waiting for the timeout.
Non-owning, std::span-style read-only view of BLE data.
BLEMIDIPacketBuilder * packet