#include #include #include #include #include static BLEAddress *pServerAddress; BLEScan* pBLEScan; BLEClient* pClient; std::vector beacons; unsigned long entry; class MyAdvertisedDeviceCallbacks: public BLEAdvertisedDeviceCallbacks { //Called for each advertising BLE server. void onResult(BLEAdvertisedDevice advertisedDevice) { pServerAddress = new BLEAddress(advertisedDevice.getAddress()); BeaconBLE tag; tag.adresse = pServerAddress->toString().c_str(); tag.qualite = advertisedDevice.getRSSI(); beacons.push_back(tag); /* Serial.println(); Serial.print("Device found: "); Serial.print(tag.adresse); Serial.print(" => "); Serial.print(tag.qualite); */ } }; // MyAdvertisedDeviceCallbacks void setup_ble(){ Serial.println("Starting Arduino BLE Client application..."); BLEDevice::init(""); pClient = BLEDevice::createClient(); Serial.println(" - Created client"); pBLEScan = BLEDevice::getScan(); pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks()); pBLEScan->setActiveScan(true); } std::vector loop_ble(){ beacons.clear(); BLEScanResults scanResults = pBLEScan->start(1); return beacons; }