diff options
author | dakkar <dakkar@thenautilus.net> | 2019-02-22 12:39:08 +0000 |
---|---|---|
committer | dakkar <dakkar@thenautilus.net> | 2019-02-22 12:39:08 +0000 |
commit | 67a9dbb8e33e2bbb785e6a16a6ce5837c1a46c97 (patch) | |
tree | 0f5b064f03372305369a41b10e157aa89552e2f0 /sensor/patchedBLE/examples/BLE_scan | |
parent | uni-init BLE before sleeping (diff) | |
parent | Merge pull request #23 from tatsutaigu/master (diff) | |
download | thermostat-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.ino | 16 |
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 |