diff options
author | Sven Gothel <[email protected]> | 2020-06-09 20:55:50 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-06-09 20:55:50 +0200 |
commit | 888cda5041d45c98b93c2ed506d08f3f453240f8 (patch) | |
tree | b6944321d87c4499ce07cf8f57beea8ec4e1334e /api | |
parent | 0ae1a240086654ada3f9805c5fd4a38003007696 (diff) |
C++: Utilize 'currentScanType' for start/stop discovery same as for Java code; use atomic<ScanType> avoiding race conditions
C++/Java: Only update the discovering state for false in DISCOVERING listener if keepAlive == false.
C++ like Java pendant, only perform start/stop discovery in appropriate discovery state
C++ expose discovery state 'currentScanType'
Diffstat (limited to 'api')
-rw-r--r-- | api/direct_bt/DBTAdapter.hpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/api/direct_bt/DBTAdapter.hpp b/api/direct_bt/DBTAdapter.hpp index 48585a81..17bb9e43 100644 --- a/api/direct_bt/DBTAdapter.hpp +++ b/api/direct_bt/DBTAdapter.hpp @@ -155,7 +155,8 @@ namespace direct_bt { DBTManager& mgmt; std::shared_ptr<AdapterInfo> adapterInfo; NameAndShortName localName; - ScanType currentScanType = ScanType::SCAN_TYPE_NONE; + std::atomic<ScanType> currentScanType; // = ScanType::SCAN_TYPE_NONE + std::atomic<bool> keepDiscoveringAlive; // = false; std::shared_ptr<HCIHandler> hci; std::vector<std::shared_ptr<DBTDevice>> connectedDevices; @@ -167,7 +168,6 @@ namespace direct_bt { std::recursive_mutex mtx_discoveredDevices; std::recursive_mutex mtx_sharedDevices; std::recursive_mutex mtx_statusListenerList; - std::atomic<bool> keepDiscoveringAlive; // = false; bool validateDevInfo(); @@ -417,6 +417,20 @@ namespace direct_bt { void stopDiscovery(); /** + * Returns the discovering state the adapter. It can be modified through startDiscovery(..) and stopDiscovery(). + */ + ScanType getDiscoveringScanType() const { + return currentScanType; + } + + /** + * Returns the discovering state the adapter. It can be modified through startDiscovery(..) and stopDiscovery(). + */ + bool getDiscovering() const { + return ScanType::SCAN_TYPE_NONE != currentScanType; + } + + /** * Returns discovered devices from the last discovery. * <p> * Note that this list will be cleared when a new discovery is started over via startDiscovery(). |