max22- / ESP32-BLE-MIDI

An Arduino library to use Midi over BLE (Bluetooth Low Energy), on ESP32 boards
MIT License
214 stars 27 forks source link

Connection problems after reconnect #17

Open LeanderJDev opened 1 year ago

LeanderJDev commented 1 year ago

After restarting the esp32 (so every time it's off power and then powered on again or when being reset) MIDIBerry, which I use for midi routing, and thus my DAW don't receive any MIDI commands anymore. They do however receive them again correctly, if i go into the windows settings and remove the BLE device and then reconnect it again. Unfortunately this would be quite inconvenient, if I'd have to reconnect the device every time it got unpowered.

Is this a thing with the library or with my code?

#include <ShiftRegister74HC595.h>
#include <BLEMidi.h>

ShiftRegister74HC595<1> sr(12, 27, 14);
int sensor;
int b1 = 25;
int b2 = 33;
int b1n = 0;
int b2n = 1;
int i = 0;

void setup() {
  BLEMidiServer.begin("Basic MIDI device");
  pinMode(b1, INPUT_PULLUP);
  pinMode(b2, INPUT_PULLUP);
}

void loop() {
  sensor = ceil(analogRead(26) / 32.0);
  sr.set(1, !sr.get(1));
  sr.set(3, round(i / 1000.0));
  i++;
  if (i == 1000) {
    i = 0;
  }
  if (BLEMidiServer.isConnected()) {
    if (!digitalRead(b1) && !b1n) {
      BLEMidiServer.noteOn(0, 69, 127);
      b1n = 1;
    } else if (digitalRead(b1) && b1n) {
      BLEMidiServer.noteOff(0, 69, 127);
      b1n = 0;
    }
    if (!digitalRead(b2) && !b2n) {
      BLEMidiServer.noteOn(0, 67, 127);
      b2n = 1;
    } else if (digitalRead(b2) && b2n) {
      BLEMidiServer.noteOff(0, 67, 127);
      b2n = 0;
    }
  }
}
lileffects commented 3 months ago

I'm having the exact same issue.