diff --git a/lib/libesp32_div/NimBLE-Arduino/CHANGELOG.md b/lib/libesp32_div/NimBLE-Arduino/CHANGELOG.md
index b80c3c93b..08d274106 100644
--- a/lib/libesp32_div/NimBLE-Arduino/CHANGELOG.md
+++ b/lib/libesp32_div/NimBLE-Arduino/CHANGELOG.md
@@ -2,6 +2,17 @@
All notable changes to this project will be documented in this file.
+## [1.3.6] - 2022-01-18
+
+### Changed
+- When retrieving attributes from a server fails with a 128bit UUID containing the ble base UUID another attempt will be made with the 16bit version of the UUID.
+
+### Fixed
+- Memory leak when services are changed on server devices.
+- Rare crashing that occurs when BLE commands are sent from ISR context using IPC.
+- Crashing caused by uninitialized disconnect timer in client.
+- Potential crash due to unintialized advertising callback pointer.
+
## [1.3.5] - 2022-01-14
### Added
diff --git a/lib/libesp32_div/NimBLE-Arduino/docs/Command_line_config.md b/lib/libesp32_div/NimBLE-Arduino/docs/Command_line_config.md
index c22565f4f..3fe4acb3e 100644
--- a/lib/libesp32_div/NimBLE-Arduino/docs/Command_line_config.md
+++ b/lib/libesp32_div/NimBLE-Arduino/docs/Command_line_config.md
@@ -6,6 +6,24 @@ Sets the number of simultaneous connections (esp controller max is 9)
- Default value is 3
+`CONFIG_NIMBLE_CPP_ATT_VALUE_TIMESTAMP_ENABLED`
+
+Enable/disable storing the timestamp when an attribute value is updated
+This allows for checking the last update time using getTimeStamp() or getValue(time_t*)
+If disabled, the timestamp returned from these functions will be 0.
+Disabling timestamps will reduce the memory used for each value.
+1 = Enabled, 0 = Disabled; Default = Disabled
+
+
+`CONFIG_NIMBLE_CPP_ATT_VALUE_INIT_LENGTH`
+
+Set the default allocation size (bytes) for each attribute.
+If not specified when the constructor is called. This is also the size used when a remote
+characteristic or descriptor is constructed before a value is read/notifed.
+Increasing this will reduce reallocations but increase memory footprint.
+Default value is 20. Range: 1 : 512 (BLE_ATT_ATTR_MAX_LEN)
+
+
`CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU`
Sets the default MTU size.
@@ -24,6 +42,13 @@ If defined, enables debug log messages from the NimBLE host
- Uses approx. 32kB of flash memory.
+`CONFIG_NIMBLE_CPP_LOG_LEVEL`
+
+Define to set the debug log message level from the NimBLE CPP Wrapper.
+If not defined it will use the same value as the Arduino core debug level.
+Values: 0 = NONE, 1 = ERROR, 2 = WARNING, 3 = INFO, 4+ = DEBUG
+
+
`CONFIG_NIMBLE_CPP_ENABLE_RETURN_CODE_TEXT`
If defined, NimBLE host return codes will be printed as text in debug log messages.
diff --git a/lib/libesp32_div/NimBLE-Arduino/docs/Improvements_and_updates.md b/lib/libesp32_div/NimBLE-Arduino/docs/Improvements_and_updates.md
index 245defd2d..c3c11265e 100644
--- a/lib/libesp32_div/NimBLE-Arduino/docs/Improvements_and_updates.md
+++ b/lib/libesp32_div/NimBLE-Arduino/docs/Improvements_and_updates.md
@@ -69,7 +69,9 @@ Now takes 2 optional parameters, the first is the duration to advertise for (in
that is invoked when advertsing ends and takes a pointer to a `NimBLEAdvertising` object (similar to the `NimBLEScan::start` API).
This provides an opportunity to update the advertisment data if desired.
-
+
+Also now returns a bool value to indicate if advertising successfully started or not.
+
# Client
@@ -100,8 +102,18 @@ Has been **deprecated** as now the internally stored characteristic value is upd
`NimBLERemoteCharacteristic::subscribe` and `NimBLERemoteCharacteristic::unsubscribe` have been implemented to replace it.
A callback is no longer requred to get the most recent value unless timing is important. Instead, the application can call `NimBLERemoteCharacteristic::getValue` to
get the last updated value any time.
+
-In addition `NimBLERemoteCharacteristic::readValue` and `NimBLERemoteCharacteristic::getValue` take an optional timestamp parameter which will update it's value with
+The `notifiy_callback` function is now defined as a `std::function` to take advantage of using `std::bind` to specifiy a class member function for the callback.
+
+Example:
+```
+using namespace std::placeholders;
+notify_callback callback = std::bind(&::, this, _1, _2, _3, _4);
+->subscribe(true, callback);
+```
+
+`NimBLERemoteCharacteristic::readValue` and `NimBLERemoteCharacteristic::getValue` take an optional timestamp parameter which will update it's value with
the time the last value was recieved.
> NimBLEClient::getService
diff --git a/lib/libesp32_div/NimBLE-Arduino/examples/NimBLE_Server/NimBLE_Server.ino b/lib/libesp32_div/NimBLE-Arduino/examples/NimBLE_Server/NimBLE_Server.ino
index 409ec64d6..7b8c42949 100644
--- a/lib/libesp32_div/NimBLE-Arduino/examples/NimBLE_Server/NimBLE_Server.ino
+++ b/lib/libesp32_div/NimBLE-Arduino/examples/NimBLE_Server/NimBLE_Server.ino
@@ -127,7 +127,7 @@ class CharacteristicCallbacks: public NimBLECharacteristicCallbacks {
/** Handler class for descriptor actions */
class DescriptorCallbacks : public NimBLEDescriptorCallbacks {
void onWrite(NimBLEDescriptor* pDescriptor) {
- std::string dscVal((char*)pDescriptor->getValue(), pDescriptor->getLength());
+ std::string dscVal = pDescriptor->getValue();
Serial.print("Descriptor witten value:");
Serial.println(dscVal.c_str());
};
diff --git a/lib/libesp32_div/NimBLE-Arduino/library.json b/lib/libesp32_div/NimBLE-Arduino/library.json
index e501aed59..69468f68d 100644
--- a/lib/libesp32_div/NimBLE-Arduino/library.json
+++ b/lib/libesp32_div/NimBLE-Arduino/library.json
@@ -2,7 +2,7 @@
"name": "NimBLE-Arduino",
"keywords": "esp32, bluetooth",
"description": "Bluetooth low energy (BLE) library for arduino-esp32 based on NimBLE",
- "version": "1.3.5",
+ "version": "1.3.6",
"frameworks": "arduino",
"platforms": "espressif32"
}
diff --git a/lib/libesp32_div/NimBLE-Arduino/library.properties b/lib/libesp32_div/NimBLE-Arduino/library.properties
index cbea51f6a..38f044cde 100644
--- a/lib/libesp32_div/NimBLE-Arduino/library.properties
+++ b/lib/libesp32_div/NimBLE-Arduino/library.properties
@@ -1,5 +1,5 @@
name=NimBLE-Arduino
-version=1.3.5
+version=1.3.6
author=h2zero
maintainer=h2zero
sentence=Bluetooth low energy (BLE) library for arduino-esp32 based on NimBLE.
diff --git a/lib/libesp32_div/NimBLE-Arduino/src/HIDTypes.h b/lib/libesp32_div/NimBLE-Arduino/src/HIDTypes.h
index 726b84be3..8ee31dae6 100644
--- a/lib/libesp32_div/NimBLE-Arduino/src/HIDTypes.h
+++ b/lib/libesp32_div/NimBLE-Arduino/src/HIDTypes.h
@@ -45,13 +45,8 @@
/* of data as per HID Class standard */
/* Main items */
-#ifdef ARDUINO_ARCH_ESP32
-#define HIDINPUT(size) (0x80 | size)
-#define HIDOUTPUT(size) (0x90 | size)
-#else
-#define INPUT(size) (0x80 | size)
-#define OUTPUT(size) (0x90 | size)
-#endif
+#define HIDINPUT(size) (0x80 | size)
+#define HIDOUTPUT(size) (0x90 | size)
#define FEATURE(size) (0xb0 | size)
#define COLLECTION(size) (0xa0 | size)
#define END_COLLECTION(size) (0xc0 | size)
diff --git a/lib/libesp32_div/NimBLE-Arduino/src/NimBLE2904.cpp b/lib/libesp32_div/NimBLE-Arduino/src/NimBLE2904.cpp
index 80318b5b8..282eff55f 100644
--- a/lib/libesp32_div/NimBLE-Arduino/src/NimBLE2904.cpp
+++ b/lib/libesp32_div/NimBLE-Arduino/src/NimBLE2904.cpp
@@ -16,11 +16,8 @@
* See also:
* https://www.bluetooth.com/specifications/gatt/viewer?attributeXmlFile=org.bluetooth.descriptor.gatt.characteristic_presentation_format.xml
*/
-#include "sdkconfig.h"
-#if defined(CONFIG_BT_ENABLED)
-
#include "nimconfig.h"
-#if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
+#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
#include "NimBLE2904.h"
@@ -86,5 +83,4 @@ void NimBLE2904::setUnit(uint16_t unit) {
setValue((uint8_t*) &m_data, sizeof(m_data));
} // setUnit
-#endif // #if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
-#endif
+#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */
diff --git a/lib/libesp32_div/NimBLE-Arduino/src/NimBLE2904.h b/lib/libesp32_div/NimBLE-Arduino/src/NimBLE2904.h
index d8800dd2f..29dde51e8 100644
--- a/lib/libesp32_div/NimBLE-Arduino/src/NimBLE2904.h
+++ b/lib/libesp32_div/NimBLE-Arduino/src/NimBLE2904.h
@@ -14,11 +14,8 @@
#ifndef MAIN_NIMBLE2904_H_
#define MAIN_NIMBLE2904_H_
-#include "sdkconfig.h"
-#if defined(CONFIG_BT_ENABLED)
-
#include "nimconfig.h"
-#if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
+#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
#include "NimBLEDescriptor.h"
@@ -82,6 +79,5 @@ private:
BLE2904_Data m_data;
}; // BLE2904
-#endif // #if defined(CONFIG_BT_NIMBLE_ROLE_PERIPHERAL)
-#endif /* CONFIG_BT_ENABLED */
+#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_PERIPHERAL */
#endif /* MAIN_NIMBLE2904_H_ */
diff --git a/lib/libesp32_div/NimBLE-Arduino/src/NimBLEAddress.cpp b/lib/libesp32_div/NimBLE-Arduino/src/NimBLEAddress.cpp
index e1d3e548b..b8df5ac83 100644
--- a/lib/libesp32_div/NimBLE-Arduino/src/NimBLEAddress.cpp
+++ b/lib/libesp32_div/NimBLE-Arduino/src/NimBLEAddress.cpp
@@ -11,7 +11,7 @@
* Created on: Jul 2, 2017
* Author: kolban
*/
-#include "sdkconfig.h"
+#include "nimconfig.h"
#if defined(CONFIG_BT_ENABLED)
#include
diff --git a/lib/libesp32_div/NimBLE-Arduino/src/NimBLEAddress.h b/lib/libesp32_div/NimBLE-Arduino/src/NimBLEAddress.h
index 50f9231fe..a6e10a09c 100644
--- a/lib/libesp32_div/NimBLE-Arduino/src/NimBLEAddress.h
+++ b/lib/libesp32_div/NimBLE-Arduino/src/NimBLEAddress.h
@@ -14,10 +14,15 @@
#ifndef COMPONENTS_NIMBLEADDRESS_H_
#define COMPONENTS_NIMBLEADDRESS_H_
-#include "sdkconfig.h"
+#include "nimconfig.h"
#if defined(CONFIG_BT_ENABLED)
+#if defined(CONFIG_NIMBLE_CPP_IDF)
#include "nimble/ble.h"
+#else
+#include "nimble/nimble/include/nimble/ble.h"
+#endif
+
/**** FIX COMPILATION ****/
#undef min
#undef max
diff --git a/lib/libesp32_div/NimBLE-Arduino/src/NimBLEAdvertisedDevice.cpp b/lib/libesp32_div/NimBLE-Arduino/src/NimBLEAdvertisedDevice.cpp
index ecfd49814..01dd75d41 100644
--- a/lib/libesp32_div/NimBLE-Arduino/src/NimBLEAdvertisedDevice.cpp
+++ b/lib/libesp32_div/NimBLE-Arduino/src/NimBLEAdvertisedDevice.cpp
@@ -11,11 +11,9 @@
* Created on: Jul 3, 2017
* Author: kolban
*/
-#include "sdkconfig.h"
-#if defined(CONFIG_BT_ENABLED)
#include "nimconfig.h"
-#if defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
+#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
#include "NimBLEDevice.h"
#include "NimBLEAdvertisedDevice.h"
@@ -783,7 +781,5 @@ size_t NimBLEAdvertisedDevice::getPayloadLength() {
return m_payload.size();
} // getPayloadLength
-
-#endif // #if defined( CONFIG_BT_NIMBLE_ROLE_CENTRAL)
-#endif /* CONFIG_BT_ENABLED */
+#endif /* CONFIG_BT_ENABLED && CONFIG_BT_NIMBLE_ROLE_CENTRAL */
diff --git a/lib/libesp32_div/NimBLE-Arduino/src/NimBLEAdvertisedDevice.h b/lib/libesp32_div/NimBLE-Arduino/src/NimBLEAdvertisedDevice.h
index 7d378ed0f..39410e665 100644
--- a/lib/libesp32_div/NimBLE-Arduino/src/NimBLEAdvertisedDevice.h
+++ b/lib/libesp32_div/NimBLE-Arduino/src/NimBLEAdvertisedDevice.h
@@ -14,20 +14,22 @@
#ifndef COMPONENTS_NIMBLEADVERTISEDDEVICE_H_
#define COMPONENTS_NIMBLEADVERTISEDDEVICE_H_
-#include "sdkconfig.h"
-#if defined(CONFIG_BT_ENABLED)
-
#include "nimconfig.h"
-#if defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
+#if defined(CONFIG_BT_ENABLED) && defined(CONFIG_BT_NIMBLE_ROLE_OBSERVER)
#include "NimBLEAddress.h"
#include "NimBLEScan.h"
#include "NimBLEUUID.h"
+#if defined(CONFIG_NIMBLE_CPP_IDF)
#include "host/ble_hs_adv.h"
+#else
+#include "nimble/nimble/host/include/host/ble_hs_adv.h"
+#endif
#include