MIDI Control Surface library for Arduino
|
Go to the documentation of this file.
16 public BLEServerCallbacks,
17 public BLECharacteristicCallbacks {
30 ERROR(
F(
"Error: disconnect event, but was not connected"), 0x7788);
36 void onRead(BLECharacteristic *pCharacteristic)
override {
38 pCharacteristic->setValue(
nullptr, 0);
40 void onWrite(BLECharacteristic *pCharacteristic)
override {
42 std::string value = pCharacteristic->getValue();
43 const uint8_t *
const data =
44 reinterpret_cast<const uint8_t *>(value.data());
45 size_t len = value.size();
46 for (
size_t i = 0; i < len; i++) {
47 Serial.print(data[i], HEX);
80 DEBUGFN(
"No connected BLE clients");
98 bool first =
index == 0;
103 DEBUGFN(
"Message is larger than buffer");
125 void sendImpl(uint8_t m, uint8_t c, uint8_t d1, uint8_t d2,
126 uint8_t cn)
override {
128 uint8_t msg[3] = {uint8_t(m | c), d1, d2};
131 void sendImpl(uint8_t m, uint8_t c, uint8_t d1, uint8_t cn)
override {
133 uint8_t msg[2] = {uint8_t(m | c), d1};
137 void sendImpl(
const uint8_t *data,
size_t length, uint8_t cn)
override {
148 void parse(
const uint8_t *
const data,
const size_t len) {
155 bool prevWasTimestamp =
true;
156 for (
const uint8_t *d = data + 2; d < data + len; d++) {
159 prevWasTimestamp =
false;
161 if (prevWasTimestamp)
163 prevWasTimestamp = !prevWasTimestamp;
void begin(BLEServerCallbacks *serverCallbacks, BLECharacteristicCallbacks *midiCallbacks)
void sendImpl(uint8_t rt, uint8_t cn) override
Low-level function for sending a single-byte MIDI message.
Bluetooth Low Energy MIDI Interface for the ESP32.
BluetoothMIDI_Interface()
MIDI_read_t parse(uint8_t midibyte)
static bool isData(uint8_t data)
Check if the given byte is a MIDI data byte.
An abstract class for MIDI interfaces.
void onDisconnect(BLEServer *pServer) override
bool dispatchMIDIEvent(MIDI_read_t event)
void onConnect(BLEServer *pServer) override
void addToBuffer(const uint8_t *data, size_t len)
constexpr static unsigned long MAX_MESSAGE_TIME
#define BEGIN_CS_NAMESPACE
void onWrite(BLECharacteristic *pCharacteristic) override
void onRead(BLECharacteristic *pCharacteristic) override
void sendImpl(const uint8_t *data, size_t length, uint8_t cn) override
Low-level function for sending a system exclusive MIDI message.
void update() override
Read the MIDI interface and call the callback if a message is received.
void addToBuffer(const uint8_t(&data)[N])
#define ERROR(msg, errc)
Print the error message and error code, and stop the execution if FATAL_ERRORS are enabled.
MIDI_read_t read() override
void notifyValue(uint8_t *data, size_t len)
void sendImpl(uint8_t m, uint8_t c, uint8_t d1, uint8_t d2, uint8_t cn) override
Low-level function for sending a 3-byte MIDI message.
void begin() override
Initialize the MIDI Interface.
void sendImpl(uint8_t m, uint8_t c, uint8_t d1, uint8_t cn) override
Low-level function for sending a 2-byte MIDI message.
void parse(const uint8_t *const data, const size_t len)
constexpr static size_t BUFFER_LENGTH
#define DEBUGFN(x)
Print an expression and its function (function name and line number) to the debug output if debugging...
bool hasSpaceFor(size_t bytes)
uint8_t buffer[BUFFER_LENGTH]