#include <MIDI_Interfaces/BLEMIDI/BTstackBackgroundBackend.hpp>
Raspberry Pi Pico BTstack background backend intended to be plugged into GenericBLEMIDI_Interface.
Definition at line 20 of file BTstackBackgroundBackend.hpp.
Inheritance diagram for BTstackBackgroundBackend:
Collaboration diagram for BTstackBackgroundBackend:Classes | |
| struct | VolatileSize |
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<BTstackBackgroundBackend> |
Private Member Functions | |
| void | handleConnect (BLEConnectionHandle conn_handle) 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 char_handle, 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 | |
| volatile sig_atomic_t | connected = 0xFFFF |
| Are we connected to a BLE Central? | |
| volatile sig_atomic_t | subscribed = 0xFFFF |
| Did the BLE Central subscribe to be notified for the MIDI characteristic? | |
| BufferedBLEMIDIParser< 1024, VolatileSize > | 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 88 of file BTstackBackgroundBackend.hpp.
|
private |
Definition at line 114 of file BTstackBackgroundBackend.hpp.
|
inlineoverrideprivatevirtual |
Called by the BLE stack when a connection is established.
Implements MIDIBLEInstance.
Definition at line 25 of file BTstackBackgroundBackend.hpp.
|
inlineoverrideprivatevirtual |
Called by the BLE stack when a connection is terminated.
Implements MIDIBLEInstance.
Definition at line 28 of file BTstackBackgroundBackend.hpp.
|
inlineoverrideprivatevirtual |
Called by the BLE stack when the maximum transmission unit for the connection changes.
Implements MIDIBLEInstance.
Definition at line 31 of file BTstackBackgroundBackend.hpp.
|
inlineoverrideprivatevirtual |
Called by the BLE stack when the central subscribes to receive notifications for the MIDI GATT characteristic.
Implements MIDIBLEInstance.
Definition at line 34 of file BTstackBackgroundBackend.hpp.
|
inlineoverrideprivatevirtual |
Called by the BLE stack when the central writes data to the MIDI GATT characteristic.
Implements MIDIBLEInstance.
Definition at line 39 of file BTstackBackgroundBackend.hpp.
|
inline |
Retrieve and remove a single incoming MIDI message from the buffer.
Definition at line 91 of file BTstackBackgroundBackend.hpp.
|
inline |
Initialize the BLE stack etc.
Definition at line 102 of file BTstackBackgroundBackend.hpp.
|
inline |
Deinitialize the BLE stack.
Definition at line 108 of file BTstackBackgroundBackend.hpp.
|
inline |
Returns true if we are connected to a BLE Central device.
Definition at line 110 of file BTstackBackgroundBackend.hpp.
|
inlineprivate |
Send the given MIDI BLE packet.
Definition at line 117 of file BTstackBackgroundBackend.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.
|
private |
Are we connected to a BLE Central?
Definition at line 57 of file BTstackBackgroundBackend.hpp.
|
private |
Did the BLE Central subscribe to be notified for the MIDI characteristic?
Definition at line 59 of file BTstackBackgroundBackend.hpp.
|
private |
Contains incoming BLE MIDI data to be parsed.
Definition at line 85 of file BTstackBackgroundBackend.hpp.
Definition at line 115 of file BTstackBackgroundBackend.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.