summaryrefslogtreecommitdiff
path: root/sensor/patchedBLE/examples/BLE_scan/BLE_scan.ino
diff options
context:
space:
mode:
Diffstat (limited to 'sensor/patchedBLE/examples/BLE_scan/BLE_scan.ino')
-rw-r--r--sensor/patchedBLE/examples/BLE_scan/BLE_scan.ino16
1 files changed, 10 insertions, 6 deletions
diff --git a/sensor/patchedBLE/examples/BLE_scan/BLE_scan.ino b/sensor/patchedBLE/examples/BLE_scan/BLE_scan.ino
index ef7d892..094f793 100644
--- a/sensor/patchedBLE/examples/BLE_scan/BLE_scan.ino
+++ b/sensor/patchedBLE/examples/BLE_scan/BLE_scan.ino
@@ -8,7 +8,8 @@
#include <BLEScan.h>
#include <BLEAdvertisedDevice.h>
-int scanTime = 30; //In seconds
+int scanTime = 5; //In seconds
+BLEScan* pBLEScan;
class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks {
void onResult(BLEAdvertisedDevice advertisedDevice) {
@@ -21,16 +22,19 @@ void setup() {
Serial.println("Scanning...");
BLEDevice::init("");
- BLEScan* pBLEScan = BLEDevice::getScan(); //create new scan
+ pBLEScan = BLEDevice::getScan(); //create new scan
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
pBLEScan->setActiveScan(true); //active scan uses more power, but get results faster
- BLEScanResults foundDevices = pBLEScan->start(scanTime);
- Serial.print("Devices found: ");
- Serial.println(foundDevices.getCount());
- Serial.println("Scan done!");
+ pBLEScan->setInterval(100);
+ pBLEScan->setWindow(99); // less or equal setInterval value
}
void loop() {
// put your main code here, to run repeatedly:
+ BLEScanResults foundDevices = pBLEScan->start(scanTime, false);
+ Serial.print("Devices found: ");
+ Serial.println(foundDevices.getCount());
+ Serial.println("Scan done!");
+ pBLEScan->clearResults(); // delete results fromBLEScan buffer to release memory
delay(2000);
} \ No newline at end of file