diff --git a/CHANGELOG.md b/CHANGELOG.md index 8dfc5a1..faae042 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,16 @@ All notable changes to this project will be documented in this file. +## [Unreleased] + +### Added +- `NimBLEClient::getCharacteristic(uint16_t handle)` Enabling the use of the characteristic handle to be used to find +the NimBLERemoteCharacteristic object. + +### Changed +- `NimBLEScan` When the scan ends the scan stopped flag is now set before calling the scan complete callback (if used) +this allows the starting of a new scan from the callback function. + ## [1.0.2] - 2020-09-13 ### Changed diff --git a/src/NimBLEScan.cpp b/src/NimBLEScan.cpp index dc82de5..73fc7f8 100644 --- a/src/NimBLEScan.cpp +++ b/src/NimBLEScan.cpp @@ -125,11 +125,12 @@ NimBLEScan::~NimBLEScan() { NIMBLE_LOGD(LOG_TAG, "discovery complete; reason=%d", event->disc_complete.reason); + pScan->m_stopped = true; + if (pScan->m_scanCompleteCB != nullptr) { pScan->m_scanCompleteCB(pScan->m_scanResults); } - pScan->m_stopped = true; if(pScan->m_pTaskData != nullptr) { pScan->m_pTaskData->rc = event->disc_complete.reason; xTaskNotifyGive(pScan->m_pTaskData->task); @@ -263,7 +264,7 @@ bool NimBLEScan::start(uint32_t duration, void (*scanCompleteCB)(NimBLEScanResul return false; } - // If we are already scanning don't start again or we will get stuck on the semaphore. + // If we are already scanning don't start again if(!m_stopped || ble_gap_disc_active()) { // double check - can cause host reset. NIMBLE_LOGE(LOG_TAG, "Scan already in progress"); return false;