summaryrefslogtreecommitdiffstats
path: root/examples/direct_bt_scanner10
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-02-09 06:03:04 +0100
committerSven Gothel <[email protected]>2021-02-09 06:03:04 +0100
commit9d183a87e84e0f7d71683769653933b5a909f0a4 (patch)
tree69fdb98a5cc967c8ae022321e3a573f62db1318f /examples/direct_bt_scanner10
parent7ce8651a5737f5a66c8be3f4cb975e134a7a0699 (diff)
SMPKeyBin (C++/Java): Add 'apply(BTDevice&)' method, setting Security params and uploading available LTKs
Moving the SMPKeyBin setup and key-upload for the BTDevice to public SMPKeyBin, providing the proper setup and upload method. One change compared to removed coding in Scanner10 example occured: "BTSecurityLevel::ENC_ONLY is set to avoid a new SMP PairingMode negotiation, which is undesired as this instances' stored LTK shall be used for PairingMode::PRE_PAIRED." i.e.: 'device.setConnSecurity(BTSecurityLevel.ENC_ONLY, SMPIOCapability.NO_INPUT_NO_OUTPUT);' This has been evaluate with a Secure Connections capable LE device using BTSecurityLevel::ENC_AUTH_FIPS and SMPIOCapability::KEYBOARD_ONLY. After initial pairing using a dynamic generated passkey, we connected successfully and stored the LTKs and CSRKs with this connection parameter. Thereafter reconnect after setting (BTSecurityLevel.ENC_ONLY, SMPIOCapability.NO_INPUT_NO_OUTPUT) and uploading stored keys succeeded with Linux Kernel-BlueZ host implementation.
Diffstat (limited to 'examples/direct_bt_scanner10')
-rw-r--r--examples/direct_bt_scanner10/dbt_scanner10.cpp17
1 files changed, 2 insertions, 15 deletions
diff --git a/examples/direct_bt_scanner10/dbt_scanner10.cpp b/examples/direct_bt_scanner10/dbt_scanner10.cpp
index 4d0db4ee..f56b2c1b 100644
--- a/examples/direct_bt_scanner10/dbt_scanner10.cpp
+++ b/examples/direct_bt_scanner10/dbt_scanner10.cpp
@@ -470,21 +470,8 @@ static void connectDiscoveredDevice(std::shared_ptr<BTDevice> device) {
{
SMPKeyBin smpKeyBin;
smpKeyBin.setVerbose( true );
- if( smpKeyBin.read(KEY_PATH, device->getAddressAndType()) &&
- device->setConnSecurity(smpKeyBin.getSecLevel(), smpKeyBin.getIOCap()) )
- {
- useSMPKeyBin = true;
-
- if( smpKeyBin.hasLTKInit() &&
- HCIStatusCode::SUCCESS != device->setLongTermKeyInfo(smpKeyBin.getLTKInit()) )
- {
- useSMPKeyBin = false; // error setting LTK init
- }
- if( smpKeyBin.hasLTKResp() &&
- HCIStatusCode::SUCCESS != device->setLongTermKeyInfo(smpKeyBin.getLTKResp()) )
- {
- useSMPKeyBin = false; // error setting LTK resp
- }
+ if( smpKeyBin.read(KEY_PATH, device->getAddressAndType()) ) {
+ useSMPKeyBin = HCIStatusCode::SUCCESS == smpKeyBin.apply(*device);
}
}
if( !useSMPKeyBin ) {