Skip to content

[Bugfix] Disable HCI VS on esp32 on older cores#1122

Merged
h2zero merged 1 commit intomasterfrom
bugfix/older-arduino-core-vhci
Mar 20, 2026
Merged

[Bugfix] Disable HCI VS on esp32 on older cores#1122
h2zero merged 1 commit intomasterfrom
bugfix/older-arduino-core-vhci

Conversation

@h2zero
Copy link
Owner

@h2zero h2zero commented Mar 19, 2026

Older Arduino cores would cause the BLE controller to fail if sent vendor specific commands, this disables that feature to prevent errors.

Fixes #1039

Summary by CodeRabbit

  • Bug Fixes
    • Improved Bluetooth configuration handling for ESP32-family microcontrollers, including better legacy feature management and version-specific compatibility adjustments.

@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: d9ead888-1a93-49bb-8c15-6edab0169875

📥 Commits

Reviewing files that changed from the base of the PR and between 083d921 and 3cf3a4a.

📒 Files selected for processing (1)
  • src/nimconfig.h
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/nimconfig.h

📝 Walkthrough

Walkthrough

Arr — Within #ifdef ESP_PLATFORM the patch swaps sdkconfig.h to angle-bracket include, adds <esp_idf_version.h>, and changes macro behavior: it now #undef and unconditionally redefines CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE (1 for ESP32/ESP32C3/ESP32S3, else 0), sets NIMBLE_CFG_CONTROLLER explicitly per branch, and adds MYNEWT_VAL_BLE_HCI_VS=0 for ESP32 when ESP-IDF < 5.0.0.

Changes

Cohort / File(s) Summary
Configuration Macro Redefinition
src/nimconfig.h
Replaced the prior conditional definition of CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE with an unconditional #undef then redefine: (1) for CONFIG_IDF_TARGET_ESP32 / ESP32C3 / ESP32S3, else (0). NIMBLE_CFG_CONTROLLER is explicitly set in both branches ((0) for ESP32-family, else CONFIG_BT_CONTROLLER_ENABLED). Switched sdkconfig.h include to <sdkconfig.h>, added <esp_idf_version.h>, and added MYNEWT_VAL_BLE_HCI_VS = 0 for ESP32 when ESP_IDF_VERSION < 5.0.0.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

⚓ Macros hoisted, undef'd, and set to sea,
ESP kin marked one or zero for thee,
Includes tidied up with proper trim and cheer,
A tiny compass tweak to steer builds clear,
Yarrr — quick fix, sails ready, code's in gear!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: disabling HCI VS on ESP32 for older cores to fix initialization hangs.
Linked Issues check ✅ Passed The pull request addresses the core objective of issue #1039 by disabling vendor-specific HCI commands on ESP32 with older IDF versions to prevent initialization hangs.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing the initialization hang: include path updates, macro redefinitions for legacy VHCI handling, and conditional HCI VS disabling for older cores.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/older-arduino-core-vhci

Comment @coderabbitai help to get the list of available commands and usage tips.

@h2zero h2zero force-pushed the bugfix/older-arduino-core-vhci branch from 33ea50e to 083d921 Compare March 20, 2026 15:33
@h2zero h2zero changed the title [Bugfix] Set Legacy VHCI correctly - fixes older Arduino core crashes [Bugfix] Disable HCI VS on esp32 on older cores Mar 20, 2026
Older Arduino cores would cause the BLE controller to fail if sent vendor specific commands,
this disables that feature to prevent errors.
@h2zero h2zero force-pushed the bugfix/older-arduino-core-vhci branch from 083d921 to 3cf3a4a Compare March 20, 2026 15:41
@h2zero h2zero merged commit b5110a2 into master Mar 20, 2026
42 checks passed
@h2zero h2zero deleted the bugfix/older-arduino-core-vhci branch March 20, 2026 16:01
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.

ESP hangs in NimBLEDevice::init function @ v2.3.6 (v2.3.2 works fine!)

1 participant