Add BT controller diagnostics, init BLE before USB MIDI

This commit is contained in:
ash
2026-06-30 06:43:58 +00:00
parent 8a36296043
commit 2db09b76bf
4 changed files with 81 additions and 9 deletions
+16
View File
@@ -1,6 +1,8 @@
#include "ble_midi_transport.h"
#include <Arduino.h>
#include <NimBLEDevice.h>
#include <esp_bt.h>
#include <esp_bt_main.h>
#define BLE_MIDI_SERVICE_UUID "03B80E5A-EDE8-4B33-A751-6CE34EC4C700"
#define BLE_MIDI_CHAR_UUID "7772E5DB-3868-4112-A1A9-F2669D106BF3"
@@ -44,6 +46,20 @@ BleMidiTransport::~BleMidiTransport() {
bool BleMidiTransport::begin() {
Serial.println("[BLE] Initializing BLE MIDI...");
esp_err_t err;
err = esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT);
Serial.printf("[BLE] bt_mem_release: %d (%s)\n", err, esp_err_to_name(err));
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
err = esp_bt_controller_init(&bt_cfg);
Serial.printf("[BLE] bt_controller_init: %d (%s)\n", err, esp_err_to_name(err));
if (err != ESP_OK) { initialized = false; return false; }
err = esp_bt_controller_enable(ESP_BT_MODE_BTDM);
Serial.printf("[BLE] bt_controller_enable: %d (%s)\n", err, esp_err_to_name(err));
if (err != ESP_OK) { initialized = false; return false; }
Serial.println("[BLE] NimBLEDevice init...");
NimBLEDevice::init("JOC Midi");
Serial.println("[BLE] NimBLEDevice initialized");