summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-10-24 04:09:55 +0200
committerSven Gothel <[email protected]>2020-10-24 04:09:55 +0200
commitc7cc9acfe7fcce0df302de16497b3d730d337e36 (patch)
treed9cd9f37c5c7640e6c6c1fccda9ee3dfb4dbf1cd
parent985f87f0565c6b6e3c9da485655f2c84cfa8fdfc (diff)
DBTManager: Start dropping index (idx) for adapter id, use dev_id - drop index requirement
-rw-r--r--api/direct_bt/DBTManager.hpp9
-rw-r--r--src/direct_bt/DBTAdapter.cpp6
-rw-r--r--src/direct_bt/DBTManager.cpp4
3 files changed, 10 insertions, 9 deletions
diff --git a/api/direct_bt/DBTManager.hpp b/api/direct_bt/DBTManager.hpp
index 78ed6a74..fc9a424d 100644
--- a/api/direct_bt/DBTManager.hpp
+++ b/api/direct_bt/DBTManager.hpp
@@ -282,11 +282,12 @@ namespace direct_bt {
int getAdapterCount() const noexcept { return adapterInfos.size(); }
/**
- * Returns the AdapterInfo index (== dev_id) with the given address or -1 if not found.
+ * Returns the AdapterInfo dev_id with the given address or -1 if not found.
*/
- int findAdapterInfoIdx(const EUI48 &mac) const noexcept;
+ int findAdapterInfoDevId(const EUI48 &mac) const noexcept;
+
/**
- * Returns the AdapterInfo (index == dev_id) with the given address or nullptr if not found.
+ * Returns the AdapterInfo with the given address or nullptr if not found.
*/
std::shared_ptr<AdapterInfo> findAdapterInfo(const EUI48 &mac) const noexcept;
@@ -321,7 +322,7 @@ namespace direct_bt {
* or function returns -1 if no adapter is available.
* </p>
*/
- int getDefaultAdapterIdx() const noexcept;
+ int getDefaultAdapterDevId() const noexcept;
bool setMode(const uint16_t dev_id, const MgmtOpcode opc, const uint8_t mode) noexcept;
diff --git a/src/direct_bt/DBTAdapter.cpp b/src/direct_bt/DBTAdapter.cpp
index 821e6217..b17d571a 100644
--- a/src/direct_bt/DBTAdapter.cpp
+++ b/src/direct_bt/DBTAdapter.cpp
@@ -198,7 +198,7 @@ bool DBTAdapter::validateDevInfo() noexcept {
DBTAdapter::DBTAdapter() noexcept
: debug_event(jau::environment::getBooleanProperty("direct_bt.debug.adapter.event", false)),
mgmt( DBTManager::get(BTMode::NONE /* use env default */) ),
- dev_id( mgmt.getDefaultAdapterIdx() ),
+ dev_id( mgmt.getDefaultAdapterDevId() ),
hci( dev_id )
{
valid = validateDevInfo();
@@ -207,7 +207,7 @@ DBTAdapter::DBTAdapter() noexcept
DBTAdapter::DBTAdapter(EUI48 &mac) noexcept
: debug_event(jau::environment::getBooleanProperty("direct_bt.debug.adapter.event", false)),
mgmt( DBTManager::get(BTMode::NONE /* use env default */) ),
- dev_id( mgmt.findAdapterInfoIdx(mac) ),
+ dev_id( mgmt.findAdapterInfoDevId(mac) ),
hci( dev_id )
{
valid = validateDevInfo();
@@ -216,7 +216,7 @@ DBTAdapter::DBTAdapter(EUI48 &mac) noexcept
DBTAdapter::DBTAdapter(const int _dev_id) noexcept
: debug_event(jau::environment::getBooleanProperty("direct_bt.debug.adapter.event", false)),
mgmt( DBTManager::get(BTMode::NONE /* use env default */) ),
- dev_id( 0 <= _dev_id ? _dev_id : mgmt.getDefaultAdapterIdx() ),
+ dev_id( 0 <= _dev_id ? _dev_id : mgmt.getDefaultAdapterDevId() ),
hci( dev_id )
{
valid = validateDevInfo();
diff --git a/src/direct_bt/DBTManager.cpp b/src/direct_bt/DBTManager.cpp
index 19a054bb..c865039f 100644
--- a/src/direct_bt/DBTManager.cpp
+++ b/src/direct_bt/DBTManager.cpp
@@ -532,7 +532,7 @@ void DBTManager::close() noexcept {
DBG_PRINT("DBTManager::close: End");
}
-int DBTManager::findAdapterInfoIdx(const EUI48 &mac) const noexcept {
+int DBTManager::findAdapterInfoDevId(const EUI48 &mac) const noexcept {
auto begin = adapterInfos.begin();
auto it = std::find_if(begin, adapterInfos.end(), [&](std::shared_ptr<AdapterInfo> const& p) {
return p->address == mac;
@@ -581,7 +581,7 @@ std::shared_ptr<AdapterInfo> DBTManager::getDefaultAdapterInfo() const noexcept
return adapterInfos.size() > 0 ? getAdapterInfo(0) : nullptr; // first adapter or nullptr, if none.
}
-int DBTManager::getDefaultAdapterIdx() const noexcept {
+int DBTManager::getDefaultAdapterDevId() const noexcept {
std::shared_ptr<AdapterInfo> ai = getDefaultAdapterInfo();
if( nullptr == ai ) {
return -1;