-
I have a bunch of devices around the house to measure environment data. They are all the same, except that they have slightly different sensors attached and/or should log their data to different mqtt topics. I have this working with some old and brittle C code that I want to get rid of. Basically, when I flash the device, I add a per-device custom element that contains the device provisioning. My hope was to do a similar thing with toit/jaguar. All devices get the same software and then I would put a provision file on the device giving it its identity, what sensors, what mqtt topics and so on. How would I do that? I can have the devices come up, report their name to a service and pull that provision file down, but this is cumbersome and requires infrastructure. Is there a way for me to give a provision file when I flash the device (not ideal but ok) or when I install the software with jaguar? I looked into assets but I wanted to avoid recompiling the firmware. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Note that assets don't require you to recompile the firmware. Adding an asset consists of adding new data to the firmware envelope without changing the elf file that is in the envelope. @kasperl, do we expose the asset functionality nicely in Jaguar? That said, there is probably an easier way. You could just store the configuration in flash (see https://libs.toit.io/device/class-FlashStore). I could imagine the following work-flow:
Alternatively; more sophisticated:
|
Beta Was this translation helpful? Give feedback.
-
Assets should work well for this case. You can create the firmware.envelope file and flash it onto a device. Once you install a container on the device using You create the assets file using
From within |
Beta Was this translation helpful? Give feedback.
-
Turned out to be pretty straightforward. No idea how I did not notice the
rinse, repeat for device 2, 3, 4 etc. I generate the json files from a script locally. Super-easy. Thank you! I think toit already saved me more time fuzzing around with SDKs, cross compilers and all that pain than I put into the first version of these little critters. |
Beta Was this translation helpful? Give feedback.
Assets should work well for this case. You can create the firmware.envelope file and flash it onto a device. Once you install a container on the device using
jag container install
or run code there usingjag run
you can add the device specific assets.You create the assets file using
sdk/tools/assets
like described here: https://github.com/toitlang/toit#adding-container-assets. You can then add the assets when you run like this:From within
program.toit
you should now be able to see the assets by importingsystem.assets
and callingassets.decode
.