any interest? adapted from Kolban "BLESCAN". After some adjustments getting "...Arduino\libraries\ClassicBTScan-master\src/BTAdvertisedDevice.cpp:482: undefined reference to `BTAdvertisedDevice::getServiceUUID()'". Listing follows.
/*
Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleScan.cpp
Ported to Arduino ESP32 by Evandro Copercini
and notes from rexxZ marked as RZNOTE
*/
#include <BTDevice.h>
#include <BTUtils.h>
#include <BTScan.h>
#include <BTAdvertisedDevice.h>
int scanTime = 5; //In seconds
BTScan* pBTScan;
class MyAdvertisedDeviceCallbacks: public BTAdvertisedDeviceCallbacks {
void onResult(BTAdvertisedDevice advertisedDevice) {
Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str());
}
};
void setup() {
Serial.begin(115200);
Serial.println("Scanning...");
BTDevice::init("");
pBTScan = BTDevice::getScan(); //create new scan
pBTScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
// RZ NOTE setActiveScan and setInterval and setWindow all exist in BLEScan.cpp but not in BTScan.cpp
// pBTScan->setActiveScan(true); //active scan uses more power, but get results faster
// pBTScan->setInterval(100);
//pBTScan->setWindow(99); // less or equal setInterval value
}
void loop() {
// put your main code here, to run repeatedly:
//RZ NOTE changed from BTScanResults foundDevices = pBTScan->start(scanTime, false);
BTScanResults foundDevices = pBTScan->start(scanTime);
Serial.print("Devices found: ");
Serial.println(foundDevices.getCount());
Serial.println("Scan done!");
// RZ NOTE clearResults not found
// pBTScan->clearResults(); // delete results fromBLEScan buffer to release memory
delay(2000);
}
any interest? adapted from Kolban "BLESCAN". After some adjustments getting "...Arduino\libraries\ClassicBTScan-master\src/BTAdvertisedDevice.cpp:482: undefined reference to `BTAdvertisedDevice::getServiceUUID()'". Listing follows.
/*
Based on Neil Kolban example for IDF: https://github.com/nkolban/esp32-snippets/blob/master/cpp_utils/tests/BLE%20Tests/SampleScan.cpp
Ported to Arduino ESP32 by Evandro Copercini
and notes from rexxZ marked as RZNOTE
*/
#include <BTDevice.h>
#include <BTUtils.h>
#include <BTScan.h>
#include <BTAdvertisedDevice.h>
int scanTime = 5; //In seconds
BTScan* pBTScan;
class MyAdvertisedDeviceCallbacks: public BTAdvertisedDeviceCallbacks {
void onResult(BTAdvertisedDevice advertisedDevice) {
Serial.printf("Advertised Device: %s \n", advertisedDevice.toString().c_str());
}
};
void setup() {
Serial.begin(115200);
Serial.println("Scanning...");
BTDevice::init("");
pBTScan = BTDevice::getScan(); //create new scan
pBTScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks());
// RZ NOTE setActiveScan and setInterval and setWindow all exist in BLEScan.cpp but not in BTScan.cpp
// pBTScan->setActiveScan(true); //active scan uses more power, but get results faster
// pBTScan->setInterval(100);
//pBTScan->setWindow(99); // less or equal setInterval value
}
void loop() {
// put your main code here, to run repeatedly:
//RZ NOTE changed from BTScanResults foundDevices = pBTScan->start(scanTime, false);
BTScanResults foundDevices = pBTScan->start(scanTime);
Serial.print("Devices found: ");
Serial.println(foundDevices.getCount());
Serial.println("Scan done!");
// RZ NOTE clearResults not found
// pBTScan->clearResults(); // delete results fromBLEScan buffer to release memory
delay(2000);
}