File tree Expand file tree Collapse file tree 6 files changed +32
-17
lines changed Expand file tree Collapse file tree 6 files changed +32
-17
lines changed Original file line number Diff line number Diff line change @@ -32,15 +32,26 @@ void setup()
32
32
33
33
void scan_callback (ble_gap_evt_adv_report_t * report)
34
34
{
35
- Serial.print (" Scan data: " );
35
+ Serial.println (" Timestamp Addr Rssi Data" );
36
+
37
+ Serial.printf (" %09d " , millis ());
38
+
39
+ Serial.printBuffer (report->peer_addr .addr , 6 , ' :' );
40
+ Serial.print (" " );
41
+
42
+ Serial.print (report->rssi );
43
+ Serial.print (" " );
44
+
36
45
Serial.printBuffer (report->data , report->dlen , ' -' );
37
46
Serial.println ();
38
47
39
48
// Check if advertising contain BleUart service
40
49
if ( Bluefruit.Central .checkUuidInScan (report, BLEUART_UUID_SERVICE) )
41
50
{
42
- Serial.println (" BLE UART service detected" );
51
+ Serial.println (" BLE UART service detected" );
43
52
}
53
+
54
+ Serial.println ();
44
55
}
45
56
46
57
void loop ()
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);
Original file line number Diff line number Diff line change @@ -104,7 +104,7 @@ AdafruitBluefruit::AdafruitBluefruit(void)
104
104
_bonded = false ;
105
105
106
106
_auth_type = BLE_GAP_AUTH_KEY_TYPE_NONE;
107
- varclr (_pin);
107
+ // varclr(_pin);
108
108
109
109
_chars_count = 0 ;
110
110
for (uint8_t i=0 ; i<BLE_MAX_CHARS; i++) _chars_list[i] = NULL ;
@@ -480,6 +480,7 @@ bool AdafruitBluefruit::txbuf_get(uint32_t ms)
480
480
return xSemaphoreTake (_txbuf_sem, ms2tick (ms));
481
481
}
482
482
483
+ #if 0
483
484
bool AdafruitBluefruit::setPIN(const char* pin)
484
485
{
485
486
VERIFY ( strlen(pin) == BLE_GAP_PASSKEY_LEN );
@@ -496,6 +497,7 @@ bool AdafruitBluefruit::setPIN(const char* pin)
496
497
497
498
return true;
498
499
}
500
+ #endif
499
501
500
502
err_t AdafruitBluefruit::_saveBondedCCCD (void )
501
503
{
@@ -750,10 +752,10 @@ void AdafruitBluefruit::_poll(void)
750
752
751
753
case BLE_GAP_EVT_PASSKEY_DISPLAY:
752
754
{
753
- ble_gap_evt_passkey_display_t const * passkey_display = &evt->evt .gap_evt .params .passkey_display ;
754
-
755
- PRINT_INT (passkey_display->match_request );
756
- PRINT_BUFFER (passkey_display->passkey , 6 );
755
+ // ble_gap_evt_passkey_display_t const* passkey_display = &evt->evt.gap_evt.params.passkey_display;
756
+ //
757
+ // PRINT_INT(passkey_display->match_request);
758
+ // PRINT_BUFFER(passkey_display->passkey, 6);
757
759
758
760
// sd_ble_gap_auth_key_reply
759
761
}
Original file line number Diff line number Diff line change @@ -118,7 +118,7 @@ class AdafruitBluefruit
118
118
119
119
bool txbuf_get (uint32_t ms);
120
120
121
- bool setPIN (const char * pin);
121
+ // bool setPIN(const char* pin);
122
122
123
123
/* ------------------------------------------------------------------*/
124
124
/* Central API object
@@ -166,7 +166,7 @@ class AdafruitBluefruit
166
166
bool _bonded;
167
167
168
168
uint8_t _auth_type;
169
- char _pin[BLE_GAP_PASSKEY_LEN];
169
+ // char _pin[BLE_GAP_PASSKEY_LEN];
170
170
171
171
// TODO move to bonding place
172
172
public: // temporary
You can’t perform that action at this time.
0 commit comments