26 bool notify)
override {
Type definitions and callback interfaces for communication between the low-level BLE stacks and highe...
BLEDataLifetime
Should a buffer of BLEData be consumed immediately inside of the callback, or can we hold on to it an...
#define BEGIN_CS_NAMESPACE
ArduinoBLE backend intended to be plugged into GenericBLEMIDI_Interface.
void handleSubscribe(BLEConnectionHandle, BLECharacteristicHandle, bool notify) override
Called by the BLE stack when the central subscribes to receive notifications for the MIDI GATT charac...
void handleMTU(BLEConnectionHandle, uint16_t mtu) override
Called by the BLE stack when the maximum transmission unit for the connection changes.
void handleConnect(BLEConnectionHandle) override
Called by the BLE stack when a connection is established.
void sendData(BLEDataView data)
Send the given MIDI BLE packet.
void handleData(BLEConnectionHandle, BLEDataGenerator &&data, BLEDataLifetime) override
Called by the BLE stack when the central writes data to the MIDI GATT characteristic.
void begin(BLESettings ble_settings)
Initialize the BLE stack etc.
bool isConnected() const
Returns true if we are connected to a BLE Central device.
bool subscribed
Did the BLE Central subscribe to be notified for the MIDI characteristic?
void end()
Deinitialize the BLE stack.
bool connected
Are we connected to a BLE Central?
bool popMessage(IncomingMIDIMessage &incomingMessage)
Retrieve and remove a single incoming MIDI message from the buffer.
void handleDisconnect(BLEConnectionHandle) override
Called by the BLE stack when a connection is terminated.
BufferedBLEMIDIParser< 1024 > parser
Contains incoming BLE MIDI data to be parsed.
Callable that returns the next chunk of data from a BLE packet when called.
FIFO buffer that you can push BLE packets into, and pop MIDI messages out of.
bool pushPacket(BLEDataView packet, BLEDataType type=BLEDataType::Packet)
Add a new BLE packet or chunk to the buffer.
bool popMessage(IncomingMIDIMessage &incomingMessage)
Retrieve and remove a single incoming MIDI message from the buffer.
Defines the interface for callback functions registered by the low-level BLE code.
Class that buffers MIDI BLE packets.
BLEMIDIPacketBuilder packet
View of the data to send.
uint16_t getMinMTU() const
Get the minimum MTU of all connected clients.
void setTimeout(std::chrono::milliseconds timeout)
Set the timeout, the number of milliseconds to buffer the outgoing MIDI messages.
void forceMinMTU(uint16_t mtu)
Force the MTU to an artificially small value (used for testing).
ProtectedBuilder acquirePacket()
Acquire exclusive access to the buffer.
void releasePacketAndNotify(ProtectedBuilder &lck)
Release exclusive access to the buffer and notify the sender thread that data is available.
void updateMTU(uint16_t mtu)
Set the maximum transmission unit of the Bluetooth link.
void sendNow(ProtectedBuilder &lck)
Sends the data immediately without waiting for the timeout.
#define DEBUGREF(x)
Print an expression and its location (file and line number) to the debug output if debugging is enabl...
void notify(BLEDataView data)
bool init(MIDIBLEInstance &instance, BLESettings ble_settings)
MIDI message variant type (with timestamp).
Represents a handle to a local GATT characteristic.
Represents a handle to the connection to another device.
Non-owning, std::span-style read-only view of BLE data.
Configuration options for the low-level BLE code.