Skip to content

Commit f672d04

Browse files
committed
Update Documentation.
1 parent d3aa435 commit f672d04

File tree

5 files changed

+110
-38
lines changed

5 files changed

+110
-38
lines changed

docs/Doxyfile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "esp-nimble-cpp / NimBLE-Arduino"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER =
41+
PROJECT_NUMBER = 1.0.0
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a
@@ -913,7 +913,9 @@ RECURSIVE = YES
913913

914914
EXCLUDE = ./README.md \
915915
./src/FreeRTOS.h \
916-
./src/FreeRTOS.cpp
916+
./src/FreeRTOS.cpp \
917+
./examples \
918+
./CMakelists.txt
917919

918920
# The EXCLUDE_SYMLINKS tag can be used to select whether or not files or
919921
# directories that are symbolic links (a Unix file system feature) are excluded

docs/Improvements_and_updates.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,14 @@
11
# Improvements and updates
22

3+
Many improvements have been made to this library vs the original, this is a brief overview of the most significant changes.
4+
Refer to the [class documentation](https://h2zero.github.io/esp-nimble-cpp/annotated.html) for futher information on class specifics.
5+
6+
* [Server](#server)
7+
* [Client](#client)
8+
* [General](#general)
9+
<br/>
10+
11+
<a name="server"></a>
312
# Server
413

514
`NimBLECharacteristic::setValue(const T &s)`
@@ -51,6 +60,7 @@ it's characteristics / descriptors will remain valid and the service can be re-a
5160
using `NimBLEServer::addService`.
5261
<br/>
5362

63+
<a name="client"></a>
5464
# Client
5565

5666
`NimBLERemoteCharacteristic::readValue(time_t\*, bool)`
@@ -96,8 +106,9 @@ These changes allow more control for the user to manage the resources used for t
96106
`NimBLEClient::connect()` can now be called without an address or advertised device parameter. This will connect to the
97107
device with the address previously set when last connected or set with `NimBLEDevice::setPeerAddress()`.
98108

109+
<a name="general"></a>
99110
# General
100-
To reduce resource use all instances of std::map have been replaced with std::vector.
111+
To reduce resource use all instances of `std::map` have been replaced with `std::vector`.
101112

102113
Use of `FreeRTOS::Semaphore` has been removed as it was consuming too much ram, the related files have been left in place to accomodate application use.
103114

@@ -110,7 +121,5 @@ Security/pairing operations are now handled in the respective `NimBLEClientCallb
110121
Configuration options have been added to add or remove debugging information, when disabled (default) significatly reduces binary size.
111122
In ESP-IDF the options are in menuconfig: `Main menu -> ESP-NimBLE-cpp configuration`.
112123
For Arduino the options must be commented / uncommented in nimconfig.h.
113-
114-
Many more internal improvements have been made as well, this is a brief overview. Refer to the class docs for futher information on class specifics.
115124
<br/>
116125

docs/Migration_guide.md

Lines changed: 86 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This guide describes the required changes to existing projects migrating from the original bluedroid API to NimBLE.
44

5-
The changes listed here are only the **required changes that must be made** and a short overview of options for migrating existing applications.
5+
**The changes listed here are only the required changes that must be made**, and a short overview of options for migrating existing applications.
66

77
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)
88

@@ -11,13 +11,18 @@ For more information on the improvements and additions please refer to the [clas
1111
* [Services](#services)
1212
* [characteristics](#characteristics)
1313
* [descriptors](#descriptors)
14+
* [Security](#server-security)
15+
* [Advertising](#advertising-api)
1416
* [Client](#client-api)
1517
* [Remote Services](#remote-services)
1618
* [Remote characteristics](#remote-characteristics)
17-
* [Security](#security-api)
19+
* [Security](#client-security)
20+
* [General Security](#security-api)
21+
* [Configuration](#arduino-configuration)
1822
<br/>
1923

20-
# General Information {#general-information}
24+
<a name="general-information"></a>
25+
## General Information
2126

2227
### Header Files
2328
All classes are accessible by including `NimBLEDevice.h` in your application, no further headers need to be included.
@@ -42,20 +47,22 @@ For example `BLEAddress addr(11:22:33:44:55:66, 1)` will create the address obje
4247

4348
As this paramameter is optional no changes to existing code are needed, it is mentioned here for information.
4449
<br/>
45-
46-
## Server API {#server-api}
50+
<a name="server-api"></a>
51+
## Server API
4752
Creating a `BLEServer` instance is the same as original, no changes required.
4853
For example `BLEDevice::createServer()` will work just as it did before.
4954

5055
`BLEServerCallbacks` (`NimBLEServerCallbacks`) has new methods for handling security operations.
5156
**Note:** All callback methods have default implementations which allows the application to implement only the methods applicable.
5257
<br/>
5358

54-
### Services {#services}
59+
<a name="services"></a>
60+
### Services
5561
Creating a `BLEService` (`NimBLEService`) instance is the same as original, no changes required.
5662
For example `BLEServer::createService(SERVICE_UUID)` will work just as it did before.
5763

58-
### Characteristics {#characteristics}
64+
<a name="characteristics"></a>
65+
### Characteristics
5966
`BLEService::createCharacteristic` (`NimBLEService::createCharacteristic`) is used the same way as originally except the properties parameter has changed.
6067

6168
When creating a characteristic the properties are now set with `NIMBLE_PROPERTY::XXXX` instead of `BLECharacteristic::XXXX`.
@@ -103,11 +110,32 @@ BLECharacteristic *pCharacteristic = pService->createCharacteristic(
103110
```
104111
<br/>
105112

106-
`BLECharacteristicCallbacks` (`NimBLECharacteristicCallbacks`) has a new method `NimBLECharacteristicCallbacks::onSubscribe` which called when a client subscribes to notifications/indications.
113+
`BLECharacteristicCallbacks` (`NimBLECharacteristicCallbacks`) has a new method `NimBLECharacteristicCallbacks::onSubscribe`
114+
which is called when a client subscribes to notifications/indications.
115+
107116
**Note:** All callback methods have default implementations which allows the application to implement only the methods applicable.
108117
<br/>
109118

110-
### Descriptors {descriptors}
119+
> BLECharacteristic::getData
120+
121+
**Has been removed from the API.**
122+
Originally this returned a `uint8_t*` to the internal data, which is volatile.
123+
To prevent possibly throwing exceptions this has been removed and `NimBLECharacteristic::getValue` should be used
124+
to get a copy of the data first which can then safely be accessed via pointer.
125+
126+
**Example:**
127+
```
128+
std::string value = pCharacteristic->getValue();
129+
uint8_t *pData = (uint8_t*)value.data();
130+
```
131+
Alternatively use the `getValue` template:
132+
```
133+
my_struct_t myStruct = pChr->getValue<my_struct_t>();
134+
```
135+
<br/>
136+
137+
<a name="descriptors"></a>
138+
### Descriptors
111139
The previous method `BLECharacteristic::addDescriptor()` has been removed.
112140

113141
Descriptors are now created using the `NimBLECharacteristic::createDescriptor` method.
@@ -158,6 +186,7 @@ p2904 = (NimBLE2904*)pCharacteristic->createDescriptor("2904");
158186
```
159187
<br/>
160188

189+
<a name="server-security"></a>
161190
### Server Security
162191
Security is set on the characteristic or descriptor properties by applying one of the following:
163192
> NIMBLE_PROPERTY::READ_ENC
@@ -172,7 +201,18 @@ it will trigger the pairing process. By default the "just-works" pairing will be
172201
This can be changed to use passkey authentication or numeric comparison. See [Security API](#security-api) for details.
173202
<br/>
174203

175-
## Client API {#client-api}
204+
<a name="advertising-api"></a>
205+
## Advertising API
206+
Advertising works the same as the original API except with the removal of:
207+
> BLEAdvertising::setMinPreferred
208+
> BLEAdvertising::setMaxPreferred
209+
210+
These methods were found to not provide useful functionality and consumed valuable advertising space (6 bytes of 31) if used unknowingly.
211+
If you wish to advertise these parameters you can still do so manually via `NimBLEAdvertisementData::addData`.
212+
<br/>
213+
214+
<a name="client-api"></a>
215+
## Client API
176216

177217
Client instances are created just as before with `BLEDevice::createClient` (`NimBLEDevice::createClient`).
178218

@@ -205,7 +245,8 @@ the user may not be interested in.
205245
to replace the the removed automatic functionality.
206246
<br/>
207247

208-
### Remote Services {#remote-services}
248+
<a name="remote-services"></a>
249+
### Remote Services
209250
`BLERemoteService` (`NimBLERemoteService`) Methods remain mostly unchanged with the exceptions of:
210251

211252
> BLERemoteService::getCharacteristicsByHandle
@@ -220,7 +261,8 @@ the currently known database returned (false : default).
220261
Also now returns a pointer to `std::vector` instead of `std::map`.
221262
<br/>
222263

223-
### Remote Characteristics{#remote-characteristics}
264+
<a name="remote-characteristics"></a>
265+
### Remote Characteristics
224266
`BLERemoteCharacteristic` (`NimBLERemoteCharacteristic`) There have been a few changes to the methods in this class:
225267

226268
> `BLERemoteCharacteristic::writeValue` (`NimBLERemoteCharacteristic::writeValue`)
@@ -232,8 +274,8 @@ Now return true or false to indicate success or failure so you can choose to dis
232274
> `BLERemoteCharacteristic::registerForNotify` (`NimBLERemoteCharacteristic::registerForNotify`)
233275
234276
Is now **deprecated**.
235-
> NimBLERemoteCharacteristic::subscribe
236-
> NimBLERemoteCharacteristic::unsubscribe
277+
> `NimBLERemoteCharacteristic::subscribe`
278+
> `NimBLERemoteCharacteristic::unsubscribe`
237279
238280
Are the new methods added to replace it.
239281
<br/>
@@ -246,13 +288,15 @@ Are the new methods added to replace it.
246288
Are **deprecated** a template: NimBLERemoteCharacteristic::readValue<type\>(time_t\*, bool) has been added to replace them.
247289
<br/>
248290

249-
> BLERemoteCharacteristic::readRawData
291+
> `BLERemoteCharacteristic::readRawData`
250292
251-
Has been removed from the API as it stored an unnecessary copy of the data.
293+
**Has been removed from the API**
294+
Originally it stored an unnecessary copy of the data and was returning a `uint8_t` pointer to volatile internal data.
252295
The user application should use `NimBLERemoteCharacteristic::readValue` or `NimBLERemoteCharacteristic::getValue`.
253-
Then cast the returned std::string to the type they wish such as:
296+
To obatain a copy of the data, then cast the returned std::string to the type required such as:
254297
```
255-
uint8_t *val = (uint8_t*)pChr->readValue().data();
298+
std::string value = pChr->readValue();
299+
uint8_t *data = (uint8_t*)value.data();
256300
```
257301
Alternatively use the `readValue` template:
258302
```
@@ -267,54 +311,67 @@ the currently known database returned (false : default).
267311
Also now returns a pointer to `std::vector` instead of `std::map`.
268312
<br/>
269313

270-
### Client Security {#client-security}
314+
<a name="client-security"></a>
315+
### Client Security
271316
The client will automatically initiate security when the peripheral responds that it's required.
272317
The default configuration will use "just-works" pairing with no bonding, if you wish to enable bonding see below.
273318
<br/>
274319

275-
## Security API {#security-api}
320+
<a name="security-api"></a>
321+
## Security API
276322
Security operations have been moved to `BLEDevice` (`NimBLEDevice`).
277323

278-
Also security callback methods are now incorporated in the NimBLEServerCallbacks / NimBLEClientCallbacks classes.
324+
Also security callback methods are now incorporated in the `NimBLEServerCallbacks` / `NimBLEClientCallbacks` classes.
279325
However backward compatibility with the original `BLESecurity` (`NimBLESecurity`) class is retained to minimize application code changes.
280326

281327
The callback methods are:
282328

283-
> bool onConfirmPIN(uint32_t pin);
329+
> `bool onConfirmPIN(uint32_t pin)`
284330
285331
Receives the pin when using numeric comparison authentication, `return true;` to accept.
286332
<br/>
287333

288-
> uint32_t onPassKeyRequest();
334+
> `uint32_t onPassKeyRequest()`
289335
290336
For server callback; return the passkey expected from the client.
291337
For client callback; return the passkey to send to the server.
292338
<br/>
293339

294-
> void onAuthenticationComplete(ble_gap_conn_desc\* desc);
340+
> `void onAuthenticationComplete(ble_gap_conn_desc\* desc)`
295341
296342
Authentication complete, success or failed information is in `desc`.
297343
<br/>
298344

299345
Security settings and IO capabilities are now set by the following methods of NimBLEDevice.
300-
> NimBLEDevice::setSecurityAuth(bool bonding, bool mitm, bool sc)
301-
> NimBLEDevice::setSecurityAuth(uint8_t auth_req)
346+
> `NimBLEDevice::setSecurityAuth(bool bonding, bool mitm, bool sc)`
347+
> `NimBLEDevice::setSecurityAuth(uint8_t auth_req)`
302348
303349
Sets the authorization mode for this device.
304350
<br/>
305351

306-
> NimBLEDevice::setSecurityIOCap(uint8_t iocap)
352+
> `NimBLEDevice::setSecurityIOCap(uint8_t iocap)`
307353
308354
Sets the Input/Output capabilities of this device.
309355
<br/>
310356

311-
> NimBLEDevice::setSecurityInitKey(uint8_t init_key)
357+
> `NimBLEDevice::setSecurityInitKey(uint8_t init_key)`
312358
313359
If we are the initiator of the security procedure this sets the keys we will distribute.
314360
<br/>
315361

316-
> NimBLEDevice::setSecurityRespKey(uint8_t resp_key)
362+
> `NimBLEDevice::setSecurityRespKey(uint8_t resp_key)`
317363
318364
Sets the keys we are willing to accept from the peer during pairing.
319365
<br/>
320366

367+
<a name="arduino-configuration"></a>
368+
## Arduino Configuration
369+
370+
Unlike the original library pre-packaged in the esp32-arduino, this library has all the configuration
371+
options that are normally set in menuconfig available in the *src/nimconfig.h* file.
372+
373+
This allows Arduino users to fully customize the build, such as increasing max connections
374+
or loading the BLE stack into external PSRAM.
375+
376+
For details on the options, they are fully commented in *nimconfig.h*
377+
<br/>

docs/New_user_guide.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ If you're not creating a server or do not want to advertise a name, simply pass
2121
This can be called any time you wish to use BLE functions and does not need to be called from app_main(IDF) or setup(Arduino) but usually is.
2222
<br/>
2323

24-
## Creating a Server {#creating-a-server}
24+
<a name="creating-a-server"></a>
25+
## Creating a Server
2526
BLE servers perform 2 tasks, they advertise their existance for clients to find them and they provide services which contain information for the connecting client.
2627

2728
After initializing the NimBLE stack we create a server by calling `NimBLEDevice::createServer()`, this will create a server instance and return a pointer to it.
@@ -136,7 +137,8 @@ Now if you scan with your phone using nRFConnect or any other BLE app you should
136137
For more advanced features and options please see the server examples in the examples folder.
137138
<br/>
138139

139-
## Creating a Client {#creating-a-client}
140+
<a name="creating-a-client"></a>
141+
## Creating a Client
140142

141143
BLE clients perform 2 tasks, they scan for advertising servers and form connections to them to read and write to their characteristics/descriptors.
142144

docs/index.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ Download as .zip and extract to Arduino/libraries folder, or in Arduino IDE from
1818

1919
`#include "NimBLEDevice.h"` at the beginning of your sketch.
2020

21-
Tested and working with esp32-arduino v1.0.2 and 1.0.4 in Arduino IDE v1.8.12 and platform IO.
21+
Tested and working with esp32-arduino Arduino IDE and platform IO.
2222
<br/>
2323

2424
# ESP-IDF Installation
@@ -44,7 +44,9 @@ Call `NimBLEDevice::init("");` in `app_main`.
4444
# Using
4545
This library is intended to be compatible with the original ESP32 BLE functions and types with minor changes.
4646

47-
See: [The migration guide](Migration_guide.md) for details.
47+
If you have not used the original Bluedroid library please refer to the [New user guide](New_user_guide.md).
48+
49+
If you are familiar with the original library, see: [The migration guide](Migration_guide.md) for details.
4850

4951
Also see [Improvements_and_updates](Improvements_and_updates.md) for information about non-breaking changes.
5052

0 commit comments

Comments
 (0)