diff options
author | Sven Gothel <[email protected]> | 2022-04-14 05:35:47 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2022-04-14 05:35:47 +0200 |
commit | babbcbf0e6134e5244556cdc866b681c1b0c1767 (patch) | |
tree | 9d72882d4f0243d088f45809631c81bee811da58 | |
parent | b0cf6cee7adb38d0e8a64d9c22f44083d2a79e4d (diff) |
BTDevice::notifyLEFeature(): Remove HCIStatusCode param and only call with SUCCESS status code
In case of a connection failure, status code is !SUCCESS and we shall not enter into pairing mode!
-rw-r--r-- | api/direct_bt/BTDevice.hpp | 2 | ||||
-rw-r--r-- | src/direct_bt/BTAdapter.cpp | 12 | ||||
-rw-r--r-- | src/direct_bt/BTDevice.cpp | 14 |
3 files changed, 12 insertions, 16 deletions
diff --git a/api/direct_bt/BTDevice.hpp b/api/direct_bt/BTDevice.hpp index 803208aa..ae20a48c 100644 --- a/api/direct_bt/BTDevice.hpp +++ b/api/direct_bt/BTDevice.hpp @@ -162,7 +162,7 @@ namespace direct_bt { void notifyDisconnected() noexcept; void notifyConnected(std::shared_ptr<BTDevice> sthis, const uint16_t handle, const SMPIOCapability io_cap) noexcept; - void notifyLEFeatures(std::shared_ptr<BTDevice> sthis, const HCIStatusCode status, const LE_Features features) noexcept; + void notifyLEFeatures(std::shared_ptr<BTDevice> sthis, const LE_Features features) noexcept; void notifyLEPhyUpdateComplete(const HCIStatusCode status, const LE_PHYs Tx, const LE_PHYs Rx) noexcept; /** diff --git a/src/direct_bt/BTAdapter.cpp b/src/direct_bt/BTAdapter.cpp index 30cd4710..f29b87d0 100644 --- a/src/direct_bt/BTAdapter.cpp +++ b/src/direct_bt/BTAdapter.cpp @@ -1960,7 +1960,7 @@ bool BTAdapter::mgmtEvDeviceConnectedHCI(const MgmtEvent& e) noexcept { // hci.le_read_remote_features(event.getHCIHandle(), device->getAddressAndType()); // Hence .. induce it right after connect - device->notifyLEFeatures(device, HCIStatusCode::SUCCESS, LE_Features::LE_Encryption); + device->notifyLEFeatures(device, LE_Features::LE_Encryption); } return true; } @@ -2032,10 +2032,12 @@ bool BTAdapter::mgmtEvHCILERemoteUserFeaturesHCI(const MgmtEvent& e) noexcept { addDevicePausingDiscovery(device); } } - device->notifyLEFeatures(device, event.getHCIStatus(), event.getFeatures()); - // Performs optional SMP pairing, then one of - // - sendDeviceReady() - // - disconnect() .. eventually + if( HCIStatusCode::SUCCESS == event.getHCIStatus() ) { + device->notifyLEFeatures(device, event.getFeatures()); + // Performs optional SMP pairing, then one of + // - sendDeviceReady() + // - disconnect() .. eventually + } // else: disconnect will occur } else { WORDY_PRINT("BTAdapter::EventHCI:LERemoteUserFeatures(dev_id %d): Device not tracked: %s", dev_id, event.toString().c_str()); diff --git a/src/direct_bt/BTDevice.cpp b/src/direct_bt/BTDevice.cpp index 6359f958..0737e068 100644 --- a/src/direct_bt/BTDevice.cpp +++ b/src/direct_bt/BTDevice.cpp @@ -547,17 +547,12 @@ void BTDevice::notifyConnected(std::shared_ptr<BTDevice> sthis, const uint16_t h (void)sthis; // not used yet } -void BTDevice::notifyLEFeatures(std::shared_ptr<BTDevice> sthis, const HCIStatusCode status, const LE_Features features) noexcept { - if( HCIStatusCode::SUCCESS == status ) { - le_features = features; - } else { - le_features = le_features | LE_Features::LE_Encryption; // required! - } - DBG_PRINT("BTDevice::notifyLEFeatures: %s: %s -> %s, %s", - direct_bt::to_string(status).c_str(), - direct_bt::to_string(features).c_str(), +void BTDevice::notifyLEFeatures(std::shared_ptr<BTDevice> sthis, const LE_Features features) noexcept { + DBG_PRINT("BTDevice::notifyLEFeatures: %s -> %s, %s", direct_bt::to_string(le_features).c_str(), + direct_bt::to_string(features).c_str(), toString().c_str()); + le_features = features; const bool is_local_server = BTRole::Master == btRole; // -> local GattRole::Server if( addressAndType.isLEAddress() && ( !l2cap_att->isOpen() || is_local_server ) ) { std::thread bg(&BTDevice::processL2CAPSetup, this, sthis); // @suppress("Invalid arguments") @@ -716,7 +711,6 @@ bool BTDevice::checkPairingKeyDistributionComplete() const noexcept { res = true; } } - return res; } |