Skip to content

Add a flag to to use arduino header paths#1138

Merged
h2zero merged 1 commit intomasterfrom
header-flag
Mar 31, 2026
Merged

Add a flag to to use arduino header paths#1138
h2zero merged 1 commit intomasterfrom
header-flag

Conversation

@h2zero
Copy link
Copy Markdown
Owner

@h2zero h2zero commented Mar 31, 2026

Summary by CodeRabbit

  • Chores

    • Added a build-time toggle to prefer Arduino-packaged NimBLE headers for Arduino/portable builds.
  • Refactor

    • Standardized header-selection logic and formatting across the library to improve compatibility with Arduino-based toolchains and other build environments.
    • No public APIs or runtime behavior were changed.

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Mar 31, 2026

📝 Walkthrough

Walkthrough

Arr — Replaced many CONFIG_NIMBLE_CPP_IDF conditionals with a new USING_NIMBLE_ARDUINO_HEADERS macro (now defined in src/nimconfig.h); updated include paths and a few preprocessor gates across many source and header files, plus minor whitespace/formatting tweaks.

Changes

Cohort / File(s) Summary
Global config
src/nimconfig.h
Added #define USING_NIMBLE_ARDUINO_HEADERS (1).
Header include selection (ble_gap / ble_hs / ble_gatt / ble_uuid, etc.)
src/NimBLEAdvertisedDevice.h, src/NimBLEAdvertising.h, src/NimBLEClient.h, src/NimBLEConnInfo.h, src/NimBLEDevice.h, src/NimBLEExtAdvertising.h, src/NimBLEL2CAPChannel.h, src/NimBLEScan.h, src/NimBLEServer.h, src/NimBLEAdvertisementData.cpp, src/NimBLELocalValueAttribute.h, src/NimBLERemoteValueAttribute.h, src/NimBLEUUID.h, src/NimBLEUtils.cpp
Replaced CONFIG_NIMBLE_CPP_IDF-based include branches with USING_NIMBLE_ARDUINO_HEADERS checks to select Arduino-packaged NimBLE include paths vs. host paths.
Porting / NPL / mbuf / port headers
src/NimBLEAttValue.cpp, src/NimBLEClient.cpp, src/NimBLEScan.cpp, src/NimBLEStream.cpp, src/NimBLEStream.h, src/NimBLEL2CAPChannel.h
Swapped selection logic for nimble_port.h, nimble_npl.h, os_mbuf.h, and related porting headers to use USING_NIMBLE_ARDUINO_HEADERS.
GAP/GATT service headers
src/NimBLEAdvertising.cpp, src/NimBLEExtAdvertising.cpp, src/NimBLEServer.cpp
Changed conditional includes for GAP/GATT service headers to use the new Arduino-headers macro.
Compile-time gating / platform conditionals
src/NimBLECharacteristic.cpp, src/NimBLEClient.cpp, src/NimBLEDevice.cpp, src/NimBLEServer.cpp
Adjusted preprocessor guards that gate platform-specific calls and data-length APIs to depend on USING_NIMBLE_ARDUINO_HEADERS (and negations) instead of CONFIG_NIMBLE_CPP_IDF.
Logging
src/NimBLELog.h
Changed guard to !defined(USING_NIMBLE_ARDUINO_HEADERS) for selecting ESP-IDF logging includes and NIMBLE_LOG* macros.
Minor formatting changes
src/NimBLEAddress.h, src/NimBLEAdvertisedDevice.h, src/NimBLEScan.cpp, src/NimBLEUUID.h
Whitespace/indentation tweaks in conversion operators and member alignment; no API changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

Arr, a macro hoisted high upon the mast,
Headers set to port or Arduino fast,
Preproc charts in order, flags in line,
NimBLE sails tidy — builds shall soon be fine,
⚓️ Yo-ho, the include sea be calm at last!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 77.78% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: introducing a new flag (USING_NIMBLE_ARDUINO_HEADERS) to control header path selection throughout the codebase.

✏️ 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 header-flag

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

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

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (4)
src/NimBLERemoteValueAttribute.h (1)

24-28: Arr, the logic be sound but the formattin' be a bit off-keel!

The #ifdef on line 24 be lackin' the space after # that the other nested directives in this PR be usin' (e.g., # ifdef in src/NimBLEScan.h, src/NimBLEClient.h). 'Tis a minor cosmetic matter, but consistency across the fleet makes fer easier navigation, savvy?

🧹 Optional: Align indentation with other files
-#ifdef USING_NIMBLE_ARDUINO_HEADERS
-#  include "nimble/nimble/host/include/host/ble_gatt.h"
+# ifdef USING_NIMBLE_ARDUINO_HEADERS
+#  include "nimble/nimble/host/include/host/ble_gatt.h"
 # else
 #  include "host/ble_gatt.h"
 # endif
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/NimBLERemoteValueAttribute.h` around lines 24 - 28, Update the
preprocessor directive formatting for the conditional that checks
USING_NIMBLE_ARDUINO_HEADERS so it matches the project's style (space after the
# and consistent indentation for the nested # if/ # else/ # endif); locate the
block that references the USING_NIMBLE_ARDUINO_HEADERS macro and the two include
lines for "nimble/nimble/host/include/host/ble_gatt.h" and "host/ble_gatt.h" in
NimBLERemoteValueAttribute.h and change the directives to use the same "#
ifdef", "# else", and "# endif" spacing/indentation pattern used in other files
like NimBLEScan.h and NimBLEClient.h.
src/NimBLEAdvertising.h (1)

24-28: Same formattin' quirk as before, captain!

Arr, the #ifdef on line 24 be missin' that space after the #, just like in src/NimBLERemoteValueAttribute.h. The functionality be correct, but ye might want to hoist the same flag fer consistency across yer fleet.

🧹 Optional: Align indentation with other files
-#ifdef USING_NIMBLE_ARDUINO_HEADERS
+# ifdef USING_NIMBLE_ARDUINO_HEADERS
 #  include "nimble/nimble/host/include/host/ble_gap.h"
 # else
 #  include "host/ble_gap.h"
 # endif
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/NimBLEAdvertising.h` around lines 24 - 28, The preprocessor directives in
src/NimBLEAdvertising.h use inconsistent hashing spacing; update the directives
to match the style used in src/NimBLERemoteValueAttribute.h by adding a space
after the '#' in each directive (change "#ifdef USING_NIMBLE_ARDUINO_HEADERS" to
"# ifdef USING_NIMBLE_ARDUINO_HEADERS", and similarly change "# else" and "#
endif" to use consistent "# else" and "# endif" spacing), ensuring the include
lines (e.g., the "include" lines that reference
"nimble/nimble/host/include/host/ble_gap.h" and "host/ble_gap.h") keep their
current indentation so the file's preprocessor formatting is consistent with the
rest of the codebase.
src/NimBLEAdvertising.cpp (1)

21-26: Arr, same barnacle as before, matey!

The header path change be correct for the GAP service, but ye've got the same formatting inconsistency as NimBLEAdvertisementData.cpp - line 21 uses #ifdef while lines 23-25 use # else and # endif with spaces after the #.

🔧 Optional fix for consistent formatting
-#ifdef USING_NIMBLE_ARDUINO_HEADERS
+# ifdef USING_NIMBLE_ARDUINO_HEADERS
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/NimBLEAdvertising.cpp` around lines 21 - 26, The preprocessor directives
in NimBLEAdvertising.cpp are inconsistently formatted: change the spaced
directives "# else" and "# endif" to match the style of "#ifdef" (use "#else"
and "#endif" with no extra space) so the block that checks
USING_NIMBLE_ARDUINO_HEADERS and includes
"nimble/nimble/host/services/gap/include/services/gap/ble_svc_gap.h" or
"services/gap/ble_svc_gap.h" uses consistent directive formatting (update the "#
else" and "# endif" tokens to "#else" and "#endif").
src/NimBLEAdvertisementData.cpp (1)

26-30: Arr, ye got a wee formatting barnacle on the hull here!

The change be functionally correct, matey, but there be a small inconsistency in yer formatting. Line 26 uses #ifdef (no space after #), while lines 28-30 use # else and # endif (with space). Other files in this here PR like NimBLEScan.cpp use # ifdef with the space.

🔧 Optional fix for consistent formatting
-#ifdef USING_NIMBLE_ARDUINO_HEADERS
+# ifdef USING_NIMBLE_ARDUINO_HEADERS
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/NimBLEAdvertisementData.cpp` around lines 26 - 30, The preprocessor
directives in NimBLEAdvertisementData.cpp are inconsistently spaced; change the
block using `#ifdef USING_NIMBLE_ARDUINO_HEADERS` / `# else` / `# endif` to
match the project's style (use the same spacing as other files such as `# ifdef`
/ `# else` / `# endif`), so update the directives around the includes for
"nimble/nimble/host/include/host/ble_hs_adv.h" and "host/ble_hs_adv.h" to use
the consistent `# ifdef` / `# else` / `# endif` spacing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/nimconfig.h`:
- Line 229: Update the inline comment that currently reads "theesp-nimble-cpp"
to correct the typo by inserting a space so it reads "the esp-nimble-cpp"
(locate the comment containing the string "theesp-nimble-cpp" in nimconfig.h and
replace it with "the esp-nimble-cpp").

---

Nitpick comments:
In `@src/NimBLEAdvertisementData.cpp`:
- Around line 26-30: The preprocessor directives in NimBLEAdvertisementData.cpp
are inconsistently spaced; change the block using `#ifdef
USING_NIMBLE_ARDUINO_HEADERS` / `# else` / `# endif` to match the project's
style (use the same spacing as other files such as `# ifdef` / `# else` / `#
endif`), so update the directives around the includes for
"nimble/nimble/host/include/host/ble_hs_adv.h" and "host/ble_hs_adv.h" to use
the consistent `# ifdef` / `# else` / `# endif` spacing.

In `@src/NimBLEAdvertising.cpp`:
- Around line 21-26: The preprocessor directives in NimBLEAdvertising.cpp are
inconsistently formatted: change the spaced directives "# else" and "# endif" to
match the style of "#ifdef" (use "#else" and "#endif" with no extra space) so
the block that checks USING_NIMBLE_ARDUINO_HEADERS and includes
"nimble/nimble/host/services/gap/include/services/gap/ble_svc_gap.h" or
"services/gap/ble_svc_gap.h" uses consistent directive formatting (update the "#
else" and "# endif" tokens to "#else" and "#endif").

In `@src/NimBLEAdvertising.h`:
- Around line 24-28: The preprocessor directives in src/NimBLEAdvertising.h use
inconsistent hashing spacing; update the directives to match the style used in
src/NimBLERemoteValueAttribute.h by adding a space after the '#' in each
directive (change "#ifdef USING_NIMBLE_ARDUINO_HEADERS" to "# ifdef
USING_NIMBLE_ARDUINO_HEADERS", and similarly change "# else" and "# endif" to
use consistent "# else" and "# endif" spacing), ensuring the include lines
(e.g., the "include" lines that reference
"nimble/nimble/host/include/host/ble_gap.h" and "host/ble_gap.h") keep their
current indentation so the file's preprocessor formatting is consistent with the
rest of the codebase.

In `@src/NimBLERemoteValueAttribute.h`:
- Around line 24-28: Update the preprocessor directive formatting for the
conditional that checks USING_NIMBLE_ARDUINO_HEADERS so it matches the project's
style (space after the # and consistent indentation for the nested # if/ # else/
# endif); locate the block that references the USING_NIMBLE_ARDUINO_HEADERS
macro and the two include lines for "nimble/nimble/host/include/host/ble_gatt.h"
and "host/ble_gatt.h" in NimBLERemoteValueAttribute.h and change the directives
to use the same "# ifdef", "# else", and "# endif" spacing/indentation pattern
used in other files like NimBLEScan.h and NimBLEClient.h.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b3bfda2f-6132-46fd-ba5e-d02bc4227383

📥 Commits

Reviewing files that changed from the base of the PR and between 8370464 and ccd5747.

📒 Files selected for processing (28)
  • src/NimBLEAddress.h
  • src/NimBLEAdvertisedDevice.h
  • src/NimBLEAdvertisementData.cpp
  • src/NimBLEAdvertising.cpp
  • src/NimBLEAdvertising.h
  • src/NimBLEAttValue.cpp
  • src/NimBLECharacteristic.cpp
  • src/NimBLEClient.cpp
  • src/NimBLEClient.h
  • src/NimBLEConnInfo.h
  • src/NimBLEDevice.cpp
  • src/NimBLEDevice.h
  • src/NimBLEExtAdvertising.cpp
  • src/NimBLEExtAdvertising.h
  • src/NimBLEL2CAPChannel.cpp
  • src/NimBLEL2CAPChannel.h
  • src/NimBLELocalValueAttribute.h
  • src/NimBLELog.h
  • src/NimBLERemoteValueAttribute.h
  • src/NimBLEScan.cpp
  • src/NimBLEScan.h
  • src/NimBLEServer.cpp
  • src/NimBLEServer.h
  • src/NimBLEStream.cpp
  • src/NimBLEStream.h
  • src/NimBLEUUID.h
  • src/NimBLEUtils.cpp
  • src/nimconfig.h

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
src/NimBLEUUID.h (1)

24-28: Arr, the treasure map be correct, but the handwritin' be a wee bit wobbly!

The logic be sound for selectin' the ble_uuid.h header path. However, me keen pirate eye spots a minor formattin' inconsistency: Line 26 uses #else while Line 28 uses # endif (with a space). Other files in yer fleet use # else with a space.

🏴‍☠️ Optional formatting fix for consistency
 `#ifdef` USING_NIMBLE_ARDUINO_HEADERS
 #  include "nimble/nimble/host/include/host/ble_uuid.h"
-#else
+# else
 #  include "host/ble_uuid.h"
 # endif
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/NimBLEUUID.h` around lines 24 - 28, Preprocessor spacing is inconsistent
around the USING_NIMBLE_ARDUINO_HEADERS conditional: change the directives so
they match the project's style (use a space after '#' for conditional
directives). Specifically, update the block that checks
USING_NIMBLE_ARDUINO_HEADERS (the lines containing "#else" and "# endif") to use
"# else" and "# endif" so both directives follow the same spacing convention as
other files.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@src/NimBLEUUID.h`:
- Around line 24-28: Preprocessor spacing is inconsistent around the
USING_NIMBLE_ARDUINO_HEADERS conditional: change the directives so they match
the project's style (use a space after '#' for conditional directives).
Specifically, update the block that checks USING_NIMBLE_ARDUINO_HEADERS (the
lines containing "#else" and "# endif") to use "# else" and "# endif" so both
directives follow the same spacing convention as other files.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 69c65631-12fd-4994-9b91-f3b31ae0f7c3

📥 Commits

Reviewing files that changed from the base of the PR and between ccd5747 and 13f2fb7.

📒 Files selected for processing (28)
  • src/NimBLEAddress.h
  • src/NimBLEAdvertisedDevice.h
  • src/NimBLEAdvertisementData.cpp
  • src/NimBLEAdvertising.cpp
  • src/NimBLEAdvertising.h
  • src/NimBLEAttValue.cpp
  • src/NimBLECharacteristic.cpp
  • src/NimBLEClient.cpp
  • src/NimBLEClient.h
  • src/NimBLEConnInfo.h
  • src/NimBLEDevice.cpp
  • src/NimBLEDevice.h
  • src/NimBLEExtAdvertising.cpp
  • src/NimBLEExtAdvertising.h
  • src/NimBLEL2CAPChannel.cpp
  • src/NimBLEL2CAPChannel.h
  • src/NimBLELocalValueAttribute.h
  • src/NimBLELog.h
  • src/NimBLERemoteValueAttribute.h
  • src/NimBLEScan.cpp
  • src/NimBLEScan.h
  • src/NimBLEServer.cpp
  • src/NimBLEServer.h
  • src/NimBLEStream.cpp
  • src/NimBLEStream.h
  • src/NimBLEUUID.h
  • src/NimBLEUtils.cpp
  • src/nimconfig.h
✅ Files skipped from review due to trivial changes (9)
  • src/NimBLEAdvertisementData.cpp
  • src/nimconfig.h
  • src/NimBLEScan.h
  • src/NimBLEScan.cpp
  • src/NimBLEAdvertising.cpp
  • src/NimBLEStream.cpp
  • src/NimBLEAdvertisedDevice.h
  • src/NimBLEExtAdvertising.cpp
  • src/NimBLEDevice.cpp
🚧 Files skipped from review as they are similar to previous changes (13)
  • src/NimBLEAttValue.cpp
  • src/NimBLEL2CAPChannel.cpp
  • src/NimBLEServer.h
  • src/NimBLEStream.h
  • src/NimBLECharacteristic.cpp
  • src/NimBLEDevice.h
  • src/NimBLERemoteValueAttribute.h
  • src/NimBLEAddress.h
  • src/NimBLELog.h
  • src/NimBLEClient.cpp
  • src/NimBLEL2CAPChannel.h
  • src/NimBLEExtAdvertising.h
  • src/NimBLEServer.cpp

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/NimBLEConnInfo.h`:
- Around line 21-24: Add a direct include of nimconfig.h at the top of
NimBLEConnInfo.h so the USING_NIMBLE_ARDUINO_HEADERS macro is always defined
before the `#ifdef` branch; then fix the conditional include block that references
host/ble_gap.h by either removing the non-existent fallback or replacing it with
the correct repository include path so the include in NimBLEConnInfo.h is
self-contained (update the `#ifdef` USING_NIMBLE_ARDUINO_HEADERS ... `#else` ...
`#endif` block accordingly).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e9299496-30bb-4414-952a-5db09233540e

📥 Commits

Reviewing files that changed from the base of the PR and between 13f2fb7 and cd7f331.

📒 Files selected for processing (28)
  • src/NimBLEAddress.h
  • src/NimBLEAdvertisedDevice.h
  • src/NimBLEAdvertisementData.cpp
  • src/NimBLEAdvertising.cpp
  • src/NimBLEAdvertising.h
  • src/NimBLEAttValue.cpp
  • src/NimBLECharacteristic.cpp
  • src/NimBLEClient.cpp
  • src/NimBLEClient.h
  • src/NimBLEConnInfo.h
  • src/NimBLEDevice.cpp
  • src/NimBLEDevice.h
  • src/NimBLEExtAdvertising.cpp
  • src/NimBLEExtAdvertising.h
  • src/NimBLEL2CAPChannel.cpp
  • src/NimBLEL2CAPChannel.h
  • src/NimBLELocalValueAttribute.h
  • src/NimBLELog.h
  • src/NimBLERemoteValueAttribute.h
  • src/NimBLEScan.cpp
  • src/NimBLEScan.h
  • src/NimBLEServer.cpp
  • src/NimBLEServer.h
  • src/NimBLEStream.cpp
  • src/NimBLEStream.h
  • src/NimBLEUUID.h
  • src/NimBLEUtils.cpp
  • src/nimconfig.h
✅ Files skipped from review due to trivial changes (13)
  • src/NimBLEAdvertising.h
  • src/NimBLELocalValueAttribute.h
  • src/NimBLEL2CAPChannel.cpp
  • src/nimconfig.h
  • src/NimBLEUtils.cpp
  • src/NimBLEExtAdvertising.cpp
  • src/NimBLEScan.h
  • src/NimBLEScan.cpp
  • src/NimBLEUUID.h
  • src/NimBLEStream.cpp
  • src/NimBLEAdvertisementData.cpp
  • src/NimBLEClient.cpp
  • src/NimBLEAdvertisedDevice.h
🚧 Files skipped from review as they are similar to previous changes (10)
  • src/NimBLEClient.h
  • src/NimBLEStream.h
  • src/NimBLEServer.h
  • src/NimBLERemoteValueAttribute.h
  • src/NimBLECharacteristic.cpp
  • src/NimBLEExtAdvertising.h
  • src/NimBLELog.h
  • src/NimBLEAddress.h
  • src/NimBLEDevice.cpp
  • src/NimBLEAttValue.cpp

Comment on lines +21 to +24
#ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/host/include/host/ble_gap.h"
#else
# include "host/ble_gap.h"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Macro definition =="
rg -n '^\s*#\s*define\s+USING_NIMBLE_ARDUINO_HEADERS\b' src/nimconfig.h

echo
echo "== Include gate location in src/NimBLEConnInfo.h =="
nl -ba src/NimBLEConnInfo.h | sed -n '1,40p'

echo
echo "== Candidate ble_gap.h paths in repo =="
fd -a 'ble_gap\.h$' | rg '/host/ble_gap\.h$|/nimble/nimble/host/include/host/ble_gap\.h$' || true

echo
echo "== Files including NimBLEConnInfo.h =="
rg -n '#\s*include\s*"NimBLEConnInfo\.h"'

Repository: h2zero/NimBLE-Arduino

Length of output: 245


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== First 40 lines of src/NimBLEConnInfo.h =="
head -40 src/NimBLEConnInfo.h

echo
echo "== Check if nimconfig.h is included in src/NimBLEConnInfo.h =="
rg -n 'nimconfig\.h' src/NimBLEConnInfo.h || echo "(not found)"

echo
echo "== Check ble_gap.h paths =="
fd -a 'ble_gap\.h$'

echo
echo "== Files directly including NimBLEConnInfo.h =="
rg -l 'include.*NimBLEConnInfo\.h' src/ || echo "(none found)"

echo
echo "== Sample: first includer of NimBLEConnInfo.h =="
rg -B5 -A2 'include.*NimBLEConnInfo\.h' src/ | head -30 || true

Repository: h2zero/NimBLE-Arduino

Length of output: 2033


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== src/NimBLEDevice.h: lines around NimBLEConnInfo.h include =="
rg -B20 -A5 'include.*NimBLEConnInfo\.h' src/NimBLEDevice.h

echo
echo "== Check if nimconfig.h is included in src/NimBLEDevice.h =="
rg -n 'nimconfig\.h' src/NimBLEDevice.h | head -5

echo
echo "== Verify USING_NIMBLE_ARDUINO_HEADERS in nimconfig.h =="
grep -n 'USING_NIMBLE_ARDUINO_HEADERS' src/nimconfig.h

Repository: h2zero/NimBLE-Arduino

Length of output: 834


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Files that include nimconfig.h =="
rg -l 'nimconfig\.h' src/ | head -10

echo
echo "== Check for Arduino/build system includes =="
rg -r -n '#\s*include.*nimconfig\.h' src/ | head -10 || echo "(pattern not found)"

echo
echo "== First 50 lines of src/NimBLEDevice.h =="
head -50 src/NimBLEDevice.h

echo
echo "== Check if Arduino.h or config brings in nimconfig =="
rg -l 'Arduino\.h|nimble_host_config\.h' src/ | head -5

Repository: h2zero/NimBLE-Arduino

Length of output: 1727


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Contents of src/syscfg/syscfg.h =="
head -60 src/syscfg/syscfg.h

echo
echo "== Check if nimconfig.h defines USING_NIMBLE_ARDUINO_HEADERS =="
grep -A2 -B2 'USING_NIMBLE_ARDUINO_HEADERS' src/nimconfig.h

echo
echo "== Direct include pattern: does user code directly include NimBLEConnInfo.h? =="
rg 'include.*NimBLEConnInfo' --type cpp --type h . 2>/dev/null | grep -v src/NimBLEDevice.h || echo "(only from NimBLEDevice.h)"

echo
echo "== Verify fallback path really doesn't exist =="
find . -path "*/host/ble_gap.h" 2>/dev/null || echo "(confirmed: fallback path not in repo)"

Repository: h2zero/NimBLE-Arduino

Length of output: 2286


Ensure header includes its config dependency before conditional path branching.

Arrr, src/NimBLEConnInfo.h be lacking a direct include o' nimconfig.h, so the USING_NIMBLE_ARDUINO_HEADERS macro may not be in scope at Lines 21–24. The fallback path host/ble_gap.h does not exist in the repo either, makin' the fallback liable to fail. While currently 'tis only included from src/NimBLEDevice.h (where the macro is visible through syscfg.h), proper header design requires each header to be self-contained.

⚙️ Proposed fix
+#include "nimconfig.h"
 `#ifdef` USING_NIMBLE_ARDUINO_HEADERS
 # include "nimble/nimble/host/include/host/ble_gap.h"
 `#else`
 # include "host/ble_gap.h"
 `#endif`
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
#ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/host/include/host/ble_gap.h"
#else
# include "host/ble_gap.h"
`#include` "nimconfig.h"
`#ifdef` USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/host/include/host/ble_gap.h"
`#else`
# include "host/ble_gap.h"
`#endif`
🧰 Tools
🪛 Clang (14.0.6)

[error] 24-24: 'host/ble_gap.h' file not found

(clang-diagnostic-error)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/NimBLEConnInfo.h` around lines 21 - 24, Add a direct include of
nimconfig.h at the top of NimBLEConnInfo.h so the USING_NIMBLE_ARDUINO_HEADERS
macro is always defined before the `#ifdef` branch; then fix the conditional
include block that references host/ble_gap.h by either removing the non-existent
fallback or replacing it with the correct repository include path so the include
in NimBLEConnInfo.h is self-contained (update the `#ifdef`
USING_NIMBLE_ARDUINO_HEADERS ... `#else` ... `#endif` block accordingly).

@h2zero h2zero merged commit bc2b46e into master Mar 31, 2026
42 checks passed
@h2zero h2zero deleted the header-flag branch March 31, 2026 23:06
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