diff options
Diffstat (limited to 'api/direct_bt')
-rw-r--r-- | api/direct_bt/BTAdapter.hpp | 4 | ||||
-rw-r--r-- | api/direct_bt/BTManager.hpp | 2 | ||||
-rw-r--r-- | api/direct_bt/MgmtTypes.hpp | 28 |
3 files changed, 34 insertions, 0 deletions
diff --git a/api/direct_bt/BTAdapter.hpp b/api/direct_bt/BTAdapter.hpp index 4370d791..308f2457 100644 --- a/api/direct_bt/BTAdapter.hpp +++ b/api/direct_bt/BTAdapter.hpp @@ -349,6 +349,7 @@ namespace direct_bt { */ BDAddressAndType visibleAddressAndType; HCILEOwnAddressType visibleMACType; + MgmtIdentityResolvingKeyInfo privacyIRK; public: typedef jau::nsize_t size_type; @@ -527,6 +528,7 @@ namespace direct_bt { void mgmtEvPairDeviceCompleteMgmt(const MgmtEvent& e) noexcept; void mgmtEvNewLongTermKeyMgmt(const MgmtEvent& e) noexcept; void mgmtEvNewLinkKeyMgmt(const MgmtEvent& e) noexcept; + void mgmtEvNewIdentityResolvingKeyMgmt(const MgmtEvent& e) noexcept; void mgmtEvHCIAnyHCI(const MgmtEvent& e) noexcept; void mgmtEvDeviceDiscoveringHCI(const MgmtEvent& e) noexcept; @@ -745,6 +747,8 @@ namespace direct_bt { */ bool setPowered(const bool power_on) noexcept; + HCIStatusCode setPrivacy(const bool enable) noexcept; + /** * Returns whether Secure Connections (SC) is enabled. * @see setSecureConnections() diff --git a/api/direct_bt/BTManager.hpp b/api/direct_bt/BTManager.hpp index 2bbcc55e..3a80621b 100644 --- a/api/direct_bt/BTManager.hpp +++ b/api/direct_bt/BTManager.hpp @@ -420,6 +420,8 @@ namespace direct_bt { HCIStatusCode initializeAdapter(AdapterInfo& adapterInfo, const uint16_t dev_id, const BTMode btMode, const bool powerOn) noexcept; + HCIStatusCode setPrivacy(const uint16_t dev_id, const uint8_t privacy, const jau::uint128_t& irk, AdapterSetting& current_settings) noexcept; + /** * Read default connection parameter for given adapter to the kernel. * diff --git a/api/direct_bt/MgmtTypes.hpp b/api/direct_bt/MgmtTypes.hpp index 444e3035..9329edd3 100644 --- a/api/direct_bt/MgmtTypes.hpp +++ b/api/direct_bt/MgmtTypes.hpp @@ -826,6 +826,34 @@ namespace direct_bt { }; /** + * uint8_t privacy 0x00 disabled, 0x01 always on (discoverable + pairing), 0x02 limited (not when discoverable, bondable) + * jau::uint128_t irk Identity Resolving Key + */ + class MgmtSetPrivacyCmd : public MgmtCommand + { + protected: + std::string valueString() const noexcept override { + const jau::uint128_t& irk = getIdentityResolvingKey(); + return "param[size "+std::to_string(getParamSize())+", data[privacy "+std::to_string(getPrivacy())+ + ", irk "+jau::bytesHexString(irk.data, 0, sizeof(irk), true /* lsbFirst */)+"]]"; + } + + public: + MgmtSetPrivacyCmd(const uint16_t dev_id, const uint8_t privacy, const jau::uint128_t& irk) + : MgmtCommand(Opcode::SET_PRIVACY, dev_id, 1 + sizeof(irk)) + { + pdu.put_uint8_nc(MGMT_HEADER_SIZE, privacy); + memcpy(pdu.get_wptr_nc(MGMT_HEADER_SIZE+1), &irk, sizeof(irk)); + } + + uint8_t getPrivacy() const noexcept { return pdu.get_uint8_nc(MGMT_HEADER_SIZE); } + + const jau::uint128_t& getIdentityResolvingKey() const { + return *reinterpret_cast<const jau::uint128_t *>( pdu.get_ptr_nc(MGMT_HEADER_SIZE + 1) ); + } + }; + + /** * mgmt_addr_info { EUI48, uint8_t type }, */ class MgmtGetConnectionInfoCmd : public MgmtCmdAdressInfoMeta |