From e2db658037ebf98f862160d9125052f788a73c48 Mon Sep 17 00:00:00 2001 From: Ashley Strahle Date: Tue, 30 Jun 2026 12:12:50 +0000 Subject: [PATCH] TEST: disable BLE init to isolate button press crash --- src/app_task.cpp | 13 +++++-------- src/ble_midi_transport.cpp | 21 +-------------------- src/main.cpp | 9 +++++---- src/midi_transport.cpp | 11 +---------- 4 files changed, 12 insertions(+), 42 deletions(-) diff --git a/src/app_task.cpp b/src/app_task.cpp index 47b692a..24fd29b 100644 --- a/src/app_task.cpp +++ b/src/app_task.cpp @@ -37,9 +37,7 @@ void AppTask::begin() { void AppTask::update() { for (uint8_t i = 0; i < NUM_PADS; i++) { - Serial.printf("[APP DBG] reading switch %d\n", i); bool is_pressed = switch_driver->is_pressed(i); - Serial.printf("[APP DBG] switch %d = %d\n", i, is_pressed); if (is_pressed && !last_switch_state[i]) { Serial.printf("[APP] Switch %d pressed\n", i); @@ -138,15 +136,14 @@ void AppTask::process_switch_event(uint8_t switch_id, bool pressed) { uint8_t cc_num = cc_map[i]; uint8_t value = pressed ? 127 : 0; - // DEBUG: just print, don't send anything - Serial.printf("[APP DEBUG] Switch %d pressed, would send Ch%d CC%d Val%d\n", - switch_id, channel, cc_num, value); - if (pressed) { - Serial.println("[APP DEBUG] would send USB MIDI"); - Serial.println("[APP DEBUG] would send BLE MIDI"); + usb_midi->send_cc(channel, cc_num, value); + if (ble_midi) ble_midi->send_cc(channel, cc_num, value); } + Serial.printf("[APP] Switch %d -> Ch%d CC%d Val%d (%s)\n", + switch_id, channel, cc_num, value, + pressed ? "PRESS" : "RELEASE"); break; } } diff --git a/src/ble_midi_transport.cpp b/src/ble_midi_transport.cpp index d9ff06d..b94e986 100644 --- a/src/ble_midi_transport.cpp +++ b/src/ble_midi_transport.cpp @@ -111,20 +111,7 @@ void BleMidiTransport::on_midi_receive(std::function cal } void BleMidiTransport::send_midi_packet(const uint8_t* data, uint8_t len) { - if (!initialized) { - Serial.println("[BLE DBG] send_midi_packet: not initialized"); - return; - } - if (!client_connected) { - Serial.println("[BLE DBG] send_midi_packet: no client"); - return; - } - if (!ble_char) { - Serial.println("[BLE DBG] send_midi_packet: null char"); - return; - } - - Serial.println("[BLE DBG] send_midi_packet: proceeding to send"); + if (!initialized || !client_connected || !ble_char) return; uint16_t timestamp = micros() & 0x3FFF; uint8_t packet[16]; @@ -135,11 +122,8 @@ void BleMidiTransport::send_midi_packet(const uint8_t* data, uint8_t len) { packet[idx++] = data[i]; } - Serial.println("[BLE DBG] calling setValue..."); ble_char->setValue(packet, idx); - Serial.println("[BLE DBG] calling notify..."); ble_char->notify(); - Serial.println("[BLE DBG] notify done"); } void BleMidiTransport::send_note_on(uint8_t channel, uint8_t note, uint8_t velocity) { @@ -155,11 +139,8 @@ void BleMidiTransport::send_note_off(uint8_t channel, uint8_t note, uint8_t velo } void BleMidiTransport::send_cc(uint8_t channel, uint8_t cc, uint8_t value) { - Serial.printf("[BLE DBG] send_cc entered: ch=%d cc=%d val=%d init=%d conn=%d char=%p\n", - channel, cc, value, initialized, client_connected, ble_char); uint8_t packet[3] = {(uint8_t)(0xB0 | (channel - 1)), cc, value}; send_midi_packet(packet, 3); - Serial.printf("[BLE OUT] Ch:%d CC:%d:%d\n", channel, cc, value); } bool BleMidiTransport::is_connected() { diff --git a/src/main.cpp b/src/main.cpp index e1e8968..0832ada 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -346,14 +346,15 @@ void setup() { switch_driver.set_mux(&mux); switch_driver.begin(); + // BLE disabled for crash diagnosis + // Serial.println("[INIT] Initializing BLE MIDI..."); + // delay(1000); + // ble_midi_transport.begin(); + Serial.println("[INIT] Initializing USB MIDI..."); midi_transport.begin(); delay(500); - Serial.println("[INIT] Initializing BLE MIDI..."); - delay(1000); - ble_midi_transport.begin(); - Serial.println("[INIT] Registering MIDI callbacks..."); controller.begin(); diff --git a/src/midi_transport.cpp b/src/midi_transport.cpp index 450d528..8276b18 100644 --- a/src/midi_transport.cpp +++ b/src/midi_transport.cpp @@ -91,18 +91,9 @@ void UsbMidiTransport::send_note_off(uint8_t channel, uint8_t note, uint8_t velo } void UsbMidiTransport::send_cc(uint8_t channel, uint8_t cc, uint8_t value) { - if (!initialized) { - Serial.println("[MIDI DBG] send_cc: not initialized"); - return; - } - if (!TinyUSBDevice.ready()) { - Serial.println("[MIDI DBG] send_cc: USB not ready"); - return; - } - Serial.println("[MIDI DBG] send_cc: calling writePacket..."); + if (!initialized) return; uint8_t packet[4] = {0x0B, (uint8_t)(0xB0 | (channel - 1)), cc, value}; usb_midi.writePacket(packet); - Serial.printf("[MIDI OUT] Ch:%d CC:%d:%d\n", channel, cc, value); } bool UsbMidiTransport::is_connected() {