mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-12-24 19:50:47 +01:00
Add NimBLEClient::cancelConnect
Adds a function to cancel and in-progress connection.
This commit is contained in:
parent
38e764d157
commit
65e05e6c57
2 changed files with 16 additions and 0 deletions
|
@ -369,6 +369,21 @@ bool NimBLEClient::disconnect(uint8_t reason) {
|
|||
return true;
|
||||
} // disconnect
|
||||
|
||||
/**
|
||||
* @brief Cancel an ongoing connection attempt.
|
||||
* @return True if the command was successfully sent.
|
||||
*/
|
||||
bool NimBLEClient::cancelConnect() {
|
||||
int rc = ble_gap_conn_cancel();
|
||||
if (rc != 0 && rc != BLE_HS_EALREADY) {
|
||||
NIMBLE_LOGE(LOG_TAG, "ble_gap_conn_cancel failed: rc=%d %s", rc, NimBLEUtils::returnCodeToString(rc));
|
||||
m_lastErr = rc;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
} // cancelConnect
|
||||
|
||||
# if CONFIG_BT_NIMBLE_EXT_ADV
|
||||
/**
|
||||
* @brief Set the PHY types to use when connecting to a server.
|
||||
|
|
|
@ -51,6 +51,7 @@ class NimBLEClient {
|
|||
bool connect(const NimBLEAddress& address, bool deleteAttributes = true, bool asyncConnect = false, bool exchangeMTU = true);
|
||||
bool connect(bool deleteAttributes = true, bool asyncConnect = false, bool exchangeMTU = true);
|
||||
bool disconnect(uint8_t reason = BLE_ERR_REM_USER_CONN_TERM);
|
||||
bool cancelConnect();
|
||||
NimBLEAddress getPeerAddress() const;
|
||||
bool setPeerAddress(const NimBLEAddress& address);
|
||||
int getRssi() const;
|
||||
|
|
Loading…
Reference in a new issue