diff options
author | Sven Gothel <[email protected]> | 2020-06-27 12:05:41 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-06-27 12:05:41 +0200 |
commit | 0d4ce1aa1b5f8fccd1fa8457c0957119269e7f71 (patch) | |
tree | d8124257f33d2a76693a13855b4bb9667e51afc7 /api | |
parent | 898526066ff34decceb69314e047ee818f6db851 (diff) |
DBTAdapter: Unify all findDevice*(..) methods, ensure all list access is synchronized
Diffstat (limited to 'api')
-rw-r--r-- | api/direct_bt/DBTAdapter.hpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/api/direct_bt/DBTAdapter.hpp b/api/direct_bt/DBTAdapter.hpp index 7e4fb9e2..238bdcdb 100644 --- a/api/direct_bt/DBTAdapter.hpp +++ b/api/direct_bt/DBTAdapter.hpp @@ -150,7 +150,9 @@ namespace direct_bt { { private: /** Returns index >= 0 if found, otherwise -1 */ - static int findDevice(std::vector<std::shared_ptr<DBTDevice>> const & devices, EUI48 const & mac); + static int findDeviceIdx(std::vector<std::shared_ptr<DBTDevice>> & devices, EUI48 const & mac); + static std::shared_ptr<DBTDevice> findDevice(std::vector<std::shared_ptr<DBTDevice>> & devices, EUI48 const & mac); + std::shared_ptr<DBTDevice> findDevice(std::vector<std::shared_ptr<DBTDevice>> & devices, DBTDevice const & device); DBTManager& mgmt; std::shared_ptr<AdapterInfo> adapterInfo; @@ -186,15 +188,15 @@ namespace direct_bt { bool addConnectedDevice(const std::shared_ptr<DBTDevice> & device); bool removeConnectedDevice(const DBTDevice & device); int disconnectAllDevices(const HCIStatusCode reason=HCIStatusCode::REMOTE_USER_TERMINATED_CONNECTION ); - std::shared_ptr<DBTDevice> findConnectedDevice (EUI48 const & mac) const; + std::shared_ptr<DBTDevice> findConnectedDevice (EUI48 const & mac); bool addDiscoveredDevice(std::shared_ptr<DBTDevice> const &device); bool removeDiscoveredDevice(const DBTDevice & device); bool addSharedDevice(std::shared_ptr<DBTDevice> const &device); std::shared_ptr<DBTDevice> getSharedDevice(const DBTDevice & device); - void releaseSharedDevice(const DBTDevice & device); - std::shared_ptr<DBTDevice> findSharedDevice (EUI48 const & mac) const; + void removeSharedDevice(const DBTDevice & device); + std::shared_ptr<DBTDevice> findSharedDevice (EUI48 const & mac); bool mgmtEvDeviceDiscoveringCB(std::shared_ptr<MgmtEvent> e); bool mgmtEvNewSettingsCB(std::shared_ptr<MgmtEvent> e); @@ -447,7 +449,7 @@ namespace direct_bt { int removeDiscoveredDevices(); /** Returns shared DBTDevice if found, otherwise nullptr */ - std::shared_ptr<DBTDevice> findDiscoveredDevice (EUI48 const & mac) const; + std::shared_ptr<DBTDevice> findDiscoveredDevice (EUI48 const & mac); std::string toString() const override; }; |