summaryrefslogtreecommitdiffstats
path: root/src/direct_bt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-11-24 08:00:16 +0100
committerSven Gothel <[email protected]>2023-11-24 08:00:16 +0100
commitcf3d5a2c7e5bd54b9af514061e7d8375a0c4d9da (patch)
treea8a7998012215297f65019f5211c4d2f53b9124e /src/direct_bt
parent2c9afcdb852ccdb9155d5a8e6bfdea6cb4544674 (diff)
BTDevice::setSMPKeyBin: Align C++/Java code using setSMPKeyBin()
Diffstat (limited to 'src/direct_bt')
-rw-r--r--src/direct_bt/BTDevice.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/direct_bt/BTDevice.cpp b/src/direct_bt/BTDevice.cpp
index 8c0240f1..f0e9bfd0 100644
--- a/src/direct_bt/BTDevice.cpp
+++ b/src/direct_bt/BTDevice.cpp
@@ -1586,9 +1586,10 @@ bool BTDevice::setSMPKeyBin(const SMPKeyBin& bin) noexcept {
return false;
}
- if( (!btRole) != bin.getLocalRole() ) {
+ const BTRole btRoleAdapter = !btRole;
+ if( btRoleAdapter != bin.getLocalRole() ) {
DBG_PRINT("BTDevice::setSMPKeyBin(): Apply SMPKeyBin failed, local adapter role %s mismatch: %s, %s",
- to_string(!btRole).c_str(), bin.toString().c_str(), toString().c_str());
+ to_string(btRoleAdapter).c_str(), bin.toString().c_str(), toString().c_str());
return false;
}
@@ -1597,7 +1598,13 @@ bool BTDevice::setSMPKeyBin(const SMPKeyBin& bin) noexcept {
( SMPPairingState::COMPLETED != pairing_data.state &&
SMPPairingState::NONE != pairing_data.state ) )
{
- DBG_PRINT("BTDevice::setSMPKeyBin: Failure, pairing in progress: %s", pairing_data.toString(adapter.dev_id, addressAndType, btRole).c_str());
+ DBG_PRINT("BTDevice::setSMPKeyBin: Failure, pairing in progress: %s, %s",
+ pairing_data.toString(adapter.dev_id, addressAndType, btRole).c_str(), toString().c_str());
+ return false;
+ }
+
+ if( getConnected() ) {
+ DBG_PRINT("BTDevice::setSMPKeyBin: Failure, device connected: %s", toString().c_str());
return false;
}