diff options
author | chegewara <imperiaonline4@gmail.com> | 2018-11-30 10:59:14 +0100 |
---|---|---|
committer | chegewara <imperiaonline4@gmail.com> | 2018-11-30 10:59:14 +0100 |
commit | 934702b6169b92c71cbc850876fd17fb9ee3236d (patch) | |
tree | 048df4f7106cd4a574b609a13e62a36567f5a322 /examples/BLE_scan/BLE_scan.ino | |
parent | Upload of 0.4.16 (diff) | |
download | thermostat-934702b6169b92c71cbc850876fd17fb9ee3236d.tar.gz thermostat-934702b6169b92c71cbc850876fd17fb9ee3236d.tar.bz2 thermostat-934702b6169b92c71cbc850876fd17fb9ee3236d.zip |
Changes, bugfixes and updgrades. Library is ready to work with arduino-esp32 v1.0.1.
Diffstat (limited to 'examples/BLE_scan/BLE_scan.ino')
-rw-r--r-- | examples/BLE_scan/BLE_scan.ino | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/examples/BLE_scan/BLE_scan.ino b/examples/BLE_scan/BLE_scan.ino index ef7d892..094f793 100644 --- a/examples/BLE_scan/BLE_scan.ino +++ b/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 |