Data section in a custom library

Hi there!

I’m creating a library that tries to connect to WiFi with saved credentials, and if it fails, it starts the ESP32 in WiFi AP mode and starts a webserver. I want to be able to serve static files from that webserver using LittleFS, FatFS or SPIFFS (not sure which one is the best). The thing is that these files will be in the data folder of the library, not in the main project.

How can I make sure the main project incorporates the data folder of the library I’m using?

File structure:

main project

src/main.cpp
platformio.ini

platformio.ini

[env]
platform = espressif32
board = wemos_d1_mini32
framework = arduino
lib_extra_dirs = 
	/home/EngineerDaryl/lib/
lib_deps = 
	wifimanager

/home/EngineerDaryl/lib/wifimanager

include/wifimanager.h
src/wifimanager.cpp
data/index.html
library.json

When I click on Upload Filesystem Image in the main project, it tries to create a File System using the data folder in the main project, that doesn’t exist. I want it to upload the data in the library folder, without me having to specify it. I’m planning on using this library for more projects.

Hope I made my issue clear enough.

Daryl

1 Like

This is not a direct answer, but maybe an alternative approach.

Use a string literal in a separate header file.
This is how I solved this in my WebMonitor library (WebMonitor/WebPage.h at main · sivar2311/WebMonitor · GitHub)

1 Like

Thanks for the tip! Maybe I’ll do something like that indeed.