sblantipodi / arduino_bootstrapper

Utility classes for bootstrapping Arduino projects with Wifi management, OTA upload management, memory management, MQTT and queue management. (ESP8266/ESP32 ready)

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to set specific constant overriding those of the Configuration.h file

Pronoe opened this issue · comments

Let's take as an example, the gateway IP.
In the Configuration.h file of the library, one can find:
// GATEWAY IP
#ifndef GATEWAY_IP
#define GATEWAY_IP "192.168.1.1"
#endif
const char* const IP_GATEWAY = GATEWAY_IP;
As I don't want to modify the original library files, I have included my own file MyConfiguration.h which contains:
#define GATEWAY_IP "192.168.0.254"
Thanks to the #ifndef GATEWAY_IP directive, I expected that my own definition would be taken into account.
But this is not the case, probably due to the fact that the library Bootsrapper is compiled before my sketch.
So at the moment, I had to modify the original file inside the library folder.
What do you suggest to solve for this problem ?

Hi @Pronoe
that option can be changed by using build flags.

if you are using platformio you can set it in your platformio.ini file, example here:

'-D GATEWAY_IP="192.168.1.1"'

I don't use Arduino IDE anymore but I'm pretty sure that you can do it without problems in that IDE too.
this could give you an idea on how to do it with Arduino IDE.
https://forum.arduino.cc/t/how-to-set-compiler-constants-required-for-a-library/578762

Hi @sblantipodi
thank you very much for your answer and your help.
I have tried recently to use platformio but it has appeared a bit complex for me who is a newbie. In addition this raised some conflicts with the Arduino IDE add-on under VScode. As I had some on-going projects with Arduino IDE, I have uninstalled platformio. I will try again later on.
I will review the link that you provided for Arduino IDE, may be this the solution for now.

Thank you so much also for your sharing of the Bootstrapper library and Smartostat project.
For my current project, I am using extensively the library and valuable ideas and pieces of code from your Smartostat project.

@Pronoe thank you very much for all your ideas and for the help you gived me in the issues you opened,
the closed ones has been merged in the main branch, it will take a bit for the release, I would like to close all the issues before releasing...
thank you!!!