Skip to content

Commit 0fb00b5

Browse files
committed
Update examples for NimBLE-Arduino 2.x
1 parent 3880c97 commit 0fb00b5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

libraries/n-able/examples/BLE_Advertiser/BLE_Advertiser.ino

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ void setup() {
3030
void loop() {
3131
if (!pAdvertising->isAdvertising()) {
3232
// Update the advertised data
33-
pAdvertising->setServiceData(dataUuid, std::string((char*)&count, sizeof(count)));
33+
pAdvertising->setServiceData(dataUuid, static_cast<uint8_t*>(&count), sizeof(count));
3434

3535
// Start advertising the data
3636
pAdvertising->start(5);

libraries/n-able/examples/BLE_Scan/BLE_Scan.ino

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ NimBLEScan* pBLEScan;
1515
uint32_t scanTime = 30; // Scan duration in seconds (0 = forever)
1616

1717
// Callback class for received advertisements
18-
class MyAdvertisedDeviceCallbacks: public NimBLEAdvertisedDeviceCallbacks {
19-
void onResult(NimBLEAdvertisedDevice* advertisedDevice) {
18+
class ScanCallbacks: public NimBLEScanCallbacks {
19+
void onResult(const NimBLEAdvertisedDevice* advertisedDevice) {
2020
Serial.printf("Advertised Device: %s \n", advertisedDevice->toString().c_str());
2121
}
22-
};
22+
} scanCallbacks;
2323

2424
void setup() {
2525
Serial.begin(115200);
@@ -32,7 +32,7 @@ void setup() {
3232
pBLEScan = NimBLEDevice::getScan();
3333

3434
// Set the callback for when devices are discovered, no duplicates.
35-
pBLEScan->setAdvertisedDeviceCallbacks(new MyAdvertisedDeviceCallbacks(), false);
35+
pBLEScan->setScanCallbacks(&scanCallbacks, false);
3636

3737
// Set active scanning, this will get scan response data from the advertiser.
3838
pBLEScan->setActiveScan(true);

0 commit comments

Comments
 (0)