# OTA

数据上行: fogcloud/{productKey}/{deviceName}/thing/up/ota 数据下行: fogcloud/{productKey}/{deviceName}/thing/down/ota

具体数据类型根据 json 数据的 method 字段进行区分:

method

说明

version.post

设备上报 OTA 版本

firmware.post

云端推送 OTA 升级包信息

upgrade.post

设备上报升级信息

sub.version.post

子设备上报 OTA 版本

sub.firmware.post

云端推送子设备 OTA 升级包信息

sub.upgrade.post

子设备上报 OTA 版本

# 1 设备上报版本

  • 设备上行数据格式:
{
  "id": 123,
  "version": "1.0",
  "method": "version.post",
  "params": {
    "version": "1.0.0",
    "module": "default" //升级包所属模块
  }
}

# 2 设备上报升级进度

  • 设备上行数据格式:
{
  "id": 123,
  "version": "1.0",
  "method": "upgrade.post",
  "params": {
    "step": -1, // 有符号32位整型, 0~100升级进度,-1升级失败
    // "desc": "OTA升级失败,请求不到升级包信息。",
    "module": "mcu",
    "task_id": "123"
  }
}

# 3 云端推送 OTA 升级包信息

  • 云端下行数据格式:

{
  "id": 123,
  "version": "1.0",
  "method": "firmware.post",
  "params": {
    "size": 93796291, //单位:字节
    "sign": "f8d85b250d4d787a9f483d89a974****",
    "version": "1.0.1",
    "url": "https://the_firmware_url",
    "sign_method": "MD5",
    "module": "mcu",
    "task_id": "123" //整型字符串,当前升级任务唯一标识,设备上报进度时携带
  }
}

# 4 网关上报子设备版本

  • 设备上行数据格式:
{
    "id": 123,
    "version": "1.0",
    "method": "sub.version.post",
    "params": [
        {
            "identity": {
                "product_key": "12097812",
                "device_name": "00000001"
            },
            "version": "1.0.0",
            "module": "default" //升级包所属模块
        },
        {
            "identity": {
                "product_key": "12097812",
                "device_name": "00000001"
            },
            "version": "1.2.0",
            "module": "default" //升级包所属模块
        }
    ]
}

# 5 网关上报子设备升级进度

  • 设备上行数据格式
{
    "id": 123,
    "version": "1.0",
    "method": "sub.upgrade.post",
    "params": [
        {
            "identity": {
                "product_key": "12097812",
                "device_name": "00000001"
            },
            "step": -1, // 有符号32位整型, 0~100升级进度,-1升级失败
            "module": "mcu",
            "task_id": "123"
        },
        {
            "identity": {
                "product_key": "12097812",
                "device_name": "00000001"
            },
            "step": -1, // 有符号32位整型, 0~100升级进度,-1升级失败
            "module": "mcu",
            "task_id": "123"
        }
    ]
}

# 6 云端推送子设备 OTA 升级包信息

  • 云端下行数据格式
{
    "id": 123,
    "version": "1.0",
    "method": "sub.firmware.post",
    "params": [
        {
            "identity": {
                "product_key": "12097812",
                "device_name": "00000001"
            },
            "size": 93796291, //单位:字节
            "sign": "f8d85b250d4d787a9f483d89a974****",
            "version": "1.0.1",
            "url": "https://the_firmware_url",
            "sign_method": "MD5",
            "module": "mcu",
            "task_id": "123" //整型字符串,当前升级任务唯一标识,设备上报进度时携带
        },
        {
            "identity": {
                "product_key": "12097812",
                "device_name": "00000001"
            },
            "size": 93796291, //单位:字节
            "sign": "f8d85b250d4d787a9f483d89a974****",
            "version": "1.0.1",
            "url": "https://the_firmware_url",
            "sign_method": "MD5",
            "module": "mcu",
            "task_id": "123" //整型字符串,当前升级任务唯一标识,设备上报进度时携带
        }
    ]
}
更新时间: 2023/1/30 下午5:27:13