Hello. I am very new with Arduino and with BLE. Will anybody share the code to get all the scanned (BLE.scan()) devices and put their addresses, names and RSSIs in arrays? In the documentation I can only find the BLE.available() method to discover one peripheral. I thought looping with this command for some seconds adding to the arrays as it retreives devices, but I find it a little archacic.
check this sample code out
the BLE.available() call will return a BLEDevice instance ➜ probably easier to build an array of BLEDevice
Thank you. So basically, you say that the only way is what I thought as an archaic solution.
I was hoping to have something like a sample I found for FireBeetle-ESP32:
BLEScan *scan = BLEDevice::getScan();
scan->setActiveScan(true);
BLEScanResults results = scan->start(1);
for (int i = 0 ; i < results.getCount() ; i++) {
BLEAdvertisedDevice device = results.getDevice(i);
int myRSSI = device.getRSSI();
etc...
Isn't this feasible with nano 33 BLE?
Thank you
The API you use is in ArduinoBLE.h
You can read more about it at ArduinoBLE - Arduino Reference
There is an underlying linked list but it’s private to the class and so you won’t be able to access it directly, the API is through the available() call
That one is my bible for this protoype. Thank you.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.