aboutsummaryrefslogtreecommitdiffstats
path: root/api/direct_bt/DBTDevice.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'api/direct_bt/DBTDevice.hpp')
-rw-r--r--api/direct_bt/DBTDevice.hpp21
1 files changed, 16 insertions, 5 deletions
diff --git a/api/direct_bt/DBTDevice.hpp b/api/direct_bt/DBTDevice.hpp
index 74dab0a8..8983e72f 100644
--- a/api/direct_bt/DBTDevice.hpp
+++ b/api/direct_bt/DBTDevice.hpp
@@ -80,6 +80,7 @@ namespace direct_bt {
std::atomic<bool> allowDisconnect; // allowDisconnect = isConnected || 'isConnectIssued'
struct PairingData {
+ jau::ordered_atomic<BTSecurityLevel, std::memory_order_relaxed> sec_level=BTSecurityLevel::UNSET, sec_level_user=BTSecurityLevel::UNSET;
jau::ordered_atomic<SMPPairingState, std::memory_order_relaxed> state;
jau::ordered_atomic<PairingMode, std::memory_order_relaxed> mode;
jau::relaxed_atomic_bool res_requested_sec;
@@ -121,22 +122,22 @@ namespace direct_bt {
void processL2CAPSetup(std::shared_ptr<DBTDevice> sthis);
/**
- * Established SMP host connection and security for L2CAP connection if sec_level > BT_SECURITY_LOW.
+ * Established SMP host connection and security for L2CAP connection if sec_level > BTSecurityLevel::NONE.
* <p>
* Will be performed after connectLE(..), i.e. notifyConnected() and notifyLEFeatures().<br>
* Called from processL2CAPSetup, if supported.
* </p>
* <p>
- * If sec_level > BT_SECURITY_LOW, sets the BlueZ's L2CAP socket BT_SECURITY sec_level, determining the SMP security mode per connection.
+ * If sec_level > BTSecurityLevel::NONE, sets the BlueZ's L2CAP socket BT_SECURITY sec_level, determining the SMP security mode per connection.
* </p>
* <p>
* The SMPHandler is managed by this device instance and closed via disconnectSMP().
* </p>
*
- * @param sec_level BT_SECURITY_LOW, BT_SECURITY_MEDIUM, BT_SECURITY_HIGH or BT_SECURITY_FIPS. sec_level <= BT_SECURITY_LOW leads to not set security level.
- * @return true if a security level > BT_SECURITY_LOW has been set successfully, false if no security level has been set or if it failed.
+ * @param sec_level sec_level <= BTSecurityLevel::NONE will not set security level and returns false.
+ * @return true if a security level > BTSecurityLevel::NONE has been set successfully, false if no security level has been set or if it failed.
*/
- bool connectSMP(std::shared_ptr<DBTDevice> sthis, const uint8_t sec_level) noexcept;
+ bool connectSMP(std::shared_ptr<DBTDevice> sthis, const BTSecurityLevel sec_level) noexcept;
/**
* Forwarded from HCIHandler -> DBTAdapter -> this DBTDevice
@@ -447,6 +448,16 @@ namespace direct_bt {
HCIStatusCode setPairingPasskeyNegative() noexcept;
/**
+ * Set the overriding security level used at device connection.
+ */
+ void setSecurityLevel(const BTSecurityLevel sec_level) noexcept { pairing_data.sec_level_user = sec_level; }
+
+ /**
+ * Return the currently set security level.
+ */
+ BTSecurityLevel getCurrentSecurityLevel() const noexcept { return pairing_data.sec_level; }
+
+ /**
* Method sets the numeric comparison result, see PairingMode::NUMERIC_COMPARE_ini.
* <p>
* Call this method if the device shall be securely paired with PairingMode::NUMERIC_COMPARE_ini,