PlatformIO Community

ESP32 IDF C++ adding private Libs


#1

I am very new to this (platformio) and esp32 too…
I want to use platfromio, but don’t understand the simplest of things
I added a bunch of .h and .c files in LIBS
as cpp_utls<files> (lots of .c and .h) files

then include them as
#include <BLEDevice.h>

and platform IO no can find…

Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 0 compatible libraries
Scanning dependencies…
No dependencies
Compiling .pioenvs\esp32dev\src\main.o
src\main.cpp:9:23: fatal error: BLEDevice.h: No such file or directory




#2

Seems like you want to use the https://platformio.org/lib/show/1841/ESP32%20BLE%20Arduino/examples library. Go to your platformio.ini and add the line

lib_deps = 1841

I don’t know what you do with that other library code of yours but that doesn’t seem to cause an error yet…


#3

no I not using ARDUINO platform
just using his general C++ libs
I thought PIO would take care of the .c/,h files automatically as it
should search the /lib path no?


#4

Can you show me where the BLEDevice.h is in the ESP-IDF platform? This seems to come from an Arduino library.

I don’t know what the problem is yet with your custom files in the lib folder. Is that BLEDevice.h file there?


#5

its in \lib\cpp_utls\BLEDevice.h


#6

Hmm can you upload your project as a ZIP file on google drive / dropbox? I could take a quick a look as to why it’s not working.


#7

absolutely

there is nothing to the code (YET)


#8

You had a problem with the LDF compatibility mode (docs). Change the platformio.ini to

[env:esp32dev]
platform = espressif32
board = esp32dev
framework = espidf
lib_compat_mode = off
build_flags = -D PIO_FRAMEWORK_ESP_IDF_ENABLE_EXCEPTIONS

I also fixed “build-flags” to “build_flags”.

There is a library.properties in your cpp_utils folder by which PIO decides that this is an Arduino library and cannot be used on espidf. It even shows the library name as

Dependency Graph
|-- <ESP32 BLE Arduino> v0.1.0 (C:\Users\Maxi\Desktop\testCpp\lib\cpp_utils)

I really don’t know how this is supposed to work though, it seems like there are like 15 different libraries thrown into this folder, even with some Arduino referenes? (as the file Arduino_ESP32_BLE.library.properties)

The compilation stops because cJSON.h is nowhere to be found in the folder but JSON.cpp needs it. Once you add it from https://github.com/DaveGamble/cJSON (only cJSON.c and cJSON.h) it complains that the ESP32CPP class inside a MFRC522 driver cannot be found, whereever that class is. I would start to only pick out the needed files and start building the project from that, instead of throwing every possible CPP/H file into one big folder and try to compile it all.


#9

yes… he uses these classes to make the Arduino support
but can be used without
ok. I did this
lib/ble/ only the BLE*.h and BLE*.c

and THANKS on catching the build_flags :slight_smile:

made some progress

In file included from lib/BLE/BLECharacteristic.h:17:0,
from lib/BLE/BLEServer.h:19,
from lib/BLE/BLEDevice.h:18,
from src\main.cpp:9:
lib/BLE/BLEDescriptor.h:16:22: fatal error: FreeRTOS.h: No such file or directory
that include is part of ESP32-IDF

infact my main has “#include “freertos/FreeRTOS.h””

this is whats in the BLEDescriptor.h

#include “FreeRTOS.h”

I really hate how includes work. or don’t work… just search the paths… and it would be found

do I really need to put the folder??!?!?


#10

You can add

-I $PIOHOME_DIR/packages/framework-espidf/components/freertos/include/freertos

to your build_flags for that if you want.


#11

I gots it… that header wasn’t reference to the IDF, it was Niel’s little cpp helper util
(it was in the cpp_utils folder)
added it to

lib\FreeRTOS<files.

Successful build!

THANK YOU…

there are a couple of warnings… looks like from the IDF itself

C:\Users\mitchjs.platformio\packages\framework-espidf\components\log\log.c: In function ‘esp_log_buffer_hex_internal’:
C:\Users\mitchjs.platformio\packages\framework-espidf\components\log\log.c:378:16: warning: pointer of type ‘void *’ used in arithmetic [-Wpointer-arith]
buffer += bytes_cur_line;

anything to worry about?


#12

Great that it works now.

If you see a bug in the ESP-IDF framework better report it to the source (https://github.com/espressif/esp-idf/blob/master/components/log/log.c#L351) at their github.