So what I am trying to accomplish is to use the board type (the board = lolin_d32 entry) in my code as a macro. The use case, for instance, is allowing the running firmware to pull down down the correct firmware for the board as an OTA upgrade.
There are two places I can think of pulling it:
env.GetProjectOption("board")
env["BOARD"]
However, from what I have been able to determine, I cannot create a build flag that is available in the sketch via an extra_scripts. I know I can put a determinate build flag in the platformio.ini but that seems inelegant since it’s a place I can make a silly mistake as I add more board types in the future.
I have seen an answer pointing out that there are platform/board flags defined, however, what I am looking for is the simple board name. Using those flags I would need to add explicit code for each board like this:
#ifdef ARDUINO_LOLIN_D32
String x = "lolin_d32";
#else
String x = "unknown";
#endif
I would greatly prefer to use something simple and that does not require edits/additions as I expand, such as:
String x = BOARD;
This does not seem possible unless I’m missing something simple?
I wanted to share something I did a little differently. Since stringification is a thing when using these macros, I picked up a little macro goodness somewhere (I do not remember where):