summaryrefslogtreecommitdiff
path: root/src/BLEScan.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/BLEScan.cpp')
-rw-r--r--src/BLEScan.cpp42
1 files changed, 7 insertions, 35 deletions
diff --git a/src/BLEScan.cpp b/src/BLEScan.cpp
index 54fcac0..925c09d 100644
--- a/src/BLEScan.cpp
+++ b/src/BLEScan.cpp
@@ -21,32 +21,20 @@
static const char* LOG_TAG = "BLEScan";
+/**
+ * Constructor
+ */
BLEScan::BLEScan() {
m_scan_params.scan_type = BLE_SCAN_TYPE_PASSIVE; // Default is a passive scan.
m_scan_params.own_addr_type = BLE_ADDR_TYPE_PUBLIC;
m_scan_params.scan_filter_policy = BLE_SCAN_FILTER_ALLOW_ALL;
+ m_pAdvertisedDeviceCallbacks = nullptr;
+ m_stopped = true;
setInterval(100);
setWindow(100);
- m_pAdvertisedDeviceCallbacks = nullptr;
- m_stopped = true;
} // BLEScan
-
-/**
- * @brief Clear the history of previously detected advertised devices.
- * @return N/A
- */
-/*
-void BLEScan::clearAdvertisedDevices() {
- for (int i=0; i<m_vectorAvdertisedDevices.size(); i++) {
- delete m_vectorAvdertisedDevices[i];
- }
- m_vectorAvdertisedDevices.clear();
-} // clearAdvertisedDevices
-*/
-
-
/**
* @brief Handle GAP events related to scans.
* @param [in] event The event type for this event.
@@ -90,14 +78,7 @@ void BLEScan::gapEventHandler(
// ignore it.
BLEAddress advertisedAddress(param->scan_rst.bda);
bool found = false;
- /*
- for (int i=0; i<m_vectorAvdertisedDevices.size(); i++) {
- if (m_vectorAvdertisedDevices[i]->getAddress().equals(advertisedAddress)) {
- found = true;
- break;
- }
- }
- */
+
for (int i=0; i<m_scanResults.getCount(); i++) {
if (m_scanResults.getDevice(i).getAddress().equals(advertisedAddress)) {
found = true;
@@ -118,7 +99,6 @@ void BLEScan::gapEventHandler(
advertisedDevice.parseAdvertisement((uint8_t*)param->scan_rst.ble_adv);
advertisedDevice.setScan(this);
- //m_vectorAvdertisedDevices.push_back(pAdvertisedDevice);
if (m_pAdvertisedDeviceCallbacks) {
m_pAdvertisedDeviceCallbacks->onResult(advertisedDevice);
}
@@ -144,14 +124,6 @@ void BLEScan::gapEventHandler(
} // gapEventHandler
-/*
-void BLEScan::onResults() {
- ESP_LOGD(LOG_TAG, ">> onResults: default");
- ESP_LOGD(LOG_TAG, "<< onResults");
-} // onResults
-*/
-
-
/**
* @brief Should we perform an active or passive scan?
* The default is a passive scan. An active scan means that we will wish a scan response.
@@ -200,7 +172,7 @@ void BLEScan::setWindow(uint16_t windowMSecs) {
* @return N/A.
*/
BLEScanResults BLEScan::start(uint32_t duration) {
- ESP_LOGD(LOG_TAG, ">> start(%d)", duration);
+ ESP_LOGD(LOG_TAG, ">> start(duration=%d)", duration);
m_semaphoreScanEnd.take("start");