summaryrefslogtreecommitdiff
path: root/sensor/patchedBLE/examples/BLE_scan
diff options
context:
space:
mode:
authordakkar <dakkar@thenautilus.net>2019-02-22 12:39:08 +0000
committerdakkar <dakkar@thenautilus.net>2019-02-22 12:39:08 +0000
commit67a9dbb8e33e2bbb785e6a16a6ce5837c1a46c97 (patch)
tree0f5b064f03372305369a41b10e157aa89552e2f0 /sensor/patchedBLE/examples/BLE_scan
parentuni-init BLE before sleeping (diff)
parentMerge pull request #23 from tatsutaigu/master (diff)
downloadthermostat-67a9dbb8e33e2bbb785e6a16a6ce5837c1a46c97.tar.gz
thermostat-67a9dbb8e33e2bbb785e6a16a6ce5837c1a46c97.tar.bz2
thermostat-67a9dbb8e33e2bbb785e6a16a6ce5837c1a46c97.zip
Merge commit 'b232e7f5f0e87f36afbc2f4e03a2c49c48dd47bc'
Diffstat (limited to 'sensor/patchedBLE/examples/BLE_scan')
-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