NimBLEScan: Add isScanning method.

Adds a method to check if the scan is currently running.

* Clear up some NimBLEScan method parameter semantics.
This commit is contained in:
h2zero 2020-07-23 20:18:41 -06:00
parent 11b6f816ca
commit fe4586a3ca
2 changed files with 16 additions and 6 deletions

View file

@ -168,8 +168,8 @@ void NimBLEScan::setActiveScan(bool active) {
* @details The controller has a limited buffer and will start reporting * @details The controller has a limited buffer and will start reporting
* dupicate devices once the limit is reached. * dupicate devices once the limit is reached.
*/ */
void NimBLEScan::setDuplicateFilter(bool active) { void NimBLEScan::setDuplicateFilter(bool enabled) {
m_scan_params.filter_duplicates = active; m_scan_params.filter_duplicates = enabled;
} // setDuplicateFilter } // setDuplicateFilter
@ -178,8 +178,8 @@ void NimBLEScan::setDuplicateFilter(bool active) {
* from devices advertising in limited discovery mode, i.e. directed advertising. * 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. * @param [in] active If true, only limited discovery devices will be in scan results.
*/ */
void NimBLEScan::setLimitedOnly(bool active) { void NimBLEScan::setLimitedOnly(bool enabled) {
m_scan_params.limited = active; m_scan_params.limited = enabled;
} // setLimited } // setLimited
@ -236,6 +236,15 @@ void NimBLEScan::setWindow(uint16_t windowMSecs) {
} // setWindow } // setWindow
/**
* @brief Get the status of the scanner.
* @return true if scanning or scan starting.
*/
bool NimBLEScan::isScanning() {
return !m_stopped;
}
/** /**
* @brief Start scanning. * @brief Start scanning.
* @param [in] duration The duration in seconds for which to scan. * @param [in] duration The duration in seconds for which to scan.

View file

@ -62,12 +62,13 @@ class NimBLEScan {
public: public:
bool start(uint32_t duration, void (*scanCompleteCB)(NimBLEScanResults), bool is_continue = false); bool start(uint32_t duration, void (*scanCompleteCB)(NimBLEScanResults), bool is_continue = false);
NimBLEScanResults start(uint32_t duration, bool is_continue = false); NimBLEScanResults start(uint32_t duration, bool is_continue = false);
bool isScanning();
void setAdvertisedDeviceCallbacks(NimBLEAdvertisedDeviceCallbacks* pAdvertisedDeviceCallbacks, bool wantDuplicates = false); void setAdvertisedDeviceCallbacks(NimBLEAdvertisedDeviceCallbacks* pAdvertisedDeviceCallbacks, bool wantDuplicates = false);
void setActiveScan(bool active); void setActiveScan(bool active);
void setInterval(uint16_t intervalMSecs); void setInterval(uint16_t intervalMSecs);
void setWindow(uint16_t windowMSecs); void setWindow(uint16_t windowMSecs);
void setDuplicateFilter(bool active); void setDuplicateFilter(bool enabled);
void setLimitedOnly(bool active); void setLimitedOnly(bool enabled);
void setFilterPolicy(uint8_t filter); void setFilterPolicy(uint8_t filter);
bool stop(); bool stop();
void clearResults(); void clearResults();