change signature of cccd write callback
This commit is contained in:
1 parent
2bf4a57bee
commit
50d703503e
3 files changed
+10
-8
No files matched your search
@@ -174,13 +174,12 @@ void disconnect_callback(uint8_t reason)
|
||||
Serial.println("Advertising!");
|
||||
}
|
||||
|
||||
void cccd_callback(BLECharacteristic& chr, ble_gatts_evt_write_t* request)
|
||||
void cccd_callback(BLECharacteristic& chr, uint16_t cccd_value)
|
||||
{
|
||||
(void) request;
|
||||
|
||||
// Display the raw request packet
|
||||
Serial.print("CCCD Updated: ");
|
||||
Serial.printBuffer(request->data, request->len);
|
||||
//Serial.printBuffer(request->data, request->len);
|
||||
Serial.print(cccd_value);
|
||||
Serial.println("");
|
||||
|
||||
// Check the characteristic this CCCD update is associated with in case
|
||||
|
||||
@@ -138,7 +138,7 @@ void BLECharacteristic::setWriteCallback(write_cb_t fp)
|
||||
_wr_cb = fp;
|
||||
}
|
||||
|
||||
void BLECharacteristic::setCccdWriteCallback(write_cb_t fp)
|
||||
void BLECharacteristic::setCccdWriteCallback(write_cccd_cb_t fp)
|
||||
{
|
||||
_cccd_wr_cb = fp;
|
||||
}
|
||||
@@ -334,7 +334,9 @@ void BLECharacteristic::eventHandler(ble_evt_t* event)
|
||||
// CCCD write
|
||||
if ( _cccd_wr_cb && (request->handle == _handles.cccd_handle) )
|
||||
{
|
||||
_cccd_wr_cb(*this, request);
|
||||
uint16_t value;
|
||||
memcpy(&value, request->data, 2);
|
||||
_cccd_wr_cb(*this, value);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -75,6 +75,7 @@ class BLECharacteristic
|
||||
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_cccd_cb_t) (BLECharacteristic& chr, uint16_t value);
|
||||
|
||||
protected:
|
||||
bool _is_temp;
|
||||
@@ -101,7 +102,7 @@ class BLECharacteristic
|
||||
write_authorize_cb_t _wr_authorize_cb;
|
||||
|
||||
write_cb_t _wr_cb;
|
||||
write_cb_t _cccd_wr_cb;
|
||||
write_cccd_cb_t _cccd_wr_cb;
|
||||
|
||||
void init(void);
|
||||
void eventHandler(ble_evt_t* event);
|
||||
@@ -137,7 +138,7 @@ class BLECharacteristic
|
||||
|
||||
// Callback
|
||||
void setWriteCallback(write_cb_t fp);
|
||||
void setCccdWriteCallback(write_cb_t fp);
|
||||
void setCccdWriteCallback(write_cccd_cb_t fp);
|
||||
|
||||
void setReadAuthorizeCallback(read_authorize_cb_t fp);
|
||||
void setWriteAuthorizeCallbak(write_authorize_cb_t fp);
|
||||
|
||||
Reference in new issue
Block a user