aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2021-02-01 16:33:02 +0100
committerSven Gothel <[email protected]>2021-02-01 16:33:02 +0100
commitd19ada36815a992733b9530e8e218cdc97f26dc0 (patch)
treea6a34fdff2a6c27f51fa0c97e417324b88481d90
parent24e02130f7ec2ddbc37b22a1e05e3a2a5154897e (diff)
BTManager: Default SMPIOCapability (defaultIOCapability) is SMPIOCapability::NO_INPUT_NO_OUTPUT for JUST_WORKS
In case user desires authenticated security level, BTDevice security settings shall be utilized. Also making defaultIOCapability a 'constexpt static const'.
-rw-r--r--api/direct_bt/BTManager.hpp9
-rw-r--r--src/direct_bt/BTManager.cpp11
2 files changed, 10 insertions, 10 deletions
diff --git a/api/direct_bt/BTManager.hpp b/api/direct_bt/BTManager.hpp
index 776ff054..63fcac85 100644
--- a/api/direct_bt/BTManager.hpp
+++ b/api/direct_bt/BTManager.hpp
@@ -210,6 +210,13 @@ namespace direct_bt {
private:
friend BTAdapter::~BTAdapter() noexcept;
+#if USE_LINUX_BT_SECURITY
+ /** Default initialization with ::SMPIOCapability::NO_INPUT_NO_OUTPUT for PairingMode::JUST_WORKS. */
+ constexpr static const SMPIOCapability defaultIOCapability = SMPIOCapability::NO_INPUT_NO_OUTPUT;
+#else
+ /** Default initialization with ::SMPIOCapability::NO_INPUT_NO_OUTPUT for PairingMode::JUST_WORKS. */
+ constexpr static const SMPIOCapability defaultIOCapability = SMPIOCapability::UNSET;
+#endif
static std::mutex mtx_singleton;
struct WhitelistElem {
@@ -224,8 +231,6 @@ namespace direct_bt {
const MgmtEnv & env;
const BTMode defaultBTMode;
- /** Default initialization with SMPIOCapability::KEYBOARD_ONLY for PairingMode::PASSKEY_ENTRY. */
- const SMPIOCapability defaultIOCapability;
POctets rbuffer;
HCIComm comm;
diff --git a/src/direct_bt/BTManager.cpp b/src/direct_bt/BTManager.cpp
index e66bb78e..7105eae8 100644
--- a/src/direct_bt/BTManager.cpp
+++ b/src/direct_bt/BTManager.cpp
@@ -309,7 +309,7 @@ std::unique_ptr<AdapterInfo> BTManager::initAdapter(const uint16_t dev_id, const
#if USE_LINUX_BT_SECURITY
setMode(dev_id, MgmtCommand::Opcode::SET_DEBUG_KEYS, debug_keys, current_settings);
- setMode(dev_id, MgmtCommand::Opcode::SET_IO_CAPABILITY, direct_bt::number(defaultIOCapability), current_settings);
+ setMode(dev_id, MgmtCommand::Opcode::SET_IO_CAPABILITY, direct_bt::number(BTManager::defaultIOCapability), current_settings);
setMode(dev_id, MgmtCommand::Opcode::SET_BONDABLE, 1, current_settings); // required for pairing
#else
setMode(dev_id, MgmtCommand::Opcode::SET_SECURE_CONN, 0, current_settings);
@@ -374,11 +374,6 @@ void BTManager::shutdownAdapter(BTAdapter& adapter) noexcept {
BTManager::BTManager(const BTMode _defaultBTMode) noexcept
: env(MgmtEnv::get()),
defaultBTMode(BTMode::NONE != _defaultBTMode ? _defaultBTMode : env.DEFAULT_BTMODE),
-#if USE_LINUX_BT_SECURITY
- defaultIOCapability(SMPIOCapability::KEYBOARD_ONLY),
-#else
- defaultIOCapability(SMPIOCapability::UNSET),
-#endif
rbuffer(ClientMaxMTU), comm(HCI_DEV_NONE, HCI_CHANNEL_CONTROL),
mgmtEventRing(env.MGMT_EVT_RING_CAPACITY), mgmtReaderShallStop(false),
mgmtReaderThreadId(0), mgmtReaderRunning(false),
@@ -487,7 +482,7 @@ next1:
if( nullptr != adapterInfo ) {
std::shared_ptr<BTAdapter> adapter = BTAdapter::make_shared(*this, *adapterInfo);
adapters.push_back( adapter );
- adapterIOCapability.push_back(defaultIOCapability);
+ adapterIOCapability.push_back(BTManager::defaultIOCapability);
DBG_PRINT("DBTManager::adapters %d/%d: dev_id %d: %s", i, num_adapter, dev_id, adapter->toString().c_str());
} else {
DBG_PRINT("DBTManager::adapters %d/%d: dev_id %d: FAILED", i, num_adapter, dev_id);
@@ -655,7 +650,7 @@ std::shared_ptr<BTAdapter> BTManager::addAdapter(const AdapterInfo& ai ) noexcep
// new entry
std::shared_ptr<BTAdapter> adapter = BTAdapter::make_shared(*this, ai);
it.push_back( adapter );
- adapterIOCapability.push_back(defaultIOCapability);
+ adapterIOCapability.push_back(BTManager::defaultIOCapability);
DBG_PRINT("DBTManager::addAdapter: Adding new: %s", adapter->toString().c_str())
it.write_back();
return adapter;