13#define ESP_LOGD(...) ((void)0)
14#define ESP_LOGE(...) ((void)0)
15#define ESP_LOGI(...) ((void)0)
26 [[no_unique_address]] Impl
impl;
32 ESP_LOGD(
"CS-BLEMIDI",
"conn=%d, char=%d", con.conn,
34 if (chr.characteristic == 0xFFFF)
36 impl.notify(con, chr, data);
43 ESP_LOGD(
"CS-BLEMIDI",
"conn=%d", conn_handle.
conn);
44 this->connection.store(conn_handle);
48 ESP_LOGD(
"CS-BLEMIDI",
"conn=%d", conn_handle.conn);
49 this->connection.store({});
50 this->characteristic.store({});
53 uint16_t mtu)
override {
54 ESP_LOGD(
"CS-BLEMIDI",
"conn=%d, mtu=%d", conn_handle.conn, mtu);
59 bool notify)
override {
60 ESP_LOGD(
"CS-BLEMIDI",
"conn=%d, char=%d, notify=%d", conn_handle.
conn,
63 this->connection.store(conn_handle);
64 this->characteristic.store(char_handle);
66 this->characteristic.store({});
71 ESP_LOGD(
"CS-BLEMIDI",
"conn=%d", conn_handle.conn);
76 ESP_LOGE(
"CS-BLEMIDI",
"BLE packet dropped, size=%d",
82 ESP_LOGE(
"CS-BLEMIDI",
"BLE chunk dropped, size=%d",
86 ESP_LOGI(
"CS-BLEMIDI",
"added chunk, size=%d", cont.length);
99 std::atomic_uint_fast16_t
value;
101 return value.load(std::memory_order_acquire);
104 value.fetch_add(t, std::memory_order_release);
107 value.fetch_sub(t, std::memory_order_release);
116 return parser.popMessage(incomingMessage);
121 impl.init(*
this, ble_settings);
127 FATAL_ERROR(F(
"ESP32BLEBackend::end not implemented"), 0x3278);
130 return connection.load(std::memory_order_relaxed).conn != 0xFFFF;
Type definitions and callback interfaces for communication between the low-level BLE stacks and highe...
@ Continuation
Buffer contains a chunk of a BLE packet.
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
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.
ESP32 backend intended to be plugged into GenericBLEMIDI_Interface.
std::atomic< BLECharacteristicHandle > characteristic
void handleData(BLEConnectionHandle conn_handle, BLEDataGenerator &&data, BLEDataLifetime) override
Called by the BLE stack when the central writes data to the MIDI GATT characteristic.
void handleConnect(BLEConnectionHandle conn_handle) override
Called by the BLE stack when a connection is established.
void handleDisconnect(BLEConnectionHandle conn_handle) override
Called by the BLE stack when a connection is terminated.
AnyMIDIMessage IncomingMIDIMessage
void sendData(BLEDataView data)
BufferedBLEMIDIParser< 4096, AtomicSize > parser
void begin(BLESettings ble_settings)
void handleMTU(BLEConnectionHandle conn_handle, uint16_t mtu) override
Called by the BLE stack when the maximum transmission unit for the connection changes.
ble_backend::ESP32BluedroidBLE impl
std::atomic< BLEConnectionHandle > connection
bool popMessage(IncomingMIDIMessage &incomingMessage)
ThreadedBLEMIDISender< ESP32BLEBackend > Sender
void handleSubscribe(BLEConnectionHandle conn_handle, BLECharacteristicHandle char_handle, bool notify) override
Called by the BLE stack when the central subscribes to receive notifications for the MIDI GATT charac...
Defines the interface for callback functions registered by the low-level BLE code.
BLEMIDIPacketBuilder packet
uint16_t getMinMTU() const
void setTimeout(std::chrono::milliseconds timeout)
void forceMinMTU(uint16_t mtu)
ProtectedBuilder acquirePacket()
void releasePacketAndNotify(ProtectedBuilder &lck)
ThreadedBLEMIDISender()=default
void updateMTU(uint16_t mtu)
void sendNow(ProtectedBuilder &lck)
#define FATAL_ERROR(msg, errc)
Print the error message and error code, and stop the execution.
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.
void add_release(uint_fast16_t t)
void sub_release(uint_fast16_t t)
std::atomic_uint_fast16_t value
uint_fast16_t load_acquire() const
static constexpr size_t alignment
AtomicSize(uint_fast16_t value)