I am using conditional compilation directives for compiling multiple versions of ESP32 CAM firmwares and that works well.
Since static IP address depends on the location (each router has different IP address) and URL for accessing each camera depends on camera number I’ve made a header file similar to:
#ifndef my_defines_header
#define my_defines_header
#define LOCATION_A 1
#define LOCATION_B 2
#define CAMERA1 1
#define CAMERA1_URL "/camera1"
#define CAMERA2 2
#define CAMERA2_URL "/camera2"
// choosing location
#define LOCATION LOCATION_A
// choosing camera number
#define FW_VER CAMERA1
#if FW_VER == CAMERA1
#define CAMERA_URL CAMERA1_URL
#elif FW_VER == CAMERA2
#define CAMERA_URL CAMERA2_URL
#endif
#endif
Then I can, after choosing location and camera number, in the code use something like:
#if FW_VER == CAMERA1
#if LOCATION == LOCATION_A
IPAddress ip(192,168,1,180);
#elif LOCATION == LOCATION_B
IPAddress ip(192,168,0,180);
#endif
#elif FW_VER == CAMERA2
#if LOCATION == LOCATION_A
IPAddress ip(192,168,1,181);
#elif LOCATION == LOCATION_B
IPAddress ip(192,168,0,181);
#endif
#endif
Now, the question is - is there a way to in platformio.ini
configure upload_port
for OTA programming depending on the location and camera number selected via #defines
in the .h file?
In other words - is it possible to access #defines
defined in header files from within platformio.ini
?