I’m trying to inject some credentials via the platformio.ini
into my build.
Unfortunately, I’m having issues with the escaping of my WiFi password:
The password looks like #blaBla\lol%Hi
(not my real password, obs).
Interestingly, the #
is interpreted as a comment start, so I have to escape it with a \
backslash. This seems to kind of change the way the rest is being read, because then I also need to escape the %
by adding another %
in front of it. But there seems to be no way to escape the \
. No matter how many \
I add before it, they are all being ignored.
platformio.ini
:
[string_defines]
wifi_ssid = myssid
wifi_pass = \#blaBla\\\lol%%Hi
[env:esp32cam]
platform = espressif32
board = esp32cam
framework = arduino
monitor_speed = 115200
build_flags =
-D WIFI_SSID=\"${string_defines.wifi_ssid}\"
-D WIFI_PASS=\"${string_defines.wifi_pass}\"
[platformio]
description = take pictures and upload them to the web
main.cpp
:
#ifdef WIFI_SSID
#pragma message WIFI_SSID
#endif
#ifdef WIFI_PASS
#pragma message WIFI_PASS
#endif
compiler output:
src\main.cpp:5:30: note: #pragma message: "myssid"
#pragma message WIFI_SSID
^
^
src\main.cpp:9:30: note: #pragma message: "#blaBlalol%Hi"
#pragma message WIFI_PASS
^