I need to flash code revisions to 7 devices, only differing in the config of IP, hostname and MQTT channel.
I want to keep the configuration as atomic as possible to avoid inconsistencies.
Is it somehow possible to access the upload IP as a precompiler definition?
On the other hand, I considered setting the configuration choose define in a header file and determine the upload IP via the /etc/hosts, because that would avoid recompiling the whole project due to change of platformio.ini.
Well, that is kind of what I wanted to do, however I am flashing OTA, so I need to flash to different IPs. It would have been great if I could have decided on the config on the basis of that IP, so I cannot accidentally flash the wrong config to the wrong IP.
Actually, I have taken anoter way now: I put a hostname into my /etc/hosts now, which I change for every flash.
I select the config with a prec define in the code. This has the danger for wrong flashes in theory (but I have to put my devices into flash mode individually anyway), but since the platformio.ini remains untouched, only very few cpps are recompiled.
Hm… I take it the devices have been allocated static IPs or by MAC?
In that case, you could specify the IP for each env with something like upload_port = 192.168.0.1, naturally with the right IP for that env, in addition to the build_flags…