#include <MIDI_Interfaces/BLEMIDI/ArduinoBLEBackend.hpp>
ArduinoBLE backend intended to be plugged into GenericBLEMIDI_Interface.
Definition at line 14 of file ArduinoBLEBackend.hpp.
Public Types | |
using | IncomingMIDIMessage = AnyMIDIMessage |
Public Member Functions | |
bool | popMessage (IncomingMIDIMessage &incomingMessage) |
Retrieve and remove a single incoming MIDI message from the buffer. | |
void | begin (BLESettings ble_settings) |
Initialize the BLE stack etc. | |
void | end () |
Deinitialize the BLE stack. | |
bool | isConnected () const |
Returns true if we are connected to a BLE Central device. | |
Private Types | |
using | Sender = PollingBLEMIDISender<ArduinoBLEBackend> |
Private Member Functions | |
void | handleConnect (BLEConnectionHandle) override |
Called by the BLE stack when a connection is established. | |
void | handleDisconnect (BLEConnectionHandle) override |
Called by the BLE stack when a connection is terminated. | |
void | handleMTU (BLEConnectionHandle, uint16_t mtu) override |
Called by the BLE stack when the maximum transmission unit for the connection changes. | |
void | handleSubscribe (BLEConnectionHandle, BLECharacteristicHandle, bool notify) override |
Called by the BLE stack when the central subscribes to receive notifications for the MIDI GATT characteristic. | |
void | handleData (BLEConnectionHandle, BLEDataGenerator &&data, BLEDataLifetime) override |
Called by the BLE stack when the central writes data to the MIDI GATT characteristic. | |
void | sendData (BLEDataView data) |
Send the given MIDI BLE packet. | |
void | begin () |
Initialize. | |
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 | sendNow (ProtectedBuilder &lck) |
Sends the data immediately without waiting for the timeout. | |
void | updateMTU (uint16_t mtu) |
Set the maximum transmission unit of the Bluetooth link. | |
uint16_t | getMinMTU () const |
Get the minimum MTU of all connected clients. | |
void | forceMinMTU (uint16_t mtu) |
Force the MTU to an artificially small value (used for testing). | |
void | setTimeout (std::chrono::milliseconds timeout) |
Set the timeout, the number of milliseconds to buffer the outgoing MIDI messages. | |
Private Attributes | |
bool | connected = false |
Are we connected to a BLE Central? | |
bool | subscribed = false |
Did the BLE Central subscribe to be notified for the MIDI characteristic? | |
BufferedBLEMIDIParser< 1024 > | parser |
Contains incoming BLE MIDI data to be parsed. | |
friend | Sender |
BLEMIDIPacketBuilder | packet |
View of the data to send. | |
unsigned long | timeout |
Timeout before the sender thread sends a packet. | |
unsigned long | packet_start_time |
Time point when the packet was started. | |
uint16_t | min_mtu |
The minimum MTU of all connected clients. | |
uint16_t | force_min_mtu |
Override the minimum MTU (0 means don't override, nonzero overrides if it's smaller than the minimum MTU of the clients). | |
Definition at line 51 of file ArduinoBLEBackend.hpp.
|
private |
Definition at line 79 of file ArduinoBLEBackend.hpp.
|
inlineoverrideprivatevirtual |
Called by the BLE stack when a connection is established.
Implements MIDIBLEInstance.
Definition at line 18 of file ArduinoBLEBackend.hpp.
|
inlineoverrideprivatevirtual |
Called by the BLE stack when a connection is terminated.
Implements MIDIBLEInstance.
Definition at line 19 of file ArduinoBLEBackend.hpp.
|
inlineoverrideprivatevirtual |
Called by the BLE stack when the maximum transmission unit for the connection changes.
Implements MIDIBLEInstance.
Definition at line 22 of file ArduinoBLEBackend.hpp.
|
inlineoverrideprivatevirtual |
Called by the BLE stack when the central subscribes to receive notifications for the MIDI GATT characteristic.
Implements MIDIBLEInstance.
Definition at line 25 of file ArduinoBLEBackend.hpp.
|
inlineoverrideprivatevirtual |
Called by the BLE stack when the central writes data to the MIDI GATT characteristic.
Implements MIDIBLEInstance.
Definition at line 29 of file ArduinoBLEBackend.hpp.
|
inline |
Retrieve and remove a single incoming MIDI message from the buffer.
Definition at line 54 of file ArduinoBLEBackend.hpp.
|
inline |
Initialize the BLE stack etc.
Definition at line 67 of file ArduinoBLEBackend.hpp.
|
inline |
Deinitialize the BLE stack.
Definition at line 73 of file ArduinoBLEBackend.hpp.
|
inline |
Returns true if we are connected to a BLE Central device.
Definition at line 75 of file ArduinoBLEBackend.hpp.
|
inlineprivate |
Send the given MIDI BLE packet.
Definition at line 82 of file ArduinoBLEBackend.hpp.
|
inherited |
Initialize.
|
inherited |
Acquire exclusive access to the buffer.
packet
member.
|
inherited |
Release exclusive access to the buffer and notify the sender thread that data is available.
|
inherited |
Sends the data immediately without waiting for the timeout.
Set the maximum transmission unit of the Bluetooth link.
Used to compute the MIDI BLE packet size.
|
inlineinherited |
Get the minimum MTU of all connected clients.
Definition at line 42 of file PollingBLEMIDISender.hpp.
Force the MTU to an artificially small value (used for testing).
|
inherited |
Set the timeout, the number of milliseconds to buffer the outgoing MIDI messages.
Are we connected to a BLE Central?
Definition at line 44 of file ArduinoBLEBackend.hpp.
Did the BLE Central subscribe to be notified for the MIDI characteristic?
Definition at line 46 of file ArduinoBLEBackend.hpp.
|
private |
Contains incoming BLE MIDI data to be parsed.
Definition at line 48 of file ArduinoBLEBackend.hpp.
Definition at line 80 of file ArduinoBLEBackend.hpp.
|
privateinherited |
View of the data to send.
Definition at line 56 of file PollingBLEMIDISender.hpp.
Timeout before the sender thread sends a packet.
Definition at line 59 of file PollingBLEMIDISender.hpp.
Time point when the packet was started.
Definition at line 61 of file PollingBLEMIDISender.hpp.
|
privateinherited |
The minimum MTU of all connected clients.
Definition at line 65 of file PollingBLEMIDISender.hpp.
|
privateinherited |
Override the minimum MTU (0 means don't override, nonzero overrides if it's smaller than the minimum MTU of the clients).
Definition at line 69 of file PollingBLEMIDISender.hpp.