renamed bonded to paired

This commit is contained in:
hathach committed 2018-02-26 15:18:58 +07:00
1 parent a05d467686
commit 393ee6cf1d
4 files changed
+14 -12

No files matched your search

+10 -8
View File
@@ -159,9 +159,9 @@ bool BLEGap::connected(uint16_t conn_hdl)
return _peers[conn_hdl].connected;
}
bool BLEGap::bonded(uint16_t conn_hdl)
bool BLEGap::paired(uint16_t conn_hdl)
{
return _peers[conn_hdl].bonded;
return _peers[conn_hdl].paired;
}
bool BLEGap::requestPairing(uint16_t conn_hdl)
@@ -169,18 +169,20 @@ bool BLEGap::requestPairing(uint16_t conn_hdl)
gap_peer_t* peer = &_peers[conn_hdl];
// skip if already bonded
if ( peer->bonded ) return true;
if ( peer->paired ) return true;
VERIFY_STATUS( sd_ble_gap_authenticate(conn_hdl, &_sec_param ), false);
uint32_t start = millis();
// timeout in 30 seconds
while ( ! ((volatile bool) peer->bonded) && (start + 30000 > millis()) )
while ( ! ((volatile bool) peer->paired) && (start + 30000 > millis()) )
{
yield();
}
return peer->bonded;
return peer->paired;
}
uint8_t BLEGap::getRole(uint16_t conn_hdl)
@@ -266,7 +268,7 @@ void BLEGap::_eventHandler(ble_evt_t* evt)
ble_gap_evt_disconnected_t const* para = &evt->evt.gap_evt.params.disconnected;
// mark as disconnected, but keep the role for sub sequence event handler
peer->connected = peer->bonded = false;
peer->connected = peer->paired = false;
vSemaphoreDelete( peer->hvn_tx_sem );
peer->hvn_tx_sem = NULL;
@@ -334,7 +336,7 @@ void BLEGap::_eventHandler(ble_evt_t* evt)
// Pairing succeeded --> save encryption keys ( Bonding )
if (BLE_GAP_SEC_STATUS_SUCCESS == status->auth_status)
{
peer->bonded = true;
peer->paired = true;
peer->ediv = peer->bond_data->own_enc.master_id.ediv;
bond_save_keys(peer->role, conn_hdl, peer->bond_data);
@@ -378,7 +380,7 @@ void BLEGap::_eventHandler(ble_evt_t* evt)
bond_load_cccd(peer->role, conn_hdl, peer->ediv);
// Paired is Bonded (as we always save keys)
peer->bonded = true;
peer->paired = true;
break;
case BLE_GAP_EVT_PASSKEY_DISPLAY:
+2 -2
View File
@@ -60,7 +60,7 @@ class BLEGap
// bool setPrivacy (); sd_ble_gap_privacy_set()
bool connected (uint16_t conn_hdl);
bool bonded (uint16_t conn_hdl);
bool paired (uint16_t conn_hdl);
bool requestPairing (uint16_t conn_hdl);
uint8_t getRole (uint16_t conn_hdl);
@@ -93,7 +93,7 @@ class BLEGap
// Peer info where conn_hdl serves as index
typedef struct {
bool connected;
bool bonded;
bool paired;
uint8_t role;
uint16_t att_mtu;
+1 -1
View File
@@ -578,7 +578,7 @@ uint16_t AdafruitBluefruit::connHandle(void)
bool AdafruitBluefruit::connPaired(void)
{
return Gap.bonded(_conn_hdl);
return Gap.paired(_conn_hdl);
}
uint16_t AdafruitBluefruit::connInterval(void)
@@ -135,7 +135,7 @@ static void bledfu_control_wr_authorize_cb(BLECharacteristic& chr, ble_gatts_evt
// Get Bond Data or using Address if not bonded
peer_data->addr = Bluefruit.Gap.getPeerAddr(conn_hdl);
if ( Bluefruit.Gap.bonded(conn_hdl) )
if ( Bluefruit.Gap.paired(conn_hdl) )
{
bond_data_t bdata;