rename Bonded to Paired
This commit is contained in:
1 parent
108b6555a1
commit
a974333516
8 files changed
+27
-14
No files matched your search
@@ -22,6 +22,8 @@ void setup()
|
||||
Serial.println("Bluefruit52 BLE ANCS Example");
|
||||
Serial.println("----------------------------");
|
||||
|
||||
Serial.println("Go to iOS's Bluetooth settings to connect to Bluefruit");
|
||||
|
||||
Bluefruit.begin();
|
||||
Bluefruit.setName("Bluefruit52");
|
||||
Bluefruit.setConnectCallback(connect_callback);
|
||||
@@ -62,8 +64,14 @@ void loop()
|
||||
if ( bleancs.discover( Bluefruit.connHandle() ) )
|
||||
{
|
||||
Serial.println("Found it");
|
||||
Serial.println("Enable Notification Source's CCCD");
|
||||
|
||||
|
||||
// ANCS requires pairing to work, it makes sense to request security here as well
|
||||
Serial.println("Attempt to bond/pair with iOS, please press PAIR on your phone");
|
||||
if ( Bluefruit.requestPairing() )
|
||||
{
|
||||
Serial.println("Enable Notification Source's CCCD");
|
||||
bleancs.enableNotification();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -88,7 +88,7 @@ void setupAdv(void)
|
||||
void loop()
|
||||
{
|
||||
// Connected and Bonded/Paired
|
||||
if ( Bluefruit.connected() && Bluefruit.connBonded() )
|
||||
if ( Bluefruit.connected() && Bluefruit.connPaired() )
|
||||
{
|
||||
// Pin is wired to GND
|
||||
if ( digitalRead(PIN_SHUTTER) == 0 )
|
||||
|
||||
@@ -40,7 +40,7 @@ disconnect KEYWORD2
|
||||
setConnInterval KEYWORD2
|
||||
setConnIntervalMS KEYWORD2
|
||||
connHandle KEYWORD2
|
||||
connBonded KEYWORD2
|
||||
connPaired KEYWORD2
|
||||
connInterval KEYWORD2
|
||||
clearBonds KEYWORD2
|
||||
|
||||
|
||||
@@ -333,7 +333,7 @@ uint16_t AdafruitBluefruit::connHandle(void)
|
||||
return _conn_hdl;
|
||||
}
|
||||
|
||||
bool AdafruitBluefruit::connBonded(void)
|
||||
bool AdafruitBluefruit::connPaired(void)
|
||||
{
|
||||
return _bonded;
|
||||
}
|
||||
@@ -685,10 +685,18 @@ void AdafruitBluefruit::_ble_handler(ble_evt_t* evt)
|
||||
/*------------------------------------------------------------------*/
|
||||
/* Bonds
|
||||
*------------------------------------------------------------------*/
|
||||
bool AdafruitBluefruit::requestBonding(void)
|
||||
bool AdafruitBluefruit::requestPairing(void)
|
||||
{
|
||||
VERIFY_STATUS( sd_ble_gap_authenticate(_conn_hdl, &_sec_param ), false);
|
||||
return true;
|
||||
uint32_t start = millis();
|
||||
|
||||
// timeout in 30 seconds
|
||||
while ( !_bonded && (start + 30000 > millis()) )
|
||||
{
|
||||
yield();
|
||||
}
|
||||
|
||||
return _bonded;
|
||||
}
|
||||
|
||||
void AdafruitBluefruit::clearBonds(void)
|
||||
|
||||
@@ -108,10 +108,10 @@ class AdafruitBluefruit
|
||||
err_t setConnIntervalMS (uint16_t min_ms, uint16_t max_ms);
|
||||
|
||||
uint16_t connHandle (void);
|
||||
bool connBonded (void);
|
||||
bool connPaired (void);
|
||||
uint16_t connInterval (void);
|
||||
|
||||
bool requestBonding (void);
|
||||
bool requestPairing (void);
|
||||
void clearBonds (void);
|
||||
|
||||
ble_gap_addr_t peerAddr(void);
|
||||
|
||||
@@ -124,9 +124,6 @@ bool BLEAncs::discover(uint16_t conn_handle)
|
||||
|
||||
_discovered = true;
|
||||
|
||||
// ANCS requires bonding to work, it makes sense to request security here as well
|
||||
Bluefruit.requestBonding();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ static void bledfu_control_wr_authorize_cb(BLECharacteristic& chr, ble_gatts_evt
|
||||
uint16_t sysattr_len = sizeof(peer_data->sys_attr);
|
||||
sd_ble_gatts_sys_attr_get(Bluefruit.connHandle(), peer_data->sys_attr, &sysattr_len, BLE_GATTS_SYS_ATTR_FLAG_SYS_SRVCS);
|
||||
|
||||
if ( !Bluefruit.connBonded() )
|
||||
if ( !Bluefruit.connPaired() )
|
||||
{
|
||||
peer_data->addr = Bluefruit.peerAddr();
|
||||
}else
|
||||
|
||||
@@ -120,7 +120,7 @@ BLEMidi::BLEMidi(uint16_t fifo_depth)
|
||||
|
||||
bool BLEMidi::notifyEnabled(void)
|
||||
{
|
||||
return Bluefruit.connBonded() && _io.notifyEnabled();
|
||||
return Bluefruit.connPaired() && _io.notifyEnabled();
|
||||
}
|
||||
|
||||
void BLEMidi::setWriteCallback(midi_write_cb_t fp)
|
||||
|
||||
Reference in new issue
Block a user