diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml
index 8b0cc60..5fbfde2 100644
--- a/.github/workflows/build.yml
+++ b/.github/workflows/build.yml
@@ -6,6 +6,7 @@ on:
push:
branches:
- master
+ - remove-conninfo-const
jobs:
build-esp-idf-component:
diff --git a/docs/Migration_guide.md b/docs/Migration_guide.md
index d1fcee8..6c860e1 100644
--- a/docs/Migration_guide.md
+++ b/docs/Migration_guide.md
@@ -31,14 +31,14 @@ For more information on the improvements and additions please refer to the [clas
### Header Files
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.
### Class Names
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 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.
### 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.
-`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.
@@ -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.
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.
`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)
```
-**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.
### Services
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.
@@ -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`.
#### Originally
-> BLECharacteristic::PROPERTY_READ |
+> BLECharacteristic::PROPERTY_READ |
BLECharacteristic::PROPERTY_WRITE
#### Is Now
-> NIMBLE_PROPERTY::READ |
+> NIMBLE_PROPERTY::READ |
NIMBLE_PROPERTY::WRITE
#### The full list of properties
-> NIMBLE_PROPERTY::READ
-NIMBLE_PROPERTY::READ_ENC
-NIMBLE_PROPERTY::READ_AUTHEN
-NIMBLE_PROPERTY::READ_AUTHOR
-NIMBLE_PROPERTY::WRITE
-NIMBLE_PROPERTY::WRITE_NR
-NIMBLE_PROPERTY::WRITE_ENC
-NIMBLE_PROPERTY::WRITE_AUTHEN
-NIMBLE_PROPERTY::WRITE_AUTHOR
-NIMBLE_PROPERTY::BROADCAST
-NIMBLE_PROPERTY::NOTIFY
-NIMBLE_PROPERTY::INDICATE
+> NIMBLE_PROPERTY::READ
+NIMBLE_PROPERTY::READ_ENC
+NIMBLE_PROPERTY::READ_AUTHEN
+NIMBLE_PROPERTY::READ_AUTHOR
+NIMBLE_PROPERTY::WRITE
+NIMBLE_PROPERTY::WRITE_NR
+NIMBLE_PROPERTY::WRITE_ENC
+NIMBLE_PROPERTY::WRITE_AUTHEN
+NIMBLE_PROPERTY::WRITE_AUTHOR
+NIMBLE_PROPERTY::BROADCAST
+NIMBLE_PROPERTY::NOTIFY
+NIMBLE_PROPERTY::INDICATE
@@ -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::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.
-**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.
> BLECharacteristic::getData
@@ -231,18 +231,18 @@ The above descriptor callbacks take an additional (required) parameter `NimBLECo
### Server Security
Security is set on the characteristic or descriptor properties by applying one of the following:
-> NIMBLE_PROPERTY::READ_ENC
-NIMBLE_PROPERTY::READ_AUTHEN
-NIMBLE_PROPERTY::READ_AUTHOR
-NIMBLE_PROPERTY::WRITE_ENC
-NIMBLE_PROPERTY::WRITE_AUTHEN
-NIMBLE_PROPERTY::WRITE_AUTHOR
+> NIMBLE_PROPERTY::READ_ENC
+NIMBLE_PROPERTY::READ_AUTHEN
+NIMBLE_PROPERTY::READ_AUTHOR
+NIMBLE_PROPERTY::WRITE_ENC
+NIMBLE_PROPERTY::WRITE_AUTHEN
+NIMBLE_PROPERTY::WRITE_AUTHOR
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.
@@ -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:
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.
> 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).
-This provides an opportunity to update the advertisement data if desired.
+This provides an opportunity to update the advertisement data if desired.
@@ -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.
-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.
> `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).
-Also now returns a pointer to `std::vector` instead of `std::map`.
+Also now returns a pointer to `std::vector` instead of `std::map`.
**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.
@@ -296,14 +296,14 @@ Also now returns a pointer to `std::vector` instead of `std::map`.
> BLERemoteService::getCharacteristicsByHandle
-This method has been removed.
+This method has been removed.
> `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
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`.
@@ -313,17 +313,17 @@ Also now returns a pointer to `std::vector` instead of `std::map`.
> `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.
> `BLERemoteCharacteristic::registerForNotify`
Has been removed.
-> `NimBLERemoteCharacteristic::subscribe`
-> `NimBLERemoteCharacteristic::unsubscribe`
+> `NimBLERemoteCharacteristic::subscribe`
+> `NimBLERemoteCharacteristic::unsubscribe`
-Are the new methods added to replace it.
+Are the new methods added to replace it.
> `BLERemoteCharacteristic::readUInt8` (`NimBLERemoteCharacteristic::readUInt8`)
@@ -331,7 +331,7 @@ Are the new methods added to replace it.
> `BLERemoteCharacteristic::readUInt32` (`NimBLERemoteCharacteristic::readUInt32`)
> `BLERemoteCharacteristic::readFloat` (`NimBLERemoteCharacteristic::readFloat`)
-Are **deprecated** a template: `NimBLERemoteCharacteristic::readValue(time_t\*, bool)` has been added to replace them.
+Are **deprecated** a template: `NimBLERemoteCharacteristic::readValue(time_t\*, bool)` has been added to replace them.
> `BLERemoteCharacteristic::readRawData`
@@ -354,7 +354,7 @@ my_struct_t myStruct = pChr->readValue();
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).
-Also now returns a pointer to `std::vector` instead of `std::map`.
+Also now returns a pointer to `std::vector` instead of `std::map`.
@@ -362,34 +362,34 @@ Also now returns a pointer to `std::vector` instead of `std::map`.
> `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.
### Client Security
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.
## 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.
## 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 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.
Call `NimBLEDevice::injectConfirmPIN(connInfo, true);` to accept or `NimBLEDevice::injectConfirmPIN(connInfo, false);` to reject.
-> `void onPassKeyEntry(const NimBLEConnInfo& connInfo)`
+> `void onPassKeyEntry(NimBLEConnInfo& connInfo)`
Client callback; client should respond with the passkey (pin) by calling `NimBLEDevice::injectPassKey(connInfo, 123456);`
@@ -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.
-> `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.
Security settings and IO capabilities are now set by the following methods of NimBLEDevice.
> `NimBLEDevice::setSecurityAuth(bool bonding, bool mitm, bool sc)`
> `NimBLEDevice::setSecurityAuth(uint8_t auth_req)`
-Sets the authorization mode for this device.
+Sets the authorization mode for this device.
> `NimBLEDevice::setSecurityIOCap(uint8_t iocap)`
-Sets the Input/Output capabilities of this device.
+Sets the Input/Output capabilities of this device.
> `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.
> `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.
@@ -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.
-For details on the options, they are fully commented in *nimconfig.h*
+For details on the options, they are fully commented in *nimconfig.h*
diff --git a/examples/Advanced/NimBLE_Client/main/main.cpp b/examples/Advanced/NimBLE_Client/main/main.cpp
index 86c04e6..47f8419 100644
--- a/examples/Advanced/NimBLE_Client/main/main.cpp
+++ b/examples/Advanced/NimBLE_Client/main/main.cpp
@@ -39,7 +39,7 @@ class ClientCallbacks : public NimBLEClientCallbacks {
/********************* Security handled here **********************
****** Note: these are the same return values as defaults ********/
- void onPassKeyEntry(const NimBLEConnInfo& connInfo){
+ void onPassKeyEntry(NimBLEConnInfo& connInfo){
printf("Server Passkey Entry\n");
/** This should prompt the user to enter the passkey displayed
* on the peer device.
@@ -47,14 +47,14 @@ class ClientCallbacks : public NimBLEClientCallbacks {
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);
/** Inject false if passkeys don't match. */
NimBLEDevice::injectConfirmPIN(connInfo, true);
};
/** Pairing process complete, we can check the results in connInfo */
- void onAuthenticationComplete(const NimBLEConnInfo& connInfo){
+ void onAuthenticationComplete(NimBLEConnInfo& connInfo){
if(!connInfo.isEncrypted()) {
printf("Encrypt connection failed - disconnecting\n");
/** Find the client with the connection handle provided in desc */
diff --git a/examples/Advanced/NimBLE_Server/main/main.cpp b/examples/Advanced/NimBLE_Server/main/main.cpp
index fd2a947..472faa7 100644
--- a/examples/Advanced/NimBLE_Server/main/main.cpp
+++ b/examples/Advanced/NimBLE_Server/main/main.cpp
@@ -52,13 +52,13 @@ class ServerCallbacks: public NimBLEServerCallbacks {
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);
/** Inject false if passkeys don't match. */
NimBLEDevice::injectConfirmPIN(connInfo, true);
};
- void onAuthenticationComplete(const NimBLEConnInfo& connInfo){
+ void onAuthenticationComplete(NimBLEConnInfo& connInfo){
/** Check that encryption was successful, if not we disconnect the client */
if(!connInfo.isEncrypted()) {
NimBLEDevice::getServer()->disconnect(connInfo.getConnHandle());
diff --git a/examples/NimBLE_server_get_client_name/main/main.cpp b/examples/NimBLE_server_get_client_name/main/main.cpp
index e255807..6f19db8 100644
--- a/examples/NimBLE_server_get_client_name/main/main.cpp
+++ b/examples/NimBLE_server_get_client_name/main/main.cpp
@@ -25,7 +25,7 @@ class ServerCallbacks : public NimBLEServerCallbacks {
}
// 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()) {
NimBLEDevice::getServer()->disconnect(connInfo.getConnHandle());
printf("Encrypt connection failed - disconnecting client\n");
diff --git a/examples/basic/BLE_client/main/main.cpp b/examples/basic/BLE_client/main/main.cpp
index cfb80e9..670c4ca 100644
--- a/examples/basic/BLE_client/main/main.cpp
+++ b/examples/basic/BLE_client/main/main.cpp
@@ -51,7 +51,7 @@ class MyClientCallback : public BLEClientCallbacks {
}
/***************** New - Security handled here ********************
****** Note: these are the same return values as defaults ********/
- void onPassKeyEntry(const NimBLEConnInfo& connInfo){
+ void onPassKeyEntry(NimBLEConnInfo& connInfo){
printf("Server Passkey Entry\n");
/** This should prompt the user to enter the passkey displayed
* on the peer device.
@@ -59,14 +59,14 @@ class MyClientCallback : public BLEClientCallbacks {
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);
/** Inject false if passkeys don't match. */
NimBLEDevice::injectConfirmPIN(connInfo, true);
};
/** Pairing process complete, we can check the results in connInfo */
- void onAuthenticationComplete(const NimBLEConnInfo& connInfo){
+ void onAuthenticationComplete(NimBLEConnInfo& connInfo){
if(!connInfo.isEncrypted()) {
printf("Encrypt connection failed - disconnecting\n");
/** Find the client with the connection handle provided in desc */
diff --git a/examples/basic/BLE_notify/main/main.cpp b/examples/basic/BLE_notify/main/main.cpp
index b17f49a..807545a 100644
--- a/examples/basic/BLE_notify/main/main.cpp
+++ b/examples/basic/BLE_notify/main/main.cpp
@@ -65,13 +65,13 @@ class MyServerCallbacks: public BLEServerCallbacks {
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);
/** Inject false if passkeys don't match. */
NimBLEDevice::injectConfirmPIN(connInfo, true);
};
- void onAuthenticationComplete(const NimBLEConnInfo& connInfo){
+ void onAuthenticationComplete(NimBLEConnInfo& connInfo){
/** Check that encryption was successful, if not we disconnect the client */
if(!connInfo.isEncrypted()) {
NimBLEDevice::getServer()->disconnect(connInfo.getConnHandle());
diff --git a/examples/basic/BLE_uart/main/main.cpp b/examples/basic/BLE_uart/main/main.cpp
index 18df6fa..3d0fd5c 100644
--- a/examples/basic/BLE_uart/main/main.cpp
+++ b/examples/basic/BLE_uart/main/main.cpp
@@ -67,13 +67,13 @@ class MyServerCallbacks: public BLEServerCallbacks {
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);
/** Inject false if passkeys don't match. */
NimBLEDevice::injectConfirmPIN(connInfo, true);
};
- void onAuthenticationComplete(const NimBLEConnInfo& connInfo){
+ void onAuthenticationComplete(NimBLEConnInfo& connInfo){
/** Check that encryption was successful, if not we disconnect the client */
if(!connInfo.isEncrypted()) {
NimBLEDevice::getServer()->disconnect(connInfo.getConnHandle());
diff --git a/src/NimBLECharacteristic.cpp b/src/NimBLECharacteristic.cpp
index 8d90b3e..2f07f53 100644
--- a/src/NimBLECharacteristic.cpp
+++ b/src/NimBLECharacteristic.cpp
@@ -203,7 +203,7 @@ size_t NimBLECharacteristic::getSubscribedCount() const {
* @brief Set the subscribe status for this characteristic.\n
* 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;
if (event->subscribe.cur_notify > 0 && (m_properties & NIMBLE_PROPERTY::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");
} // sendValue
-void NimBLECharacteristic::readEvent(const NimBLEConnInfo& connInfo) {
+void NimBLECharacteristic::readEvent(NimBLEConnInfo& 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);
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] 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");
} // onRead
@@ -441,7 +441,7 @@ void NimBLECharacteristicCallbacks::onRead(NimBLECharacteristic* pCharacteristic
* @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.
*/
-void NimBLECharacteristicCallbacks::onWrite(NimBLECharacteristic* pCharacteristic, const NimBLEConnInfo& connInfo) {
+void NimBLECharacteristicCallbacks::onWrite(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo) {
NIMBLE_LOGD("NimBLECharacteristicCallbacks", "onWrite: default");
} // onWrite
@@ -467,7 +467,7 @@ void NimBLECharacteristicCallbacks::onStatus(NimBLECharacteristic* pCharacterist
* * 3 = Notifications and Indications
*/
void NimBLECharacteristicCallbacks::onSubscribe(NimBLECharacteristic* pCharacteristic,
- const NimBLEConnInfo& connInfo,
+ NimBLEConnInfo& connInfo,
uint16_t subValue) {
NIMBLE_LOGD("NimBLECharacteristicCallbacks", "onSubscribe: default");
}
diff --git a/src/NimBLECharacteristic.h b/src/NimBLECharacteristic.h
index 5dbcdfc..5061c58 100644
--- a/src/NimBLECharacteristic.h
+++ b/src/NimBLECharacteristic.h
@@ -114,9 +114,9 @@ class NimBLECharacteristic : public NimBLELocalValueAttribute {
friend class NimBLEService;
void setService(NimBLEService* pService);
- void setSubscribe(const ble_gap_event* event, const NimBLEConnInfo& connInfo);
- void readEvent(const NimBLEConnInfo& connInfo) override;
- void writeEvent(const uint8_t* val, uint16_t len, const NimBLEConnInfo& connInfo) override;
+ void setSubscribe(const ble_gap_event* event, NimBLEConnInfo& connInfo);
+ void readEvent(NimBLEConnInfo& connInfo) override;
+ void writeEvent(const uint8_t* val, uint16_t len, NimBLEConnInfo& connInfo) override;
void sendValue(const uint8_t* value,
size_t length,
bool is_notification = true,
@@ -138,10 +138,10 @@ class NimBLECharacteristic : public NimBLELocalValueAttribute {
class NimBLECharacteristicCallbacks {
public:
virtual ~NimBLECharacteristicCallbacks() {}
- virtual void onRead(NimBLECharacteristic* pCharacteristic, const NimBLEConnInfo& connInfo);
- virtual void onWrite(NimBLECharacteristic* pCharacteristic, const NimBLEConnInfo& connInfo);
+ virtual void onRead(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo);
+ virtual void onWrite(NimBLECharacteristic* pCharacteristic, NimBLEConnInfo& connInfo);
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 */
diff --git a/src/NimBLEClient.cpp b/src/NimBLEClient.cpp
index 5803c4f..9d96fbd 100644
--- a/src/NimBLEClient.cpp
+++ b/src/NimBLEClient.cpp
@@ -1327,20 +1327,20 @@ bool NimBLEClientCallbacks::onConnParamsUpdateRequest(NimBLEClient* pClient, con
return true;
}
-void NimBLEClientCallbacks::onPassKeyEntry(const NimBLEConnInfo& connInfo){
+void NimBLEClientCallbacks::onPassKeyEntry(NimBLEConnInfo& connInfo){
NIMBLE_LOGD("NimBLEClientCallbacks", "onPassKeyEntry: default: 123456");
NimBLEDevice::injectPassKey(connInfo, 123456);
} //onPassKeyEntry
-void NimBLEClientCallbacks::onAuthenticationComplete(const NimBLEConnInfo& connInfo){
+void NimBLEClientCallbacks::onAuthenticationComplete(NimBLEConnInfo& connInfo){
NIMBLE_LOGD("NimBLEClientCallbacks", "onAuthenticationComplete: default");
}
-void NimBLEClientCallbacks::onIdentity(const NimBLEConnInfo& connInfo){
+void NimBLEClientCallbacks::onIdentity(NimBLEConnInfo& connInfo){
NIMBLE_LOGD("NimBLEClientCallbacks", "onIdentity: default");
} // onIdentity
-void NimBLEClientCallbacks::onConfirmPIN(const NimBLEConnInfo& connInfo, uint32_t pin){
+void NimBLEClientCallbacks::onConfirmPIN(NimBLEConnInfo& connInfo, uint32_t pin){
NIMBLE_LOGD("NimBLEClientCallbacks", "onConfirmPIN: default: true");
NimBLEDevice::injectConfirmPIN(connInfo, true);
}
diff --git a/src/NimBLEClient.h b/src/NimBLEClient.h
index 0ffca9c..b571e90 100644
--- a/src/NimBLEClient.h
+++ b/src/NimBLEClient.h
@@ -148,27 +148,27 @@ public:
* @brief Called when server requests a passkey for pairing.
* @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.
* @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.
*/
- virtual void onAuthenticationComplete(const NimBLEConnInfo& connInfo);
+ virtual void onAuthenticationComplete(NimBLEConnInfo& connInfo);
/**
* @brief Called when using numeric comparision for pairing.
* @param [in] connInfo A reference to a NimBLEConnInfo instance containing the peer info.
* @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.
* @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 */
diff --git a/src/NimBLEDescriptor.cpp b/src/NimBLEDescriptor.cpp
index dc9b34c..1f0bcad 100644
--- a/src/NimBLEDescriptor.cpp
+++ b/src/NimBLEDescriptor.cpp
@@ -118,11 +118,11 @@ std::string NimBLEDescriptor::toString() const {
return res;
} // toString
-void NimBLEDescriptor::readEvent(const NimBLEConnInfo& connInfo) {
+void NimBLEDescriptor::readEvent(NimBLEConnInfo& connInfo) {
m_pCallbacks->onRead(this, connInfo);
} // 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);
m_pCallbacks->onWrite(this, connInfo);
} // 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] 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");
} // 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] 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");
} // onWrite
diff --git a/src/NimBLEDescriptor.h b/src/NimBLEDescriptor.h
index e0df1ff..435e103 100644
--- a/src/NimBLEDescriptor.h
+++ b/src/NimBLEDescriptor.h
@@ -51,8 +51,8 @@ class NimBLEDescriptor : public NimBLELocalValueAttribute {
friend class NimBLEService;
void setCharacteristic(NimBLECharacteristic* pChar);
- void readEvent(const NimBLEConnInfo& connInfo) override;
- void writeEvent(const uint8_t* val, uint16_t len, const NimBLEConnInfo& connInfo) override;
+ void readEvent(NimBLEConnInfo& connInfo) override;
+ void writeEvent(const uint8_t* val, uint16_t len, NimBLEConnInfo& connInfo) override;
NimBLEDescriptorCallbacks* m_pCallbacks{nullptr};
NimBLECharacteristic* m_pCharacteristic{nullptr};
@@ -68,8 +68,8 @@ class NimBLEDescriptor : public NimBLELocalValueAttribute {
class NimBLEDescriptorCallbacks {
public:
virtual ~NimBLEDescriptorCallbacks() = default;
- virtual void onRead(NimBLEDescriptor* pDescriptor, const NimBLEConnInfo& connInfo);
- virtual void onWrite(NimBLEDescriptor* pDescriptor, const NimBLEConnInfo& connInfo);
+ virtual void onRead(NimBLEDescriptor* pDescriptor, NimBLEConnInfo& connInfo);
+ virtual void onWrite(NimBLEDescriptor* pDescriptor, NimBLEConnInfo& connInfo);
};
# include "NimBLE2904.h"
diff --git a/src/NimBLEDevice.cpp b/src/NimBLEDevice.cpp
index 74e3fd1..c110de8 100644
--- a/src/NimBLEDevice.cpp
+++ b/src/NimBLEDevice.cpp
@@ -1142,7 +1142,7 @@ int NimBLEDevice::startSecurity(uint16_t conn_id) {
* @param [in] pin The 6-digit pin to inject
* @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;
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] 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;
struct ble_sm_io pkey = {0,0};
diff --git a/src/NimBLEDevice.h b/src/NimBLEDevice.h
index 121df58..2439780 100644
--- a/src/NimBLEDevice.h
+++ b/src/NimBLEDevice.h
@@ -135,8 +135,8 @@ public:
static void setSecurityPasskey(uint32_t pin);
static uint32_t getSecurityPasskey();
static int startSecurity(uint16_t conn_id);
- static bool injectConfirmPIN(const NimBLEConnInfo& peerInfo, bool accept);
- static bool injectPassKey(const NimBLEConnInfo& peerInfo, uint32_t pin);
+ static bool injectConfirmPIN(NimBLEConnInfo& peerInfo, bool accept);
+ static bool injectPassKey(NimBLEConnInfo& peerInfo, uint32_t pin);
static int setMTU(uint16_t mtu);
static uint16_t getMTU();
static bool isIgnored(const NimBLEAddress &address);
diff --git a/src/NimBLELocalValueAttribute.h b/src/NimBLELocalValueAttribute.h
index 7b9778e..746acb6 100644
--- a/src/NimBLELocalValueAttribute.h
+++ b/src/NimBLELocalValueAttribute.h
@@ -124,7 +124,7 @@ class NimBLELocalValueAttribute : public NimBLELocalAttribute {
* @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.
*/
- virtual void readEvent(const NimBLEConnInfo& connInfo) = 0;
+ virtual void readEvent(NimBLEConnInfo& connInfo) = 0;
/**
* @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.
* @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.
diff --git a/src/NimBLEServer.cpp b/src/NimBLEServer.cpp
index 3ed4893..db57af1 100644
--- a/src/NimBLEServer.cpp
+++ b/src/NimBLEServer.cpp
@@ -460,7 +460,7 @@ std::string NimBLEServer::getPeerNameInternal(uint16_t conn_handle, TaskHandle_t
* @returns A string containing the name.
* @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());
return name;
}
@@ -1073,20 +1073,20 @@ uint32_t NimBLEServerCallbacks::onPassKeyDisplay(){
return 123456;
} //onPassKeyDisplay
-void NimBLEServerCallbacks::onConfirmPIN(const NimBLEConnInfo& connInfo, uint32_t pin){
+void NimBLEServerCallbacks::onConfirmPIN(NimBLEConnInfo& connInfo, uint32_t pin){
NIMBLE_LOGD("NimBLEServerCallbacks", "onConfirmPIN: default: true");
NimBLEDevice::injectConfirmPIN(connInfo, true);
} // onConfirmPIN
-void NimBLEServerCallbacks::onIdentity(const NimBLEConnInfo& connInfo){
+void NimBLEServerCallbacks::onIdentity(NimBLEConnInfo& connInfo){
NIMBLE_LOGD("NimBLEServerCallbacks", "onIdentity: default");
} // onIdentity
-void NimBLEServerCallbacks::onAuthenticationComplete(const NimBLEConnInfo& connInfo){
+void NimBLEServerCallbacks::onAuthenticationComplete(NimBLEConnInfo& connInfo){
NIMBLE_LOGD("NimBLEServerCallbacks", "onAuthenticationComplete: default");
} // 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");
} // onAuthenticationComplete
diff --git a/src/NimBLEServer.h b/src/NimBLEServer.h
index 8cc989d..22b67dc 100644
--- a/src/NimBLEServer.h
+++ b/src/NimBLEServer.h
@@ -78,7 +78,7 @@ public:
NimBLEConnInfo getPeerInfo(size_t index);
NimBLEConnInfo getPeerInfo(const NimBLEAddress& address);
NimBLEConnInfo getPeerIDInfo(uint16_t id);
- std::string getPeerName(const NimBLEConnInfo& connInfo);
+ std::string getPeerName(NimBLEConnInfo& connInfo);
void getPeerNameOnConnect(bool enable);
#if !CONFIG_BT_NIMBLE_EXT_ADV || defined(_DOXYGEN_)
void advertiseOnDisconnect(bool);
@@ -183,14 +183,14 @@ public:
* Should be passed back to NimBLEDevice::injectConfirmPIN
* @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.
* @param [in] connInfo A reference to a NimBLEConnInfo instance with information
* about the peer connection parameters.
*/
- virtual void onAuthenticationComplete(const NimBLEConnInfo& connInfo);
+ virtual void onAuthenticationComplete(NimBLEConnInfo& connInfo);
/**
* @brief Called when the pairing procedure is complete.
@@ -198,13 +198,13 @@ public:
* @param [in] name The name of the connected peer device.
* 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.
* @param [in] connInfo A reference to a NimBLEConnInfo instance with information
*/
- virtual void onIdentity(const NimBLEConnInfo& connInfo);
+ virtual void onIdentity(NimBLEConnInfo& connInfo);
}; // NimBLEServerCallbacks
#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */