Commit Graph

524 Commits

Author SHA1 Message Date
h2zero 24a89199a1 Return error if calling function will block host task
This will prevent applications from hanging forever when calling a blocking function from the host task.
2026-03-30 13:31:31 -06:00
copilot-swe-agent[bot] dd32365625 Fix setValue() using sizeof instead of strlen for char array arguments
Agent-Logs-Url: https://github.com/h2zero/NimBLE-Arduino/sessions/42ace199-2049-4c37-8f0a-30443045b8b2

Co-authored-by: h2zero <32826625+h2zero@users.noreply.github.com>
2026-03-29 17:06:10 -06:00
h2zero 8bb9578b41 Fix backward compatability issue with remote charactertistic sorting 2026-03-29 15:53:34 -06:00
h2zero 28d49a0d28 Add ANCS example 2026-03-29 15:34:30 -06:00
h2zero b11d34ee06 [Bugfix] get remote characteristic by uuid returning the wrong instance.
This fixes a bug introduced when sorting the characteristic vector where the last item on in the vector was
returned but the characteristc wasn't at the end anymore.

This reverts the previous sorting of the vector after retrieval and instead sorts as the characteristics are found and also
provides a pointer to the characteristic from the retrieval callback.
2026-03-29 14:21:42 -06:00
h2zero 67fa4776f4 [Bugfix] Remote descriptor not found when char handles out of order
This resolves the issue of retrieving characteristics out of handle order and then trying to subscribe or
do some other fetch of a descriptor belonging to that characteristic and the search handle was limited
to the handle of the next characteristic in the vector.

This ensures that the vector is sorted in ascending order based on handle values so the next characteristic
in the vector will always have a higher handle value and the desciptor serach will function as intended.
2026-03-29 11:14:56 -06:00
h2zero 0db2215c2f [Bugfix] Set server created client connection status on creation. 2026-03-29 10:40:10 -06:00
h2zero 182796d756 [Bugfix] HCI response to disconnect of unknown ID should return success.
* Update macro use to use conversion macros.
2026-03-28 15:53:01 -06:00
h2zero afe12212ff [Feat] Wait for connections to establish before callback, retry on fail
* Delay onConnect until connection is likely established using a timer (7x conn interval), with early completion on peer activity.
* Suppress onDisconnect for 0x3e and route terminal 0x3e failures to onConnectFail.
* Add configurable 0x3e reconnect attempts via `setConnectRetries` or client config (default 2).
* Retry logic suppresses callbacks while retrying; callbacks fire only on final outcome.
* Refactor connect-start path into a shared helper used by initial connect and retries.
2026-03-27 15:56:34 -06:00
h2zero 5d48f9479b [Bugfix] Arduino detection for headers. 2026-03-25 13:30:51 -06:00
h2zero 0dbca80bcf [Bugfix] Incorrect Client connection state tracking and self delete
This adds better client state tracking so that functions like NimBLEDevice::getDisconnectedClient get a more accurate state and will not return a connecting client.

This also fixes the client self delete on connection error where function call errors did not delete the client
2026-03-25 12:35:26 -06:00
h2zero 74443d93ee Add NimBLEServer::sendServiceChangedIndication
This reverts changing NimBLEServer::serviceChanged from private to public and adds a new function that is more user firendly to indicate to clients that the services should be re-discovered.

* Renames serviceChanged to setServiceChanged to better indicate its function.
2026-03-24 12:51:25 -06:00
h2zero 7b897b1551 Add a timer for scan responses
This ensures that the callback will be called within the configured time (in ms) when devices fail to respond to a scan response request within that time.

* Adds stats when debug logging to help tune the scan response timeout/scan parameters.
2026-03-24 12:26:18 -06:00
Chris Morgan bc6bb9836d NimBLEServer::serviceChanged() should be public to enable it being called outside of the library to indicate GATT changes 2026-03-21 07:40:19 -06:00
h2zero 2cb68e242d [Bugfix] getBondedAddress index could go out of array bounds. 2026-03-18 09:08:01 -06:00
h2zero 6f16880c25 Cleanup compiler warnings when using HID device or bonds disabled. 2026-03-18 09:08:01 -06:00
copilot-swe-agent[bot] a672ecd86b Add NimBLECppVersion.h with version macros and runtime version function
Co-authored-by: h2zero <32826625+h2zero@users.noreply.github.com>
2026-03-17 18:52:55 -06:00
Ryan Powell 3aace03f54 [Bugfix] NimBLEDevice::createServer can crash if stack not initialized.
* [Bugfix] NimBLEDevice::createServer can crash if stack not initialized.

This removes the gatts/gap reset calls from NimBLEDevice::createServer so that it can be safely used before initializing the stack.

This also deprecates NimBLEService::start the the services will now be added/created only when the server is started.
2026-03-17 18:52:55 -06:00
copilot-swe-agent[bot] 494f647e1f Add onPassKeyEntry to NimBLEServerCallbacks and onPassKeyDisplay to NimBLEClientCallbacks
Co-authored-by: h2zero <32826625+h2zero@users.noreply.github.com>
2026-03-17 18:52:55 -06:00
h2zero 22e7d6fe8d [Bugfix] Delete all bonds does not allow re-pairing.
This change iterates through each bond and unpairs it rather than just deleting the bond data in nvs, allowing a connected peer to rebond.
2026-03-16 19:07:31 -06:00
h2zero c731adc441 [Bugfix] Missing notification data when length > 255 bytes
When the ACL buffer is less than the MTU, the data arrives in more than one mbuf.
This combines the data from the mbuf chain and stores it before calling the appliation callback, ensuring it has all the data.
2026-03-16 18:15:20 -06:00
h2zero 42c33fcdb5 Update build workflow - remove IDF v4.x builds 2026-03-16 08:56:09 -06:00
h2zero 59ef15a218 Add BLE stream classes.
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
2026-03-16 08:56:09 -06:00
Stijn Eijndhoven a0a8db992c Restore comment for disable_observer_mode field 2026-03-14 16:09:41 -06:00
Stijn Eijndhoven c64ca74c34 Conditionally guard disable_observer_mode behind ESP_PLATFORM and CONFIG_USING_NIMBLE_COMPONENT 2026-03-14 16:09:41 -06:00
Stijn Eijndhoven 4cb427ef51 Use designated initializer for NimBLEScan::m_scanParams and guard disable_observer_mode field for ESP-IDF >= 5.4.2
The NimBLEScan constructor previously used positional struct initialization,
which no longer matches the ble_gap_disc_params layout in newer ESP-IDF
versions (>= 5.4.2) where the field `disable_observer_mode` was added.

This is caused by -Wmissing-field-initializers.

Switch to designated initializers to make the field assignments explicit
and more robust across ESP-IDF/NimBLE revisions. The new field is only
initialized when building against ESP-IDF 5.4.2 or later to maintain
backwards compatibility.
2026-03-14 16:09:41 -06:00
copilot-swe-agent[bot] 04a7a792ac [Bugfix] whitelist bounds checks
Co-authored-by: doudar <17362216+doudar@users.noreply.github.com>
2026-03-14 08:23:46 -06:00
h2zero 540ebfcb64 Properly set attribute handles and improve dynamic service changes
This changes how attribute handles are set so they can be correctly identified when there is more than one attribute with the same UUID.
Instead of reading from the stack by UUID to get the handles this will now use the registration callback to set them correctly.

This also improves handling of dynamic service changes by properly removing characteristics/descriptors when required and resetting the GATT when advertising is started instead of after the last client disconnects.

* Adds NimBLEUUID constructor overload for ble_uuid_t*.
* NimBLECharacteristic::getDescriptorByUUID now takes an optional index value to support multiple same-uuid descriptors.
2026-03-13 15:35:35 -06:00
h2zero 437e651e0c Add NimBLEConnInfo::toString method. 2026-03-13 14:18:54 -06:00
h2zero ea7075a2f7 Use a single macro to detect if scan duplicate filtering is enabled 2026-03-13 14:16:00 -06:00
h2zero 002abf91e9 Fix kconfig warnings
Redefining the kconfig BLE options for the esp32p4 is no longer needed as
bluetooth support is enabled in newer esp-idf versions and can be added to
the project config if older versions are used.
2026-03-03 10:40:14 -07:00
h2zero 3266951aee Release 2.3.4 2025-12-27 08:34:13 -07:00
h2zero 4c07a1d892 Add void pointer argument to setCustomGapHandler. 2025-12-08 17:12:44 -07:00
hjlee 9a7db6a16e Fix descriptor search range in retrieveDescriptors()
The previous implementation incorrectly used the service's end handle
when searching for descriptors, which caused it to retrieve descriptors
from subsequent characteristics as well.

This fix calculates the correct end handle by finding the next
characteristic's handle and using (next_handle - 1) as the search limit.
This ensures only descriptors belonging to the current characteristic
are retrieved.

Fixes incorrect descriptor retrieval when multiple characteristics
exist in the same service.
2025-12-03 14:18:04 -07:00
iranl 25af28bcad Add support for esp32c61 2025-11-24 05:35:43 -07:00
h2zero f216e95770 Add characteristic callbacks onStatus overload with conn info.
Adds a new overloaded callback to NimBLECharacteristicCallbacks for the notification/indication onStatus method that provides a NimBLEConnInfo reference.
2025-11-17 19:21:13 -07:00
h2zero 222f1590ed Refactor notify/indicate
This refactors the handling of sending notifications and indications for greater efficiency.
* Adds client subscription state tracking to NimBLECharacteristic rather than relying on the stack.
* Notifications/indications are now sent directly, no longer calling the callback to read the values.
  This avoids delays and flash writes in the stack, allowing for greater throughput.
2025-11-17 19:21:13 -07:00
srgg 149716a506 correct container byte size calculation to writeValue, notify, and indicate 2025-11-16 09:22:40 -07:00
srgg 4199c52af1 fix: correct byte size calculation for ATT values set from containers 2025-11-16 09:22:37 -07:00
h2zero 20158d62d0 [Bugfix] make sure the notify event is sent to server created clients 2025-10-24 13:19:42 -06:00
Quentin F f6c8728ca3 Update 1.x_to2.x_migration_guide.md 2025-10-24 13:19:03 -06:00
h2zero e0d3c4be39 Update workflows + add release publish 2025-10-24 13:09:46 -06:00
Guo-Rong d163a9fdc6 Find client by handle during disconnect event.
If the peer has RPA enabled, searching by address fails due to address
resolution.
If this occurs, attempt to find the client by connection handle.
2025-10-23 11:55:24 -06:00
Chris Morgan 133c1a5da4 Usage_tips.md - Note that the library is threadsafe. 2025-10-23 11:54:37 -06:00
Chris Morgan f622cdff0c README.md - Add a note about threadsafety 2025-10-23 11:54:37 -06:00
Chris Morgan 68068677ab Usage_tips.md - 'Device Local Name' information to help guide setting the GATT Device Name or Advertising name. 2025-09-28 19:31:04 -06:00
Chris Morgan 2c6ab706b3 Usage_tips.md - Detail persisted bonds limitations and considerations relative to CONFIG_BT_NIMBLE_MAX_CCCDS 2025-09-23 21:04:11 -06:00
h2zero 6f0b9ddf5d Convert NIMBLE_CPP macros to MYNEWT. 2025-09-06 16:59:55 -06:00
h2zero 8f9e85a46a Release 2.3.3 2025-09-05 16:11:11 -06:00
h2zero 7706f5a6b2 Support up to 1650 bytes of advertisement with extended advertising. 2025-09-05 15:44:47 -06:00