remove offset parameter in BLECharacteristic's write_cb_t signature
This commit is contained in:
1 parent
59b12ded0e
commit
3f01e1f069
10 files changed
+60
-33
No files matched your search
@@ -440,10 +440,10 @@ void BLECharacteristic::_eventHandler(ble_evt_t* event)
|
||||
{
|
||||
if (_use_ada_cb.write)
|
||||
{
|
||||
ada_callback(_long_wr.buffer, _long_wr.count, _wr_cb, conn_hdl, this, _long_wr.buffer, _long_wr.count, 0);
|
||||
ada_callback(_long_wr.buffer, _long_wr.count, _wr_cb, conn_hdl, this, _long_wr.buffer, _long_wr.count);
|
||||
}else
|
||||
{
|
||||
_wr_cb(conn_hdl, this, _long_wr.buffer, _long_wr.count, 0);
|
||||
_wr_cb(conn_hdl, this, _long_wr.buffer, _long_wr.count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,10 +479,10 @@ void BLECharacteristic::_eventHandler(ble_evt_t* event)
|
||||
{
|
||||
if (_use_ada_cb.write)
|
||||
{
|
||||
ada_callback(request->data, request->len, _wr_cb, conn_hdl, this, request->data, request->len, request->offset);
|
||||
ada_callback(request->data, request->len, _wr_cb, conn_hdl, this, request->data, request->len);
|
||||
}else
|
||||
{
|
||||
_wr_cb(conn_hdl, this, request->data, request->len, request->offset);
|
||||
_wr_cb(conn_hdl, this, request->data, request->len);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -601,11 +601,13 @@ uint32_t BLECharacteristic::read32(void)
|
||||
}
|
||||
|
||||
|
||||
uint16_t BLECharacteristic::getCccd(void)
|
||||
{
|
||||
return getCccd(Bluefruit.connHandle());
|
||||
}
|
||||
|
||||
uint16_t BLECharacteristic::getCccd(uint16_t conn_hdl)
|
||||
{
|
||||
// use default conn handle if not passed
|
||||
if ( conn_hdl == BLE_CONN_HANDLE_INVALID ) conn_hdl = Bluefruit.connHandle();
|
||||
|
||||
VERIFY( Bluefruit.connected(conn_hdl) && (_handles.cccd_handle != BLE_GATT_HANDLE_INVALID), 0 );
|
||||
|
||||
uint16_t cccd;
|
||||
@@ -633,6 +635,11 @@ uint16_t BLECharacteristic::getCccd(uint16_t conn_hdl)
|
||||
/*------------------------------------------------------------------*/
|
||||
/* NOTIFY
|
||||
*------------------------------------------------------------------*/
|
||||
bool BLECharacteristic::notifyEnabled(void)
|
||||
{
|
||||
return notifyEnabled(Bluefruit.connHandle());
|
||||
}
|
||||
|
||||
bool BLECharacteristic::notifyEnabled(uint16_t conn_hdl)
|
||||
{
|
||||
VERIFY( _properties.notify );
|
||||
@@ -717,6 +724,11 @@ bool BLECharacteristic::notify32(int num, uint16_t conn_hdl)
|
||||
/*------------------------------------------------------------------*/
|
||||
/* INDICATE
|
||||
*------------------------------------------------------------------*/
|
||||
bool BLECharacteristic::indicateEnabled(void)
|
||||
{
|
||||
return indicateEnabled(Bluefruit.connHandle());
|
||||
}
|
||||
|
||||
bool BLECharacteristic::indicateEnabled(uint16_t conn_hdl)
|
||||
{
|
||||
VERIFY( _properties.indicate );
|
||||
|
||||
@@ -76,7 +76,7 @@ class BLECharacteristic
|
||||
/*--------- Callback Signatures ----------*/
|
||||
typedef void (*read_authorize_cb_t) (uint16_t conn_hdl, BLECharacteristic* chr, ble_gatts_evt_read_t * request);
|
||||
typedef void (*write_authorize_cb_t) (uint16_t conn_hdl, BLECharacteristic* chr, ble_gatts_evt_write_t* request);
|
||||
typedef void (*write_cb_t) (uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len, uint16_t offset);
|
||||
typedef void (*write_cb_t) (uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
typedef void (*write_cccd_cb_t) (uint16_t conn_hdl, BLECharacteristic* chr, uint16_t value);
|
||||
|
||||
BLEUuid uuid;
|
||||
@@ -134,9 +134,11 @@ class BLECharacteristic
|
||||
uint32_t read32(void);
|
||||
|
||||
/*------------- Notify -------------*/
|
||||
uint16_t getCccd(uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
uint16_t getCccd(void);
|
||||
uint16_t getCccd(uint16_t conn_hdl);
|
||||
|
||||
bool notifyEnabled(uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
bool notifyEnabled(void);
|
||||
bool notifyEnabled(uint16_t conn_hdl);
|
||||
|
||||
bool notify (const void* data, uint16_t len, uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
bool notify (const char* str, uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
@@ -147,7 +149,8 @@ class BLECharacteristic
|
||||
bool notify32 (int num, uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
|
||||
/*------------- Indicate -------------*/
|
||||
bool indicateEnabled(uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
bool indicateEnabled(void);
|
||||
bool indicateEnabled(uint16_t conn_hdl);
|
||||
|
||||
bool indicate (const void* data, uint16_t len, uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
bool indicate (const char* str, uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
|
||||
@@ -222,7 +222,7 @@ err_t BLEHidAdafruit::begin(void)
|
||||
/* Keyboard
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
void blehid_ada_keyboard_output_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len, uint16_t offset)
|
||||
void blehid_ada_keyboard_output_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len)
|
||||
{
|
||||
(void) conn_hdl;
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ class BLEHidAdafruit : public BLEHidGeneric
|
||||
uint8_t _mse_buttons;
|
||||
kbd_led_cb_t _kbd_led_cb;
|
||||
|
||||
friend void blehid_ada_keyboard_output_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len, uint16_t offset);
|
||||
friend void blehid_ada_keyboard_output_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
};
|
||||
|
||||
#endif /* BLEHIDADAFRUIT_H_ */
|
||||
@@ -130,7 +130,7 @@ void BLEHidGeneric::setOutputReportCallback(uint8_t reportID, BLECharacteristic:
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Callbacks
|
||||
*------------------------------------------------------------------*/
|
||||
void blehid_generic_protocol_mode_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len, uint16_t offset)
|
||||
void blehid_generic_protocol_mode_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len)
|
||||
{
|
||||
(void) conn_hdl;
|
||||
BLEHidGeneric& svc = (BLEHidGeneric&) chr->parentService();
|
||||
|
||||
@@ -149,7 +149,7 @@ class BLEHidGeneric : public BLEService
|
||||
|
||||
BLECharacteristic _chr_control;
|
||||
|
||||
friend void blehid_generic_protocol_mode_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len, uint16_t offset);
|
||||
friend void blehid_generic_protocol_mode_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@@ -106,7 +106,7 @@ typedef struct ATTR_PACKED
|
||||
|
||||
VERIFY_STATIC ( sizeof(midi_split_packet_t) == (BLE_MIDI_TX_BUFFER_SIZE + 1) );
|
||||
|
||||
void blemidi_write_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len, uint16_t offset);
|
||||
void blemidi_write_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* IMPLEMENTATION
|
||||
@@ -120,7 +120,7 @@ BLEMidi::BLEMidi(uint16_t fifo_depth)
|
||||
|
||||
bool BLEMidi::notifyEnabled(void)
|
||||
{
|
||||
return Bluefruit.connPaired() && _io.notifyEnabled();
|
||||
return _io.notifyEnabled();
|
||||
}
|
||||
|
||||
void BLEMidi::setWriteCallback(midi_write_cb_t fp)
|
||||
@@ -161,10 +161,9 @@ err_t BLEMidi::begin(void)
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Callbacks
|
||||
*------------------------------------------------------------------*/
|
||||
void blemidi_write_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len, uint16_t offset)
|
||||
void blemidi_write_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len)
|
||||
{
|
||||
(void) conn_hdl;
|
||||
(void) offset;
|
||||
if ( len < 3 ) return;
|
||||
|
||||
BLEMidi& midi_svc = (BLEMidi&) chr->parentService();
|
||||
|
||||
@@ -91,7 +91,7 @@ class BLEMidi: public BLEService, public Stream
|
||||
|
||||
void _write_handler(uint8_t* data, uint16_t len);
|
||||
|
||||
friend void blemidi_write_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len, uint16_t offset);
|
||||
friend void blemidi_write_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -83,15 +83,16 @@ BLEUart::~BLEUart()
|
||||
if ( _tx_fifo ) delete _tx_fifo;
|
||||
}
|
||||
|
||||
|
||||
// Callback when received new data
|
||||
void bleuart_rxd_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len, uint16_t offset)
|
||||
void bleuart_rxd_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len)
|
||||
{
|
||||
(void) conn_hdl;
|
||||
(void) offset;
|
||||
|
||||
BLEUart& svc = (BLEUart&) chr->parentService();
|
||||
svc._rx_fifo->write(data, len);
|
||||
svc._rxd_hanlder(conn_hdl, data, len);
|
||||
}
|
||||
|
||||
void BLEUart::_rxd_hanlder(uint16_t conn_hdl, uint8_t const * data, uint16_t len)
|
||||
{
|
||||
_rx_fifo->write(data, len);
|
||||
|
||||
#if CFG_DEBUG >= 2
|
||||
LOG_LV2("BLEUART", "RX: ");
|
||||
@@ -99,7 +100,7 @@ void bleuart_rxd_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, ui
|
||||
#endif
|
||||
|
||||
// invoke user callback
|
||||
if ( svc._rx_cb ) svc._rx_cb();
|
||||
if ( _rx_cb ) _rx_cb();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,6 +241,16 @@ int BLEUart::read (uint8_t * buf, size_t size)
|
||||
return _rx_fifo->read(buf, size);
|
||||
}
|
||||
|
||||
size_t BLEUart::write (uint8_t b)
|
||||
{
|
||||
return write(&b, 1, Bluefruit.connHandle());
|
||||
}
|
||||
|
||||
size_t BLEUart::write (const uint8_t *content, size_t len)
|
||||
{
|
||||
return write(content, len, Bluefruit.connHandle());
|
||||
}
|
||||
|
||||
size_t BLEUart::write (uint8_t b, uint16_t conn_hdl)
|
||||
{
|
||||
return write(&b, 1, conn_hdl);
|
||||
@@ -247,9 +258,6 @@ size_t BLEUart::write (uint8_t b, uint16_t conn_hdl)
|
||||
|
||||
size_t BLEUart::write (const uint8_t *content, size_t len, uint16_t conn_hdl)
|
||||
{
|
||||
// use default conn handle if not passed
|
||||
if ( conn_hdl == BLE_CONN_HANDLE_INVALID ) conn_hdl = Bluefruit.connHandle();
|
||||
|
||||
BLEConnection* conn = Bluefruit.Connection(conn_hdl);
|
||||
VERIFY(conn, 0);
|
||||
|
||||
|
||||
@@ -66,8 +66,12 @@ class BLEUart : public BLEService, public Stream
|
||||
virtual int read ( void );
|
||||
virtual int read ( uint8_t * buf, size_t size );
|
||||
int read ( char * buf, size_t size ) { return read( (uint8_t*) buf, size); }
|
||||
virtual size_t write ( uint8_t b, uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID );
|
||||
virtual size_t write ( const uint8_t *content, size_t len, uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
virtual size_t write ( uint8_t b );
|
||||
virtual size_t write ( const uint8_t *content, size_t len);
|
||||
|
||||
virtual size_t write ( uint8_t b, uint16_t conn_hdl);
|
||||
virtual size_t write ( const uint8_t *content, size_t len, uint16_t conn_hdl);
|
||||
|
||||
virtual int available ( void );
|
||||
virtual int peek ( void );
|
||||
virtual void flush ( void );
|
||||
@@ -90,13 +94,14 @@ class BLEUart : public BLEService, public Stream
|
||||
TimerHandle_t _buffered_th;
|
||||
|
||||
bool _flush_txd(uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
void _rxd_hanlder(uint16_t conn_hdl, uint8_t const * data, uint16_t len);
|
||||
|
||||
// from BLEService
|
||||
virtual void _disconnect_cb(void);
|
||||
virtual void _connect_cb(void);
|
||||
|
||||
// friend callbacks
|
||||
friend void bleuart_rxd_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len, uint16_t offset);
|
||||
friend void bleuart_rxd_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len);
|
||||
friend void bleuart_txd_cccd_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint16_t value);
|
||||
friend void bleuart_txd_buffered_hdlr(TimerHandle_t timer);
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user