Skip to content

Commit 888c5ae

Browse files
committed
Fix/cleanup examples
1 parent 047128a commit 888c5ae

File tree

8 files changed

+19
-22
lines changed

8 files changed

+19
-22
lines changed

examples/BLE_EddystoneTLM_Beacon/BLE_EddystoneTLM_Beacon.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ void setup() {
6666
Serial.printf("Deep sleep (%llds since last reset, %llds since last boot)\n",
6767
nowTimeStruct.tv_sec,
6868
nowTimeStruct.tv_sec - last);
69-
last = nowTimeStruct.tv_sec;
69+
last = nowTimeStruct.tv_sec;
7070

7171
NimBLEDevice::init("TLMBeacon");
7272
NimBLEDevice::setPower(BEACON_POWER);

examples/Bluetooth_5/NimBLE_extended_client/NimBLE_extended_client.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* Created: on April 2 2022
77
* Author: H2zero
88
*
9-
*/
9+
*/
1010

1111
#include <Arduino.h>
1212
#include <NimBLEDevice.h>

examples/Bluetooth_5/NimBLE_extended_scan/NimBLE_extended_scan.ino

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ static NimBLEScan::Phy scanPhy = NimBLEScan::Phy::SCAN_ALL;
2020
class ScanCallbacks : public NimBLEScanCallbacks {
2121
void onResult(const NimBLEAdvertisedDevice* advertisedDevice) {
2222
Serial.printf("Advertised Device found: %s\n PHY1: %d\n PHY2: %d\n",
23-
advertisedDevice->toString().c_str(),
24-
advertisedDevice->getPrimaryPhy(),
25-
advertisedDevice->getSecondaryPhy());
23+
advertisedDevice->toString().c_str(),
24+
advertisedDevice->getPrimaryPhy(),
25+
advertisedDevice->getSecondaryPhy());
2626
}
2727

2828
/** Callback to process the results of the completed scan or restart it */
@@ -52,6 +52,7 @@ class ScanCallbacks : public NimBLEScanCallbacks {
5252
} scanCallbacks;
5353

5454
void setup() {
55+
Serial.begin(115200);
5556
Serial.printf("Starting Extended Scanner\n");
5657

5758
/** Initialize NimBLE and set the device name */

examples/Bluetooth_5/NimBLE_extended_server/NimBLE_extended_server.ino

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,13 @@ class AdvertisingCallbacks : public NimBLEExtAdvertisingCallbacks {
7575
#ifdef ESP_PLATFORM
7676
esp_deep_sleep_start();
7777
#else
78-
systemRestart(); // nRF platforms restart then sleep via delay in setup.
78+
delay(sleepSeconds * 1000); // system ON sleep mode for nRF platforms to simulate the esp deep sleep with timer wakeup
79+
systemRestart(); // nRF platforms restart then sleep via delay in setup.
7980
#endif
8081
}
8182
} advertisingCallbacks;
8283

8384
void setup() {
84-
#ifndef ESP_PLATFORM
85-
delay(sleepSeconds * 1000); // system ON sleep mode for nRF platforms to simulate the esp deep sleep with timer wakeup
86-
#endif
8785
Serial.begin(115200);
8886

8987
/** Initialize NimBLE and set the device name */

examples/Bluetooth_5/NimBLE_multi_advertiser/NimBLE_multi_advertiser.ino

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ class AdvCallbacks : public NimBLEExtAdvertisingCallbacks {
7979
#ifdef ESP_PLATFORM
8080
esp_deep_sleep_start();
8181
#else
82-
systemRestart(); // nRF platforms restart then sleep via delay in setup.
82+
delay(sleepSeconds * 1000); // system ON sleep mode for nRF platforms to simulate the esp deep sleep with timer wakeup
83+
systemRestart(); // nRF platforms restart then sleep via delay in setup.
8384
#endif
8485
}
8586

@@ -99,9 +100,6 @@ class AdvCallbacks : public NimBLEExtAdvertisingCallbacks {
99100
} advCallbacks;
100101

101102
void setup() {
102-
#ifndef ESP_PLATFORM
103-
delay(sleepSeconds * 1000); // system ON sleep mode for nRF platforms to simulate the esp deep sleep with timer wakeup
104-
#endif
105103
Serial.begin(115200);
106104

107105
/** Initialize NimBLE and set the device name */
@@ -143,7 +141,7 @@ void setup() {
143141
extScannable.enableScanRequestCallback(true);
144142

145143
/** Optional custom address for this advertisment. */
146-
legacyConnectable.setAddress(NimBLEAddress("DE:AD:BE:EF:BA:AD"));
144+
legacyConnectable.setAddress(NimBLEAddress("DE:AD:BE:EF:BA:AD", BLE_ADDR_RANDOM));
147145

148146
/** Set the advertising data. */
149147
legacyConnectable.setName("Legacy");

examples/NimBLE_Scan_Continuous/NimBLE_Scan_Continuous.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ void setup() {
4040
NimBLEDevice::init(""); // Initialize the device, you can specify a device name if you want.
4141
NimBLEScan* pBLEScan = NimBLEDevice::getScan(); // Create the scan object.
4242
pBLEScan->setScanCallbacks(&scanCallbacks, false); // Set the callback for when devices are discovered, no duplicates.
43-
pBLEScan->setActiveScan(true); // Set active scanning, this will get more data from the advertiser.
44-
pBLEScan->setMaxResults(0); // Do not store the scan results, use callback only.
43+
pBLEScan->setActiveScan(true); // Set active scanning, this will get more data from the advertiser.
44+
pBLEScan->setMaxResults(0); // Do not store the scan results, use callback only.
4545
pBLEScan->start(scanTimeMs, false, true); // duration, not a continuation of last scan, restart to get all devices again.
4646
printf("Scanning...\n");
4747
}

examples/NimBLE_Secure_Client/NimBLE_Secure_Client.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ void setup() {
2929
Serial.println("Starting NimBLE Client");
3030

3131
NimBLEDevice::init("");
32-
NimBLEDevice::setPower(3); /** +3db */
33-
NimBLEDevice::setSecurityAuth(true, true, true); /** bonding, MITM, BLE secure connections */
32+
NimBLEDevice::setPower(3); /** +3db */
33+
NimBLEDevice::setSecurityAuth(true, true, true); /** bonding, MITM, BLE secure connections */
3434
NimBLEDevice::setSecurityIOCap(BLE_HS_IO_KEYBOARD_ONLY); /** passkey */
3535
NimBLEScan* pScan = NimBLEDevice::getScan();
3636
NimBLEScanResults results = pScan->getResults(5 * 1000);

examples/NimBLE_Server/NimBLE_Server.ino

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ class ServerCallbacks : public NimBLEServerCallbacks {
7171
class CharacteristicCallbacks : public NimBLECharacteristicCallbacks {
7272
void onRead(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo) override {
7373
Serial.printf("%s : onRead(), value: %s\n",
74-
pCharacteristic->getUUID().toString().c_str(),
75-
pCharacteristic->getValue().c_str());
74+
pCharacteristic->getUUID().toString().c_str(),
75+
pCharacteristic->getValue().c_str());
7676
}
7777

7878
void onWrite(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo) override {
7979
Serial.printf("%s : onWrite(), value: %s\n",
80-
pCharacteristic->getUUID().toString().c_str(),
81-
pCharacteristic->getValue().c_str());
80+
pCharacteristic->getUUID().toString().c_str(),
81+
pCharacteristic->getValue().c_str());
8282
}
8383

8484
/**

0 commit comments

Comments
 (0)