oseiler2 / CO2Monitor

https://oseiler2.github.io/CO2Monitor/
GNU General Public License v3.0
45 stars 5 forks source link

Support board models and versions #6

Closed mattbnz closed 2 years ago

mattbnz commented 2 years ago

To support easily flashing different board configs (aka models) without having to edit the source to change defines every time, set up platformio environments for the different board configs (leds and neopixel) so you can simply use -e MODEL to do the right thing with no editing required.

To support understanding what has been flashed, include a version number, build timestamp and git revision hash in the built image, and display that in both serial debug and MQTT messages. This works via a platformio extra_scripts pre hook and associated python script. This hook also sets the generated firmware filenames to include the model and version for convenience/clarity.

The versioning strategy is semver (for compatibility with esp32FOTA logic) with the release version set in platformio.ini and used when the :release environments are built. The default environments for each model, increment the patch level of the release version and add a -BUILD_TIMESTAMP pre-release suffix to the version they are built with, such that they can be forceOTA'd to a device and a regular ota check will not cause them to be downgraded, but a later release will cause them to be upgraded.

(sorry, again - this pull request is a bit messy because it's from a branch off the OTA upgrade branch in my repo, but I don't know git/giithub well enough to figure out how to get that reflected here, so you see all the changes, not just the ones on top of the OTA/LittleFS branches...)

oseiler2 commented 2 years ago

My intention with the different configuration options (mainly LEDs, Neopixel, but also some more exotic variants) is to move that into the configuration in order to support OTA updates using the same binary across different hardware varieties (at least to some degree). I'll look into the additional changes you've made for versioning separately. Thanks for your contribtion!

mattbnz commented 2 years ago

That sounds reasonable assuming their is space in the app image for all the different libraries to be compiled into a single image - I had assumed the reason it was #define'd out was that you'd been having size constraints (hence the custom partition sizes, etc) and therefore the build options would be needed long-term, but we could certainly drop the "model" specific bits easily enough and just have a single version if everything can fit.

oseiler2 commented 2 years ago

Yes, the libs fit with the slightly larger partitions. See https://github.com/oseiler2/CO2Monitor/pull/9 for current work in progress

mattbnz commented 2 years ago

I've updated this to merge in your changes supporting everything in software and therefore remove the need for the MODEL label that was previously being set. So now this is purely about improving how the versioning works.

It will go best with the parallel branch/pull request to upgrade the OTA library in the end, but I've also managed to fix-up my git branhces so you get a much cleaner, independent diff here.

oseiler2 commented 2 years ago

I'll push an update adding semantic versioning soon. That should cover the remaining bits of this PR.

oseiler2 commented 2 years ago

See https://github.com/oseiler2/CO2Monitor/commit/5a366d4280696be7f4296625f02935cf5d4430c2 I haven't added the APP_VERSION to the startup MQTT message since it's already contained in getConfig.

mattbnz commented 2 years ago

Looks good, thanks!