diff options
author | Sven Gothel <[email protected]> | 2020-10-23 04:16:48 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2020-10-23 04:16:48 +0200 |
commit | 49186b1b6faa8e3215b27c2e607fa37d972c96dc (patch) | |
tree | 39647df0be04b08f1b1a217cde72f22784a8bc21 /api/direct_bt/DBTAdapter.hpp | |
parent | a40f2d0fa03a3f71901f300b175d660a966b1d29 (diff) |
Sent discovery event directly (!off-thread) guaranteeing SC; Push ScanType differentiating further.
Discovery events will be sent directly instead off-thread.
This is now possible w/o deadlock risk as we utilize the lock-free jau::cow_vector.
Further, off-thread event sending can cause non sequentially consistence (SC)
as the new threads potentially can be executed later on.
This happened in some test cases where event-2 has been received before event-1.
HCIHandler
- add setCurrentScanType(), allowing outside events to update its state
- sendMgmtEvent() directly, see above
DBTAdapter
- small renamings for clarity
- more ScanType differentiating: LE, BREDR and DUAL
using 'hasScanType(ScanType current, ScanType test)'
- FIXME note on AdapterStatusListener::discoveringChanged():
Method shall include the enabled/disabled ScanType plus the current overall ScanType state.
For now, we only report LE discovery state.
-
Diffstat (limited to 'api/direct_bt/DBTAdapter.hpp')
-rw-r--r-- | api/direct_bt/DBTAdapter.hpp | 27 |
1 files changed, 22 insertions, 5 deletions
diff --git a/api/direct_bt/DBTAdapter.hpp b/api/direct_bt/DBTAdapter.hpp index 59b5a091..e43d447b 100644 --- a/api/direct_bt/DBTAdapter.hpp +++ b/api/direct_bt/DBTAdapter.hpp @@ -94,6 +94,10 @@ namespace direct_bt { /** * DBTAdapter's discovery state has changed, i.e. enabled or disabled. + * <p> + * FIXME: Method shall include the enabled/disabled ScanType plus the current overall ScanType state. + * For now, we only report LE discovery state. + * </p> * @param adapter the adapter which discovering state has changed. * @param enabled the new discovery state * @param keepAlive if {@code true}, the discovery will be re-enabled if disabled by the underlying Bluetooth implementation. @@ -186,7 +190,7 @@ namespace direct_bt { std::atomic<BTMode> btMode = BTMode::NONE; NameAndShortName localName; std::atomic<ScanType> currentMetaScanType; // = ScanType::NONE - std::atomic<bool> keepDiscoveringAlive; // = false; + std::atomic<bool> keep_le_scan_alive; // = false; std::vector<std::shared_ptr<DBTDevice>> connectedDevices; std::vector<std::shared_ptr<DBTDevice>> discoveredDevices; // all discovered devices @@ -248,6 +252,8 @@ namespace direct_bt { bool mgmtEvConnectFailedHCI(std::shared_ptr<MgmtEvent> e) noexcept; bool mgmtEvDeviceDisconnectedHCI(std::shared_ptr<MgmtEvent> e) noexcept; + bool mgmtEvDeviceDiscoveringAny(std::shared_ptr<MgmtEvent> e, const bool hciSourced) noexcept; + void startDiscoveryBackground() noexcept; void checkDiscoveryState() noexcept; @@ -530,21 +536,32 @@ namespace direct_bt { HCIStatusCode stopDiscovery() noexcept; /** - * Returns the meta discovering state. It can be modified through startDiscovery(..) and stopDiscovery(). + * Returns the current meta discovering ScanType. It can be modified through startDiscovery(..) and stopDiscovery(). + * <p> + * Note that if startDiscovery(..) has been issued with keepAlive==true, + * the meta ScanType will still keep the desired ScanType enabled + * even if it has been temporarily disabled. + * </p> + * @see startDiscovery() + * @see stopDiscovery() */ - ScanType getDiscoveringScanType() const noexcept { + ScanType getCurrentScanType() const noexcept { return currentMetaScanType; } /** - * Returns the adapter's native discovering state. It can be modified through startDiscovery(..) and stopDiscovery(). + * Returns the adapter's current native discovering ScanType. It can be modified through startDiscovery(..) and stopDiscovery(). + * @see startDiscovery() + * @see stopDiscovery() */ - ScanType getNativeDiscoveringScanType() const noexcept{ + ScanType getCurrentNativeScanType() const noexcept{ return hci.getCurrentScanType(); } /** * Returns the meta discovering state. It can be modified through startDiscovery(..) and stopDiscovery(). + * @see startDiscovery() + * @see stopDiscovery() */ bool getDiscovering() const noexcept { return ScanType::NONE != currentMetaScanType; |