summaryrefslogtreecommitdiffstats
path: root/src/direct_bt/BTDevice.cpp
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2023-10-23 09:33:15 +0200
committerSven Gothel <[email protected]>2023-10-23 09:33:15 +0200
commitf25e6eb1d3c25ddd91bc249c3f84be1e5d483837 (patch)
tree7c1032fd7fb677f2bcc3ed55d7e4b3a023b4b974 /src/direct_bt/BTDevice.cpp
parent3dadb1e183a5ce8cb0ef071b7bdfc0c925589b9e (diff)
GATT Server Auth: Expose PASSKEY_NOTIFY from BTManager -> BTDevice; App using AdapterStatusListener::devicePairingState() + SMPPairingState::PASSKEY_NOTIFY to display generated PassKey
Diffstat (limited to 'src/direct_bt/BTDevice.cpp')
-rw-r--r--src/direct_bt/BTDevice.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/direct_bt/BTDevice.cpp b/src/direct_bt/BTDevice.cpp
index 876463ed..caab6c58 100644
--- a/src/direct_bt/BTDevice.cpp
+++ b/src/direct_bt/BTDevice.cpp
@@ -768,6 +768,7 @@ std::string BTDevice::PairingData::toString(const uint16_t dev_id, const BDAddre
res.append(" - IOCap "+to_string(ioCap_resp)+"\n");
res.append(" - EncSz "+std::to_string(maxEncsz_resp)+"\n");
res.append(" - Keys "+to_string(keys_resp_has)+" / "+to_string(keys_resp_exp)+"\n");
+ res.append(" - PassKey "+toPassKeyString(passKey_resp)+"\n");
res.append(" - "+ltk_resp.toString()+"\n");
res.append(" - "+lk_resp.toString()+"\n");
res.append(" - "+irk_resp.toString()+"\n");
@@ -836,6 +837,14 @@ bool BTDevice::updatePairingState(const std::shared_ptr<BTDevice>& sthis, const
dc.detach();
}
break;
+ case SMPPairingState::PASSKEY_NOTIFY:
+ if( MgmtEvent::Opcode::PASSKEY_NOTIFY == mgmtEvtOpcode ) {
+ // we must be in slave/responder mode, i.e. peripheral/GATT-server providing auth passkey
+ const MgmtEvtPasskeyNotify& event = *static_cast<const MgmtEvtPasskeyNotify *>(&evt);
+ mode = PairingMode::PASSKEY_ENTRY_ini;
+ pairing_data.passKey_resp = event.getPasskey();
+ }
+ break;
case SMPPairingState::OOB_EXPECTED:
// 2
mode = PairingMode::OUT_OF_BAND;
@@ -1864,6 +1873,8 @@ void BTDevice::clearSMPStates(const bool connected) noexcept {
pairing_data.use_sc = false;
pairing_data.encryption_enabled = false;
+ pairing_data.passKey_resp = 0;
+
pairing_data.authReqs_resp = SMPAuthReqs::NONE;
pairing_data.ioCap_resp = SMPIOCapability::NO_INPUT_NO_OUTPUT;
pairing_data.oobFlag_resp = SMPOOBDataFlag::OOB_AUTH_DATA_NOT_PRESENT;
@@ -2314,6 +2325,10 @@ exit:
return res;
}
+std::uint32_t BTDevice::getResponderSMPPassKey() const noexcept {
+ return pairing_data.passKey_resp;
+}
+
HCIStatusCode BTDevice::unpair() noexcept {
if constexpr ( USE_LINUX_BT_SECURITY ) {
const BTManagerRef& mngr = adapter.getManager();