From fe4586a3ca2361a831c4e8750f61972f20d4448c Mon Sep 17 00:00:00 2001 From: h2zero Date: Thu, 23 Jul 2020 20:18:41 -0600 Subject: [PATCH] NimBLEScan: Add isScanning method. Adds a method to check if the scan is currently running. * Clear up some NimBLEScan method parameter semantics. --- src/NimBLEScan.cpp | 17 +++++++++++++---- src/NimBLEScan.h | 5 +++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/NimBLEScan.cpp b/src/NimBLEScan.cpp index b3187ce..498d9fa 100644 --- a/src/NimBLEScan.cpp +++ b/src/NimBLEScan.cpp @@ -168,8 +168,8 @@ void NimBLEScan::setActiveScan(bool active) { * @details The controller has a limited buffer and will start reporting * dupicate devices once the limit is reached. */ -void NimBLEScan::setDuplicateFilter(bool active) { - m_scan_params.filter_duplicates = active; +void NimBLEScan::setDuplicateFilter(bool enabled) { + m_scan_params.filter_duplicates = enabled; } // setDuplicateFilter @@ -178,8 +178,8 @@ void NimBLEScan::setDuplicateFilter(bool active) { * from devices advertising in limited discovery mode, i.e. directed advertising. * @param [in] active If true, only limited discovery devices will be in scan results. */ -void NimBLEScan::setLimitedOnly(bool active) { - m_scan_params.limited = active; +void NimBLEScan::setLimitedOnly(bool enabled) { + m_scan_params.limited = enabled; } // setLimited @@ -236,6 +236,15 @@ void NimBLEScan::setWindow(uint16_t windowMSecs) { } // setWindow +/** + * @brief Get the status of the scanner. + * @return true if scanning or scan starting. + */ +bool NimBLEScan::isScanning() { + return !m_stopped; +} + + /** * @brief Start scanning. * @param [in] duration The duration in seconds for which to scan. diff --git a/src/NimBLEScan.h b/src/NimBLEScan.h index 28abd1c..75a301e 100644 --- a/src/NimBLEScan.h +++ b/src/NimBLEScan.h @@ -62,12 +62,13 @@ class NimBLEScan { public: bool start(uint32_t duration, void (*scanCompleteCB)(NimBLEScanResults), bool is_continue = false); NimBLEScanResults start(uint32_t duration, bool is_continue = false); + bool isScanning(); void setAdvertisedDeviceCallbacks(NimBLEAdvertisedDeviceCallbacks* pAdvertisedDeviceCallbacks, bool wantDuplicates = false); void setActiveScan(bool active); void setInterval(uint16_t intervalMSecs); void setWindow(uint16_t windowMSecs); - void setDuplicateFilter(bool active); - void setLimitedOnly(bool active); + void setDuplicateFilter(bool enabled); + void setLimitedOnly(bool enabled); void setFilterPolicy(uint8_t filter); bool stop(); void clearResults();