From ba7ab284bb3b4bbbbef75b54dfbc87478079a72a Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Wed, 9 Dec 2020 11:32:57 +0100 Subject: DBTDevice: Add get/set methods for SMPLongTermKeyInfo (tested); TODO: Java --- src/direct_bt/DBTDevice.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src') diff --git a/src/direct_bt/DBTDevice.cpp b/src/direct_bt/DBTDevice.cpp index 314b9f9b..cda1d3bf 100644 --- a/src/direct_bt/DBTDevice.cpp +++ b/src/direct_bt/DBTDevice.cpp @@ -867,6 +867,18 @@ void DBTDevice::hciSMPMsgCallback(std::shared_ptr sthis, std::shared_ } } +SMPLongTermKeyInfo DBTDevice::getLongTermKeyInfo(const bool responder) const noexcept { + jau::sc_atomic_critical sync(const_cast(this)->sync_pairing); + return responder ? pairing_data.ltk_resp : pairing_data.ltk_init; +} + +HCIStatusCode DBTDevice::setLongTermKeyInfo(const SMPLongTermKeyInfo& ltk, const bool responder) noexcept { + jau::sc_atomic_critical sync(sync_pairing); + DBTManager & mngr = adapter.getManager(); + HCIStatusCode res = mngr.uploadLongTermKeyInfo(adapter.dev_id, address, addressType, ltk, responder); + return res; +} + HCIStatusCode DBTDevice::pair(const SMPIOCapability io_cap) noexcept { /** * Experimental only. -- cgit v1.2.3