Trouble with include paths - esp-idf


I have some trouble with integrating BLE from the esp-idf components in my esp-idf project with platformio. So what I tried is to include "#include “esp_bt.h”, which throws me a “src\main.c:26:11: fatal error: esp_bt.h: No such file or directory”

Ok, so I had a look in the c_cpp_properties.json and did not found the path to the “C:\Users\Hans.platformio\packages\framework-espidf\components\bt\include” header file.

As stated in the comment in top of this file, platformio.ini should be used for this include search path definition and I tried to use: build_flags = -Idir C:\Users\Hans.platformio\packages\framework-espidf\components\bt\include, but this was not successful.

Now I’m unsure if I’m really on the correct way? I have seen BLE projects, where there is no configuration in the platformio.ini about include path, but still it appears in the c_cpp_properties.json.

So how should be added the include and src path correctly to a platformio project?

Edit Ok got it, it is build_flags = -I/Users/Hans/.platformio/packages/framework-espidf/components/bt/include

Can you tell me, how I can automatically search for header files in the path /Users/Hans/.platformio/packages/framework-espidf/components/bt/?

If you want to enable bluetooth in an ESP-IDF application, you need to configure it as shown in docs with menuconfig. As the top comment in the c_cpp_properties.json shows, you should never-ever modify that file yourself since it’s generated by PlatformIO based on what include paths will be there during the compilation process – if you modify that file, it will have 0 effect on the compiled binary.

See menuconfig above, see sdkconfig.defaults in example project where bluetooth is enabled.