From d9fc069a4f7d3a502f7b4032d5a9bdb4ce459f81 Mon Sep 17 00:00:00 2001 From: lathoub <4082369+lathoub@users.noreply.github.com> Date: Sun, 27 Sep 2020 13:36:16 +0200 Subject: [PATCH] fixed copy/paste error --- examples/MidiBle/MidiBle.ino | 12 +++++++++--- src/hardware/MIDI_ESP32_NimBLE.h | 23 ++--------------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/examples/MidiBle/MidiBle.ino b/examples/MidiBle/MidiBle.ino index d15f588..d7d60cb 100644 --- a/examples/MidiBle/MidiBle.ino +++ b/examples/MidiBle/MidiBle.ino @@ -7,6 +7,7 @@ BLEMIDI_CREATE_DEFAULT_INSTANCE() unsigned long t0 = millis(); +unsigned long t1 = millis(); bool isConnected = false; // ----------------------------------------------------------------------------- @@ -14,7 +15,7 @@ bool isConnected = false; // ----------------------------------------------------------------------------- void setup() { - Serial.begin(9600); // initialize serial communication + Serial.begin(115200); // initialize serial communication while (!Serial); MIDI.begin(); @@ -42,8 +43,13 @@ void loop() { t0 = millis(); - // MIDI.sendNoteOn (60, 100, 1); // note 60, velocity 127 on channel 1 - // MIDI.sendNoteOff(60, 0, 1); + MIDI.sendNoteOn (60, 100, 1); // note 60, velocity 127 on channel 1 + } + if (isConnected && (millis() - t1) > 1250) + { + t1 = millis(); + + MIDI.sendNoteOff(60, 0, 1); } } diff --git a/src/hardware/MIDI_ESP32_NimBLE.h b/src/hardware/MIDI_ESP32_NimBLE.h index ad474b3..2f4b2fe 100644 --- a/src/hardware/MIDI_ESP32_NimBLE.h +++ b/src/hardware/MIDI_ESP32_NimBLE.h @@ -30,28 +30,9 @@ public: _characteristic->notify(); } - size_t available(uint8_t* buffer, size_t index, const size_t max) + size_t available(void *pvBuffer) { - size_t length = uxQueueMessagesWaiting(mRxQueue); - if (0 == length) return 0; - - Serial.print("nimBLE available: "); - - while (xQueueReceive(mRxQueue, buffer + index++, 0)) - { - Serial.print(" 0x"); - Serial.print(buffer[index], HEX); - index++; - } - Serial.println(""); - - if (length > 0) - { - Serial.print("index: "); - Serial.println(length); - } - - return length; + return xQueueReceive(mRxQueue, pvBuffer, 0); // return immediately when the queue is empty } /*