Replace direct NimBLE-Arduino dependency with max22/ESP32-BLE-MIDI wrapper library (v0.3.2). Rewrite ble_midi_transport to use BLEMidiServer API instead of raw NimBLEDevice calls. Removes patch_nimble_device() from pre_build.py — no longer needed since BT controller init is managed by the library internally. The library uses NimBLE v1.4.1 internally and configures advertising without setScanResponse() or setName(), which may resolve the invisible BLE advertising issue on ESP32-S3.
34 lines
1001 B
C++
34 lines
1001 B
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <functional>
|
|
#include "midi_transport.h"
|
|
|
|
class BleMidiTransport {
|
|
public:
|
|
BleMidiTransport();
|
|
~BleMidiTransport();
|
|
|
|
bool begin();
|
|
void update();
|
|
|
|
void on_midi_receive(std::function<void(const MidiEvent&)> callback);
|
|
|
|
void send_note_on(uint8_t channel, uint8_t note, uint8_t velocity);
|
|
void send_note_off(uint8_t channel, uint8_t note, uint8_t velocity);
|
|
void send_cc(uint8_t channel, uint8_t cc, uint8_t value);
|
|
|
|
bool is_connected();
|
|
|
|
private:
|
|
static void on_control_change(uint8_t channel, uint8_t controller, uint8_t value, uint16_t timestamp);
|
|
static void on_note_on(uint8_t channel, uint8_t note, uint8_t velocity, uint16_t timestamp);
|
|
static void on_note_off(uint8_t channel, uint8_t note, uint8_t velocity, uint16_t timestamp);
|
|
static void on_connect();
|
|
static void on_disconnect();
|
|
|
|
std::function<void(const MidiEvent&)> receive_callback;
|
|
bool initialized;
|
|
bool client_connected;
|
|
};
|