Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,4 @@ config NIMBLE_CPP_FREERTOS_TASK_BLOCK_BIT
Configure the bit to set in the task notification value when a task is blocked waiting for an event.
This should be set to a bit that is not used by other notifications in the system.

config NIMBLE_CPP_IDF
bool
default BT_NIMBLE_ENABLED

endmenu
10 changes: 5 additions & 5 deletions src/NimBLEAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include "syscfg/syscfg.h"
#if CONFIG_BT_NIMBLE_ENABLED

# if defined(CONFIG_NIMBLE_CPP_IDF)
# include "nimble/ble.h"
# else
# ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/include/nimble/ble.h"
# else
# include "nimble/ble.h"
# endif

/**** FIX COMPILATION ****/
Expand Down Expand Up @@ -63,8 +63,8 @@ class NimBLEAddress : private ble_addr_t {
const NimBLEAddress& reverseByteOrder();
bool operator==(const NimBLEAddress& rhs) const;
bool operator!=(const NimBLEAddress& rhs) const;
operator std::string() const;
operator uint64_t() const;
operator std::string() const;
operator uint64_t() const;
};

#endif // CONFIG_BT_NIMBLE_ENABLED
Expand Down
22 changes: 11 additions & 11 deletions src/NimBLEAdvertisedDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@
# include "NimBLEScan.h"
# include "NimBLEUUID.h"

# if defined(CONFIG_NIMBLE_CPP_IDF)
# include "host/ble_hs_adv.h"
# include "host/ble_gap.h"
# else
# ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/host/include/host/ble_hs_adv.h"
# include "nimble/nimble/host/include/host/ble_gap.h"
# else
# include "host/ble_hs_adv.h"
# include "host/ble_gap.h"
# endif

# include <vector>
Expand Down Expand Up @@ -158,13 +158,13 @@ class NimBLEAdvertisedDevice {
uint8_t findAdvField(uint8_t type, uint8_t index = 0, size_t* data_loc = nullptr) const;
size_t findServiceData(uint8_t index, uint8_t* bytes) const;

NimBLEAddress m_address{};
uint8_t m_advType{};
int8_t m_rssi{};
uint8_t m_callbackSent{};
uint16_t m_advLength{};
ble_npl_time_t m_time{};
NimBLEAdvertisedDevice* m_pNextWaiting{}; // intrusive list node; self-pointer means "not in list", set in ctor
NimBLEAddress m_address{};
uint8_t m_advType{};
int8_t m_rssi{};
uint8_t m_callbackSent{};
uint16_t m_advLength{};
ble_npl_time_t m_time{};
NimBLEAdvertisedDevice* m_pNextWaiting{}; // intrusive list node; self-pointer means "not in list", set in ctor

# if MYNEWT_VAL(BLE_EXT_ADV)
bool m_isLegacyAdv{};
Expand Down
6 changes: 3 additions & 3 deletions src/NimBLEAdvertisementData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
# include "NimBLEUUID.h"
# include "NimBLELog.h"

# if defined(CONFIG_NIMBLE_CPP_IDF)
# include "host/ble_hs_adv.h"
# else
#ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/host/include/host/ble_hs_adv.h"
# else
# include "host/ble_hs_adv.h"
# endif

static const char* LOG_TAG = "NimBLEAdvertisementData";
Expand Down
7 changes: 4 additions & 3 deletions src/NimBLEAdvertising.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
#include "NimBLEAdvertising.h"
#if (CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && !MYNEWT_VAL(BLE_EXT_ADV)) || defined(_DOXYGEN_)

# if defined(CONFIG_NIMBLE_CPP_IDF)
# include "services/gap/ble_svc_gap.h"
# else
#ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/host/services/gap/include/services/gap/ble_svc_gap.h"
# else
# include "services/gap/ble_svc_gap.h"
# endif

# include "NimBLEDevice.h"
# include "NimBLEServer.h"
# include "NimBLEUtils.h"
Expand Down
6 changes: 3 additions & 3 deletions src/NimBLEAdvertising.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include "syscfg/syscfg.h"
#if (CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && !MYNEWT_VAL(BLE_EXT_ADV)) || defined(_DOXYGEN_)

# if defined(CONFIG_NIMBLE_CPP_IDF)
# include "host/ble_gap.h"
# else
#ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/host/include/host/ble_gap.h"
# else
# include "host/ble_gap.h"
# endif

/**** FIX COMPILATION ****/
Expand Down
6 changes: 3 additions & 3 deletions src/NimBLEAttValue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
#include "NimBLEAttValue.h"
#if CONFIG_BT_NIMBLE_ENABLED

# if defined(CONFIG_NIMBLE_CPP_IDF)
# include "nimble/nimble_npl.h"
# else
# ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/include/nimble/nimble_npl.h"
# else
# include "nimble/nimble_npl.h"
# endif

# include "NimBLEUtils.h"
Expand Down
2 changes: 1 addition & 1 deletion src/NimBLECharacteristic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "NimBLECharacteristic.h"
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)

# if defined(CONFIG_NIMBLE_CPP_IDF)
# ifndef USING_NIMBLE_ARDUINO_HEADERS
# if !defined(ESP_IDF_VERSION_MAJOR) || ESP_IDF_VERSION_MAJOR < 5
# define ble_gatts_notify_custom ble_gattc_notify_custom
# define ble_gatts_indicate_custom ble_gattc_indicate_custom
Expand Down
8 changes: 4 additions & 4 deletions src/NimBLEClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
# include "NimBLEDevice.h"
# include "NimBLELog.h"

# if defined(CONFIG_NIMBLE_CPP_IDF)
# include "nimble/nimble_port.h"
# else
# ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/porting/nimble/include/nimble/nimble_port.h"
# else
# include "nimble/nimble_port.h"
# endif

# include <climits>
Expand Down Expand Up @@ -550,7 +550,7 @@ bool NimBLEClient::updateConnParams(uint16_t minInterval, uint16_t maxInterval,
* @param [in] txOctets The preferred number of payload octets to use (Range 0x001B-0x00FB).
*/
bool NimBLEClient::setDataLen(uint16_t txOctets) {
# if defined(CONFIG_NIMBLE_CPP_IDF) && !defined(ESP_IDF_VERSION) || \
# if !defined(USING_NIMBLE_ARDUINO_HEADERS) && !defined(ESP_IDF_VERSION) || \
(ESP_IDF_VERSION_MAJOR * 100 + ESP_IDF_VERSION_MINOR * 10 + ESP_IDF_VERSION_PATCH) < 432
return false;
# else
Expand Down
8 changes: 4 additions & 4 deletions src/NimBLEClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include "syscfg/syscfg.h"
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL)

# if defined(CONFIG_NIMBLE_CPP_IDF)
# include "host/ble_gap.h"
# else
# ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/host/include/host/ble_gap.h"
# else
# include "host/ble_gap.h"
# endif

# include "NimBLEAddress.h"
Expand Down Expand Up @@ -118,7 +118,7 @@ class NimBLEClient {
* - deleteOnConnectFail: false
* - asyncConnect: false
* - exchangeMTU: true
* - connectFailRetries: 2
* - connectFailRetries: 2
*/
Config()
: deleteCallbacks(0),
Expand Down
6 changes: 3 additions & 3 deletions src/NimBLEConnInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
#ifndef NIMBLE_CPP_CONNINFO_H_
#define NIMBLE_CPP_CONNINFO_H_

#if defined(CONFIG_NIMBLE_CPP_IDF)
# include "host/ble_gap.h"
#else
#ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/host/include/host/ble_gap.h"
#else
# include "host/ble_gap.h"
#endif

#include "NimBLEAddress.h"
Expand Down
10 changes: 5 additions & 5 deletions src/NimBLEDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
# include "esp_bt.h"
# endif
# include "nvs_flash.h"
# if defined(CONFIG_NIMBLE_CPP_IDF)
# ifndef USING_NIMBLE_ARDUINO_HEADERS
# if (ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) || CONFIG_BT_NIMBLE_LEGACY_VHCI_ENABLE)
# include "esp_nimble_hci.h"
# endif
Expand All @@ -35,14 +35,14 @@
# include "host/util/util.h"
# include "services/gap/ble_svc_gap.h"
# include "services/gatt/ble_svc_gatt.h"
# else
# else // USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/esp_port/esp-hci/include/esp_nimble_hci.h"
# endif
# else
# include "nimble/nimble/controller/include/controller/ble_phy.h"
# endif

# ifndef CONFIG_NIMBLE_CPP_IDF
# ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/porting/nimble/include/nimble/nimble_port.h"
# include "nimble/porting/npl/freertos/include/nimble/nimble_port_freertos.h"
# include "nimble/nimble/host/include/host/ble_hs.h"
Expand Down Expand Up @@ -911,7 +911,7 @@ bool NimBLEDevice::init(const std::string& deviceName) {
esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT);
# endif

# if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) || !defined(CONFIG_NIMBLE_CPP_IDF)
# if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) || defined(USING_NIMBLE_ARDUINO_HEADERS)
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
# if defined(CONFIG_IDF_TARGET_ESP32)
bt_cfg.mode = ESP_BT_MODE_BLE;
Expand Down Expand Up @@ -1025,7 +1025,7 @@ bool NimBLEDevice::deinit(bool clearAll) {
rc = nimble_port_stop();
if (rc == 0) {
nimble_port_deinit();
# ifdef CONFIG_NIMBLE_CPP_IDF
# ifndef USING_NIMBLE_ARDUINO_HEADERS
# if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0)
rc = esp_nimble_hci_and_controller_deinit();
if (rc != ESP_OK) {
Expand Down
6 changes: 3 additions & 3 deletions src/NimBLEDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
(CONFIG_BTDM_BLE_SCAN_DUPL || CONFIG_BT_LE_SCAN_DUPL || CONFIG_BT_CTRL_BLE_SCAN_DUPL)
# endif

# if defined(CONFIG_NIMBLE_CPP_IDF)
# include <host/ble_gap.h>
# ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/host/include/host/ble_gap.h"
# else
# include <nimble/nimble/host/include/host/ble_gap.h>
# include "host/ble_gap.h"
Comment on lines +32 to +35
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 | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "== Macro usage / definitions =="
rg -n --no-heading '\bUSING_NIMBLE_ARDUINO_HEADERS\b'

echo
echo "== Old vs new build-flag references =="
rg -n --no-heading 'CONFIG_NIMBLE_CPP_IDF|USING_NIMBLE_ARDUINO_HEADERS'

echo
echo "== Include gates for ble_gap.h after migration =="
rg -n --no-heading -C2 'ble_gap\.h|USING_NIMBLE_ARDUINO_HEADERS'

Repository: h2zero/esp-nimble-cpp

Length of output: 16255


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Search for macro definition in build config files ==="
echo
echo "Checking library.json for build flags:"
if [ -f library.json ]; then
    cat -n library.json | head -30
fi
echo
echo "Checking for CMakeLists.txt files:"
find . -name "CMakeLists.txt" -type f | head -5
echo
echo "Checking platformio.ini:"
if [ -f platformio.ini ]; then
    cat -n platformio.ini
fi
echo
echo "=== Searching for -DUSING_NIMBLE_ARDUINO_HEADERS ==="
rg -n 'USING_NIMBLE_ARDUINO_HEADERS' --type-list | grep -i config
rg -r '-DUSING_NIMBLE_ARDUINO_HEADERS' .
echo
echo "=== Check for Arduino framework integration ==="
fd -e 'h' -e 'hpp' -e 'cmake' | xargs rg -l 'Arduino\|ARDUINO' 2>/dev/null | head -5

Repository: h2zero/esp-nimble-cpp

Length of output: 1543


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Full library.json content ==="
wc -l library.json
cat library.json
echo
echo "=== CMakeLists.txt for macro definitions ==="
cat CMakeLists.txt
echo
echo "=== Search for USING_NIMBLE_ARDUINO_HEADERS definition ==="
rg -n 'define.*USING_NIMBLE_ARDUINO_HEADERS|add_compile_definitions.*USING_NIMBLE_ARDUINO_HEADERS|-DUSING_NIMBLE_ARDUINO_HEADERS'

Repository: h2zero/esp-nimble-cpp

Length of output: 3083


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Search for `#define` USING_NIMBLE_ARDUINO_HEADERS in any file ==="
rg -n '#define.*USING_NIMBLE_ARDUINO_HEADERS' --type-all

echo
echo "=== Check if it's conditionally defined in any header ==="
rg -n -A3 'ifdef.*ARDUINO|if defined.*ARDUINO' src/ | head -50

echo
echo "=== Search library.json in git history or PR changes ==="
git log --oneline -n 20 -- library.json 2>/dev/null || echo "No git history available"

echo
echo "=== Check if Arduino framework itself would define this macro ==="
echo "Searching for any references to Arduino framework macros or build system variables:"
rg -n 'ARDUINO|__PLATFORMIO__|ESP_PLATFORM' src/ | head -20

Repository: h2zero/esp-nimble-cpp

Length of output: 588


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Search for `#define` USING_NIMBLE_ARDUINO_HEADERS ==="
rg -n '#define USING_NIMBLE_ARDUINO_HEADERS'

echo
echo "=== Check if macro is conditionally set based on build environment ==="
rg -n -B5 -A5 'USING_NIMBLE_ARDUINO_HEADERS' src/ | grep -E '(`#define`|#if|Arduino|PLATFORMIO)' | head -40

echo
echo "=== Look for build configuration that sets this macro ==="
find . -name '*.cmake' -o -name '*.py' -o -name 'setup.py' | xargs rg -l 'USING_NIMBLE_ARDUINO_HEADERS' 2>/dev/null || echo "No cmake/python build files set this macro"

echo
echo "=== Check if this should come from Arduino ESP32 framework ==="
rg -n 'framework-arduinoespressif32|arduino-esp32' CMakeLists.txt

echo
echo "=== Search for build system or preprocessor integration ==="
fd -e 'idf_component.yml' -o -e 'build.gradle' -o -e 'platformio.ini'

Repository: h2zero/esp-nimble-cpp

Length of output: 120


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Check PR changes for library.json or build flag additions ==="
git diff HEAD~1 library.json 2>/dev/null || echo "No git diff available, checking if library.json was modified"

echo
echo "=== Look for any build flag or compile definition changes in this PR ==="
git show --stat 2>/dev/null | head -30

echo
echo "=== Verify if USING_NIMBLE_ARDUINO_HEADERS might come from Arduino core ==="
echo "Checking for Arduino framework detection patterns:"
rg -n 'ARDUINO\b' src/ | head -20

echo
echo "=== Check if macro should be set as a compiler flag in build system ==="
echo "Looking for similar macro patterns (CONFIG_*, USING_*, etc):"
rg -n '#ifdef.*CONFIG_|#ifdef.*USING_' src/ | head -20

echo
echo "=== Summary: Is USING_NIMBLE_ARDUINO_HEADERS actually defined? ==="
if rg -q 'USING_NIMBLE_ARDUINO_HEADERS' . && ! rg -q '#define USING_NIMBLE_ARDUINO_HEADERS'; then
    echo "MACRO USED: Yes (44+ locations)"
    echo "MACRO DEFINED: No"
    echo "RESULT: Macro is referenced but never defined in the repository"
fi

Repository: h2zero/esp-nimble-cpp

Length of output: 1956


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Read Kconfig file for USING_NIMBLE_ARDUINO_HEADERS ==="
cat Kconfig | head -100

echo
echo "=== Search for where macro is actually DEFINED/SET in CMakeLists ==="
rg -n -A5 -B5 'add_compile_definitions|idf_component_set_property|target_compile_definitions' CMakeLists.txt

echo
echo "=== Check idf_component.yml if it exists ==="
if [ -f idf_component.yml ]; then
    cat idf_component.yml
fi

echo
echo "=== Final check: Where is this macro defined in the build system? ==="
rg -n 'USING_NIMBLE_ARDUINO_HEADERS' CMakeLists.txt Kconfig 2>/dev/null || echo "Not found in CMakeLists or Kconfig"

Repository: h2zero/esp-nimble-cpp

Length of output: 3650


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Search entire Kconfig for USING_NIMBLE_ARDUINO_HEADERS ==="
rg -n 'USING_NIMBLE_ARDUINO_HEADERS' Kconfig

echo
echo "=== Get full CMakeLists.txt and check for compile definitions ==="
wc -l CMakeLists.txt
echo "---"
cat CMakeLists.txt

echo
echo "=== Check if Arduino framework sets this macro externally ==="
echo "Searching for any mechanism that might auto-define this:"
rg -n 'idf_component_register' CMakeLists.txt -A50 | grep -i 'compile\|flag\|define'

echo
echo "=== Final diagnosis: Is USING_NIMBLE_ARDUINO_HEADERS supposed to be set? ==="
git log --all --oneline --grep="arduino" 2>/dev/null | head -10 || echo "No git history"

Repository: h2zero/esp-nimble-cpp

Length of output: 127


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Display complete CMakeLists.txt again with line count ==="
cat -n CMakeLists.txt | tail -50

echo
echo "=== Check if USING_NIMBLE_ARDUINO_HEADERS is set via CMake variable ==="
rg -n 'set\(.*ARDUINO\|add_compile_options.*ARDUINO' CMakeLists.txt

echo
echo "=== Comprehensive search: Where should this macro be set? ==="
echo "Checking for any preprocessor flag definition pattern:"
rg -rn '\-DUSING_NIMBLE_ARDUINO_HEADERS|\-DARDUINO' . --include='*.txt' --include='*.cmake' --include='*.json' --include='*.yml'

echo
echo "=== Conclusion: Is the macro actually defined anywhere? ==="
if ! rg -q 'USING_NIMBLE_ARDUINO_HEADERS.*=' .; then
    echo "NO DEFINITION FOUND for USING_NIMBLE_ARDUINO_HEADERS"
    echo "This macro is used in 44+ places but is never set in:"
    echo "  - CMakeLists.txt"
    echo "  - Kconfig"
    echo "  - library.json"
    echo "  - Any source files"
fi

Repository: h2zero/esp-nimble-cpp

Length of output: 1666


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Show FIRST 31 lines of CMakeLists.txt (Arduino detection) ==="
head -31 CMakeLists.txt

echo
echo "=== Look for any conditional compile definitions based on Arduino detection ==="
rg -n -A10 '__COMPONENT_TARGETS.*arduino' CMakeLists.txt

echo
echo "=== Search for idf_component_set_property or target_compile_definitions ==="
rg -n 'idf_component_set_property\|target_compile_definitions\|idf_build_set_property' . --include='*.txt' --include='*.cmake'

echo
echo "=== Check if this PR is incomplete - search commit files ==="
git show --name-only 2>/dev/null | grep -i 'cmake\|kconfig\|library' || echo "Checking file modifications..."

echo
echo "=== CRITICAL CHECK: Does any part of the code SET this macro? ==="
echo "Exact search for where macro gets defined:"
git show HEAD 2>/dev/null | grep -i 'USING_NIMBLE_ARDUINO_HEADERS' | head -20 || rg -n 'USING_NIMBLE_ARDUINO_HEADERS.*=' . --include='*.cpp' --include='*.h'

Repository: h2zero/esp-nimble-cpp

Length of output: 2313


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Does CMAKE actually SET the macro anywhere? ==="
rg -n 'idf_component_set_property\|target_compile_definitions'

echo
echo "=== Verify CMakeLists.txt is COMPLETE (check file size) ==="
wc -l CMakeLists.txt
tail -5 CMakeLists.txt

echo
echo "=== FINAL DIAGNOSIS: Search for USING_NIMBLE_ARDUINO_HEADERS definition ==="
echo "In CMakeLists: "
rg 'USING_NIMBLE_ARDUINO_HEADERS' CMakeLists.txt || echo "  NOT FOUND"

echo "In Kconfig: "
rg 'USING_NIMBLE_ARDUINO_HEADERS' Kconfig || echo "  NOT FOUND"

echo "In library.json: "
rg 'USING_NIMBLE_ARDUINO_HEADERS' library.json || echo "  NOT FOUND"

echo "In ANY source file: "
rg 'USING_NIMBLE_ARDUINO_HEADERS' src/ | wc -l
echo "  (matches found above)"

echo
echo "=== CONCLUSION ==="
echo "Macro USED: 44+ times in code"
echo "Macro DEFINED: 0 times in build system"
echo "RESULT: Macro is referenced but NEVER SET"

Repository: h2zero/esp-nimble-cpp

Length of output: 116


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "=== Final verification: library.json for build.flags ==="
cat library.json
echo
echo "=== Does library.json have build.flags section? ==="
rg 'build.flags' library.json || echo "NO build.flags section found"

echo
echo "=== COMPREHENSIVE FINAL RESULT ==="
echo "1. Macro Usage: 44+ locations use USING_NIMBLE_ARDUINO_HEADERS"
echo "2. Macro Definition: ZERO locations define it"
echo
echo "Files that USE the macro:"
rg -l 'USING_NIMBLE_ARDUINO_HEADERS' src/ | wc -l
echo
echo "Files that DEFINE the macro:"
rg -l '#define USING_NIMBLE_ARDUINO_HEADERS' . || echo "NONE"
echo
echo "Build system files that SET it:"
rg 'USING_NIMBLE_ARDUINO_HEADERS' CMakeLists.txt Kconfig library.json 2>/dev/null || echo "NONE FOUND"

Repository: h2zero/esp-nimble-cpp

Length of output: 943


Arrr, the USING_NIMBLE_ARDUINO_HEADERS macro be used in 44+ places but ne'er actually defined in the build system, ye scallywag!

The macro be referenced across 27 source/header files in conditional include gates (lines like 32-35 in src/NimBLEDevice.h), but there be no mechanism to set it:

  • library.json lacks a build.flags section to define -DUSING_NIMBLE_ARDUINO_HEADERS
  • CMakeLists.txt detects Arduino frameworks but don't add any compile definitions
  • Kconfig contains no flag fer this macro

Without this macro being defined, all #ifdef USING_NIMBLE_ARDUINO_HEADERS blocks will always evaluate false, causin' the code to always use the fallback host/ble_gap.h paths instead o' the Arduino header layouts. The commit message says "Add a flag to use arduino header paths" but the flag was ne'er added to the build configuration. Set this macro explicitly in the build system so Arduino-oriented PlatformIO builds actually use the correct header paths.

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

In `@src/NimBLEDevice.h` around lines 32 - 35, The build never defines the macro
USING_NIMBLE_ARDUINO_HEADERS so all `#ifdef` USING_NIMBLE_ARDUINO_HEADERS include
branches (e.g., in src/NimBLEDevice.h) never trigger; add a compile definition
for this macro in the build system: update library.json to add a build.flags
entry (e.g., "-DUSING_NIMBLE_ARDUINO_HEADERS") for PlatformIO/Arduino builds,
update CMakeLists.txt to add target_compile_definitions or
add_compile_definitions when the Arduino framework is detected, and optionally
expose a Kconfig boolean (e.g., CONFIG_USING_NIMBLE_ARDUINO_HEADERS) that when
enabled adds the -D define so developers can toggle the Arduino header path
behavior.

# endif

/**** FIX COMPILATION ****/
Expand Down
6 changes: 3 additions & 3 deletions src/NimBLEExtAdvertising.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
#include "NimBLEExtAdvertising.h"
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && MYNEWT_VAL(BLE_EXT_ADV)

# if defined(CONFIG_NIMBLE_CPP_IDF)
# include "services/gap/ble_svc_gap.h"
# else
#ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/host/services/gap/include/services/gap/ble_svc_gap.h"
#else
# include "services/gap/ble_svc_gap.h"
# endif

# include "NimBLEDevice.h"
Expand Down
6 changes: 3 additions & 3 deletions src/NimBLEExtAdvertising.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include "syscfg/syscfg.h"
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_BROADCASTER) && MYNEWT_VAL(BLE_EXT_ADV)

# if defined(CONFIG_NIMBLE_CPP_IDF)
# include "host/ble_gap.h"
# else
# ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/host/include/host/ble_gap.h"
# else
# include "host/ble_gap.h"
# endif

/**** FIX COMPILATION ****/
Expand Down
6 changes: 3 additions & 3 deletions src/NimBLEL2CAPChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
# include "NimBLELog.h"
# include "NimBLEUtils.h"

# if defined(CONFIG_NIMBLE_CPP_IDF)
# include "host/ble_gap.h"
# else
# ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/host/include/host/ble_gap.h"
# else
# include "host/ble_gap.h"
# endif

// L2CAP buffer block size
Expand Down
8 changes: 4 additions & 4 deletions src/NimBLEL2CAPChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_L2CAP_COC_MAX_NUM)

# include "inttypes.h"
# if defined(CONFIG_NIMBLE_CPP_IDF)
# include "host/ble_l2cap.h"
# include "os/os_mbuf.h"
# else
# ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/host/include/host/ble_l2cap.h"
# include "nimble/porting/nimble/include/os/os_mbuf.h"
# else
# include "host/ble_l2cap.h"
# include "os/os_mbuf.h"
# endif

/**** FIX COMPILATION ****/
Expand Down
6 changes: 3 additions & 3 deletions src/NimBLELocalValueAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include "syscfg/syscfg.h"
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_PERIPHERAL)

# if defined(CONFIG_NIMBLE_CPP_IDF)
# include "host/ble_hs.h"
# else
#ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/host/include/host/ble_hs.h"
# else
# include "host/ble_hs.h"
# endif

/**** FIX COMPILATION ****/
Expand Down
4 changes: 2 additions & 2 deletions src/NimBLELog.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
# endif
# endif

# if defined(CONFIG_NIMBLE_CPP_IDF)
# ifndef USING_NIMBLE_ARDUINO_HEADERS
# include "esp_log.h"
# include "console/console.h"

Expand Down Expand Up @@ -172,7 +172,7 @@
# define NIMBLE_LOGE(tag, format, ...) (void)tag
# endif

# endif /* CONFIG_NIMBLE_CPP_IDF */
# endif /* !USING_NIMBLE_ARDUINO_HEADERS */

# define NIMBLE_LOGD_IF(cond, tag, format, ...) { if (cond) { NIMBLE_LOGD(tag, format, ##__VA_ARGS__); }}
# define NIMBLE_LOGI_IF(cond, tag, format, ...) { if (cond) { NIMBLE_LOGI(tag, format, ##__VA_ARGS__); }}
Expand Down
6 changes: 3 additions & 3 deletions src/NimBLERemoteValueAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
#include "syscfg/syscfg.h"
#if CONFIG_BT_NIMBLE_ENABLED && MYNEWT_VAL(BLE_ROLE_CENTRAL)

# if defined(CONFIG_NIMBLE_CPP_IDF)
# include <host/ble_gatt.h>
#ifdef USING_NIMBLE_ARDUINO_HEADERS
# include "nimble/nimble/host/include/host/ble_gatt.h"
# else
# include <nimble/nimble/host/include/host/ble_gatt.h>
# include "host/ble_gatt.h"
# endif

/**** FIX COMPILATION ****/
Expand Down
Loading