Skip to content

Skip automatic DLE when peer reports no support - #1217

Open
ecushman wants to merge 1 commit into
h2zero:release/2.5from
ecushman:fix/unsupported-peer-auto-dle
Open

ecushman wants to merge 1 commit into
h2zero:release/2.5from
ecushman:fix/unsupported-peer-auto-dle

Conversation

@ecushman

@ecushman ecushman commented Nov 15, 2026 •

Copy link
Copy Markdown

Fixes #1216.

Skip automatic DLE when a successful peer feature response says it is unsupported. Keep existing behavior when support is unknown or advertised. Cache feature validity under the host lock.

Tested on a classic ESP32 with a Basen BMS, Arduino-ESP32 3.3.12 and NimBLE 2.5.2, with the application workaround removed: 26 successful polls on one connection, zero disconnects, and one early poll failure. The same link stayed up across samples 80 seconds apart, past the previous 40-second timeout. Longer testing is still needed.

ESP32 builds and a local host regression harness passed.

Summary by CodeRabbit

  • Bug Fixes
    • Improved Bluetooth connection setup when a connected device does not support extended data packet lengths.
    • Preserved connection setup behavior when the device’s capabilities are unknown or the connection fails, and improved handling of feature information for connections in different roles.

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

Arr, the connection setup path now records whether remote feature data is valid. It skips the default data-length request only when a successful connection has valid feature data that indicates the peer does not support DLE.

Changes: Peer DLE feature handling

Layer / File(s) Summary
Record remote feature validity
src/nimble/nimble/host/src/ble_hs_conn_priv.h, src/nimble/nimble/host/src/ble_gap.c
Arr, the connection structure gains a feature-validity field. The feature-completion handler stores remote feature bits only when the HCI response succeeds.
Gate the default data-length request
src/nimble/nimble/host/src/ble_gap.c
Arr, the connection event skips the default request when a successful connection has valid feature data that lacks DLE support. It still requests data length when the connection fails, feature data is unknown, or the peer supports DLE.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Medium

Suggested reviewers: h2zero

Merge Risk: Minimal · up to 349ea

This change stops the automatic data-length request when the peer reports it does not support the feature, which should prevent the recurring disconnects described in the linked issue. Behavior is unchanged when support is unknown or advertised. No merge-blocking risk was found.

Pre-merge checks: Passed 3 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Out of Scope Changes check Inconclusive The summary of ble_gap.c says ble_gap_rx_rd_rem_sup_feat_complete now records features only on successful reads, tracks feature validity, and changes control flow. It continues the master version-read… Provide readable diff hunks for ble_gap_rx_rd_rem_sup_feat_complete in src/nimble/nimble/host/src/ble_gap.c (base 11876a7 to head 349eac4). Confirm whether the non-master connect-event and slave_conn changes are required for the DLE skip.…
Passed Passed checks: 3 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed Arr, the title be "Skip automatic DLE when peer reports no support", and it matches the main change. The changeset skips the default data-length request only when a successful remote feature read show…
Linked Issues check Passed Arr, the requirement of #1216 is clear. Skip the automatic DLE request when a successful peer feature response clears BLE_HS_HCI_LE_FEAT_DATA_PACKET_LENGTH_EXT. Keep the request when support is unknow…
Full details: Title check

Explanation

Arr, the title be "Skip automatic DLE when peer reports no support", and it matches the main change. The changeset skips the default data-length request only when a successful remote feature read shows the peer lacks BLE_HS_HCI_LE_FEAT_DATA_PACKET_LENGTH_EXT. The struct gains a supported_feat_valid field to track feature validity, which supports that logic. The title names the primary behavior change in plain terms, so it be a fair match.

Full details: Linked Issues check

Explanation

Arr, the requirement of #1216 is clear. Skip the automatic DLE request when a successful peer feature response clears BLE_HS_HCI_LE_FEAT_DATA_PACKET_LENGTH_EXT. Keep the request when support is unknown, failed, or advertised. Per the AI-generated summary of ble_gap.c, a new helper checks the remote-feature response for validity and the DLE bit. ble_gap_event_connect_call() skips the default data-length request only when the connection completed successfully and the helper confirms no DLE support. Unknown or failed status, or advertised support, still sends the request. ble_hs_conn_priv.h adds supported_feat_valid to struct ble_hs_conn to hold feature validity. The behavior matches the issue. Limits: the diff could not be read (changed blobs missing from checkout), so this verdict rests on the summary. The summary does not confirm the host-lock caching detail from the PR description, and no test file appears in the changed-file summary. The issue does not require a specific test file. [#1216]

Full details: Out of Scope Changes check

Explanation

The summary of ble_gap.c says ble_gap_rx_rd_rem_sup_feat_complete now records features only on successful reads, tracks feature validity, and changes control flow. It continues the master version-read path, or for an existing non-master connection, issues the connect event and sets slave_conn. The feature-validity recording supports the #1216 fix. The change to connect-event dispatch and slave_conn handling for non-master connections is not shown to be needed for #1216. Its effect on slave-role connections cannot be verified. The diff was unreadable, so the changed hunks could not be checked.

Resolution

Provide readable diff hunks for ble_gap_rx_rd_rem_sup_feat_complete in src/nimble/nimble/host/src/ble_gap.c (base 11876a7 to head 349eac4). Confirm whether the non-master connect-event and slave_conn changes are required for the DLE skip. If they are not required, remove them or justify them against #1216. Also confirm the host-lock caching described in the PR description.

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Arr, feature bits come sailing in,
A validity flag marks their kin.
If DLE is not aboard,
The default request is ignored.
Unknown flags keep the old course true.
Safe harbor waits for the next HCI crew.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 26370cb9-789b-497f-a686-67cdd1131e8f
Commits

Reviewing files that changed from the base of the PR and between 11876a7 and 349eac4.

Files selected for processing: 2

  • src/nimble/nimble/host/src/ble_gap.c
  • src/nimble/nimble/host/src/ble_hs_conn_priv.h

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

@ecushman

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant