Sorry for the n00b question, I’m not too well trained as a C / C++ / low-level programmer yet…
I’ve been searching for this for hours by googling and by browsing other peoples open sourced projects, but without success…
I have a little IoT-project (ESP8266, BME280, …) I’d like to open source, but what hinders me doing so is the line of code I have that reads something like that:
within my main.cpp file.
How can I extract string constants from main.cpp into a separate config file that gets parsed on building / deploying so that it’s available as string constant to use in my main.cpp code?
Are you sure you don’t want to do the same thing as everyone does with in their WiFi projects? Just
#include <Credentials.h> in your cpp code, then add a
Credentials.h in which you do
#define WIFI_SSID "MyWiFiSSID"
#define WIFI_PW "some_secret_password"
the use the macros in the
WiFi.begin() call and add
Credentials.h to the
.gitignore so that it won’t be pushed. Then tell people in the README that they need this file.
What I have done in the past is to supply a file named, for example,
.gitignore the file
credentials.h. The tpl file is a dummy and the docs state that it has to be copied to
credentials.h and filled in appropriately before compiling.
thank you guys, that helped a lot
Here’s my project