BLEGapConnection paired()
This commit is contained in:
4 files changed
+12
-19
No files matched your search
@@ -147,11 +147,6 @@ bool BLEGap::connected(uint16_t conn_hdl)
|
||||
return _connection[conn_hdl] != NULL;
|
||||
}
|
||||
|
||||
bool BLEGap::paired(uint16_t conn_hdl)
|
||||
{
|
||||
return _connection[conn_hdl]->paired;
|
||||
}
|
||||
|
||||
bool BLEGap::requestPairing(uint16_t conn_hdl)
|
||||
{
|
||||
gap_peer_t* peer = &_peers[conn_hdl];
|
||||
@@ -159,7 +154,7 @@ bool BLEGap::requestPairing(uint16_t conn_hdl)
|
||||
VERIFY(conn);
|
||||
|
||||
// skip if already paired
|
||||
if ( conn->paired ) return true;
|
||||
if ( conn->_paired ) return true;
|
||||
|
||||
uint16_t cntr_ediv = 0xFFFF;
|
||||
|
||||
@@ -190,7 +185,7 @@ bool BLEGap::requestPairing(uint16_t conn_hdl)
|
||||
|
||||
// Failed to pair using central stored keys, this happens when
|
||||
// Prph delete bonds while we did not --> let's remove the obsolete keyfile and move on
|
||||
if ( !conn->paired && (cntr_ediv != 0xffff) )
|
||||
if ( !conn->_paired && (cntr_ediv != 0xffff) )
|
||||
{
|
||||
bond_remove_key(BLE_GAP_ROLE_CENTRAL, cntr_ediv);
|
||||
|
||||
@@ -203,7 +198,7 @@ bool BLEGap::requestPairing(uint16_t conn_hdl)
|
||||
vSemaphoreDelete(conn->pair_sem);
|
||||
conn->pair_sem = NULL;
|
||||
|
||||
return conn->paired;
|
||||
return conn->_paired;
|
||||
}
|
||||
|
||||
uint8_t BLEGap::getRole(uint16_t conn_hdl)
|
||||
@@ -379,7 +374,7 @@ void BLEGap::_eventHandler(ble_evt_t* evt)
|
||||
// Pairing succeeded --> save encryption keys ( Bonding )
|
||||
if (BLE_GAP_SEC_STATUS_SUCCESS == status->auth_status)
|
||||
{
|
||||
conn->paired = true;
|
||||
conn->_paired = true;
|
||||
conn->ediv = conn->bond_keys->own_enc.master_id.ediv;
|
||||
|
||||
bond_save_keys(conn->role, conn_hdl, conn->bond_keys);
|
||||
@@ -430,7 +425,7 @@ void BLEGap::_eventHandler(ble_evt_t* evt)
|
||||
sd_ble_gatts_sys_attr_set(conn_hdl, NULL, 0, 0);
|
||||
}
|
||||
|
||||
conn->paired = true;
|
||||
conn->_paired = true;
|
||||
}
|
||||
|
||||
if (conn->pair_sem) xSemaphoreGive(conn->pair_sem);
|
||||
|
||||
@@ -55,11 +55,9 @@ class BLEGapConnection
|
||||
public:
|
||||
ble_gap_addr_t _addr;
|
||||
uint16_t att_mtu;
|
||||
bool paired;
|
||||
bool _paired;
|
||||
uint8_t role;
|
||||
|
||||
SemaphoreHandle_t pair_sem;
|
||||
|
||||
SemaphoreHandle_t hvn_tx_sem;
|
||||
SemaphoreHandle_t wrcmd_tx_sem;
|
||||
|
||||
@@ -67,14 +65,16 @@ class BLEGapConnection
|
||||
SemaphoreHandle_t hvc_sem;
|
||||
bool hvc_received;
|
||||
|
||||
SemaphoreHandle_t pair_sem;
|
||||
|
||||
uint16_t ediv;
|
||||
bond_keys_t* bond_keys; // Shared keys with bonded device, size ~ 80 bytes
|
||||
|
||||
BLEGapConnection(void) { _conn_hdl = BLE_CONN_HANDLE_INVALID; }
|
||||
BLEGapConnection(uint16_t conn_hdl) { _conn_hdl = conn_hdl; }
|
||||
|
||||
uint16_t handle(void) { return _conn_hdl; }
|
||||
bool connected(void);
|
||||
bool paired(void) { return _paired; }
|
||||
uint8_t getRole(void);
|
||||
|
||||
uint16_t getMTU (void)
|
||||
@@ -120,15 +120,13 @@ class BLEGap
|
||||
|
||||
BLEGapConnection* getConnection(uint16_t conn_hdl)
|
||||
{
|
||||
return _connection[conn_hdl];
|
||||
return ( conn_hdl != BLE_CONN_HANDLE_INVALID ) ?_connection[conn_hdl] : NULL;
|
||||
}
|
||||
|
||||
bool connected (uint16_t conn_hdl);
|
||||
bool paired (uint16_t conn_hdl);
|
||||
bool requestPairing (uint16_t conn_hdl);
|
||||
|
||||
uint8_t getRole (uint16_t conn_hdl);
|
||||
|
||||
uint16_t getPeerName (uint16_t conn_hdl, char* buf, uint16_t bufsize);
|
||||
|
||||
uint16_t getMaxMtuByConnCfg (uint8_t conn_cfg);
|
||||
|
||||
@@ -603,7 +603,7 @@ uint16_t AdafruitBluefruit::connHandle(void)
|
||||
|
||||
bool AdafruitBluefruit::connPaired(void)
|
||||
{
|
||||
return ( _conn_hdl != BLE_CONN_HANDLE_INVALID ) && Gap.paired(_conn_hdl);
|
||||
return ( _conn_hdl != BLE_CONN_HANDLE_INVALID ) && Gap.getConnection(_conn_hdl)->paired();
|
||||
}
|
||||
|
||||
uint16_t AdafruitBluefruit::connInterval(void)
|
||||
|
||||
@@ -139,7 +139,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 = conn->getPeerAddr();
|
||||
|
||||
if ( Bluefruit.Gap.paired(conn_hdl) )
|
||||
if ( conn->paired() )
|
||||
{
|
||||
bond_keys_t bkeys;
|
||||
|
||||
|
||||
Reference in new issue
Block a user