Merge branch 'master' of github.com:adafruit/Adafruit_nRF52_Arduino
This commit is contained in:
commit
84553d50c7
6 files changed
+32
-17
No files matched your search
@@ -32,15 +32,26 @@ void setup()
|
||||
|
||||
void scan_callback(ble_gap_evt_adv_report_t* report)
|
||||
{
|
||||
Serial.print("Scan data: ");
|
||||
Serial.println("Timestamp Addr Rssi Data");
|
||||
|
||||
Serial.printf("%09d ", millis());
|
||||
|
||||
Serial.printBuffer(report->peer_addr.addr, 6, ':');
|
||||
Serial.print(" ");
|
||||
|
||||
Serial.print(report->rssi);
|
||||
Serial.print(" ");
|
||||
|
||||
Serial.printBuffer(report->data, report->dlen, '-');
|
||||
Serial.println();
|
||||
|
||||
// Check if advertising contain BleUart service
|
||||
if ( Bluefruit.Central.checkUuidInScan(report, BLEUART_UUID_SERVICE) )
|
||||
{
|
||||
Serial.println("BLE UART service detected");
|
||||
Serial.println(" BLE UART service detected");
|
||||
}
|
||||
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void loop()
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -104,7 +104,7 @@ AdafruitBluefruit::AdafruitBluefruit(void)
|
||||
_bonded = false;
|
||||
|
||||
_auth_type = BLE_GAP_AUTH_KEY_TYPE_NONE;
|
||||
varclr(_pin);
|
||||
// varclr(_pin);
|
||||
|
||||
_chars_count = 0;
|
||||
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)
|
||||
return xSemaphoreTake(_txbuf_sem, ms2tick(ms));
|
||||
}
|
||||
|
||||
#if 0
|
||||
bool AdafruitBluefruit::setPIN(const char* pin)
|
||||
{
|
||||
VERIFY ( strlen(pin) == BLE_GAP_PASSKEY_LEN );
|
||||
@@ -496,6 +497,7 @@ bool AdafruitBluefruit::setPIN(const char* pin)
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
err_t AdafruitBluefruit::_saveBondedCCCD(void)
|
||||
{
|
||||
@@ -750,10 +752,10 @@ void AdafruitBluefruit::_poll(void)
|
||||
|
||||
case BLE_GAP_EVT_PASSKEY_DISPLAY:
|
||||
{
|
||||
ble_gap_evt_passkey_display_t const* passkey_display = &evt->evt.gap_evt.params.passkey_display;
|
||||
|
||||
PRINT_INT(passkey_display->match_request);
|
||||
PRINT_BUFFER(passkey_display->passkey, 6);
|
||||
// ble_gap_evt_passkey_display_t const* passkey_display = &evt->evt.gap_evt.params.passkey_display;
|
||||
//
|
||||
// PRINT_INT(passkey_display->match_request);
|
||||
// PRINT_BUFFER(passkey_display->passkey, 6);
|
||||
|
||||
// sd_ble_gap_auth_key_reply
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ class AdafruitBluefruit
|
||||
|
||||
bool txbuf_get(uint32_t ms);
|
||||
|
||||
bool setPIN(const char* pin);
|
||||
// bool setPIN(const char* pin);
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Central API object
|
||||
@@ -166,7 +166,7 @@ class AdafruitBluefruit
|
||||
bool _bonded;
|
||||
|
||||
uint8_t _auth_type;
|
||||
char _pin[BLE_GAP_PASSKEY_LEN];
|
||||
// char _pin[BLE_GAP_PASSKEY_LEN];
|
||||
|
||||
// TODO move to bonding place
|
||||
public: // temporary
|
||||
|
||||
Reference in new issue
Block a user