diff options
author | Sven Gothel <[email protected]> | 2023-10-26 13:46:40 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2023-10-26 13:46:40 +0200 |
commit | 6e40e413c3750e7b139717c1d055d25d804ad4ef (patch) | |
tree | 56e8d7936976ad07be79d23f06927f53bcdc8759 /src | |
parent | 917b9b4f6a8884b6abd9babcdb15a500fe36a09e (diff) |
GATT Server Auth: BTDevice::processL2CAPSetup don't set sec_level w/ authentication in server mode; Read-out l2cap's actual sec_level when paired
This state works w/ pairing against an Android phone using Random Private Address and authentication.
Diffstat (limited to 'src')
-rw-r--r-- | src/direct_bt/BTDevice.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/direct_bt/BTDevice.cpp b/src/direct_bt/BTDevice.cpp index 0f9d4d00..ff4a3d7b 100644 --- a/src/direct_bt/BTDevice.cpp +++ b/src/direct_bt/BTDevice.cpp @@ -657,7 +657,7 @@ void BTDevice::processL2CAPSetup(std::shared_ptr<BTDevice> sthis) { // NOLINT(pe } else { l2cap_att = std::move(l2cap_att_new); DBG_PRINT("L2CAP-ACCEPT: BTDevice::processL2CAPSetup: dev_id %d, td %" PRIu64 "ms, l2cap_att %s", adapter.dev_id, td, l2cap_att->toString().c_str()); - if( BTSecurityLevel::UNSET < sec_level ) { + if( BTSecurityLevel::UNSET < sec_level && sec_level < BTSecurityLevel::ENC_AUTH ) { // authentication must be left alone in server mode l2cap_open = l2cap_att->setBTSecurityLevel(sec_level); } else { l2cap_open = true; @@ -1119,12 +1119,14 @@ bool BTDevice::updatePairingState(const std::shared_ptr<BTDevice>& sthis, const if( !is_device_ready && check_pairing_complete ) { is_device_ready = checkPairingKeyDistributionComplete(); - if( is_device_ready ) { - pairing_data.is_pre_paired = true; - } else { + if( !is_device_ready ) { claimed_state = pairing_data.state; // not yet } } + if( is_device_ready ) { + pairing_data.is_pre_paired = true; + pairing_data.sec_level_conn = l2cap_att->getBTSecurityLevel(); + } } // if( pairing_data.state != claimed_state ) // 5 @@ -1440,6 +1442,7 @@ void BTDevice::hciSMPMsgCallback(const std::shared_ptr<BTDevice>& sthis, const S pstate = SMPPairingState::COMPLETED; is_device_ready = true; pairing_data.is_pre_paired = true; + pairing_data.sec_level_conn = l2cap_att->getBTSecurityLevel(); } if( jau::environment::get().debug ) { |