mirror of
https://github.com/h2zero/esp-nimble-cpp.git
synced 2024-11-24 22:20:55 +01:00
Remove const from NimBLEConnInfo references in callbacks.
The use of const is a unnecessary breaking change as there is nothing that can be changed in the class.
This commit is contained in:
parent
2d3ff4922e
commit
031ba8f437
19 changed files with 113 additions and 112 deletions
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
|
@ -6,6 +6,7 @@ on:
|
||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
|
- remove-conninfo-const
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-esp-idf-component:
|
build-esp-idf-component:
|
||||||
|
|
|
@ -31,14 +31,14 @@ For more information on the improvements and additions please refer to the [clas
|
||||||
### Header Files
|
### Header Files
|
||||||
All classes are accessible by including `NimBLEDevice.h` in your application, no further headers need to be included.
|
All classes are accessible by including `NimBLEDevice.h` in your application, no further headers need to be included.
|
||||||
|
|
||||||
(Mainly for Arduino) You may choose to include `NimBLELog.h` in your application if you want to use the `NIMBLE_LOGx` macros for debugging. These macros are used the same way as the `ESP_LOGx` macros.
|
(Mainly for Arduino) You may choose to include `NimBLELog.h` in your application if you want to use the `NIMBLE_LOGx` macros for debugging. These macros are used the same way as the `ESP_LOGx` macros.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
### Class Names
|
### Class Names
|
||||||
Class names remain the same as the original with the addition of a "Nim" prefix.
|
Class names remain the same as the original with the addition of a "Nim" prefix.
|
||||||
For example `BLEDevice` is now `NimBLEDevice` and `BLEServer` is now `NimBLEServer` etc.
|
For example `BLEDevice` is now `NimBLEDevice` and `BLEServer` is now `NimBLEServer` etc.
|
||||||
|
|
||||||
For convenience definitions have been added to allow applications to use either name for all classes this means **no class names need to be changed in existing code** and makes migrating easier.
|
For convenience definitions have been added to allow applications to use either name for all classes this means **no class names need to be changed in existing code** and makes migrating easier.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
### BLE Addresses
|
### BLE Addresses
|
||||||
|
@ -48,7 +48,7 @@ For example `BLEAddress addr(11:22:33:44:55:66, 1)` will create the address obje
|
||||||
|
|
||||||
As this parameter is optional no changes to existing code are needed, it is mentioned here for information.
|
As this parameter is optional no changes to existing code are needed, it is mentioned here for information.
|
||||||
|
|
||||||
`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.
|
`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.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<a name="server-api"></a>
|
<a name="server-api"></a>
|
||||||
|
@ -56,7 +56,7 @@ As this parameter is optional no changes to existing code are needed, it is ment
|
||||||
Creating a `BLEServer` instance is the same as original, no changes required.
|
Creating a `BLEServer` instance is the same as original, no changes required.
|
||||||
For example `BLEDevice::createServer()` will work just as it did before.
|
For example `BLEDevice::createServer()` will work just as it did before.
|
||||||
|
|
||||||
`BLEServerCallbacks` (`NimBLEServerCallbacks`) has new methods for handling security operations.
|
`BLEServerCallbacks` (`NimBLEServerCallbacks`) has new methods for handling security operations.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
`BLEServerCallbacks::onConnect` (`NimBLEServerCallbacks::onConnect`) only has a single callback declaration which takes an additional (required) parameter `NimBLEConnInfo & connInfo`, which has methods to get information about the connected peer.
|
`BLEServerCallbacks::onConnect` (`NimBLEServerCallbacks::onConnect`) only has a single callback declaration which takes an additional (required) parameter `NimBLEConnInfo & connInfo`, which has methods to get information about the connected peer.
|
||||||
|
@ -78,13 +78,13 @@ void onDisconnect(NimBLEServer* pServer, NimBLEConnInfo& connInfo, int reason)`
|
||||||
onMTUChange(uint16_t MTU, NimBLEConnInfo& connInfo)
|
onMTUChange(uint16_t MTU, NimBLEConnInfo& connInfo)
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** All callback methods have default implementations which allows the application to implement only the methods applicable.
|
**Note:** All callback methods have default implementations which allows the application to implement only the methods applicable.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<a name="services"></a>
|
<a name="services"></a>
|
||||||
### Services
|
### Services
|
||||||
Creating a `BLEService` (`NimBLEService`) instance is the same as original, no changes required.
|
Creating a `BLEService` (`NimBLEService`) instance is the same as original, no changes required.
|
||||||
For example `BLEServer::createService(SERVICE_UUID)` will work just as it did before.
|
For example `BLEServer::createService(SERVICE_UUID)` will work just as it did before.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<a name="characteristics"></a>
|
<a name="characteristics"></a>
|
||||||
|
@ -94,27 +94,27 @@ For example `BLEServer::createService(SERVICE_UUID)` will work just as it did be
|
||||||
When creating a characteristic the properties are now set with `NIMBLE_PROPERTY::XXXX` instead of `BLECharacteristic::XXXX`.
|
When creating a characteristic the properties are now set with `NIMBLE_PROPERTY::XXXX` instead of `BLECharacteristic::XXXX`.
|
||||||
|
|
||||||
#### Originally
|
#### Originally
|
||||||
> BLECharacteristic::PROPERTY_READ |
|
> BLECharacteristic::PROPERTY_READ |
|
||||||
BLECharacteristic::PROPERTY_WRITE
|
BLECharacteristic::PROPERTY_WRITE
|
||||||
|
|
||||||
#### Is Now
|
#### Is Now
|
||||||
> NIMBLE_PROPERTY::READ |
|
> NIMBLE_PROPERTY::READ |
|
||||||
NIMBLE_PROPERTY::WRITE
|
NIMBLE_PROPERTY::WRITE
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
#### The full list of properties
|
#### The full list of properties
|
||||||
> NIMBLE_PROPERTY::READ
|
> NIMBLE_PROPERTY::READ
|
||||||
NIMBLE_PROPERTY::READ_ENC
|
NIMBLE_PROPERTY::READ_ENC
|
||||||
NIMBLE_PROPERTY::READ_AUTHEN
|
NIMBLE_PROPERTY::READ_AUTHEN
|
||||||
NIMBLE_PROPERTY::READ_AUTHOR
|
NIMBLE_PROPERTY::READ_AUTHOR
|
||||||
NIMBLE_PROPERTY::WRITE
|
NIMBLE_PROPERTY::WRITE
|
||||||
NIMBLE_PROPERTY::WRITE_NR
|
NIMBLE_PROPERTY::WRITE_NR
|
||||||
NIMBLE_PROPERTY::WRITE_ENC
|
NIMBLE_PROPERTY::WRITE_ENC
|
||||||
NIMBLE_PROPERTY::WRITE_AUTHEN
|
NIMBLE_PROPERTY::WRITE_AUTHEN
|
||||||
NIMBLE_PROPERTY::WRITE_AUTHOR
|
NIMBLE_PROPERTY::WRITE_AUTHOR
|
||||||
NIMBLE_PROPERTY::BROADCAST
|
NIMBLE_PROPERTY::BROADCAST
|
||||||
NIMBLE_PROPERTY::NOTIFY
|
NIMBLE_PROPERTY::NOTIFY
|
||||||
NIMBLE_PROPERTY::INDICATE
|
NIMBLE_PROPERTY::INDICATE
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
|
@ -143,11 +143,11 @@ BLECharacteristic *pCharacteristic = pService->createCharacteristic(
|
||||||
|
|
||||||
`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.
|
`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.
|
||||||
|
|
||||||
`BLECharacteristicCallbacks::onWrite` (`NimBLECharacteristicCallbacks::onWrite`) only has a single callback declaration, which takes an additional (required) parameter of `NimBLEConnInfo& connInfo`, which provides connection information about the peer.
|
`BLECharacteristicCallbacks::onWrite` (`NimBLECharacteristicCallbacks::onWrite`) only has a single callback declaration, which takes an additional (required) parameter of `NimBLEConnInfo& connInfo`, which provides connection information about the peer.
|
||||||
|
|
||||||
`BLECharacteristicCallbacks::onStatus` (`NimBLECharacteristicCallbacks::onStatus`) has had the status parameter removed as it was unnecessary since the status code from the BLE stack was also provided. The status code for success is 0 for notifications and BLE_HS_EDONE for indications, any other value is an error.
|
`BLECharacteristicCallbacks::onStatus` (`NimBLECharacteristicCallbacks::onStatus`) has had the status parameter removed as it was unnecessary since the status code from the BLE stack was also provided. The status code for success is 0 for notifications and BLE_HS_EDONE for indications, any other value is an error.
|
||||||
|
|
||||||
**Note:** All callback methods have default implementations which allows the application to implement only the methods applicable.
|
**Note:** All callback methods have default implementations which allows the application to implement only the methods applicable.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
> BLECharacteristic::getData
|
> BLECharacteristic::getData
|
||||||
|
@ -231,18 +231,18 @@ The above descriptor callbacks take an additional (required) parameter `NimBLECo
|
||||||
<a name="server-security"></a>
|
<a name="server-security"></a>
|
||||||
### Server Security
|
### Server Security
|
||||||
Security is set on the characteristic or descriptor properties by applying one of the following:
|
Security is set on the characteristic or descriptor properties by applying one of the following:
|
||||||
> NIMBLE_PROPERTY::READ_ENC
|
> NIMBLE_PROPERTY::READ_ENC
|
||||||
NIMBLE_PROPERTY::READ_AUTHEN
|
NIMBLE_PROPERTY::READ_AUTHEN
|
||||||
NIMBLE_PROPERTY::READ_AUTHOR
|
NIMBLE_PROPERTY::READ_AUTHOR
|
||||||
NIMBLE_PROPERTY::WRITE_ENC
|
NIMBLE_PROPERTY::WRITE_ENC
|
||||||
NIMBLE_PROPERTY::WRITE_AUTHEN
|
NIMBLE_PROPERTY::WRITE_AUTHEN
|
||||||
NIMBLE_PROPERTY::WRITE_AUTHOR
|
NIMBLE_PROPERTY::WRITE_AUTHOR
|
||||||
|
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
When a peer wants to read or write a characteristic or descriptor with any of these properties applied it will trigger the pairing process. By default the "just-works" pairing will be performed automatically.
|
When a peer wants to read or write a characteristic or descriptor with any of these properties applied it will trigger the pairing process. By default the "just-works" pairing will be performed automatically.
|
||||||
|
|
||||||
This can be changed to use passkey authentication or numeric comparison. See [Security API](#security-api) for details.
|
This can be changed to use passkey authentication or numeric comparison. See [Security API](#security-api) for details.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<a name="advertising-api"></a>
|
<a name="advertising-api"></a>
|
||||||
|
@ -250,13 +250,13 @@ This can be changed to use passkey authentication or numeric comparison. See [Se
|
||||||
Advertising works the same as the original API except:
|
Advertising works the same as the original API except:
|
||||||
|
|
||||||
Calling `NimBLEAdvertising::setAdvertisementData` will entirely replace any data set with `NimBLEAdvertising::addServiceUUID`, or
|
Calling `NimBLEAdvertising::setAdvertisementData` will entirely replace any data set with `NimBLEAdvertising::addServiceUUID`, or
|
||||||
`NimBLEAdvertising::setAppearance` or similar methods. You should set all the data you wish to advertise within the `NimBLEAdvertisementData` instead.
|
`NimBLEAdvertising::setAppearance` or similar methods. You should set all the data you wish to advertise within the `NimBLEAdvertisementData` instead.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
> BLEAdvertising::start (NimBLEAdvertising::start)
|
> BLEAdvertising::start (NimBLEAdvertising::start)
|
||||||
|
|
||||||
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).
|
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).
|
||||||
This provides an opportunity to update the advertisement data if desired.
|
This provides an opportunity to update the advertisement data if desired.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<a name="client-api"></a>
|
<a name="client-api"></a>
|
||||||
|
@ -276,18 +276,18 @@ The type parameter has been removed and a new bool parameter has been added to i
|
||||||
|
|
||||||
If set to false the client will use the attribute database it retrieved from the peripheral when previously connected.
|
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.
|
This allows for faster connections and power saving if the devices dropped connection and are reconnecting.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
> `BLEClient::getServices` (`NimBLEClient::getServices`)
|
> `BLEClient::getServices` (`NimBLEClient::getServices`)
|
||||||
|
|
||||||
This method now takes an optional (bool) parameter to indicate if the services should be retrieved from the server (true) or the currently known database returned (false : default).
|
This method now takes an optional (bool) parameter to indicate if the services should be retrieved from the server (true) or the currently known database returned (false : default).
|
||||||
Also now returns a pointer to `std::vector` instead of `std::map`.
|
Also now returns a pointer to `std::vector` instead of `std::map`.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
**Removed:** the automatic discovery of all peripheral attributes as they consumed time and resources for data the user may not be interested in.
|
**Removed:** the automatic discovery of all peripheral attributes as they consumed time and resources for data the user may not be interested in.
|
||||||
|
|
||||||
**Added:** `NimBLEClient::discoverAttributes` for the user to discover all the peripheral attributes to replace the the removed automatic functionality.
|
**Added:** `NimBLEClient::discoverAttributes` for the user to discover all the peripheral attributes to replace the the removed automatic functionality.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<a name="remote-services"></a>
|
<a name="remote-services"></a>
|
||||||
|
@ -296,14 +296,14 @@ Also now returns a pointer to `std::vector` instead of `std::map`.
|
||||||
|
|
||||||
> BLERemoteService::getCharacteristicsByHandle
|
> BLERemoteService::getCharacteristicsByHandle
|
||||||
|
|
||||||
This method has been removed.
|
This method has been removed.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
> `BLERemoteService::getCharacteristics` (`NimBLERemoteService::getCharacteristics`)
|
> `BLERemoteService::getCharacteristics` (`NimBLERemoteService::getCharacteristics`)
|
||||||
|
|
||||||
This method now takes an optional (bool) parameter to indicate if the characteristics should be retrieved from the server (true) or
|
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 (false : default).
|
the currently known database returned (false : default).
|
||||||
Also now returns a pointer to `std::vector` instead of `std::map`.
|
Also now returns a pointer to `std::vector` instead of `std::map`.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<a name="remote-characteristics"></a>
|
<a name="remote-characteristics"></a>
|
||||||
|
@ -313,17 +313,17 @@ Also now returns a pointer to `std::vector` instead of `std::map`.
|
||||||
|
|
||||||
> `BLERemoteCharacteristic::writeValue` (`NimBLERemoteCharacteristic::writeValue`)
|
> `BLERemoteCharacteristic::writeValue` (`NimBLERemoteCharacteristic::writeValue`)
|
||||||
|
|
||||||
Now returns true or false to indicate success or failure so you can choose to disconnect or try again.
|
Now returns true or false to indicate success or failure so you can choose to disconnect or try again.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
> `BLERemoteCharacteristic::registerForNotify`
|
> `BLERemoteCharacteristic::registerForNotify`
|
||||||
|
|
||||||
Has been removed.
|
Has been removed.
|
||||||
|
|
||||||
> `NimBLERemoteCharacteristic::subscribe`
|
> `NimBLERemoteCharacteristic::subscribe`
|
||||||
> `NimBLERemoteCharacteristic::unsubscribe`
|
> `NimBLERemoteCharacteristic::unsubscribe`
|
||||||
|
|
||||||
Are the new methods added to replace it.
|
Are the new methods added to replace it.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
> `BLERemoteCharacteristic::readUInt8` (`NimBLERemoteCharacteristic::readUInt8`)
|
> `BLERemoteCharacteristic::readUInt8` (`NimBLERemoteCharacteristic::readUInt8`)
|
||||||
|
@ -331,7 +331,7 @@ Are the new methods added to replace it.
|
||||||
> `BLERemoteCharacteristic::readUInt32` (`NimBLERemoteCharacteristic::readUInt32`)
|
> `BLERemoteCharacteristic::readUInt32` (`NimBLERemoteCharacteristic::readUInt32`)
|
||||||
> `BLERemoteCharacteristic::readFloat` (`NimBLERemoteCharacteristic::readFloat`)
|
> `BLERemoteCharacteristic::readFloat` (`NimBLERemoteCharacteristic::readFloat`)
|
||||||
|
|
||||||
Are **deprecated** a template: `NimBLERemoteCharacteristic::readValue<type\>(time_t\*, bool)` has been added to replace them.
|
Are **deprecated** a template: `NimBLERemoteCharacteristic::readValue<type\>(time_t\*, bool)` has been added to replace them.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
> `BLERemoteCharacteristic::readRawData`
|
> `BLERemoteCharacteristic::readRawData`
|
||||||
|
@ -354,7 +354,7 @@ my_struct_t myStruct = pChr->readValue<my_struct_t>();
|
||||||
|
|
||||||
This method now takes an optional (bool) parameter to indicate if the descriptors should be retrieved from the server (true) or
|
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 (false : default).
|
the currently known database returned (false : default).
|
||||||
Also now returns a pointer to `std::vector` instead of `std::map`.
|
Also now returns a pointer to `std::vector` instead of `std::map`.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<a name="client-callbacks"></a>
|
<a name="client-callbacks"></a>
|
||||||
|
@ -362,34 +362,34 @@ Also now returns a pointer to `std::vector` instead of `std::map`.
|
||||||
|
|
||||||
> `BLEClientCallbacks::onDisconnect` (`NimBLEClientCallbacks::onDisconnect`)
|
> `BLEClientCallbacks::onDisconnect` (`NimBLEClientCallbacks::onDisconnect`)
|
||||||
|
|
||||||
This now takes a second parameter `int reason` which provides the reason code for disconnection.
|
This now takes a second parameter `int reason` which provides the reason code for disconnection.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<a name="client-security"></a>
|
<a name="client-security"></a>
|
||||||
### Client Security
|
### Client Security
|
||||||
The client will automatically initiate security when the peripheral responds that it's required.
|
The client will automatically initiate security when the peripheral responds that it's required.
|
||||||
The default configuration will use "just-works" pairing with no bonding, if you wish to enable bonding see below.
|
The default configuration will use "just-works" pairing with no bonding, if you wish to enable bonding see below.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<a name="scan-api"></a>
|
<a name="scan-api"></a>
|
||||||
## BLE Scan
|
## BLE Scan
|
||||||
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.
|
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.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<a name="security-api"></a>
|
<a name="security-api"></a>
|
||||||
## Security API
|
## Security API
|
||||||
Security operations have been moved to `BLEDevice` (`NimBLEDevice`).
|
Security operations have been moved to `BLEDevice` (`NimBLEDevice`).
|
||||||
The security callback methods are now incorporated in the `NimBLEServerCallbacks` / `NimBLEClientCallbacks` classes.
|
The security callback methods are now incorporated in the `NimBLEServerCallbacks` / `NimBLEClientCallbacks` classes.
|
||||||
|
|
||||||
The callback methods are:
|
The callback methods are:
|
||||||
|
|
||||||
> `bool onConfirmPIN(const NimBLEConnInfo& connInfo, uint32_t pin)`
|
> `bool onConfirmPIN(NimBLEConnInfo& connInfo, uint32_t pin)`
|
||||||
|
|
||||||
Receives the pin when using numeric comparison authentication.
|
Receives the pin when using numeric comparison authentication.
|
||||||
Call `NimBLEDevice::injectConfirmPIN(connInfo, true);` to accept or `NimBLEDevice::injectConfirmPIN(connInfo, false);` to reject.
|
Call `NimBLEDevice::injectConfirmPIN(connInfo, true);` to accept or `NimBLEDevice::injectConfirmPIN(connInfo, false);` to reject.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
> `void onPassKeyEntry(const NimBLEConnInfo& connInfo)`
|
> `void onPassKeyEntry(NimBLEConnInfo& connInfo)`
|
||||||
|
|
||||||
Client callback; client should respond with the passkey (pin) by calling `NimBLEDevice::injectPassKey(connInfo, 123456);`
|
Client callback; client should respond with the passkey (pin) by calling `NimBLEDevice::injectPassKey(connInfo, 123456);`
|
||||||
<br/>
|
<br/>
|
||||||
|
@ -399,31 +399,31 @@ Client callback; client should respond with the passkey (pin) by calling `NimBLE
|
||||||
Server callback; should return the passkey (pin) expected from the client.
|
Server callback; should return the passkey (pin) expected from the client.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
> `void onAuthenticationComplete(const NimBLEConnInfo& connInfo)`
|
> `void onAuthenticationComplete(NimBLEConnInfo& connInfo)`
|
||||||
|
|
||||||
Authentication complete, success or failed information is available from the `NimBLEConnInfo` methods.
|
Authentication complete, success or failed information is available from the `NimBLEConnInfo` methods.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
Security settings and IO capabilities are now set by the following methods of NimBLEDevice.
|
Security settings and IO capabilities are now set by the following methods of NimBLEDevice.
|
||||||
> `NimBLEDevice::setSecurityAuth(bool bonding, bool mitm, bool sc)`
|
> `NimBLEDevice::setSecurityAuth(bool bonding, bool mitm, bool sc)`
|
||||||
> `NimBLEDevice::setSecurityAuth(uint8_t auth_req)`
|
> `NimBLEDevice::setSecurityAuth(uint8_t auth_req)`
|
||||||
|
|
||||||
Sets the authorization mode for this device.
|
Sets the authorization mode for this device.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
> `NimBLEDevice::setSecurityIOCap(uint8_t iocap)`
|
> `NimBLEDevice::setSecurityIOCap(uint8_t iocap)`
|
||||||
|
|
||||||
Sets the Input/Output capabilities of this device.
|
Sets the Input/Output capabilities of this device.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
> `NimBLEDevice::setSecurityInitKey(uint8_t init_key)`
|
> `NimBLEDevice::setSecurityInitKey(uint8_t init_key)`
|
||||||
|
|
||||||
If we are the initiator of the security procedure this sets the keys we will distribute.
|
If we are the initiator of the security procedure this sets the keys we will distribute.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
> `NimBLEDevice::setSecurityRespKey(uint8_t resp_key)`
|
> `NimBLEDevice::setSecurityRespKey(uint8_t resp_key)`
|
||||||
|
|
||||||
Sets the keys we are willing to accept from the peer during pairing.
|
Sets the keys we are willing to accept from the peer during pairing.
|
||||||
<br/>
|
<br/>
|
||||||
|
|
||||||
<a name="arduino-configuration"></a>
|
<a name="arduino-configuration"></a>
|
||||||
|
@ -433,5 +433,5 @@ Unlike the original library pre-packaged in the esp32-arduino, this library has
|
||||||
|
|
||||||
This allows Arduino users to fully customize the build, such as increasing max connections or loading the BLE stack into external PSRAM.
|
This allows Arduino users to fully customize the build, such as increasing max connections or loading the BLE stack into external PSRAM.
|
||||||
|
|
||||||
For details on the options, they are fully commented in *nimconfig.h*
|
For details on the options, they are fully commented in *nimconfig.h*
|
||||||
<br/>
|
<br/>
|
||||||
|
|
|
@ -39,7 +39,7 @@ class ClientCallbacks : public NimBLEClientCallbacks {
|
||||||
|
|
||||||
/********************* Security handled here **********************
|
/********************* Security handled here **********************
|
||||||
****** Note: these are the same return values as defaults ********/
|
****** Note: these are the same return values as defaults ********/
|
||||||
void onPassKeyEntry(const NimBLEConnInfo& connInfo){
|
void onPassKeyEntry(NimBLEConnInfo& connInfo){
|
||||||
printf("Server Passkey Entry\n");
|
printf("Server Passkey Entry\n");
|
||||||
/** This should prompt the user to enter the passkey displayed
|
/** This should prompt the user to enter the passkey displayed
|
||||||
* on the peer device.
|
* on the peer device.
|
||||||
|
@ -47,14 +47,14 @@ class ClientCallbacks : public NimBLEClientCallbacks {
|
||||||
NimBLEDevice::injectPassKey(connInfo, 123456);
|
NimBLEDevice::injectPassKey(connInfo, 123456);
|
||||||
};
|
};
|
||||||
|
|
||||||
void onConfirmPIN(const NimBLEConnInfo& connInfo, uint32_t pass_key){
|
void onConfirmPIN(NimBLEConnInfo& connInfo, uint32_t pass_key){
|
||||||
printf("The passkey YES/NO number: %" PRIu32 "\n", pass_key);
|
printf("The passkey YES/NO number: %" PRIu32 "\n", pass_key);
|
||||||
/** Inject false if passkeys don't match. */
|
/** Inject false if passkeys don't match. */
|
||||||
NimBLEDevice::injectConfirmPIN(connInfo, true);
|
NimBLEDevice::injectConfirmPIN(connInfo, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Pairing process complete, we can check the results in connInfo */
|
/** Pairing process complete, we can check the results in connInfo */
|
||||||
void onAuthenticationComplete(const NimBLEConnInfo& connInfo){
|
void onAuthenticationComplete(NimBLEConnInfo& connInfo){
|
||||||
if(!connInfo.isEncrypted()) {
|
if(!connInfo.isEncrypted()) {
|
||||||
printf("Encrypt connection failed - disconnecting\n");
|
printf("Encrypt connection failed - disconnecting\n");
|
||||||
/** Find the client with the connection handle provided in desc */
|
/** Find the client with the connection handle provided in desc */
|
||||||
|
|
|
@ -52,13 +52,13 @@ class ServerCallbacks: public NimBLEServerCallbacks {
|
||||||
return 123456;
|
return 123456;
|
||||||
};
|
};
|
||||||
|
|
||||||
void onConfirmPIN(const NimBLEConnInfo& connInfo, uint32_t pass_key){
|
void onConfirmPIN(NimBLEConnInfo& connInfo, uint32_t pass_key){
|
||||||
printf("The passkey YES/NO number: %" PRIu32 "\n", pass_key);
|
printf("The passkey YES/NO number: %" PRIu32 "\n", pass_key);
|
||||||
/** Inject false if passkeys don't match. */
|
/** Inject false if passkeys don't match. */
|
||||||
NimBLEDevice::injectConfirmPIN(connInfo, true);
|
NimBLEDevice::injectConfirmPIN(connInfo, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
void onAuthenticationComplete(const NimBLEConnInfo& connInfo){
|
void onAuthenticationComplete(NimBLEConnInfo& connInfo){
|
||||||
/** Check that encryption was successful, if not we disconnect the client */
|
/** Check that encryption was successful, if not we disconnect the client */
|
||||||
if(!connInfo.isEncrypted()) {
|
if(!connInfo.isEncrypted()) {
|
||||||
NimBLEDevice::getServer()->disconnect(connInfo.getConnHandle());
|
NimBLEDevice::getServer()->disconnect(connInfo.getConnHandle());
|
||||||
|
|
|
@ -25,7 +25,7 @@ class ServerCallbacks : public NimBLEServerCallbacks {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Same as before but now includes the name parameter
|
// Same as before but now includes the name parameter
|
||||||
void onAuthenticationComplete(const NimBLEConnInfo& connInfo, const std::string& name) override {
|
void onAuthenticationComplete(NimBLEConnInfo& connInfo, const std::string& name) override {
|
||||||
if (!connInfo.isEncrypted()) {
|
if (!connInfo.isEncrypted()) {
|
||||||
NimBLEDevice::getServer()->disconnect(connInfo.getConnHandle());
|
NimBLEDevice::getServer()->disconnect(connInfo.getConnHandle());
|
||||||
printf("Encrypt connection failed - disconnecting client\n");
|
printf("Encrypt connection failed - disconnecting client\n");
|
||||||
|
|
|
@ -51,7 +51,7 @@ class MyClientCallback : public BLEClientCallbacks {
|
||||||
}
|
}
|
||||||
/***************** New - Security handled here ********************
|
/***************** New - Security handled here ********************
|
||||||
****** Note: these are the same return values as defaults ********/
|
****** Note: these are the same return values as defaults ********/
|
||||||
void onPassKeyEntry(const NimBLEConnInfo& connInfo){
|
void onPassKeyEntry(NimBLEConnInfo& connInfo){
|
||||||
printf("Server Passkey Entry\n");
|
printf("Server Passkey Entry\n");
|
||||||
/** This should prompt the user to enter the passkey displayed
|
/** This should prompt the user to enter the passkey displayed
|
||||||
* on the peer device.
|
* on the peer device.
|
||||||
|
@ -59,14 +59,14 @@ class MyClientCallback : public BLEClientCallbacks {
|
||||||
NimBLEDevice::injectPassKey(connInfo, 123456);
|
NimBLEDevice::injectPassKey(connInfo, 123456);
|
||||||
};
|
};
|
||||||
|
|
||||||
void onConfirmPIN(const NimBLEConnInfo& connInfo, uint32_t pass_key){
|
void onConfirmPIN(NimBLEConnInfo& connInfo, uint32_t pass_key){
|
||||||
printf("The passkey YES/NO number: %" PRIu32 "\n", pass_key);
|
printf("The passkey YES/NO number: %" PRIu32 "\n", pass_key);
|
||||||
/** Inject false if passkeys don't match. */
|
/** Inject false if passkeys don't match. */
|
||||||
NimBLEDevice::injectConfirmPIN(connInfo, true);
|
NimBLEDevice::injectConfirmPIN(connInfo, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Pairing process complete, we can check the results in connInfo */
|
/** Pairing process complete, we can check the results in connInfo */
|
||||||
void onAuthenticationComplete(const NimBLEConnInfo& connInfo){
|
void onAuthenticationComplete(NimBLEConnInfo& connInfo){
|
||||||
if(!connInfo.isEncrypted()) {
|
if(!connInfo.isEncrypted()) {
|
||||||
printf("Encrypt connection failed - disconnecting\n");
|
printf("Encrypt connection failed - disconnecting\n");
|
||||||
/** Find the client with the connection handle provided in desc */
|
/** Find the client with the connection handle provided in desc */
|
||||||
|
|
|
@ -65,13 +65,13 @@ class MyServerCallbacks: public BLEServerCallbacks {
|
||||||
return 123456;
|
return 123456;
|
||||||
};
|
};
|
||||||
|
|
||||||
void onConfirmPIN(const NimBLEConnInfo& connInfo, uint32_t pass_key){
|
void onConfirmPIN(NimBLEConnInfo& connInfo, uint32_t pass_key){
|
||||||
printf("The passkey YES/NO number: %" PRIu32 "\n", pass_key);
|
printf("The passkey YES/NO number: %" PRIu32 "\n", pass_key);
|
||||||
/** Inject false if passkeys don't match. */
|
/** Inject false if passkeys don't match. */
|
||||||
NimBLEDevice::injectConfirmPIN(connInfo, true);
|
NimBLEDevice::injectConfirmPIN(connInfo, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
void onAuthenticationComplete(const NimBLEConnInfo& connInfo){
|
void onAuthenticationComplete(NimBLEConnInfo& connInfo){
|
||||||
/** Check that encryption was successful, if not we disconnect the client */
|
/** Check that encryption was successful, if not we disconnect the client */
|
||||||
if(!connInfo.isEncrypted()) {
|
if(!connInfo.isEncrypted()) {
|
||||||
NimBLEDevice::getServer()->disconnect(connInfo.getConnHandle());
|
NimBLEDevice::getServer()->disconnect(connInfo.getConnHandle());
|
||||||
|
|
|
@ -67,13 +67,13 @@ class MyServerCallbacks: public BLEServerCallbacks {
|
||||||
return 123456;
|
return 123456;
|
||||||
};
|
};
|
||||||
|
|
||||||
void onConfirmPIN(const NimBLEConnInfo& connInfo, uint32_t pass_key){
|
void onConfirmPIN(NimBLEConnInfo& connInfo, uint32_t pass_key){
|
||||||
printf("The passkey YES/NO number: %" PRIu32 "\n", pass_key);
|
printf("The passkey YES/NO number: %" PRIu32 "\n", pass_key);
|
||||||
/** Inject false if passkeys don't match. */
|
/** Inject false if passkeys don't match. */
|
||||||
NimBLEDevice::injectConfirmPIN(connInfo, true);
|
NimBLEDevice::injectConfirmPIN(connInfo, true);
|
||||||
};
|
};
|
||||||
|
|
||||||
void onAuthenticationComplete(const NimBLEConnInfo& connInfo){
|
void onAuthenticationComplete(NimBLEConnInfo& connInfo){
|
||||||
/** Check that encryption was successful, if not we disconnect the client */
|
/** Check that encryption was successful, if not we disconnect the client */
|
||||||
if(!connInfo.isEncrypted()) {
|
if(!connInfo.isEncrypted()) {
|
||||||
NimBLEDevice::getServer()->disconnect(connInfo.getConnHandle());
|
NimBLEDevice::getServer()->disconnect(connInfo.getConnHandle());
|
||||||
|
|
|
@ -203,7 +203,7 @@ size_t NimBLECharacteristic::getSubscribedCount() const {
|
||||||
* @brief Set the subscribe status for this characteristic.\n
|
* @brief Set the subscribe status for this characteristic.\n
|
||||||
* This will maintain a vector of subscribed clients and their indicate/notify status.
|
* This will maintain a vector of subscribed clients and their indicate/notify status.
|
||||||
*/
|
*/
|
||||||
void NimBLECharacteristic::setSubscribe(const ble_gap_event* event, const NimBLEConnInfo& connInfo) {
|
void NimBLECharacteristic::setSubscribe(const ble_gap_event* event, NimBLEConnInfo& connInfo) {
|
||||||
uint16_t subVal = 0;
|
uint16_t subVal = 0;
|
||||||
if (event->subscribe.cur_notify > 0 && (m_properties & NIMBLE_PROPERTY::NOTIFY)) {
|
if (event->subscribe.cur_notify > 0 && (m_properties & NIMBLE_PROPERTY::NOTIFY)) {
|
||||||
subVal |= NIMBLE_SUB_NOTIFY;
|
subVal |= NIMBLE_SUB_NOTIFY;
|
||||||
|
@ -379,11 +379,11 @@ void NimBLECharacteristic::sendValue(const uint8_t* value, size_t length, bool i
|
||||||
NIMBLE_LOGD(LOG_TAG, "<< sendValue");
|
NIMBLE_LOGD(LOG_TAG, "<< sendValue");
|
||||||
} // sendValue
|
} // sendValue
|
||||||
|
|
||||||
void NimBLECharacteristic::readEvent(const NimBLEConnInfo& connInfo) {
|
void NimBLECharacteristic::readEvent(NimBLEConnInfo& connInfo) {
|
||||||
m_pCallbacks->onRead(this, connInfo);
|
m_pCallbacks->onRead(this, connInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
void NimBLECharacteristic::writeEvent(const uint8_t* val, uint16_t len, const NimBLEConnInfo& connInfo) {
|
void NimBLECharacteristic::writeEvent(const uint8_t* val, uint16_t len, NimBLEConnInfo& connInfo) {
|
||||||
setValue(val, len);
|
setValue(val, len);
|
||||||
m_pCallbacks->onWrite(this, connInfo);
|
m_pCallbacks->onWrite(this, connInfo);
|
||||||
}
|
}
|
||||||
|
@ -432,7 +432,7 @@ std::string NimBLECharacteristic::toString() const {
|
||||||
* @param [in] pCharacteristic The characteristic that is the source of the event.
|
* @param [in] pCharacteristic The characteristic that is the source of the event.
|
||||||
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.
|
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.
|
||||||
*/
|
*/
|
||||||
void NimBLECharacteristicCallbacks::onRead(NimBLECharacteristic* pCharacteristic, const NimBLEConnInfo& connInfo) {
|
void NimBLECharacteristicCallbacks::onRead(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo) {
|
||||||
NIMBLE_LOGD("NimBLECharacteristicCallbacks", "onRead: default");
|
NIMBLE_LOGD("NimBLECharacteristicCallbacks", "onRead: default");
|
||||||
} // onRead
|
} // onRead
|
||||||
|
|
||||||
|
@ -441,7 +441,7 @@ void NimBLECharacteristicCallbacks::onRead(NimBLECharacteristic* pCharacteristic
|
||||||
* @param [in] pCharacteristic The characteristic that is the source of the event.
|
* @param [in] pCharacteristic The characteristic that is the source of the event.
|
||||||
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.
|
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.
|
||||||
*/
|
*/
|
||||||
void NimBLECharacteristicCallbacks::onWrite(NimBLECharacteristic* pCharacteristic, const NimBLEConnInfo& connInfo) {
|
void NimBLECharacteristicCallbacks::onWrite(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo) {
|
||||||
NIMBLE_LOGD("NimBLECharacteristicCallbacks", "onWrite: default");
|
NIMBLE_LOGD("NimBLECharacteristicCallbacks", "onWrite: default");
|
||||||
} // onWrite
|
} // onWrite
|
||||||
|
|
||||||
|
@ -467,7 +467,7 @@ void NimBLECharacteristicCallbacks::onStatus(NimBLECharacteristic* pCharacterist
|
||||||
* * 3 = Notifications and Indications
|
* * 3 = Notifications and Indications
|
||||||
*/
|
*/
|
||||||
void NimBLECharacteristicCallbacks::onSubscribe(NimBLECharacteristic* pCharacteristic,
|
void NimBLECharacteristicCallbacks::onSubscribe(NimBLECharacteristic* pCharacteristic,
|
||||||
const NimBLEConnInfo& connInfo,
|
NimBLEConnInfo& connInfo,
|
||||||
uint16_t subValue) {
|
uint16_t subValue) {
|
||||||
NIMBLE_LOGD("NimBLECharacteristicCallbacks", "onSubscribe: default");
|
NIMBLE_LOGD("NimBLECharacteristicCallbacks", "onSubscribe: default");
|
||||||
}
|
}
|
||||||
|
|
|
@ -114,9 +114,9 @@ class NimBLECharacteristic : public NimBLELocalValueAttribute {
|
||||||
friend class NimBLEService;
|
friend class NimBLEService;
|
||||||
|
|
||||||
void setService(NimBLEService* pService);
|
void setService(NimBLEService* pService);
|
||||||
void setSubscribe(const ble_gap_event* event, const NimBLEConnInfo& connInfo);
|
void setSubscribe(const ble_gap_event* event, NimBLEConnInfo& connInfo);
|
||||||
void readEvent(const NimBLEConnInfo& connInfo) override;
|
void readEvent(NimBLEConnInfo& connInfo) override;
|
||||||
void writeEvent(const uint8_t* val, uint16_t len, const NimBLEConnInfo& connInfo) override;
|
void writeEvent(const uint8_t* val, uint16_t len, NimBLEConnInfo& connInfo) override;
|
||||||
void sendValue(const uint8_t* value,
|
void sendValue(const uint8_t* value,
|
||||||
size_t length,
|
size_t length,
|
||||||
bool is_notification = true,
|
bool is_notification = true,
|
||||||
|
@ -138,10 +138,10 @@ class NimBLECharacteristic : public NimBLELocalValueAttribute {
|
||||||
class NimBLECharacteristicCallbacks {
|
class NimBLECharacteristicCallbacks {
|
||||||
public:
|
public:
|
||||||
virtual ~NimBLECharacteristicCallbacks() {}
|
virtual ~NimBLECharacteristicCallbacks() {}
|
||||||
virtual void onRead(NimBLECharacteristic* pCharacteristic, const NimBLEConnInfo& connInfo);
|
virtual void onRead(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo);
|
||||||
virtual void onWrite(NimBLECharacteristic* pCharacteristic, const NimBLEConnInfo& connInfo);
|
virtual void onWrite(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo);
|
||||||
virtual void onStatus(NimBLECharacteristic* pCharacteristic, int code);
|
virtual void onStatus(NimBLECharacteristic* pCharacteristic, int code);
|
||||||
virtual void onSubscribe(NimBLECharacteristic* pCharacteristic, const NimBLEConnInfo& connInfo, uint16_t subValue);
|
virtual void onSubscribe(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo, uint16_t subValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */
|
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */
|
||||||
|
|
|
@ -1327,20 +1327,20 @@ bool NimBLEClientCallbacks::onConnParamsUpdateRequest(NimBLEClient* pClient, con
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NimBLEClientCallbacks::onPassKeyEntry(const NimBLEConnInfo& connInfo){
|
void NimBLEClientCallbacks::onPassKeyEntry(NimBLEConnInfo& connInfo){
|
||||||
NIMBLE_LOGD("NimBLEClientCallbacks", "onPassKeyEntry: default: 123456");
|
NIMBLE_LOGD("NimBLEClientCallbacks", "onPassKeyEntry: default: 123456");
|
||||||
NimBLEDevice::injectPassKey(connInfo, 123456);
|
NimBLEDevice::injectPassKey(connInfo, 123456);
|
||||||
} //onPassKeyEntry
|
} //onPassKeyEntry
|
||||||
|
|
||||||
void NimBLEClientCallbacks::onAuthenticationComplete(const NimBLEConnInfo& connInfo){
|
void NimBLEClientCallbacks::onAuthenticationComplete(NimBLEConnInfo& connInfo){
|
||||||
NIMBLE_LOGD("NimBLEClientCallbacks", "onAuthenticationComplete: default");
|
NIMBLE_LOGD("NimBLEClientCallbacks", "onAuthenticationComplete: default");
|
||||||
}
|
}
|
||||||
|
|
||||||
void NimBLEClientCallbacks::onIdentity(const NimBLEConnInfo& connInfo){
|
void NimBLEClientCallbacks::onIdentity(NimBLEConnInfo& connInfo){
|
||||||
NIMBLE_LOGD("NimBLEClientCallbacks", "onIdentity: default");
|
NIMBLE_LOGD("NimBLEClientCallbacks", "onIdentity: default");
|
||||||
} // onIdentity
|
} // onIdentity
|
||||||
|
|
||||||
void NimBLEClientCallbacks::onConfirmPIN(const NimBLEConnInfo& connInfo, uint32_t pin){
|
void NimBLEClientCallbacks::onConfirmPIN(NimBLEConnInfo& connInfo, uint32_t pin){
|
||||||
NIMBLE_LOGD("NimBLEClientCallbacks", "onConfirmPIN: default: true");
|
NIMBLE_LOGD("NimBLEClientCallbacks", "onConfirmPIN: default: true");
|
||||||
NimBLEDevice::injectConfirmPIN(connInfo, true);
|
NimBLEDevice::injectConfirmPIN(connInfo, true);
|
||||||
}
|
}
|
||||||
|
|
|
@ -148,27 +148,27 @@ public:
|
||||||
* @brief Called when server requests a passkey for pairing.
|
* @brief Called when server requests a passkey for pairing.
|
||||||
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.
|
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.
|
||||||
*/
|
*/
|
||||||
virtual void onPassKeyEntry(const NimBLEConnInfo& connInfo);
|
virtual void onPassKeyEntry(NimBLEConnInfo& connInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called when the pairing procedure is complete.
|
* @brief Called when the pairing procedure is complete.
|
||||||
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.\n
|
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.\n
|
||||||
* This can be used to check the status of the connection encryption/pairing.
|
* This can be used to check the status of the connection encryption/pairing.
|
||||||
*/
|
*/
|
||||||
virtual void onAuthenticationComplete(const NimBLEConnInfo& connInfo);
|
virtual void onAuthenticationComplete(NimBLEConnInfo& connInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called when using numeric comparision for pairing.
|
* @brief Called when using numeric comparision for pairing.
|
||||||
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.
|
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.
|
||||||
* @param [in] pin The pin to compare with the server.
|
* @param [in] pin The pin to compare with the server.
|
||||||
*/
|
*/
|
||||||
virtual void onConfirmPIN(const NimBLEConnInfo& connInfo, uint32_t pin);
|
virtual void onConfirmPIN(NimBLEConnInfo& connInfo, uint32_t pin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called when the peer identity address is resolved.
|
* @brief Called when the peer identity address is resolved.
|
||||||
* @param [in] connInfo A reference to a NimBLEConnInfo instance with information
|
* @param [in] connInfo A reference to a NimBLEConnInfo instance with information
|
||||||
*/
|
*/
|
||||||
virtual void onIdentity(const NimBLEConnInfo& connInfo);
|
virtual void onIdentity(NimBLEConnInfo& connInfo);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL */
|
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL */
|
||||||
|
|
|
@ -118,11 +118,11 @@ std::string NimBLEDescriptor::toString() const {
|
||||||
return res;
|
return res;
|
||||||
} // toString
|
} // toString
|
||||||
|
|
||||||
void NimBLEDescriptor::readEvent(const NimBLEConnInfo& connInfo) {
|
void NimBLEDescriptor::readEvent(NimBLEConnInfo& connInfo) {
|
||||||
m_pCallbacks->onRead(this, connInfo);
|
m_pCallbacks->onRead(this, connInfo);
|
||||||
} // readEvent
|
} // readEvent
|
||||||
|
|
||||||
void NimBLEDescriptor::writeEvent(const uint8_t* val, uint16_t len, const NimBLEConnInfo& connInfo) {
|
void NimBLEDescriptor::writeEvent(const uint8_t* val, uint16_t len, NimBLEConnInfo& connInfo) {
|
||||||
setValue(val, len);
|
setValue(val, len);
|
||||||
m_pCallbacks->onWrite(this, connInfo);
|
m_pCallbacks->onWrite(this, connInfo);
|
||||||
} // writeEvent
|
} // writeEvent
|
||||||
|
@ -132,7 +132,7 @@ void NimBLEDescriptor::writeEvent(const uint8_t* val, uint16_t len, const NimBLE
|
||||||
* @param [in] pDescriptor The descriptor that is the source of the event.
|
* @param [in] pDescriptor The descriptor that is the source of the event.
|
||||||
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.
|
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.
|
||||||
*/
|
*/
|
||||||
void NimBLEDescriptorCallbacks::onRead(NimBLEDescriptor* pDescriptor, const NimBLEConnInfo& connInfo) {
|
void NimBLEDescriptorCallbacks::onRead(NimBLEDescriptor* pDescriptor, NimBLEConnInfo& connInfo) {
|
||||||
NIMBLE_LOGD("NimBLEDescriptorCallbacks", "onRead: default");
|
NIMBLE_LOGD("NimBLEDescriptorCallbacks", "onRead: default");
|
||||||
} // onRead
|
} // onRead
|
||||||
|
|
||||||
|
@ -141,7 +141,7 @@ void NimBLEDescriptorCallbacks::onRead(NimBLEDescriptor* pDescriptor, const NimB
|
||||||
* @param [in] pDescriptor The descriptor that is the source of the event.
|
* @param [in] pDescriptor The descriptor that is the source of the event.
|
||||||
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.
|
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.
|
||||||
*/
|
*/
|
||||||
void NimBLEDescriptorCallbacks::onWrite(NimBLEDescriptor* pDescriptor, const NimBLEConnInfo& connInfo) {
|
void NimBLEDescriptorCallbacks::onWrite(NimBLEDescriptor* pDescriptor, NimBLEConnInfo& connInfo) {
|
||||||
NIMBLE_LOGD("NimBLEDescriptorCallbacks", "onWrite: default");
|
NIMBLE_LOGD("NimBLEDescriptorCallbacks", "onWrite: default");
|
||||||
} // onWrite
|
} // onWrite
|
||||||
|
|
||||||
|
|
|
@ -51,8 +51,8 @@ class NimBLEDescriptor : public NimBLELocalValueAttribute {
|
||||||
friend class NimBLEService;
|
friend class NimBLEService;
|
||||||
|
|
||||||
void setCharacteristic(NimBLECharacteristic* pChar);
|
void setCharacteristic(NimBLECharacteristic* pChar);
|
||||||
void readEvent(const NimBLEConnInfo& connInfo) override;
|
void readEvent(NimBLEConnInfo& connInfo) override;
|
||||||
void writeEvent(const uint8_t* val, uint16_t len, const NimBLEConnInfo& connInfo) override;
|
void writeEvent(const uint8_t* val, uint16_t len, NimBLEConnInfo& connInfo) override;
|
||||||
|
|
||||||
NimBLEDescriptorCallbacks* m_pCallbacks{nullptr};
|
NimBLEDescriptorCallbacks* m_pCallbacks{nullptr};
|
||||||
NimBLECharacteristic* m_pCharacteristic{nullptr};
|
NimBLECharacteristic* m_pCharacteristic{nullptr};
|
||||||
|
@ -68,8 +68,8 @@ class NimBLEDescriptor : public NimBLELocalValueAttribute {
|
||||||
class NimBLEDescriptorCallbacks {
|
class NimBLEDescriptorCallbacks {
|
||||||
public:
|
public:
|
||||||
virtual ~NimBLEDescriptorCallbacks() = default;
|
virtual ~NimBLEDescriptorCallbacks() = default;
|
||||||
virtual void onRead(NimBLEDescriptor* pDescriptor, const NimBLEConnInfo& connInfo);
|
virtual void onRead(NimBLEDescriptor* pDescriptor, NimBLEConnInfo& connInfo);
|
||||||
virtual void onWrite(NimBLEDescriptor* pDescriptor, const NimBLEConnInfo& connInfo);
|
virtual void onWrite(NimBLEDescriptor* pDescriptor, NimBLEConnInfo& connInfo);
|
||||||
};
|
};
|
||||||
|
|
||||||
# include "NimBLE2904.h"
|
# include "NimBLE2904.h"
|
||||||
|
|
|
@ -1142,7 +1142,7 @@ int NimBLEDevice::startSecurity(uint16_t conn_id) {
|
||||||
* @param [in] pin The 6-digit pin to inject
|
* @param [in] pin The 6-digit pin to inject
|
||||||
* @return true if the passkey was injected successfully.
|
* @return true if the passkey was injected successfully.
|
||||||
*/
|
*/
|
||||||
bool NimBLEDevice::injectPassKey(const NimBLEConnInfo& peerInfo, uint32_t pin) {
|
bool NimBLEDevice::injectPassKey(NimBLEConnInfo& peerInfo, uint32_t pin) {
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
struct ble_sm_io pkey = {0,0};
|
struct ble_sm_io pkey = {0,0};
|
||||||
|
|
||||||
|
@ -1160,7 +1160,7 @@ bool NimBLEDevice::injectPassKey(const NimBLEConnInfo& peerInfo, uint32_t pin) {
|
||||||
* @param [in] peerInfo Connection information for the peer
|
* @param [in] peerInfo Connection information for the peer
|
||||||
* @param [in] accept Whether the user confirmed or declined the comparison
|
* @param [in] accept Whether the user confirmed or declined the comparison
|
||||||
*/
|
*/
|
||||||
bool NimBLEDevice::injectConfirmPIN(const NimBLEConnInfo& peerInfo, bool accept) {
|
bool NimBLEDevice::injectConfirmPIN(NimBLEConnInfo& peerInfo, bool accept) {
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
struct ble_sm_io pkey = {0,0};
|
struct ble_sm_io pkey = {0,0};
|
||||||
|
|
||||||
|
|
|
@ -135,8 +135,8 @@ public:
|
||||||
static void setSecurityPasskey(uint32_t pin);
|
static void setSecurityPasskey(uint32_t pin);
|
||||||
static uint32_t getSecurityPasskey();
|
static uint32_t getSecurityPasskey();
|
||||||
static int startSecurity(uint16_t conn_id);
|
static int startSecurity(uint16_t conn_id);
|
||||||
static bool injectConfirmPIN(const NimBLEConnInfo& peerInfo, bool accept);
|
static bool injectConfirmPIN(NimBLEConnInfo& peerInfo, bool accept);
|
||||||
static bool injectPassKey(const NimBLEConnInfo& peerInfo, uint32_t pin);
|
static bool injectPassKey(NimBLEConnInfo& peerInfo, uint32_t pin);
|
||||||
static int setMTU(uint16_t mtu);
|
static int setMTU(uint16_t mtu);
|
||||||
static uint16_t getMTU();
|
static uint16_t getMTU();
|
||||||
static bool isIgnored(const NimBLEAddress &address);
|
static bool isIgnored(const NimBLEAddress &address);
|
||||||
|
|
|
@ -124,7 +124,7 @@ class NimBLELocalValueAttribute : public NimBLELocalAttribute {
|
||||||
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.
|
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.
|
||||||
* @details This function is called by NimBLEServer when a read request is received.
|
* @details This function is called by NimBLEServer when a read request is received.
|
||||||
*/
|
*/
|
||||||
virtual void readEvent(const NimBLEConnInfo& connInfo) = 0;
|
virtual void readEvent(NimBLEConnInfo& connInfo) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Callback function to support a write request.
|
* @brief Callback function to support a write request.
|
||||||
|
@ -133,7 +133,7 @@ class NimBLELocalValueAttribute : public NimBLELocalAttribute {
|
||||||
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.
|
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.
|
||||||
* @details This function is called by NimBLEServer when a write request is received.
|
* @details This function is called by NimBLEServer when a write request is received.
|
||||||
*/
|
*/
|
||||||
virtual void writeEvent(const uint8_t* val, uint16_t len, const NimBLEConnInfo& connInfo) = 0;
|
virtual void writeEvent(const uint8_t* val, uint16_t len, NimBLEConnInfo& connInfo) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get a pointer to value of the attribute.
|
* @brief Get a pointer to value of the attribute.
|
||||||
|
|
|
@ -460,7 +460,7 @@ std::string NimBLEServer::getPeerNameInternal(uint16_t conn_handle, TaskHandle_t
|
||||||
* @returns A string containing the name.
|
* @returns A string containing the name.
|
||||||
* @note This is a blocking call and should NOT be called from any callbacks!
|
* @note This is a blocking call and should NOT be called from any callbacks!
|
||||||
*/
|
*/
|
||||||
std::string NimBLEServer::getPeerName(const NimBLEConnInfo& connInfo) {
|
std::string NimBLEServer::getPeerName(NimBLEConnInfo& connInfo) {
|
||||||
std::string name = getPeerNameInternal(connInfo.getConnHandle(), xTaskGetCurrentTaskHandle());
|
std::string name = getPeerNameInternal(connInfo.getConnHandle(), xTaskGetCurrentTaskHandle());
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
|
@ -1073,20 +1073,20 @@ uint32_t NimBLEServerCallbacks::onPassKeyDisplay(){
|
||||||
return 123456;
|
return 123456;
|
||||||
} //onPassKeyDisplay
|
} //onPassKeyDisplay
|
||||||
|
|
||||||
void NimBLEServerCallbacks::onConfirmPIN(const NimBLEConnInfo& connInfo, uint32_t pin){
|
void NimBLEServerCallbacks::onConfirmPIN(NimBLEConnInfo& connInfo, uint32_t pin){
|
||||||
NIMBLE_LOGD("NimBLEServerCallbacks", "onConfirmPIN: default: true");
|
NIMBLE_LOGD("NimBLEServerCallbacks", "onConfirmPIN: default: true");
|
||||||
NimBLEDevice::injectConfirmPIN(connInfo, true);
|
NimBLEDevice::injectConfirmPIN(connInfo, true);
|
||||||
} // onConfirmPIN
|
} // onConfirmPIN
|
||||||
|
|
||||||
void NimBLEServerCallbacks::onIdentity(const NimBLEConnInfo& connInfo){
|
void NimBLEServerCallbacks::onIdentity(NimBLEConnInfo& connInfo){
|
||||||
NIMBLE_LOGD("NimBLEServerCallbacks", "onIdentity: default");
|
NIMBLE_LOGD("NimBLEServerCallbacks", "onIdentity: default");
|
||||||
} // onIdentity
|
} // onIdentity
|
||||||
|
|
||||||
void NimBLEServerCallbacks::onAuthenticationComplete(const NimBLEConnInfo& connInfo){
|
void NimBLEServerCallbacks::onAuthenticationComplete(NimBLEConnInfo& connInfo){
|
||||||
NIMBLE_LOGD("NimBLEServerCallbacks", "onAuthenticationComplete: default");
|
NIMBLE_LOGD("NimBLEServerCallbacks", "onAuthenticationComplete: default");
|
||||||
} // onAuthenticationComplete
|
} // onAuthenticationComplete
|
||||||
|
|
||||||
void NimBLEServerCallbacks::onAuthenticationComplete(const NimBLEConnInfo& connInfo, const std::string& name){
|
void NimBLEServerCallbacks::onAuthenticationComplete(NimBLEConnInfo& connInfo, const std::string& name){
|
||||||
NIMBLE_LOGD("NimBLEServerCallbacks", "onAuthenticationComplete: default");
|
NIMBLE_LOGD("NimBLEServerCallbacks", "onAuthenticationComplete: default");
|
||||||
} // onAuthenticationComplete
|
} // onAuthenticationComplete
|
||||||
|
|
||||||
|
|
|
@ -78,7 +78,7 @@ public:
|
||||||
NimBLEConnInfo getPeerInfo(size_t index);
|
NimBLEConnInfo getPeerInfo(size_t index);
|
||||||
NimBLEConnInfo getPeerInfo(const NimBLEAddress& address);
|
NimBLEConnInfo getPeerInfo(const NimBLEAddress& address);
|
||||||
NimBLEConnInfo getPeerIDInfo(uint16_t id);
|
NimBLEConnInfo getPeerIDInfo(uint16_t id);
|
||||||
std::string getPeerName(const NimBLEConnInfo& connInfo);
|
std::string getPeerName(NimBLEConnInfo& connInfo);
|
||||||
void getPeerNameOnConnect(bool enable);
|
void getPeerNameOnConnect(bool enable);
|
||||||
#if !CONFIG_BT_NIMBLE_EXT_ADV || defined(_DOXYGEN_)
|
#if !CONFIG_BT_NIMBLE_EXT_ADV || defined(_DOXYGEN_)
|
||||||
void advertiseOnDisconnect(bool);
|
void advertiseOnDisconnect(bool);
|
||||||
|
@ -183,14 +183,14 @@ public:
|
||||||
* Should be passed back to NimBLEDevice::injectConfirmPIN
|
* Should be passed back to NimBLEDevice::injectConfirmPIN
|
||||||
* @param [in] pin The pin to compare with the client.
|
* @param [in] pin The pin to compare with the client.
|
||||||
*/
|
*/
|
||||||
virtual void onConfirmPIN(const NimBLEConnInfo& connInfo, uint32_t pin);
|
virtual void onConfirmPIN(NimBLEConnInfo& connInfo, uint32_t pin);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called when the pairing procedure is complete.
|
* @brief Called when the pairing procedure is complete.
|
||||||
* @param [in] connInfo A reference to a NimBLEConnInfo instance with information
|
* @param [in] connInfo A reference to a NimBLEConnInfo instance with information
|
||||||
* about the peer connection parameters.
|
* about the peer connection parameters.
|
||||||
*/
|
*/
|
||||||
virtual void onAuthenticationComplete(const NimBLEConnInfo& connInfo);
|
virtual void onAuthenticationComplete(NimBLEConnInfo& connInfo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called when the pairing procedure is complete.
|
* @brief Called when the pairing procedure is complete.
|
||||||
|
@ -198,13 +198,13 @@ public:
|
||||||
* @param [in] name The name of the connected peer device.
|
* @param [in] name The name of the connected peer device.
|
||||||
* about the peer connection parameters.
|
* about the peer connection parameters.
|
||||||
*/
|
*/
|
||||||
virtual void onAuthenticationComplete(const NimBLEConnInfo& connInfo, const std::string& name);
|
virtual void onAuthenticationComplete(NimBLEConnInfo& connInfo, const std::string& name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called when the peer identity address is resolved.
|
* @brief Called when the peer identity address is resolved.
|
||||||
* @param [in] connInfo A reference to a NimBLEConnInfo instance with information
|
* @param [in] connInfo A reference to a NimBLEConnInfo instance with information
|
||||||
*/
|
*/
|
||||||
virtual void onIdentity(const NimBLEConnInfo& connInfo);
|
virtual void onIdentity(NimBLEConnInfo& connInfo);
|
||||||
}; // NimBLEServerCallbacks
|
}; // NimBLEServerCallbacks
|
||||||
|
|
||||||
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */
|
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */
|
||||||
|
|
Loading…
Reference in a new issue