Skip to content

Commit acce660

Browse files
committed
add conn_hdl to midi write callback
1 parent a3a2f87 commit acce660

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

libraries/Bluefruit52Lib/src/services/BLEMidi.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,13 @@ err_t BLEMidi::begin(void)
168168
*------------------------------------------------------------------*/
169169
void BLEMidi::blemidi_write_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len)
170170
{
171-
(void) conn_hdl;
172171
if ( len < 3 ) return;
173172

174173
BLEMidi& midi_svc = (BLEMidi&) chr->parentService();
175-
midi_svc._write_handler(data, len);
174+
midi_svc._write_handler(conn_hdl, data, len);
176175
}
177176

178-
void BLEMidi::_write_handler(uint8_t* data, uint16_t len)
177+
void BLEMidi::_write_handler(uint16_t conn_hdl, uint8_t* data, uint16_t len)
179178
{
180179
// drop the BLE MIDI header byte
181180
data++;
@@ -204,7 +203,7 @@ void BLEMidi::_write_handler(uint8_t* data, uint16_t len)
204203
}
205204

206205
// Call write callback if configured
207-
if ( _write_cb ) _write_cb();
206+
if ( _write_cb ) _write_cb(conn_hdl);
208207

209208
#ifdef MIDI_LIB_INCLUDED
210209
// read while possible if configured

libraries/Bluefruit52Lib/src/services/BLEMidi.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ extern const uint8_t BLEMIDI_UUID_CHR_IO[];
5252
class BLEMidi: public BLEService, public Stream
5353
{
5454
public:
55-
typedef void (*midi_write_cb_t) (void);
55+
typedef void (*midi_write_cb_t) (uint16_t conn_hdl);
5656

5757
BLEMidi(uint16_t fifo_depth = BLE_MIDI_DEFAULT_FIFO_DEPTH);
5858

@@ -91,7 +91,7 @@ class BLEMidi: public BLEService, public Stream
9191

9292
void* _midilib_obj;
9393

94-
void _write_handler(uint8_t* data, uint16_t len);
94+
void _write_handler(uint16_t conn_hdl, uint8_t* data, uint16_t len);
9595

9696
static void blemidi_write_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len);
9797
};

0 commit comments

Comments
 (0)