You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When playing around with MIDI characteristic I found that every note sent from a Central (iMac MIDI) was echoed back, that is not always what is wanted.
The reason is that the function setValue(const unsigned char value[], unsigned char length) that actually makes the change always invokes the listener callback. So when receiving a characteristic write from Central and we have writes without response the listener should not be invoked.
midiCharacteristic is configured BLEWriteWithoutResponse.
The sketch does not send any midi data, it only receives. So there should be no output.
Compiled and loaded to a Micro:Bit board.
Connect to a BLE MIDI enabled computer
On a Mac computer, open Tools : Sound/MIDI settings
Double click Bluetooth Tool icon
Connect to the MICRO:Midi ble unit
Use some midi generator to send MIDI notes to the board and monitor the traffic
Use MIDI Keys , a minimal virtual MIDI keyboard and route output to the MICRO:Midi
Use MIDI Monitor to record output from MICRO:Midi and also spy in traffic to the board.
Now every MIDI message sent to to board will be echoed back to the computer, this is not done by the application code in the sketch but by the BLE transport layer.
When playing around with MIDI characteristic I found that every note sent from a Central (iMac MIDI) was echoed back, that is not always what is wanted.
The reason is that the function setValue(const unsigned char value[], unsigned char length) that actually makes the change always invokes the listener callback. So when receiving a characteristic write from Central and we have writes without response the listener should not be invoked.
One possible way, that so far works for me is:
void BLECharacteristic::setValue(BLECentral& central, const unsigned char value[], unsigned char length) {
-- this->setValue(value, length);
++ if ( _properties & BLEWriteWithoutResponse ) {
++ this->_valueLength = min(length, this->_valueSize);
++ memcpy(this->_value, value, this->_valueLength);
++ }
++ else {
++ this->setValue(value, length);
++ }
this->_written = true;
BLECharacteristicEventHandler eventHandler = this->_eventHandlers[BLEWritten];
if (eventHandler) {
eventHandler(central, *this);
}
}
The text was updated successfully, but these errors were encountered: