Releases: h2zero/esp-nimble-cpp
2.0.1
2.0.0
Finally! A new release with something more than a bugfix or some minor additions!
I'm excited to present this release properly after the unfortunate Arduino Library Manager debacle 🎉.
This was a complete overhaul of the codebase, every file as been touched up and some completely re-designed, removed, added, or changed significantly. This required A LOT of changes, many will break your current application code, but don't worry, it will be much better!
This release has so much in it!
Highlights
- Reduced the code size by over 40KB.
- Significant reduction in memory use.
- Huge performance boost.
- Asynchronous client connect, MTU exchange, and secure connection options to speed up the connecting process.
- Asynchronous passkey entry/confirmation so the client/server can have time to properly display/enter the passkey before action is performed.
- Scan restart option to clear the duplicate cache so the same devices will be found again.
- New scan callbacks class with extra functions that will get called on first discovery, before and scan response data is received.
- Ability to update advertised data while advertising.
- Improved support for dynamically changing services/characteristics/descriptors.
- Simplified code for easier maintenance and understanding for contributors.
Full Changelog
Breaking changes
- All connection oriented callbacks now receive a reference to
NimBLEConnInfo, theble_gap_conn_deschas also been replace withNimBLEConnInfoin the functions that received it. - All functions that take a time input parameter now expect the value to be in milliseconds instead of seconds.
- Removed Eddystone URL as it has been shutdown by google since 2021.
- NimBLESecurity class removed.
NimBLEDeviceIgnore list functions removed.NimBLEDevice::startSecuritynow returns abool, true on success, instead of an int to be consistent with the rest of the library.NimBLEDevice::getInitializedrenamed toNimBLEDevice::isInitialized.NimBLEDevice::setPowerno longer takes theesp_power_level_tandesp_ble_power_type_t, instead only an integer value in dbm units is accepted.NimBLEDevice::setOwnAddrTypeno longer takes abool nrpaparameter.NimBLEDevice::getClientListSizereplaced withNimBLEDevice::getCreatedClientCount.NimBLEDevice::getClientListwas removed.NimBLEServer::disconnectnow returnsbool, true = success, instead ofintto be consistent with the rest of the library.NimBLEServerCallbacks::onMTUChangedrenamed toNimBLEServerCallbacks::onMTUChangeto be consistent with the client callback.NimBLEServer::getPeerIDInforenamed toNimBLEServer::getPeerInfoByHandleto better describe it's use.NimBLEServerCallbacks::onPassKeyRequesthas been replaced withNimBLEServer::onPassKeyDisplaywhich should display the pairing pin that the client is expected to send.NimBLEServerCallbacks::onAuthenticationCompletenow takes aNimBLEConnInfo¶meter.NimBLEClient::getServicesnow returns a const reference to std::vector<NimBLERemoteService*> instead of a pointer to the internal vector.NimBLEClient::getConnIdhas been renamed togetConnHandleto be consistent with bluetooth terminology.NimBLEClient::disconnectnow returns abool, true on success, instead of an int to be consistent with the rest of the library.NimBLEClientCallbacks::onDisconnectnow takes an additionalint reasonparameter to let the application know why the disconnect occurred.NimBLEClientCallbacks::onPassKeyRequesthas been changed toNimBLEClientCallbacks::onPassKeyEntrywhich takes aNimBLEConnInfo¶meter and does not return a value. Instead or returning a value this callback should prompt a user to enter a pin number which is sent later viaNimBLEDevice::injectPassKey.NimBLEClientCallbacks::onConfirmPINrenamed toNimBLEClientCallbacks::onConfirmPasskeyand no longer returns a value and now takes aNimBLEConnInfo¶meter. This should be used to prompt a user to confirm the pin on the display (YES/NO) after which the response should be sent withNimBLEDevice::injectConfirmPasskey.NimBLEAdvertising::setMinPreferredandNimBLEAdvertising::setMaxPreferredhave been removed, useNimBLEAdvertising::setPreferredParamsinstead.- Advertising the name and TX power of the device will no longer happen by default and should be set manually by the application.
NimBLEAdvertising::setAdvertisementTypehas been renamed toNimBLEAdvertising::setConnectableModeto better reflect it's function.NimBLEAdvertising::setScanResponsehas been renamed toNimBLEAdvertising::enableScanResponseto better reflect it's function.NimBLEAdvertising; Scan response is no longer enabled by default.NimBLEAdvertising::startNo longer takes a callback pointer parameter, instead the new methodNimBLEAdvertising::setAdvertisingCompleteCallbackshould be used.NimBLEAdvertisementData::addDatanow takes either astd::vector<uint8_t>oruint8_t* + lengthinstead ofstd::stringorchar + length.NimBLEAdvertisementData::getPayloadnow returnsstd::vector<uint8_t>instead ofstd::string.- The callback parameter for
NimBLEScan::starthas been removed and the blocking overload ofNimBLEScan::starthas been replaced by an overload ofNimBLEScan::getResultswith the same parameters. NimBLEAdvertisedDeviceCallbacksHas been replaced byNimBLEScanCallbackswhich contains the following methods:onResult,onScanEnd, and `onDiscovered-
NimBLEScanCallbacks::onResult, functions the same as the oldNimBLEAdvertisedDeviceCallbacks::onResultbut now takes aaconst NimBLEAdvertisedDevice*instead of non-const.
-
NimBLEScanCallbacks::onScanEnd, replaces the scanEnded callback passed toNimBLEScan::startand now takes aconst NimBLEScanResults&andint reasonparameter.
-
NimBLEScanCallbacks::onDiscovered, This is called immediately when a device is first scanned, before any scan response data is available and takes aconst NimBLEAdvertisedDevice*parameter.
NimBLEScan::stopwill no longer call theonScanEndcallback as the caller should know its been stopped when this is called.NimBLEScan::clearDuplicateCachehas been removed as it was problematic and only for the esp32. Stop and start the scanner for the same effect.NimBLEScanResults::getDevicemethods now returnconst NimBLEAdvertisedDevice*.NimBLEScanResultsiterators are nowconst_iterator.NimBLEAdvertisedDevice::hasRSSIremoved as redundant, RSSI is always available.NimBLEAdvertisedDevice::getPayloadnow returnsconst std::vector<uint8_t>instead of a pointer to internal memory.NimBLEAdvertisedDeviceTimestamp removed, if needed then the app should track the time from the callback.NimBLECharacteristic::notifyno longer takes abool is_notificationparameter, insteadindicate()should be called to send indications.NimBLECharacteristicCallbacks::onNotifyremoved as unnecessary, the library does not call notify without app input.NimBLECharacteristicCallbacks::onStatusNo longer takes astatusparameter, refer to the return code for success/failure.NimBLERemoteCharacteristic::getRemoteServicenow returns aconst NimBLERemoteService*instead of non-const.NimBLERemoteCharacteristic::readUInt32Has been removed.NimBLERemoteCharacteristic::readUInt16Has been removed.NimBLERemoteCharacteristic::readUInt8Has been removed.NimBLERemoteCharacteristic::readFloatHas been removed.NimBLERemoteCharacteristic::registerForNotifyHas been removed.NimBLERemoteService::getCharacteristicsnow returns aconst std::vector<NimBLERemoteCharacteristic*>&instead of non-conststd::vector<NimBLERemoteCharacteristic*>*.NimBLERemoteService::getValuenow returnsNimBLEAttValueinstead ofstd::string.NimBLEService::getCharacteristicsnow returns aconst std::vector<NimBLECharacteristic*>&instead of std::vector<NimBLECharacteristic *>.NimBLEUUID::getNativemethod replaced withNimBLEUUID::getBasewhich returns a read-only pointer to the underlyingble_uuid_tstruct.NimBLEUUID;msbFirstparameter has been removed from constructor, caller should reverse the data first or call the newreverseByteOrdermethod after.NimBLEAddressconstructor; default value for thetypeparameter removed, caller should know the address type and specify it.NimBLEAddress::getNativereplaced withNimBLEAddress::getBaseand now returns a pointer toconst ble_addr_tinstead of a pointer to the address value.NimBLEAddress::equalsmethod andNimBLEAddress::== operatorwill now also test if the address types are the same.NimBLEUtils::dumpGapEventfunction removed.NimBLEUtils::buildHexDatareplaced withNimBLEUtils::dataToHexString, which returns astd::stringcontaining the hex string.NimBLEEddystoneTLM::setTempnow takes anint16_tparameter instead of float to be friendly to devices without floating point support.NimBLEEddystoneTLM::getTempnow returnsint16_tto work with devices that don't have floating point support.NimBLEEddystoneTLM::setDatanow takes a reference to *NimBLEEddystoneTLM::BeaconDatainstead ofstd::string.NimBLEEddystoneTLM::getDatanow returns a reference to *NimBLEEddystoneTLM::BeaconDatainstead ofstd::string.NimBLEBeacon::setDatanow takesconst NimBLEBeacon::BeaconData&instead ofstd::string.NimBLEBeacon::getDatanow returnsconst NimBLEBeacon::BeaconData&instead ofstd::string.NimBLEHIDDevice::reportMaprenamed toNimBLEHIDDevice::getReportMap.NimBLEHIDDevice::hidControlrenamed toNimBLEHIDDevice::getHidControl.NimBLEHIDDevice::inputReportrenamed toNimBLEHIDDevice::getInputReport.- `NimBLEHIDDevice::out...
v1.4.1
Fixed
- NimBLEDevice::getPower incorrect value when power level is -3db.
- Failed pairing when already in progress.
Changed
- Revert previous change that forced writing with response when subscribing in favor of allowing the application to decide.
Added
- Added NimBLEHIDDevice::batteryLevel.
- Added NimBLEDevice::setDeviceName allowing for changing the device name while the BLE stack is active.
- CI Builds
v1.4.0
Fixed
- Fixed missing data from long notification values.
- Fixed NimbleCharacteristicCallbacks::onRead not being called when a non-long read command is received.
- Prevent a potential crash when retrieving characteristics from a service if the result was successful but no characteristics found.
- logs/typos.
Changed
- AD flags are no longer set in the advertisements of non-connectable beacons, freeing up 3 bytes of advertisement room.
- Save resources when retrieving descriptors if the characteristic handle is the same as the end handle (no descriptors).
- Subscribing to characteristic notifications/indications will now always use write with response, as per BLE specifications.
NimBLEClient::discoverAttributesnow returns a bool value to indicate success/failure.- Scan result callbacks are no longer called when the scan response data is updated in order to reduce duplicates.
Added
- Preliminary support for non-esp devices, NRF51 and NRF52 devices supported with n-able arduino core
- Alias added for
NimBLEServerCallbacks::onMTUChangetoonMtuChangedin order to support porting code from original library. NimBLEAttValueClass added to reduce and control RAM footprint of characteristic/descriptor values and support conversions from Arduino Strings and many other data types.- Bluetooth 5 extended advertising support for capable devices. CODED Phy, 2M Phy, extended advertising data, and multi-advertising are supported, periodic advertising will be implemented in the future.
v1.3.3
Changed
- If attribute retrieval fails with a "not found" try again with the 16 bit version if a 128 bit base uuid is used.
Fixed
- Memory leak when deleting client instance.
- IDf version check for data length extension.
- Memory leak when server services changed.
- Compiler warnings for non-esp32 devices.
v1.3.2
Fixed
- Initialize advertising complete callback in NimBLEAdvertising constructor.
- Clear client disconnect timer in constructor before initializing.
- Fix missing data when reading large values.
- Fix missing data in notifications when using a large MTU size and more than 270 bytes of data are sent.
- Workaround fix added for cases when the task notification value is not cleared, causing various functions that should block not to block.
Added
NimBLEClient::getLastError: Gets the error code of the last function call that produces a return code from the stack.NimBLECharacteristic::notify: Overload method to send notifications/indications with custom values.- Added conditional checks for ESP32 specific functions/values to support use of the library on non-esp32 devices.
- Added an alias to use the callback name from the original library
onMtuChanged. NimBLEClient::setDataLenandNimBLEServer::setDataLen: Data length extension support (IDF version >= 4.3.2 only)- Config option to set logging level for esp-nimble-cpp
Changed
- Critical section calls now use the NimBLE API instead of FreeRTOS directly. This removes the need for a
portMUX_TYPEvariable in the class definitions. - Removed unnecessary variables in
NimBLEServiceand changed the constructor no no longer acceptnumHandlesandinst_idparameters.
1.3.1
1.3.0
Added
-
NimBLECharacteristic::removeDescriptor: Dynamically remove a descriptor from a characterisic. Takes effect after all connections are closed and sends a service changed indication. -
NimBLEService::removeCharacteristic: Dynamically remove a characteristic from a service. Takes effect after all connections are closed and sends a service changed indication -
NimBLEServerCallbacks::onMTUChange: This is callback is called when the MTU is updated after connection with a client. -
ESP32C3 support
-
Whitelist API:
NimBLEDevice::whiteListAdd: Add a device to the whitelist.NimBLEDevice::whiteListRemove: Remove a device from the whitelist.NimBLEDevice::onWhiteList: Check if the device is on the whitelist.NimBLEDevice::getWhiteListCount: Gets the size of the whitelistNimBLEDevice::getWhiteListAddress: Get the address of a device on the whitelist by index value.
-
Bond management API:
NimBLEDevice::getNumBonds: Gets the number of bonds stored.NimBLEDevice::isBonded: Checks if the device is bonded.NimBLEDevice::deleteAllBonds: Deletes all bonds.NimBLEDevice::getBondedAddress: Gets the address of a bonded device by the index value.
-
NimBLECharacteristic::getCallbacksto retrieve the current callback handler. -
Connection Information class:
NimBLEConnInfo. -
NimBLEScan::clearDuplicateCache: This can be used to reset the cache of advertised devices so they will be immediately discovered again.
Changed
- FreeRTOS files have been removed as they are not used by the library.
- Services, characteristics and descriptors can now be created statically and added after.
- Excess logging and some asserts removed.
- Use ESP_LOGx macros to enable using local log level filtering.
Fixed
NimBLECharacteristicCallbacks::onSubscribeIs now called after the connection is added to the vector.- Corrected bonding failure when reinitializing the BLE stack.
- Writing to a characterisic with a std::string value now correctly writes values with null characters.
- Retrieving remote descriptors now uses the characterisic end handle correctly.
- Missing data in long writes to remote descriptors.
- Hanging on task notification when sending an indication from the characteristic callback.
- BLE controller memory could be released when using Arduino as a component.
- Complile errors with NimBLE release 1.3.0.
Release version 1.2.0
Many additions and changes, check the changelog and documentation for complete details.
Release version 1.1.0
Many improvements and additions made, check CHANGELOG.md for details.