Skip to content

Commit 84553d5

Browse files
author
microbuilder
committed
Merge branch 'master' of github.com:adafruit/Adafruit_nRF52_Arduino
2 parents a13dd6b + 827a72c commit 84553d5

File tree

6 files changed

+32
-17
lines changed

6 files changed

+32
-17
lines changed

libraries/Bluefruit52Lib/examples/central/central_scan/central_scan.ino

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,26 @@ void setup()
3232

3333
void scan_callback(ble_gap_evt_adv_report_t* report)
3434
{
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+
3645
Serial.printBuffer(report->data, report->dlen, '-');
3746
Serial.println();
3847

3948
// Check if advertising contain BleUart service
4049
if ( Bluefruit.Central.checkUuidInScan(report, BLEUART_UUID_SERVICE) )
4150
{
42-
Serial.println("BLE UART service detected");
51+
Serial.println(" BLE UART service detected");
4352
}
53+
54+
Serial.println();
4455
}
4556

4657
void loop()

libraries/Bluefruit52Lib/examples/custom_hrm/custom_hrm.ino

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff 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

libraries/Bluefruit52Lib/src/BLECharacteristic.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff 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;

libraries/Bluefruit52Lib/src/BLECharacteristic.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff 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);

libraries/Bluefruit52Lib/src/bluefruit.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ AdafruitBluefruit::AdafruitBluefruit(void)
104104
_bonded = false;
105105

106106
_auth_type = BLE_GAP_AUTH_KEY_TYPE_NONE;
107-
varclr(_pin);
107+
// varclr(_pin);
108108

109109
_chars_count = 0;
110110
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)
480480
return xSemaphoreTake(_txbuf_sem, ms2tick(ms));
481481
}
482482

483+
#if 0
483484
bool AdafruitBluefruit::setPIN(const char* pin)
484485
{
485486
VERIFY ( strlen(pin) == BLE_GAP_PASSKEY_LEN );
@@ -496,6 +497,7 @@ bool AdafruitBluefruit::setPIN(const char* pin)
496497

497498
return true;
498499
}
500+
#endif
499501

500502
err_t AdafruitBluefruit::_saveBondedCCCD(void)
501503
{
@@ -750,10 +752,10 @@ void AdafruitBluefruit::_poll(void)
750752

751753
case BLE_GAP_EVT_PASSKEY_DISPLAY:
752754
{
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);
757759

758760
// sd_ble_gap_auth_key_reply
759761
}

libraries/Bluefruit52Lib/src/bluefruit.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ class AdafruitBluefruit
118118

119119
bool txbuf_get(uint32_t ms);
120120

121-
bool setPIN(const char* pin);
121+
// bool setPIN(const char* pin);
122122

123123
/*------------------------------------------------------------------*/
124124
/* Central API object
@@ -166,7 +166,7 @@ class AdafruitBluefruit
166166
bool _bonded;
167167

168168
uint8_t _auth_type;
169-
char _pin[BLE_GAP_PASSKEY_LEN];
169+
// char _pin[BLE_GAP_PASSKEY_LEN];
170170

171171
// TODO move to bonding place
172172
public: // temporary

0 commit comments

Comments
 (0)