Skip to content

Commit

Permalink
Update examples for NimBLE-Arduino 2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
h2zero committed Dec 20, 2024
1 parent 3880c97 commit 12017a7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ void setup() {
void loop() {
if (!pAdvertising->isAdvertising()) {
// Update the advertised data
pAdvertising->setServiceData(dataUuid, std::string((char*)&count, sizeof(count)));
pAdvertising->setServiceData(dataUuid, &count, sizeof(count));

// Start advertising the data
pAdvertising->start(5);
Expand Down
8 changes: 4 additions & 4 deletions libraries/n-able/examples/BLE_Scan/BLE_Scan.ino
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ NimBLEScan* pBLEScan;
uint32_t scanTime = 30; // Scan duration in seconds (0 = forever)

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

void setup() {
Serial.begin(115200);
Expand All @@ -32,7 +32,7 @@ void setup() {
pBLEScan = NimBLEDevice::getScan();

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

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

0 comments on commit 12017a7

Please sign in to comment.