add disconnect() to BLEConnection
This commit is contained in:
5 files changed
+15
-5
No files matched your search
@@ -104,6 +104,11 @@ uint8_t BLEConnection::getPeerAddr (uint8_t addr[6])
|
||||
return _addr.addr_type;
|
||||
}
|
||||
|
||||
bool BLEConnection::disconnect(void)
|
||||
{
|
||||
return ERROR_NONE == sd_ble_gap_disconnect(_conn_hdl, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
|
||||
}
|
||||
|
||||
bool BLEConnection::monitorRssi(uint8_t threshold)
|
||||
{
|
||||
// number of samples is 3
|
||||
|
||||
@@ -77,6 +77,8 @@ class BLEConnection
|
||||
ble_gap_addr_t getPeerAddr(void);
|
||||
uint8_t getPeerAddr(uint8_t addr[6]);
|
||||
|
||||
bool disconnect(void);
|
||||
|
||||
bool monitorRssi(uint8_t threshold = BLE_GAP_RSSI_THRESHOLD_INVALID);
|
||||
int8_t getRssi(void);
|
||||
void stopRssi(void);
|
||||
|
||||
@@ -546,12 +546,14 @@ bool AdafruitBluefruit::connected(uint16_t conn_hdl)
|
||||
return conn && conn->connected() && (conn->getRole() == BLE_GAP_ROLE_PERIPH);
|
||||
}
|
||||
|
||||
bool AdafruitBluefruit::disconnect(void)
|
||||
bool AdafruitBluefruit::disconnect(uint16_t conn_hdl)
|
||||
{
|
||||
BLEConnection* conn = Gap.Connection(conn_hdl);
|
||||
|
||||
// disconnect if connected
|
||||
if ( connected() )
|
||||
if ( conn && conn->connected() )
|
||||
{
|
||||
return ERROR_NONE == sd_ble_gap_disconnect(_conn_hdl, BLE_HCI_REMOTE_USER_TERMINATED_CONNECTION);
|
||||
return conn->disconnect();
|
||||
}
|
||||
|
||||
return true; // not connected still return true
|
||||
|
||||
@@ -151,7 +151,8 @@ class AdafruitBluefruit
|
||||
*------------------------------------------------------------------*/
|
||||
uint8_t connected (void); // Number of connected central
|
||||
bool connected (uint16_t conn_hdl); // connected to a specific central
|
||||
bool disconnect (void);
|
||||
|
||||
bool disconnect (uint16_t conn_hdl);
|
||||
|
||||
uint16_t connHandle (void);
|
||||
bool connPaired (void);
|
||||
|
||||
@@ -155,7 +155,7 @@ static void bledfu_control_wr_authorize_cb(BLECharacteristic* chr, ble_gatts_evt
|
||||
|
||||
// Initiate DFU Sequence and reboot into DFU OTA mode
|
||||
Bluefruit.Advertising.restartOnDisconnect(false);
|
||||
Bluefruit.disconnect();
|
||||
conn->disconnect();
|
||||
|
||||
// Set GPReset to DFU OTA
|
||||
enum { DFU_OTA_MAGIC = 0xB1 };
|
||||
|
||||
Reference in new issue
Block a user