Page 1 of 1

Components cannot include system component

Posted: Wed Jan 08, 2025 6:16 pm
by Duc Hoang
I have a project that want to divide into some subcomponent like
/projects
├───components
│ ├───ble_server
│ │ └───include
│ │ │ └───ble_server.h
└───main
│ ├───app_main.c

I've tried to import the bluetooth library
"#include "esp_bt.h" "

It works normally in app_main.c but when I include them on the ble_server.h file, I got error
fatal error: esp_bt.h: No such file or directory
10 | #include "esp_bt.h"
| ^~~~~~~~~~

So how to include idf component in subfolder like /components

Re: Components cannot include system component

Posted: Thu Jan 09, 2025 12:09 am
by av_jui
hallo

if you are at idf-version > 5.0 you have to edit your CMakeLists.txt in your "component" root folder and add the 'REQUIRES' argument.

Code: Select all

idf_component_register(
    REQUIRES "bt"
    SRCS "ble_server.c"
    INCLUDE_DIRS "."
)
it also seems you have an older version because after 5.2 you have to include 'esp_bt_main.h' or 'esp_bt_device.h'.

Code: Select all

#include "esp_bt_main.h"
/* if you use device functions uncomment next line */
// #include "esp_bt_device.h"	
hope this helps