Access dynamic THINGER_OTA_VERSION at runtime

Hello, we are using thinger-io/thinger.io@2.31.0 in an Arduino framework project on an ESP32-s3-devkit-c1

Following the documentation, we define the THINGER_OTA_VERSION variable dynamically in platform.ini build flag, as noted in docs as the recommended approach: https://docs.thinger.io/ota#dynamic-build-flag

A few questions:

  1. How can we access this value in our application code? THINGER_OTA_VERSION is undefined and using it will cause compilation to fail.
  2. Is this value represented any where on the Thinger dashboard? I cannot find it, but it would really be useful to see at a glance which OTA Version is running on any given Device.
  3. The reason we want to use this value in application code is to pass this value in pson to a bucket so that we can correlate logs/events with a specific firmware version. If there was a different mechanism to know which device a bucket write came from, and thus its firmware version, we wouldn’t need to use it in application code.

Very excited about the updates to the library and we are using OTA extensively right now and have just upgraded to a private cloud, please keep up the good work. These features would really make it excellent and help us enormously with harvesting diagnostic information from units in the field.

1 Like

Hi,
About point 2, I defined it as a property under the product:
2024-09-10_07h34_07

Thanks Aeromek, I created a property under console/products/<myProduct>/profile that matches yours. Is the $ota/version syntax going to map to the OTA_VERSION defined on the device? Or do you create a property in your client code and update it with the value of OTA_VERSION?

I thought I would be able to get a dropdown of device resources that would include some defaults but I could not find this.

Yes. When you link your device (under the settings) to the product where you have defined the firmware property, then this property is automatically inherited by the device. Once linked, you can view the device’s actual firmware version under the device property tab.

Since this is a device property, you should be able to read it from the device. I do not know if this is the most efficient way as I do not use dynamic build flag yet.

Sharing the finalized version of this for reference:

in platform.ini, I included this line:

build_flags = !echo '-D THINGER_OTA_VERSION=\\"'$(git rev-parse --short HEAD)'\\"'

In my application code, I can access this global variable and set the property myself during setup():

pson version = THINGER_OTA_VERSION;
wifithing.set_property("OTA_VERSION", version);

nb: I have to define everything as pson when dealing with Thinger properties