You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/Migration_guide.md
+32-35Lines changed: 32 additions & 35 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@ This guide describes the required changes to existing projects migrating from th
4
4
5
5
**The changes listed here are only the required changes that must be made**, and a short overview of options for migrating existing applications.
6
6
7
-
For more information on the improvements and additions please refer to the [class documentation](https://h2zero.github.io/NimBLE-Arduino/annotated.html) and [Improvements and updates](Improvements_and_updates.md)
7
+
For more information on the improvements and additions please refer to the [class documentation](https://h2zero.github.io/esp-nimble-cpp/annotated.html) and [Improvements and updates](Improvements_and_updates.md)
8
8
9
9
*[General Changes](#general-information)
10
10
*[Server](#server-api)
@@ -48,7 +48,7 @@ For example `BLEAddress addr(11:22:33:44:55:66, 1)` will create the address obje
48
48
49
49
As this parameter is optional no changes to existing code are needed, it is mentioned here for information.
50
50
51
-
`BLEAddress::getNative`(`NimBLEAddress::getNative`) returns a uint8_t pointer to the native address byte array. In this library the address bytes are stored in reverse order from the original library. This is due to the way the NimBLE stack expects addresses to be presented to it. All other functions such as `toString` are not affected as the endian change is made within them.
51
+
`BLEAddress::getNative`is now named `NimBLEAddress::getBase` and returns a pointer to `const ble_addr_t` instead of a pointer to the address value.
`BLEServerCallbacks::onMtuChanged` (`NimBLEServerCallbacks::onMtuChanged`) takes the parameter `NimBLEConnInfo & connInfo` instead of `esp_ble_gatts_cb_param_t`, which has methods to get information about the connected peer.
75
+
`BLEServerCallbacks::onMtuChanged`is now (`NimBLEServerCallbacks::onMtuChange`) and takes the parameter `NimBLEConnInfo & connInfo` instead of `esp_ble_gatts_cb_param_t`, which has methods to get information about the connected peer.
`BLECharacteristicCallbacks` (`NimBLECharacteristicCallbacks`) has a new method `NimBLECharacteristicCallbacks::onSubscribe` which is called when a client subscribes to notifications/indications.
143
144
144
145
`BLECharacteristicCallbacks::onRead` (`NimBLECharacteristicCallbacks::onRead`) only has a single callback declaration, which takes an additional (required) parameter of `NimBLEConnInfo& connInfo`, which provides connection information about the peer.
@@ -179,8 +180,7 @@ NimBLE automatically creates the 0x2902 descriptor if a characteristic has a not
179
180
It was no longer useful to have a class for the 0x2902 descriptor as a new callback `NimBLECharacteristicCallbacks::onSubscribe` was added
180
181
to handle callback functionality and the client subscription status is handled internally.
181
182
182
-
**Note:** Attempting to create a 0x2902 descriptor will trigger an assert to notify the error,
183
-
allowing the creation of it would cause a fault in the NimBLE stack.
183
+
**Note:** Attempting to create a 0x2902 descriptor will trigger a warning message and flag it internally as removed and will not be functional.
184
184
185
185
All other descriptors are now created just as characteristics are by using the `NimBLECharacteristic::createDescriptor` method (except 0x2904, see below).
Would create a descriptor with the UUID 0xABCD, publicly readable but only writable if paired/bonded (encrypted) and has a max value length of 25 bytes.
209
209
<br/>
210
210
211
-
For the 0x2904, there is a special class that is created when you call `createDescriptor("2904").
212
-
213
-
The pointer returned is of the base class `NimBLEDescriptor` but the call will create the derived class of `NimBLE2904` so you must cast the returned pointer to
214
-
`NimBLE2904` to access the specific class methods.
For the 0x2904, there is a specialized class that is created through `NimBLECharacteristic::create2904` which returns a pointer to a `NimBLE2904` instance which has specific
212
+
functions for handling the data expect in the Characteristic Presentation Format Descriptor specification.
The above descriptor callbacks take an additional (required) parameter `NimBLEConnInfo& connInfo`, which contains the connection information of the peer.
229
222
<br/>
@@ -255,8 +248,7 @@ Calling `NimBLEAdvertising::setAdvertisementData` will entirely replace any data
Now takes 2 optional parameters, the first is the duration to advertise for (in milliseconds), the second is a callback that is invoked when advertising ends and takes a pointer to a `NimBLEAdvertising` object (similar to the `NimBLEScan::start` API).
259
-
This provides an opportunity to update the advertisement data if desired.
251
+
Now takes 2 optional parameters, the first is the duration to advertise for (in milliseconds), the second `NimBLEAddress` to direct advertising to a specific device.
260
252
<br/>
261
253
262
254
<aname="client-api"></a>
@@ -268,15 +260,17 @@ Multiple client instances can be created, up to the maximum number of connection
268
260
269
261
`BLEClient::connect`(`NimBLEClient::connect`) Has had it's parameters altered.
The type parameter has been removed and a new bool parameter has been added to indicate if the client should delete the attribute database previously retrieved (if applicable) for the peripheral, default value is true.
276
268
277
-
If set to false the client will use the attribute database it retrieved from the peripheral when previously connected.
269
+
If set to false the client will use the attribute database it retrieved from the peripheral when previously connected. This allows for faster connections and power saving if the devices dropped connection and are reconnecting.
278
270
279
-
This allows for faster connections and power saving if the devices dropped connection and are reconnecting.
271
+
The parameter `bool asyncConnect` if true, will cause the client to send the connect command to the stack and return immediately without blocking. The return value will represent wether the command was sent successfully or not and the `NimBLEClientCallbacks::onConnect` or `NimBLEClientCallbacks::onConnectFail` will be called when the operation is complete.
272
+
273
+
The parameter `bool exchangeMTU` if true, will cause the client to perform the exchange MTU process upon connecting. If false the MTU exchange will need to be performed by the application by calling `NimBLEClient::exchangeMTU`. If the connection is only sending small payloads it may be advantageous to not exchange the MTU to gain performance in the connection process.
This method now takes an optional (bool) parameter to indicate if the characteristics should be retrieved from the server (true) or
305
-
the currently known database returned (false : default).
298
+
This method now takes an optional (bool) parameter to indicate if the characteristics should be retrieved from the server (true) or the currently known database returned, default = false.
306
299
Also now returns a pointer to `std::vector` instead of `std::map`.
This method now takes an optional (bool) parameter to indicate if the descriptors should be retrieved from the server (true) or
356
-
the currently known database returned (false : default).
348
+
This method now takes an optional (bool) parameter to indicate if the descriptors should be retrieved from the server (true) or the currently known database returned, default = false.
357
349
Also now returns a pointer to `std::vector` instead of `std::map`.
358
350
<br/>
359
351
@@ -373,7 +365,12 @@ The default configuration will use "just-works" pairing with no bonding, if you
373
365
374
366
<aname="scan-api"></a>
375
367
## BLE Scan
376
-
The scan API is mostly unchanged from the original except for `NimBLEScan::start`, in which the duration parameter is now in milliseconds instead of seconds.
368
+
The scan API is mostly unchanged from the original except for `NimBLEScan::start`, which has the following changes:
369
+
* The duration parameter is now in milliseconds instead of seconds.
370
+
* The callback parameter has been removed.
371
+
* A new parameter `bool restart` has been added, when set to true to restart the scan if already in progress and clear the duplicate cache.
372
+
373
+
The blocking overload of `NimBLEScan::start` has been replaced by an overload of `NimBLEScan::getResults` with the same parameters.
0 commit comments