add conn_hdl to all BLECharacteristic callback to support multiple prph connections
- added optional conn_hdl to getCccd(), indicateEnabled(), notifyEnabled() - added optional conn_hdl to all indicate() and notify() data function
This commit is contained in:
1 parent
0386062314
commit
5768575c42
15 files changed
+103
-93
No files matched your search
@@ -556,7 +556,7 @@ void HAPCharacteristic::_eventHandler(ble_evt_t* event)
|
||||
{
|
||||
uint16_t value;
|
||||
memcpy(&value, request->data, 2);
|
||||
_cccd_wr_cb(this, value);
|
||||
_cccd_wr_cb(conn_hdl, this, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ void setupHRM(void)
|
||||
hrmc.setCccdWriteCallback(cccd_callback); // Optionally capture CCCD updates
|
||||
hrmc.begin();
|
||||
uint8_t hrmdata[2] = { 0b00000110, 0x40 }; // Set the characteristic to use 8-bit values, with the sensor connected and detected
|
||||
hrmc.notify(hrmdata, 2); // Use .notify instead of .write!
|
||||
hrmc.write(hrmdata, 2);
|
||||
|
||||
// Configure the Body Sensor Location characteristic
|
||||
// See: https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.characteristic.body_sensor_location.xml
|
||||
@@ -183,7 +183,7 @@ void disconnect_callback(uint16_t conn_handle, uint8_t reason)
|
||||
Serial.println("Advertising!");
|
||||
}
|
||||
|
||||
void cccd_callback(BLECharacteristic* chr, uint16_t cccd_value)
|
||||
void cccd_callback(uint16_t conn_hdl, BLECharacteristic* chr, uint16_t cccd_value)
|
||||
{
|
||||
// Display the raw request packet
|
||||
Serial.print("CCCD Updated: ");
|
||||
@@ -194,7 +194,7 @@ void cccd_callback(BLECharacteristic* chr, uint16_t cccd_value)
|
||||
// Check the characteristic this CCCD update is associated with in case
|
||||
// this handler is used for multiple CCCD records.
|
||||
if (chr->uuid == hrmc.uuid) {
|
||||
if (chr->notifyEnabled()) {
|
||||
if (chr->notifyEnabled(conn_hdl)) {
|
||||
Serial.println("Heart Rate Measurement 'Notify' enabled");
|
||||
} else {
|
||||
Serial.println("Heart Rate Measurement 'Notify' disabled");
|
||||
|
||||
@@ -173,7 +173,7 @@ void disconnect_callback(uint16_t conn_handle, uint8_t reason)
|
||||
Serial.println("Advertising!");
|
||||
}
|
||||
|
||||
void cccd_callback(BLECharacteristic* chr, uint16_t cccd_value)
|
||||
void cccd_callback(uint16_t conn_hdl, BLECharacteristic* chr, uint16_t cccd_value)
|
||||
{
|
||||
// Display the raw request packet
|
||||
Serial.print("CCCD Updated: ");
|
||||
@@ -184,7 +184,7 @@ void cccd_callback(BLECharacteristic* chr, uint16_t cccd_value)
|
||||
// Check the characteristic this CCCD update is associated with in case
|
||||
// this handler is used for multiple CCCD records.
|
||||
if (chr->uuid == htmc.uuid) {
|
||||
if (chr->indicateEnabled()) {
|
||||
if (chr->indicateEnabled(conn_hdl)) {
|
||||
Serial.println("Temperature Measurement 'Indicate' enabled");
|
||||
} else {
|
||||
Serial.println("Temperature Measurement 'Indicate' disabled");
|
||||
@@ -203,8 +203,8 @@ void loop()
|
||||
|
||||
// Note: We use .indicate instead of .write!
|
||||
// If it is connected but CCCD is not enabled
|
||||
// The characteristic's value is still updated although notification is not sent
|
||||
if ( htmc.indicate(htmdata, sizeof(htmdata)) ){
|
||||
// The characteristic's value is still updated although indicate is not sent
|
||||
if ( htmc.indicate(0, htmdata, sizeof(htmdata)) ){
|
||||
Serial.print("Temperature Measurement updated to: "); Serial.println(tempvalue);
|
||||
}else{
|
||||
Serial.println("ERROR: Indicate not set in the CCCD or not connected!");
|
||||
@@ -216,4 +216,3 @@ void loop()
|
||||
// Only send update once per second
|
||||
delay(1000);
|
||||
}
|
||||
|
||||
@@ -363,11 +363,11 @@ void BLECharacteristic::_eventHandler(ble_evt_t* event)
|
||||
|
||||
if ( _use_ada_cb.read_authorize )
|
||||
{
|
||||
ada_callback(rd_req, sizeof(*rd_req), _rd_authorize_cb, this, rd_req);
|
||||
ada_callback(rd_req, sizeof(*rd_req), _rd_authorize_cb, conn_hdl, this, rd_req);
|
||||
}
|
||||
else
|
||||
{
|
||||
_rd_authorize_cb(this, rd_req);
|
||||
_rd_authorize_cb(conn_hdl, this, rd_req);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -384,10 +384,10 @@ void BLECharacteristic::_eventHandler(ble_evt_t* event)
|
||||
{
|
||||
if ( _use_ada_cb.write_authorize )
|
||||
{
|
||||
ada_callback(wr_req, sizeof(*wr_req), _wr_authorize_cb, this, wr_req);
|
||||
ada_callback(wr_req, sizeof(*wr_req), _wr_authorize_cb, conn_hdl, this, wr_req);
|
||||
}else
|
||||
{
|
||||
_wr_authorize_cb(this, wr_req);
|
||||
_wr_authorize_cb(conn_hdl, this, wr_req);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -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, 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, 0);
|
||||
}else
|
||||
{
|
||||
_wr_cb(this, _long_wr.buffer, _long_wr.count, 0);
|
||||
_wr_cb(conn_hdl, this, _long_wr.buffer, _long_wr.count, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -479,10 +479,10 @@ void BLECharacteristic::_eventHandler(ble_evt_t* event)
|
||||
{
|
||||
if (_use_ada_cb.write)
|
||||
{
|
||||
ada_callback(request->data, request->len, _wr_cb, this, request->data, request->len, request->offset);
|
||||
ada_callback(request->data, request->len, _wr_cb, conn_hdl, this, request->data, request->len, request->offset);
|
||||
}else
|
||||
{
|
||||
_wr_cb(this, request->data, request->len, request->offset);
|
||||
_wr_cb(conn_hdl, this, request->data, request->len, request->offset);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -499,11 +499,11 @@ void BLECharacteristic::_eventHandler(ble_evt_t* event)
|
||||
|
||||
if ( _use_ada_cb.cccd_write )
|
||||
{
|
||||
ada_callback(NULL, 0, _cccd_wr_cb, this, value);
|
||||
ada_callback(NULL, 0, _cccd_wr_cb, conn_hdl, this, value);
|
||||
}
|
||||
else
|
||||
{
|
||||
_cccd_wr_cb(this, value);
|
||||
_cccd_wr_cb(conn_hdl, this, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -601,9 +601,12 @@ uint32_t BLECharacteristic::read32(void)
|
||||
}
|
||||
|
||||
|
||||
uint16_t BLECharacteristic::getCccd(void)
|
||||
uint16_t BLECharacteristic::getCccd(uint16_t conn_hdl)
|
||||
{
|
||||
VERIFY( Bluefruit.connected() && (_handles.cccd_handle != BLE_GATT_HANDLE_INVALID), 0 );
|
||||
// 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;
|
||||
ble_gatts_value_t value =
|
||||
@@ -613,7 +616,7 @@ uint16_t BLECharacteristic::getCccd(void)
|
||||
.p_value = (uint8_t*) &cccd
|
||||
};
|
||||
|
||||
err_t err = sd_ble_gatts_value_get(Bluefruit.connHandle(), _handles.cccd_handle, &value);
|
||||
err_t err = sd_ble_gatts_value_get(conn_hdl, _handles.cccd_handle, &value);
|
||||
|
||||
// CCCD is not set, count as not enabled
|
||||
if ( BLE_ERROR_GATTS_SYS_ATTR_MISSING == err )
|
||||
@@ -630,23 +633,25 @@ uint16_t BLECharacteristic::getCccd(void)
|
||||
/*------------------------------------------------------------------*/
|
||||
/* NOTIFY
|
||||
*------------------------------------------------------------------*/
|
||||
bool BLECharacteristic::notifyEnabled(void)
|
||||
bool BLECharacteristic::notifyEnabled(uint16_t conn_hdl)
|
||||
{
|
||||
VERIFY( _properties.notify );
|
||||
return (getCccd() & BLE_GATT_HVX_NOTIFICATION);
|
||||
return (getCccd(conn_hdl) & BLE_GATT_HVX_NOTIFICATION);
|
||||
}
|
||||
|
||||
bool BLECharacteristic::notify(const void* data, uint16_t len)
|
||||
bool BLECharacteristic::notify(const void* data, uint16_t len, uint16_t conn_hdl)
|
||||
{
|
||||
VERIFY( _properties.notify );
|
||||
|
||||
// use default conn handle if not passed
|
||||
if ( conn_hdl == BLE_CONN_HANDLE_INVALID ) conn_hdl = Bluefruit.connHandle();
|
||||
|
||||
// could not exceed max len
|
||||
uint16_t remaining = min16(len, _max_len);
|
||||
|
||||
if ( notifyEnabled() )
|
||||
if ( notifyEnabled(conn_hdl) )
|
||||
{
|
||||
// TODO multiple connection support
|
||||
BLEConnection* conn = Bluefruit.Connection( Bluefruit.connHandle() );
|
||||
BLEConnection* conn = Bluefruit.Connection( conn_hdl );
|
||||
VERIFY(conn);
|
||||
|
||||
uint16_t const max_payload = conn->getMtu() - 3;
|
||||
@@ -669,7 +674,7 @@ bool BLECharacteristic::notify(const void* data, uint16_t len)
|
||||
};
|
||||
|
||||
LOG_LV2("CHR", "Notify %d bytes", packet_len);
|
||||
VERIFY_STATUS( sd_ble_gatts_hvx(Bluefruit.connHandle(), &hvx_params), false );
|
||||
VERIFY_STATUS( sd_ble_gatts_hvx(conn_hdl, &hvx_params), false );
|
||||
|
||||
remaining -= packet_len;
|
||||
u8data += packet_len;
|
||||
@@ -684,50 +689,52 @@ bool BLECharacteristic::notify(const void* data, uint16_t len)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BLECharacteristic::notify(const char * str)
|
||||
bool BLECharacteristic::notify(const char * str, uint16_t conn_hdl)
|
||||
{
|
||||
return notify( (const uint8_t*) str, strlen(str) );
|
||||
return notify((const uint8_t*) str, strlen(str), conn_hdl);
|
||||
}
|
||||
|
||||
bool BLECharacteristic::notify8(uint8_t num)
|
||||
bool BLECharacteristic::notify8(uint8_t num, uint16_t conn_hdl)
|
||||
{
|
||||
return notify( (uint8_t*) &num, sizeof(num));
|
||||
return notify((uint8_t*) &num, sizeof(num), conn_hdl);
|
||||
}
|
||||
|
||||
bool BLECharacteristic::notify16(uint16_t num)
|
||||
bool BLECharacteristic::notify16(uint16_t num, uint16_t conn_hdl)
|
||||
{
|
||||
return notify( (uint8_t*) &num, sizeof(num));
|
||||
return notify((uint8_t*) &num, sizeof(num), conn_hdl);
|
||||
}
|
||||
|
||||
bool BLECharacteristic::notify32(uint32_t num)
|
||||
bool BLECharacteristic::notify32(uint32_t num, uint16_t conn_hdl)
|
||||
{
|
||||
return notify( (uint8_t*) &num, sizeof(num));
|
||||
return notify((uint8_t*) &num, sizeof(num), conn_hdl);
|
||||
}
|
||||
|
||||
bool BLECharacteristic::notify32(int num)
|
||||
bool BLECharacteristic::notify32(int num, uint16_t conn_hdl)
|
||||
{
|
||||
return notify32( (uint32_t) num);
|
||||
return notify32((uint32_t) num, conn_hdl);
|
||||
}
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* INDICATE
|
||||
*------------------------------------------------------------------*/
|
||||
bool BLECharacteristic::indicateEnabled(void)
|
||||
bool BLECharacteristic::indicateEnabled(uint16_t conn_hdl)
|
||||
{
|
||||
VERIFY( _properties.indicate );
|
||||
return (getCccd() & BLE_GATT_HVX_INDICATION);
|
||||
return (getCccd(conn_hdl) & BLE_GATT_HVX_INDICATION);
|
||||
}
|
||||
|
||||
bool BLECharacteristic::indicate(const void* data, uint16_t len)
|
||||
bool BLECharacteristic::indicate(const void* data, uint16_t len, uint16_t conn_hdl)
|
||||
{
|
||||
VERIFY( _properties.indicate );
|
||||
|
||||
// use default conn handle if not passed
|
||||
if ( conn_hdl == BLE_CONN_HANDLE_INVALID ) conn_hdl = Bluefruit.connHandle();
|
||||
|
||||
// could not exceed max len
|
||||
uint16_t remaining = min16(len, _max_len);
|
||||
|
||||
if ( indicateEnabled() )
|
||||
if ( indicateEnabled(conn_hdl) )
|
||||
{
|
||||
uint16_t conn_hdl = Bluefruit.connHandle();
|
||||
BLEConnection* conn = Bluefruit.Connection( conn_hdl );
|
||||
VERIFY(conn);
|
||||
|
||||
@@ -750,7 +757,7 @@ bool BLECharacteristic::indicate(const void* data, uint16_t len)
|
||||
LOG_LV2("CHR", "Indicate %d bytes", packet_len);
|
||||
|
||||
// Blocking wait until receiving confirmation from peer
|
||||
VERIFY_STATUS( sd_ble_gatts_hvx( conn_hdl, &hvx_params), false );
|
||||
VERIFY_STATUS( sd_ble_gatts_hvx(conn_hdl, &hvx_params), false );
|
||||
VERIFY ( conn->waitForIndicateConfirm() );
|
||||
|
||||
remaining -= packet_len;
|
||||
@@ -766,27 +773,27 @@ bool BLECharacteristic::indicate(const void* data, uint16_t len)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool BLECharacteristic::indicate(const char * str)
|
||||
bool BLECharacteristic::indicate(const char * str, uint16_t conn_hdl)
|
||||
{
|
||||
return indicate( (const uint8_t*) str, strlen(str) );
|
||||
return indicate((const uint8_t*) str, strlen(str), conn_hdl);
|
||||
}
|
||||
|
||||
bool BLECharacteristic::indicate8(uint8_t num)
|
||||
bool BLECharacteristic::indicate8(uint8_t num, uint16_t conn_hdl)
|
||||
{
|
||||
return indicate( (uint8_t*) &num, sizeof(num));
|
||||
return indicate((uint8_t*) &num, sizeof(num), conn_hdl);
|
||||
}
|
||||
|
||||
bool BLECharacteristic::indicate16(uint16_t num)
|
||||
bool BLECharacteristic::indicate16(uint16_t num, uint16_t conn_hdl)
|
||||
{
|
||||
return indicate( (uint8_t*) &num, sizeof(num));
|
||||
return indicate((uint8_t*) &num, sizeof(num), conn_hdl);
|
||||
}
|
||||
|
||||
bool BLECharacteristic::indicate32(uint32_t num)
|
||||
bool BLECharacteristic::indicate32(uint32_t num, uint16_t conn_hdl)
|
||||
{
|
||||
return indicate( (uint8_t*) &num, sizeof(num));
|
||||
return indicate((uint8_t*) &num, sizeof(num), conn_hdl);
|
||||
}
|
||||
|
||||
bool BLECharacteristic::indicate32(int num)
|
||||
bool BLECharacteristic::indicate32(int num, uint16_t conn_hdl)
|
||||
{
|
||||
return indicate32( (uint32_t) num);
|
||||
return indicate32((uint32_t) num, conn_hdl);
|
||||
}
|
||||
@@ -74,10 +74,10 @@ class BLECharacteristic
|
||||
{
|
||||
public:
|
||||
/*--------- Callback Signatures ----------*/
|
||||
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, uint8_t* data, uint16_t len, uint16_t offset);
|
||||
typedef void (*write_cccd_cb_t) (BLECharacteristic* chr, uint16_t value);
|
||||
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_cccd_cb_t) (uint16_t conn_hdl, BLECharacteristic* chr, uint16_t value);
|
||||
|
||||
BLEUuid uuid;
|
||||
|
||||
@@ -134,28 +134,28 @@ class BLECharacteristic
|
||||
uint32_t read32(void);
|
||||
|
||||
/*------------- Notify -------------*/
|
||||
uint16_t getCccd(void);
|
||||
uint16_t getCccd(uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
|
||||
bool notifyEnabled(void);
|
||||
bool notifyEnabled(uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
|
||||
bool notify (const void* data, uint16_t len);
|
||||
bool notify (const char* str);
|
||||
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);
|
||||
|
||||
bool notify8 (uint8_t num);
|
||||
bool notify16 (uint16_t num);
|
||||
bool notify32 (uint32_t num);
|
||||
bool notify32 (int num);
|
||||
bool notify8 (uint8_t num, uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
bool notify16 (uint16_t num, uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
bool notify32 (uint32_t num, uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
bool notify32 (int num, uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
|
||||
/*------------- Indicate -------------*/
|
||||
bool indicateEnabled(void);
|
||||
bool indicateEnabled(uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
|
||||
bool indicate (const void* data, uint16_t len);
|
||||
bool indicate (const char* str);
|
||||
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);
|
||||
|
||||
bool indicate8 (uint8_t num);
|
||||
bool indicate16 (uint16_t num);
|
||||
bool indicate32 (uint32_t num);
|
||||
bool indicate32 (int num);
|
||||
bool indicate8 (uint8_t num, uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
bool indicate16 (uint16_t num, uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
bool indicate32 (uint32_t num, uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
bool indicate32 (int num, uint16_t conn_hdl = BLE_CONN_HANDLE_INVALID);
|
||||
|
||||
/*------------- Internal Functions -------------*/
|
||||
virtual void _eventHandler(ble_evt_t* event);
|
||||
|
||||
@@ -950,14 +950,14 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
|
||||
}
|
||||
}
|
||||
|
||||
// Periph event handler, skip if it is central connection
|
||||
if ( _prph_count && !(conn && (conn->getRole() == BLE_GAP_ROLE_CENTRAL)) )
|
||||
// Periph event handler (also handle generic non-connection event)
|
||||
if ( (conn == NULL) || (conn->getRole() == BLE_GAP_ROLE_PERIPH) )
|
||||
{
|
||||
Periph._eventHandler(evt);
|
||||
}
|
||||
|
||||
// Central Event Handler, skip if it is peripheral connection
|
||||
if ( _central_count && !(conn && (conn->getRole() == BLE_GAP_ROLE_PERIPH)) )
|
||||
// Central Event Handler (also handle generic non-connection event)
|
||||
if ( (conn == NULL) || (conn->getRole() == BLE_GAP_ROLE_CENTRAL) )
|
||||
{
|
||||
Central._eventHandler(evt);
|
||||
}
|
||||
|
||||
@@ -85,19 +85,18 @@ static uint16_t crc16(const uint8_t* data_p, uint8_t length)
|
||||
return crc;
|
||||
}
|
||||
|
||||
static void bledfu_control_wr_authorize_cb(BLECharacteristic* chr, ble_gatts_evt_write_t* request)
|
||||
static void bledfu_control_wr_authorize_cb(uint16_t conn_hdl, BLECharacteristic* chr, ble_gatts_evt_write_t* request)
|
||||
{
|
||||
if ( (request->handle == chr->handles().value_handle) &&
|
||||
(request->op != BLE_GATTS_OP_PREP_WRITE_REQ) &&
|
||||
(request->op != BLE_GATTS_OP_EXEC_WRITE_REQ_NOW) &&
|
||||
(request->op != BLE_GATTS_OP_EXEC_WRITE_REQ_CANCEL))
|
||||
{
|
||||
uint16_t conn_hdl = Bluefruit.connHandle();
|
||||
BLEConnection* conn = Bluefruit.Connection(conn_hdl);
|
||||
|
||||
ble_gatts_rw_authorize_reply_params_t reply = { .type = BLE_GATTS_AUTHORIZE_TYPE_WRITE };
|
||||
|
||||
if ( !chr->notifyEnabled() )
|
||||
if ( !chr->notifyEnabled(conn_hdl) )
|
||||
{
|
||||
reply.params.write.gatt_status = BLE_GATT_STATUS_ATTERR_CPS_CCCD_CONFIG_ERROR;
|
||||
sd_ble_gatts_rw_authorize_reply(conn_hdl, &reply);
|
||||
|
||||
@@ -222,8 +222,10 @@ err_t BLEHidAdafruit::begin(void)
|
||||
/* Keyboard
|
||||
*------------------------------------------------------------------*/
|
||||
|
||||
void blehid_ada_keyboard_output_cb(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, uint16_t offset)
|
||||
{
|
||||
(void) conn_hdl;
|
||||
|
||||
LOG_LV2("HID", "Keyboard LED : 0x%02X", data[0]);
|
||||
VERIFY(len == 1, );
|
||||
|
||||
|
||||
@@ -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(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, uint16_t offset);
|
||||
};
|
||||
|
||||
#endif /* BLEHIDADAFRUIT_H_ */
|
||||
@@ -130,8 +130,9 @@ void BLEHidGeneric::setOutputReportCallback(uint8_t reportID, BLECharacteristic:
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Callbacks
|
||||
*------------------------------------------------------------------*/
|
||||
void blehid_generic_protocol_mode_cb(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, uint16_t offset)
|
||||
{
|
||||
(void) conn_hdl;
|
||||
BLEHidGeneric& svc = (BLEHidGeneric&) chr->parentService();
|
||||
svc._protocol_mode = *data;
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ class BLEHidGeneric : public BLEService
|
||||
|
||||
BLECharacteristic _chr_control;
|
||||
|
||||
friend void blehid_generic_protocol_mode_cb(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, uint16_t offset);
|
||||
};
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
||||
@@ -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(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, uint16_t offset);
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* IMPLEMENTATION
|
||||
@@ -161,8 +161,9 @@ err_t BLEMidi::begin(void)
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Callbacks
|
||||
*------------------------------------------------------------------*/
|
||||
void blemidi_write_cb(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, uint16_t offset)
|
||||
{
|
||||
(void) conn_hdl;
|
||||
(void) offset;
|
||||
if ( len < 3 ) return;
|
||||
|
||||
|
||||
@@ -91,7 +91,7 @@ class BLEMidi: public BLEService, public Stream
|
||||
|
||||
void _write_handler(uint8_t* data, uint16_t len);
|
||||
|
||||
friend void blemidi_write_cb(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, uint16_t offset);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -90,8 +90,9 @@ BLEUart::~BLEUart()
|
||||
* @param len
|
||||
* @param offset
|
||||
*/
|
||||
void bleuart_rxd_cb(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, uint16_t offset)
|
||||
{
|
||||
(void) conn_hdl;
|
||||
(void) offset;
|
||||
|
||||
BLEUart& svc = (BLEUart&) chr->parentService();
|
||||
@@ -121,7 +122,7 @@ void bleuart_txd_buffered_hdlr(TimerHandle_t timer)
|
||||
(void) svc->flush_tx_buffered();
|
||||
}
|
||||
|
||||
void bleuart_txd_cccd_cb(BLECharacteristic* chr, uint16_t value)
|
||||
void bleuart_txd_cccd_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint16_t value)
|
||||
{
|
||||
BLEUart& svc = (BLEUart&) chr->parentService();
|
||||
|
||||
@@ -156,7 +157,7 @@ void BLEUart::bufferTXD(uint8_t enable)
|
||||
// enable cccd callback to start timer when enabled
|
||||
_txd.setCccdWriteCallback(bleuart_txd_cccd_cb);
|
||||
|
||||
// Create FIFO for TX TODO Larger MTU Size
|
||||
// Create FIFO for TX
|
||||
if ( _tx_fifo == NULL )
|
||||
{
|
||||
_tx_fifo = new Adafruit_FIFO(1);
|
||||
|
||||
@@ -95,8 +95,8 @@ class BLEUart : public BLEService, public Stream
|
||||
virtual void _disconnect_cb(void);
|
||||
virtual void _connect_cb(void);
|
||||
|
||||
friend void bleuart_rxd_cb(BLECharacteristic* chr, uint8_t* data, uint16_t len, uint16_t offset);
|
||||
friend void bleuart_txd_cccd_cb(BLECharacteristic* chr, uint16_t value);
|
||||
friend void bleuart_rxd_cb(uint16_t conn_hdl, BLECharacteristic* chr, uint8_t* data, uint16_t len, uint16_t offset);
|
||||
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