bleconnection clean up
This commit is contained in:
6 files changed
+13
-22
No files matched your search
@@ -638,7 +638,7 @@ bool BLECharacteristic::indicate(const void* data, uint16_t len)
|
||||
|
||||
// Blocking wait until receiving confirmation from peer
|
||||
VERIFY_STATUS( sd_ble_gatts_hvx( conn_hdl, &hvx_params), false );
|
||||
VERIFY ( Bluefruit.Gatt.waitForIndicateConfirm(conn_hdl) );
|
||||
VERIFY ( conn->waitForIndicateConfirm() );
|
||||
|
||||
remaining -= packet_len;
|
||||
u8data += packet_len;
|
||||
|
||||
@@ -108,12 +108,12 @@ bool BLEConnection::getWriteCmdPacket (void)
|
||||
return xSemaphoreTake(_wrcmd_sem, ms2tick(BLE_GENERIC_TIMEOUT));
|
||||
}
|
||||
|
||||
bool BLEConnection::_storeCccd(void)
|
||||
bool BLEConnection::storeCccd(void)
|
||||
{
|
||||
return bond_save_cccd( _role, _conn_hdl, _ediv);
|
||||
}
|
||||
|
||||
bool BLEConnection::_loadKeys(bond_keys_t* bkeys)
|
||||
bool BLEConnection::loadKeys(bond_keys_t* bkeys)
|
||||
{
|
||||
return bond_load_keys(_role, _ediv, bkeys);
|
||||
}
|
||||
|
||||
@@ -47,16 +47,16 @@ class BLEConnection
|
||||
uint16_t _conn_hdl;
|
||||
uint16_t _mtu;
|
||||
uint16_t _conn_interval;
|
||||
ble_gap_addr_t _addr;
|
||||
uint16_t _ediv;
|
||||
uint8_t _role;
|
||||
bool _paired;
|
||||
bool _hvc_received;
|
||||
|
||||
ble_gap_addr_t _addr;
|
||||
|
||||
SemaphoreHandle_t _hvn_sem;
|
||||
SemaphoreHandle_t _wrcmd_sem;
|
||||
|
||||
uint16_t _ediv;
|
||||
bool _paired;
|
||||
bool _hvc_received;
|
||||
|
||||
// On-demand semaphore/data that are created on the fly
|
||||
SemaphoreHandle_t _hvc_sem;
|
||||
|
||||
@@ -79,10 +79,11 @@ class BLEConnection
|
||||
|
||||
bool getHvnPacket(void);
|
||||
bool getWriteCmdPacket(void);
|
||||
|
||||
bool requestPairing(void);
|
||||
bool waitForIndicateConfirm(void);
|
||||
|
||||
bool requestPairing(void);
|
||||
bool storeCccd(void);
|
||||
bool loadKeys(bond_keys_t* bkeys);
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* INTERNAL USAGE ONLY
|
||||
@@ -90,8 +91,6 @@ class BLEConnection
|
||||
*------------------------------------------------------------------*/
|
||||
void _eventHandler(ble_evt_t* evt);
|
||||
|
||||
bool _storeCccd(void);
|
||||
bool _loadKeys(bond_keys_t* bkeys);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -75,12 +75,6 @@ uint16_t BLEGatt::readCharByUuid(uint16_t conn_hdl, BLEUuid bleuuid, void* buffe
|
||||
return (count < 0) ? 0 : count;
|
||||
}
|
||||
|
||||
bool BLEGatt::waitForIndicateConfirm(uint16_t conn_hdl)
|
||||
{
|
||||
BLEConnection* conn = Bluefruit.Gap.getConnection(conn_hdl);
|
||||
return conn->waitForIndicateConfirm();
|
||||
}
|
||||
|
||||
void BLEGatt::_eventHandler(ble_evt_t* evt)
|
||||
{
|
||||
// conn handle has fixed offset regardless of event type
|
||||
@@ -139,7 +133,7 @@ void BLEGatt::_eventHandler(ble_evt_t* evt)
|
||||
// Save CCCD if paired
|
||||
if ( conn->paired() && (evt_id == BLE_GATTS_EVT_WRITE) && (req_handle == chr->handles().cccd_handle) )
|
||||
{
|
||||
conn->_storeCccd();
|
||||
conn->storeCccd();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,8 +60,6 @@ class BLEGatt
|
||||
|
||||
uint16_t readCharByUuid(uint16_t conn_hdl, BLEUuid bleuuid, void* buffer, uint16_t bufsize, uint16_t start_hdl = 1, uint16_t end_hdl = 0xffff);
|
||||
|
||||
bool waitForIndicateConfirm(uint16_t conn_hdl);
|
||||
|
||||
/*------------------------------------------------------------------*/
|
||||
/* INTERNAL USAGE ONLY
|
||||
* Although declare as public, it is meant to be invoked by internal
|
||||
|
||||
@@ -143,7 +143,7 @@ static void bledfu_control_wr_authorize_cb(BLECharacteristic& chr, ble_gatts_evt
|
||||
{
|
||||
bond_keys_t bkeys;
|
||||
|
||||
if ( conn->_loadKeys(&bkeys) )
|
||||
if ( conn->loadKeys(&bkeys) )
|
||||
{
|
||||
peer_data->addr = bkeys.peer_id.id_addr_info;
|
||||
peer_data->irk = bkeys.peer_id.id_info;
|
||||
|
||||
Reference in new issue
Block a user