change characteristic write callback signature
This commit is contained in:
1 parent
57e3fdd4e3
commit
f31b8ec41d
9 files changed
+28
-8
No files matched your search
@@ -41,6 +41,8 @@
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define COMMENT_OUT(x)
|
||||
|
||||
#define memclr(buffer, size) memset(buffer, 0, size)
|
||||
#define varclr(_var) memclr(_var, sizeof(*(_var)))
|
||||
#define arrcount(_arr) ( sizeof(_arr) / sizeof(_arr[0]) )
|
||||
|
||||
@@ -13,6 +13,14 @@
|
||||
*********************************************************************/
|
||||
#include <bluefruit.h>
|
||||
|
||||
// To test:
|
||||
// - Run this sketch and open the Serial Monitor
|
||||
// - Open the iGrand Piano Free app
|
||||
// - Open the midimittr app on your phone and under Clients select "Bluefruit52"
|
||||
// - When you see the 'Connected' label switch to the Routing panel
|
||||
// - Set the Destination to 'iGrand Piano'
|
||||
// - Switch to the iGrand Piano Free app and you should see notes playing one by one
|
||||
|
||||
BLEDis bledis;
|
||||
BLEMidi blemidi;
|
||||
|
||||
|
||||
@@ -113,7 +113,8 @@ void connect_callback(void)
|
||||
void disconnect_callback(uint8_t reason)
|
||||
{
|
||||
(void) reason;
|
||||
|
||||
|
||||
Serial.println();
|
||||
Serial.println("Disconnected");
|
||||
Serial.println("Bluefruit will auto start advertising (default)");
|
||||
}
|
||||
@@ -328,7 +328,7 @@ void BLECharacteristic::eventHandler(ble_evt_t* event)
|
||||
// Value write
|
||||
if ( _wr_cb && (request->handle == _handles.value_handle))
|
||||
{
|
||||
_wr_cb(*this, request);
|
||||
_wr_cb(*this, request->data, request->len, request->offset);
|
||||
}
|
||||
|
||||
// CCCD write
|
||||
|
||||
@@ -74,7 +74,7 @@ class BLECharacteristic
|
||||
public:
|
||||
typedef void (*read_authorize_cb_t) (BLECharacteristic& chr, ble_gatts_evt_read_t * request);
|
||||
typedef void (*write_authorize_cb_t) (BLECharacteristic& chr, ble_gatts_evt_write_t* request);
|
||||
typedef void (*write_cb_t) (BLECharacteristic& chr, ble_gatts_evt_write_t* request);
|
||||
typedef void (*write_cb_t) (BLECharacteristic& chr, uint8_t* data, uint16_t len, uint16_t offset);
|
||||
typedef void (*write_cccd_cb_t) (BLECharacteristic& chr, uint16_t value);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -119,6 +119,7 @@ void BLEHidGeneric::setOutputReportCallback(uint8_t reportID, output_report_cb_t
|
||||
_output_cbs[reportID] = fp;
|
||||
}
|
||||
|
||||
COMMENT_OUT (
|
||||
void blehidgeneric_output_cb(BLECharacteristic& chr, ble_gatts_evt_write_t* request)
|
||||
{
|
||||
(void) chr;
|
||||
@@ -126,6 +127,7 @@ void blehidgeneric_output_cb(BLECharacteristic& chr, ble_gatts_evt_write_t* requ
|
||||
// BLEHidGeneric& hid = (BLEHidGeneric&) chr.parentService();
|
||||
// PRINT_BUFFER(request->data, request->len);
|
||||
}
|
||||
)
|
||||
|
||||
err_t BLEHidGeneric::start(void)
|
||||
{
|
||||
@@ -166,7 +168,10 @@ err_t BLEHidGeneric::start(void)
|
||||
_chr_outputs[i].setProperties(CHR_PROPS_READ | CHR_PROPS_WRITE | CHR_PROPS_WRITE_WO_RESP);
|
||||
_chr_outputs[i].setPermission(SECMODE_ENC_NO_MITM, SECMODE_NO_ACCESS);
|
||||
_chr_outputs[i].setReportRefDescriptor(i+1, REPORT_TYPE_OUTPUT);
|
||||
// _chr_outputs[i].setWriteCallback(blehidgeneric_output_cb);
|
||||
|
||||
COMMENT_OUT(
|
||||
_chr_outputs[i].setWriteCallback(blehidgeneric_output_cb);
|
||||
)
|
||||
|
||||
// Input report len is configured, else variable len up to 255
|
||||
if ( _output_len ) _chr_outputs[i].setFixedLen( _output_len[i] );
|
||||
|
||||
@@ -134,7 +134,9 @@ class BLEHidGeneric : public BLEService
|
||||
|
||||
BLECharacteristic _chr_control;
|
||||
|
||||
friend void blehidgeneric_output_cb(BLECharacteristic& chr, ble_gatts_evt_write_t* request);
|
||||
COMMENT_OUT (
|
||||
friend void blehidgeneric_output_cb(BLECharacteristic& chr, ble_gatts_evt_write_t* request);
|
||||
)
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@@ -70,10 +70,12 @@ BLEUart::BLEUart(uint16_t fifo_depth)
|
||||
_rx_cb = NULL;
|
||||
}
|
||||
|
||||
void bleuart_rxd_cb(BLECharacteristic& chr, ble_gatts_evt_write_t* request)
|
||||
void bleuart_rxd_cb(BLECharacteristic& chr, uint8_t* data, uint16_t len, uint16_t offset)
|
||||
{
|
||||
(void) offset;
|
||||
|
||||
BLEUart& uart_svc = (BLEUart&) chr.parentService();
|
||||
uart_svc._rxd_fifo.write(request->data, request->len);
|
||||
uart_svc._rxd_fifo.write(data, len);
|
||||
|
||||
// invoke user callback
|
||||
if ( uart_svc._rx_cb ) uart_svc._rx_cb();
|
||||
|
||||
@@ -74,7 +74,7 @@ class BLEUart : public BLEService, public Stream
|
||||
Adafruit_FIFO _rxd_fifo;
|
||||
rx_callback_t _rx_cb;
|
||||
|
||||
friend void bleuart_rxd_cb(BLECharacteristic& chr, ble_gatts_evt_write_t* request);
|
||||
friend void bleuart_rxd_cb(BLECharacteristic& chr, uint8_t* data, uint16_t len, uint16_t offset);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user