File tree Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Expand file tree Collapse file tree 3 files changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -174,13 +174,12 @@ void disconnect_callback(uint8_t reason)
174
174
Serial.println (" Advertising!" );
175
175
}
176
176
177
- void cccd_callback (BLECharacteristic& chr, ble_gatts_evt_write_t * request )
177
+ void cccd_callback (BLECharacteristic& chr, uint16_t cccd_value )
178
178
{
179
- (void ) request;
180
-
181
179
// Display the raw request packet
182
180
Serial.print (" CCCD Updated: " );
183
- Serial.printBuffer (request->data , request->len );
181
+ // Serial.printBuffer(request->data, request->len);
182
+ Serial.print (cccd_value);
184
183
Serial.println (" " );
185
184
186
185
// Check the characteristic this CCCD update is associated with in case
Original file line number Diff line number Diff line change @@ -138,7 +138,7 @@ void BLECharacteristic::setWriteCallback(write_cb_t fp)
138
138
_wr_cb = fp;
139
139
}
140
140
141
- void BLECharacteristic::setCccdWriteCallback (write_cb_t fp)
141
+ void BLECharacteristic::setCccdWriteCallback (write_cccd_cb_t fp)
142
142
{
143
143
_cccd_wr_cb = fp;
144
144
}
@@ -334,7 +334,9 @@ void BLECharacteristic::eventHandler(ble_evt_t* event)
334
334
// CCCD write
335
335
if ( _cccd_wr_cb && (request->handle == _handles.cccd_handle ) )
336
336
{
337
- _cccd_wr_cb (*this , request);
337
+ uint16_t value;
338
+ memcpy (&value, request->data , 2 );
339
+ _cccd_wr_cb (*this , value);
338
340
}
339
341
}
340
342
break ;
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ class BLECharacteristic
75
75
typedef void (*read_authorize_cb_t ) (BLECharacteristic& chr, ble_gatts_evt_read_t * request);
76
76
typedef void (*write_authorize_cb_t ) (BLECharacteristic& chr, ble_gatts_evt_write_t * request);
77
77
typedef void (*write_cb_t ) (BLECharacteristic& chr, ble_gatts_evt_write_t * request);
78
+ typedef void (*write_cccd_cb_t ) (BLECharacteristic& chr, uint16_t value);
78
79
79
80
protected:
80
81
bool _is_temp;
@@ -101,7 +102,7 @@ class BLECharacteristic
101
102
write_authorize_cb_t _wr_authorize_cb;
102
103
103
104
write_cb_t _wr_cb;
104
- write_cb_t _cccd_wr_cb;
105
+ write_cccd_cb_t _cccd_wr_cb;
105
106
106
107
void init (void );
107
108
void eventHandler (ble_evt_t * event);
@@ -137,7 +138,7 @@ class BLECharacteristic
137
138
138
139
// Callback
139
140
void setWriteCallback (write_cb_t fp);
140
- void setCccdWriteCallback (write_cb_t fp);
141
+ void setCccdWriteCallback (write_cccd_cb_t fp);
141
142
142
143
void setReadAuthorizeCallback (read_authorize_cb_t fp);
143
144
void setWriteAuthorizeCallbak (write_authorize_cb_t fp);
You can’t perform that action at this time.
0 commit comments