Skip to content

Commit 5f73c00

Browse files
committed
[Breaking] Rename callback setters to setCallbacks, taking a reference only
1 parent a3f9a6e commit 5f73c00

34 files changed

Lines changed: 185 additions & 175 deletions

examples/ANCS/ANCS.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ void setup() {
120120
NimBLEDevice::setPower(9);
121121

122122
NimBLEServer* pServer = NimBLEDevice::createServer();
123-
pServer->setCallbacks(&serverCallbacks);
123+
pServer->setCallbacks(serverCallbacks);
124124
pServer->advertiseOnDisconnect(true);
125125

126126
NimBLEAdvertising* pAdvertising = pServer->getAdvertising();

examples/BLE_Beacon_Scanner/BLE_Beacon_Scanner.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ void setup() {
8181

8282
NimBLEDevice::init("Beacon-scanner");
8383
pBLEScan = BLEDevice::getScan();
84-
pBLEScan->setScanCallbacks(&scanCallbacks);
84+
pBLEScan->setCallbacks(scanCallbacks);
8585
pBLEScan->setActiveScan(true);
8686
pBLEScan->setInterval(100);
8787
pBLEScan->setWindow(100);

examples/Bluetooth_5/NimBLE_extended_client/NimBLE_extended_client.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ bool connectToServer() {
5757
NimBLEClient* pClient = nullptr;
5858

5959
pClient = NimBLEDevice::createClient();
60-
pClient->setClientCallbacks(&clientCallbacks, false);
60+
pClient->setCallbacks(clientCallbacks);
6161

6262
/**
6363
* Set the PHY's to use for this connection. This is a bitmask that represents the PHY's:
@@ -112,7 +112,7 @@ void setup() {
112112

113113
/** Create aNimBLE Scan instance and set the callbacks for scan events */
114114
NimBLEScan* pScan = NimBLEDevice::getScan();
115-
pScan->setScanCallbacks(&scanCallbacks);
115+
pScan->setCallbacks(scanCallbacks);
116116

117117
/** Set scan interval (how often) and window (how long) in milliseconds */
118118
pScan->setInterval(97);

examples/Bluetooth_5/NimBLE_extended_scan/NimBLE_extended_scan.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void setup() {
6060
NimBLEScan* pScan = NimBLEDevice::getScan();
6161

6262
/** Set the callbacks that the scanner will call on events. */
63-
pScan->setScanCallbacks(&scanCallbacks);
63+
pScan->setCallbacks(scanCallbacks);
6464

6565
/** Use active scanning to obtain scan response data from advertisers */
6666
pScan->setActiveScan(true);

examples/Bluetooth_5/NimBLE_extended_server/NimBLE_extended_server.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void setup() {
8989

9090
/** Create the server and add the services/characteristics/descriptors */
9191
NimBLEServer* pServer = NimBLEDevice::createServer();
92-
pServer->setCallbacks(&serverCallbacks);
92+
pServer->setCallbacks(serverCallbacks);
9393

9494
NimBLEService* pService = pServer->createService(SERVICE_UUID);
9595
NimBLECharacteristic* pCharacteristic =
@@ -125,7 +125,7 @@ void setup() {
125125
NimBLEExtAdvertising* pAdvertising = NimBLEDevice::getAdvertising();
126126

127127
/** Set the callbacks for advertising events */
128-
pAdvertising->setCallbacks(&advertisingCallbacks);
128+
pAdvertising->setCallbacks(advertisingCallbacks);
129129

130130
/**
131131
* NimBLEExtAdvertising::setInstanceData takes the instance ID and

examples/Bluetooth_5/NimBLE_multi_advertiser/NimBLE_multi_advertiser.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ void setup() {
107107

108108
/** Create a server for our legacy advertiser */
109109
NimBLEServer* pServer = NimBLEDevice::createServer();
110-
pServer->setCallbacks(&serverCallbacks);
110+
pServer->setCallbacks(serverCallbacks);
111111

112112
NimBLEService* pService = pServer->createService(SERVICE_UUID);
113113
NimBLECharacteristic* pCharacteristic =
@@ -155,7 +155,7 @@ void setup() {
155155
NimBLEExtAdvertising* pAdvertising = NimBLEDevice::getAdvertising();
156156

157157
/** Set the callbacks to handle advertising events */
158-
pAdvertising->setCallbacks(&advCallbacks);
158+
pAdvertising->setCallbacks(advCallbacks);
159159

160160
/**
161161
* Set instance data.

examples/L2CAP/L2CAP_Client/L2CAP_Client.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void setup() {
8686
NimBLEDevice::setMTU(BLE_ATT_MTU_MAX);
8787

8888
auto scan = NimBLEDevice::getScan();
89-
scan->setScanCallbacks(&scanCallbacks);
89+
scan->setCallbacks(scanCallbacks);
9090
scan->setInterval(1349);
9191
scan->setWindow(449);
9292
scan->setActiveScan(true);
@@ -106,7 +106,7 @@ void loop() {
106106
if (!theClient) {
107107
theClient = NimBLEDevice::createClient();
108108
theClient->setConnectionParams(6, 6, 0, 42);
109-
theClient->setClientCallbacks(&clientCallbacks);
109+
theClient->setCallbacks(clientCallbacks);
110110
if (!theClient->connect(theDevice)) {
111111
Serial.println("Error: Could not connect to device");
112112
return;

examples/L2CAP/L2CAP_Server/L2CAP_Server.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ void setup() {
6565
auto channel = cocServer->createService(L2CAP_CHANNEL, L2CAP_MTU, &l2capCallbacks);
6666

6767
auto server = NimBLEDevice::createServer();
68-
server->setCallbacks(&gattCallbacks);
68+
server->setCallbacks(gattCallbacks);
6969

7070
auto service = server->createService(SERVICE_UUID);
7171
auto characteristic = service->createCharacteristic(CHARACTERISTIC_UUID, NIMBLE_PROPERTY::READ);

examples/NimBLE_Async_Client/NimBLE_Async_Client.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ class ScanCallbacks : public NimBLEScanCallbacks {
4040
}
4141
}
4242

43-
pClient->setClientCallbacks(&clientCallbacks, false);
43+
pClient->setCallbacks(clientCallbacks);
4444
if (!pClient->connect(true, true, false)) { // delete attributes, async connect, no MTU exchange
4545
NimBLEDevice::deleteClient(pClient);
4646
Serial.printf("Failed to connect\n");
@@ -62,7 +62,7 @@ void setup() {
6262
NimBLEDevice::setPower(3); /** +3db */
6363

6464
NimBLEScan* pScan = NimBLEDevice::getScan();
65-
pScan->setScanCallbacks(&scanCallbacks);
65+
pScan->setCallbacks(scanCallbacks);
6666
pScan->setInterval(45);
6767
pScan->setWindow(45);
6868
pScan->setActiveScan(true);

examples/NimBLE_Client/NimBLE_Client.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ bool connectToServer() {
122122

123123
Serial.printf("New client created\n");
124124

125-
pClient->setClientCallbacks(&clientCallbacks, false);
125+
pClient->setCallbacks(clientCallbacks);
126126
/**
127127
* Set initial connection parameters:
128128
* These settings are safe for 3 clients to connect reliably, can go faster if you have less
@@ -273,7 +273,7 @@ void setup() {
273273
NimBLEScan* pScan = NimBLEDevice::getScan();
274274

275275
/** Set the callbacks to call when scan events occur, no duplicates */
276-
pScan->setScanCallbacks(&scanCallbacks, false);
276+
pScan->setCallbacks(scanCallbacks, false);
277277

278278
/** Set scan interval (how often) and window (how long) in milliseconds */
279279
pScan->setInterval(100);

0 commit comments

Comments
 (0)