Firmware Status feedback with MQTT interface

I’m using the MQTT interface with the static templates, talking to an ESP32-S3 board. When I trigger a firmware update from the Cockpit, I receive a message on topic s/ds with the info; 515,,, , and I initiate a firmware update using the esp ota module which finishes successfully. This information is not fed back to the unit though. I’ve tried publishing to s/us with the 501, 502, and 503 IDs using the c8y_Firmware operation but the status in the cockpit remains “pending”. Is there a way to send feedback to the cockpit regarding the OTA status?

We have this exact process from a device integration perspective documented here: https://cumulocity.com/docs/device-integration/fragment-library/#installing-a-firmware-image There are also concrete examples for the MQTT SmartREST interface.

The key point is that the device needs to communicate both the status of the operation and the status of the installed firmware separately.

The only difference between what is specified in that I didn’t have the 115 report at first. So I added that and still I don’t get any feedback. The only way I know that the update took place is by looking at the Info screen and I can see the device reports the new software version tag on startup;

The MQTT_TEMPLATE defines are the 501 through 503 for reporting status, MQTT_TEMPLATE_FIRMWARE define is 115.

sprintf( mqtt_msg, “%u,%s”, MQTT_TEMPLATE_EXECUTING,FIRMWARE_OPERATION);
mqtt_interface_publish_data(standard_upstream_static_topic_, mqtt_msg, strlen(mqtt_msg), MQTT_QOS_EXACTLY_ONCE);
vTaskDelay(pdMS_TO_TICKS(5000));
if ( ota_with_credentials(fw_url) ) {
sprintf(mqtt_msg,“%u,%s,%s,%s”,MQTT_TEMPLATE_FIRMWARE,fw_name,fw_version,fw_url);
mqtt_interface_publish_data(standard_upstream_static_topic_, mqtt_msg, strlen(mqtt_msg), MQTT_QOS_EXACTLY_ONCE);
sprintf(mqtt_msg,“%u,%s,%s”,MQTT_TEMPLATE_SUCCESS,FIRMWARE_OPERATION,“Resetting”);
} else {
sprintf(mqtt_msg,“%u,%s,%s”,MQTT_TEMPLATE_FAILED,FIRMWARE_OPERATION,“Update Failed”);
}
mqtt_interface_publish_data(standard_upstream_static_topic_, mqtt_msg, strlen(mqtt_msg), MQTT_QOS_EXACTLY_ONCE);

As far as I can tell this matches perfectly with the documented procedure;

  1. Set operation status to EXECUTING
    501,c8y_Firmware
  2. Install firmware image
  3. Update device’s installed firmware state in inventory
    115,ubuntu core,20.04.3,http://test.com
  4. Set operation status to SUCCESSFUL
    503,c8y_Firmware

I don’t see any major problems with your solution. You have an additional property at the end when using the 503 template but that doesn’t impact functionality it is just ignored.

Is it possible that your device has older existing firmware operations in various statuses? The 501 template will update the oldest operation in status “PENDING” of the specified type to status “EXECUTING” The 502 and 503 templates work the same way for operations in status “EXECUTING”. If there are oder operations still present and not cleaned up by the device or user, they will be updated instead while the UI is watching for status updates on the one it recently created when the submit button was pressed.

You also mentioned that the firmware update is triggered from Cockpit. I’m not aware that we provide a firmware management widget for Cockpit. It is of course also possible that a 3rd party widget does not track the status as expected.

1 Like

Interesting, I sent a reply to this via email and it doesn’t look like it showed up here. Anyway, I shouldn’t use the term Cockpit, I’ve gotten into the habit of calling the built-in Cumulocity interfacer that. I’m using the Device Management Screen. Since I report c8y_Firmware in the supported operations of my device, the “Firmware” section becomes active on the device management page. By using that, I’m not getting any feedback.