TEST: disable BLE init to isolate button press crash
This commit is contained in:
+5
-8
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -111,20 +111,7 @@ void BleMidiTransport::on_midi_receive(std::function<void(const MidiEvent&)> 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() {
|
||||
|
||||
+5
-4
@@ -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();
|
||||
|
||||
|
||||
+1
-10
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user