forked from h2zero/esp-nimble-cpp
[BREAKING] Asynchronous pin injections for Numeric Comparison and PassKey Input (#165)
* Make NimBLEConnInfo functions const. * Update callback functions and update client to use new functions. * Update examples. * Update migration guide. --------- Co-authored-by: Casey Smith <csmith@morningstarcorp.com>
This commit is contained in:
@@ -1156,6 +1156,43 @@ int NimBLEDevice::startSecurity(uint16_t conn_id) {
|
||||
} // startSecurity
|
||||
|
||||
|
||||
/**
|
||||
* @brief Inject the provided passkey into the Security Manager
|
||||
* @param [in] peerInfo Connection information for the peer
|
||||
* @param [in] pin The 6-digit pin to inject
|
||||
* @return true if the passkey was injected successfully.
|
||||
*/
|
||||
bool NimBLEDevice::injectPassKey(const NimBLEConnInfo& peerInfo, uint32_t pin) {
|
||||
int rc = 0;
|
||||
struct ble_sm_io pkey = {0,0};
|
||||
|
||||
pkey.action = BLE_SM_IOACT_INPUT;
|
||||
pkey.passkey = pin;
|
||||
|
||||
rc = ble_sm_inject_io(peerInfo.getConnHandle(), &pkey);
|
||||
NIMBLE_LOGD(LOG_TAG, "BLE_SM_IOACT_INPUT; ble_sm_inject_io result: %d", rc);
|
||||
return rc == 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Inject the provided numeric comparison response into the Security Manager
|
||||
* @param [in] peerInfo Connection information for the peer
|
||||
* @param [in] accept Whether the user confirmed or declined the comparison
|
||||
*/
|
||||
bool NimBLEDevice::injectConfirmPIN(const NimBLEConnInfo& peerInfo, bool accept) {
|
||||
int rc = 0;
|
||||
struct ble_sm_io pkey = {0,0};
|
||||
|
||||
pkey.action = BLE_SM_IOACT_NUMCMP;
|
||||
pkey.numcmp_accept = accept;
|
||||
|
||||
rc = ble_sm_inject_io(peerInfo.getConnHandle(), &pkey);
|
||||
NIMBLE_LOGD(LOG_TAG, "BLE_SM_IOACT_NUMCMP; ble_sm_inject_io result: %d", rc);
|
||||
return rc == 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief Check if the device address is on our ignore list.
|
||||
* @param [in] address The address to look for.
|
||||
|
||||
Reference in New Issue
Block a user