EcoWatt Technologies Logo

[Beta] EMS OTA

Issue OTA Command

  • Topic:
    • User-defined MQTT: v1/watt/${PRODUCT_KEY}/${DEVICE}/ota/upgrade/command
    • Platform Default MQTT: v1/user/${TENANT}/${DEVICE}/ota/upgrade/command
  • Permissions: Subscribe
  • Payload Main Structure
ParameterTypeRequiredDescriptionRangeExample
midUUIDtrueMessage ID-3e681859-6917-4b9a-9afd-3f162cd185bd
typestrtrueMessage typeota_upgradeota_upgrade
datadatatrueMessage content-See Payload - data
sub_device_uidstrtruePrimary device UID, only needed if a secondary device reports on behalf of a primary device-jHODSda39
device_uidstrtrueDevice UID-iYRkfVpi77
timestampinttrueMessage timestamp (ms)(0, ∞)1696837112000

Payload - data

ParameterTypeRequiredDescriptionExample
sourcestringyesUpdate targetems_II
download_urlstringyesDownload linkhttp://example.com/ems\\_II
md5_codestringyesMD5 code50a2811e047dd49ace3801685eedb732

Payload Example

{
  "trace_id": "577f5df0-65d6-432d-8aac-06hjkgfg2",
  "mid": "ee2e8f09-b280-4e4d-bcb9-1529b703cfed",
  "type": "ota_upgrade",
  "device_uid": "test",
  "timestamp": 1697789021000,
  "data":{
    "source": "ems_II",
    "download_url": "http://example.com/ems_II",
    "md5_code": "50a2811e047dd49ace3801685eedb732"
  }
}

Synchronize OTA Result Response

Notes: The result will have two stages, meaning two different responses. Different stages correspond to different states.

  • First stage:

    This is the preparation stage. After the file is downloaded and verified, the status is 2 - File is prepared.

    Status codes: 1 - Update forbidden, 2 - Update prepared, 3 - Update preparation failed

  • Second stage:

    This is the final result. If the update is successful, the status is 4 - Update successful.

    Status codes: 4 - Update successful, 5 - Rollback successful, 6 - Rollback failed

  • Topic:

    • User-defined MQTT: v1/watt/${PRODUCT_KEY}/${DEVICE}/ota/upgrade/result
    • Platform Default MQTT: v1/user/${TENANT}/${DEVICE}/ota/upgrade/result
  • Permissions: Subscribe

  • Payload Main Structure

ParameterTypeRequiredDescriptionRangeExample
midUUIDtrueMessage ID-3e681859-6917-4b9a-9afd-3f162cd185bd
typestrtrueMessage typeota_upgradeota_upgrade
datadatatrueMessage content-See Payload - data
sub_device_uidstrtruePrimary device UID, only needed if a secondary device reports on behalf of a primary device-jHODSda39
device_uidstrtrueDevice UID-iYRkfVpi77
timestampinttrueMessage timestamp (ms)(0, ∞)1696837112000

Payload - data

ParameterTypeRequiredDescriptionExample
sourcestringnoSourceems_II
versionstringnoCurrent versionv1.0.0
target_commit_shastringnoTarget commit SHA6f7g8h9i0j1k
target_versionstringnoTarget versionv1.1.0
final_commit_shastringnoFinal commit SHA6f7g8h9i0j1k
final_versionstringnoFinal versionv1.1.0
statusintnoUpdate status 1-Update forbidden 2-Update prepared 3-Update preparation failed 4-Update successful 5-Rollback successful 6-Rollback failed4

Payload Example

{
    "trace_id": "577f5df0-65d6-432d-8aac-011789wfg2",
    "mid": "389d9ac9-c660-4459-b9d5-f43160183552",
    "type": "ota_upgrade",
    "device_uid": "test",
    "timestamp": 1725615497191,
    "data": {
        "source": "ems_II",
        "target_commit_sha": "6a2bbabde8d42abc6f8fef7b31f60c5e69045245",
        "target_version": "0.9.1",
        "final_commit_sha": "6a2bbabde8d42abc6f8fef7b31f60c5e69045245",
        "final_version": "0.9.1",
        "status": 4
    }
}