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)
174174 Serial.println (" Advertising!" );
175175}
176176
177- void cccd_callback (BLECharacteristic& chr, ble_gatts_evt_write_t * request )
177+ void cccd_callback (BLECharacteristic& chr, uint16_t cccd_value )
178178{
179- (void ) request;
180-
181179 // Display the raw request packet
182180 Serial.print (" CCCD Updated: " );
183- Serial.printBuffer (request->data , request->len );
181+ // Serial.printBuffer(request->data, request->len);
182+ Serial.print (cccd_value);
184183 Serial.println (" " );
185184
186185 // 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)
138138 _wr_cb = fp;
139139}
140140
141- void BLECharacteristic::setCccdWriteCallback (write_cb_t fp)
141+ void BLECharacteristic::setCccdWriteCallback (write_cccd_cb_t fp)
142142{
143143 _cccd_wr_cb = fp;
144144}
@@ -334,7 +334,9 @@ void BLECharacteristic::eventHandler(ble_evt_t* event)
334334 // CCCD write
335335 if ( _cccd_wr_cb && (request->handle == _handles.cccd_handle ) )
336336 {
337- _cccd_wr_cb (*this , request);
337+ uint16_t value;
338+ memcpy (&value, request->data , 2 );
339+ _cccd_wr_cb (*this , value);
338340 }
339341 }
340342 break ;
Original file line number Diff line number Diff line change @@ -75,6 +75,7 @@ class BLECharacteristic
7575 typedef void (*read_authorize_cb_t ) (BLECharacteristic& chr, ble_gatts_evt_read_t * request);
7676 typedef void (*write_authorize_cb_t ) (BLECharacteristic& chr, ble_gatts_evt_write_t * request);
7777 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);
7879
7980 protected:
8081 bool _is_temp;
@@ -101,7 +102,7 @@ class BLECharacteristic
101102 write_authorize_cb_t _wr_authorize_cb;
102103
103104 write_cb_t _wr_cb;
104- write_cb_t _cccd_wr_cb;
105+ write_cccd_cb_t _cccd_wr_cb;
105106
106107 void init (void );
107108 void eventHandler (ble_evt_t * event);
@@ -137,7 +138,7 @@ class BLECharacteristic
137138
138139 // Callback
139140 void setWriteCallback (write_cb_t fp);
140- void setCccdWriteCallback (write_cb_t fp);
141+ void setCccdWriteCallback (write_cccd_cb_t fp);
141142
142143 void setReadAuthorizeCallback (read_authorize_cb_t fp);
143144 void setWriteAuthorizeCallbak (write_authorize_cb_t fp);
You can’t perform that action at this time.
0 commit comments