Skip to content

设备的消息和主题

参数名 数据类型 是否必须 备注
id String 消息ID
productKey String ProductKey
deviceName String DeviceName
method String 消息类型
version String 消息版本号
timestamp Long 消息时间戳
params Object 消息数据

id

一般使用UUID来唯一标识消息

productKey

ProductKey 产品添加成功后可获得

deviceName

DeviceName 唯一标识一个同产品下的设备

method

property_post_method = "thing.event.property.post" # 属性上报
event_post_method = "thing.event.{identifier}" # 事件上报
service_method = "thing.service.{identifier}" # 服务调用
property_set_method = "thing.service.property.set" # 属性设置
property_get_method = "thing.service.property.get" # 属性获取

属性上报

属性上报主题

/sys/{ProductKey}/{DeviceName}/thing/event/property/post

属性上报回复主题

/sys/{ProductKey}/{DeviceName}/thing/event/property/post_reply

上报消息格式样例

{
    "id": "",
    "productKey": "",
    "deviceName": "",
    "method": "thing.event.property.post",
    "version": "1.0",
    "timestamp":1722325236749,
    "params": {}
}

事件上报

事件上报主题

$thingshub/events/{ProductKey}/{DeviceName}/{identifier}

事件上报回复主题

$thingshub/events/{ProductKey}/{DeviceName}/{identifier}_reply

上报消息格式

{
    "id": "",
    "productKey": "",
    "deviceName": "",
    "method": "thing.event.{identifier}",
    "version": "1.0",
    "timestamp": 1722325236749,
    "params": {}
}

服务调用

服务调用主题

/sys/{ProductKey}/{DeviceName}/thing/service/{identifier}

服务调用回复主题

/sys/{ProductKey}/{DeviceName}/thing/service/{identifier}_reply

服务调用消息格式

{
    "id": "",
    "productKey": "",
    "deviceName": "",
    "method": "thing.service.{identifier}",
    "version": "1.0",
    "timestamp": 1722325236749,
    "params": {}
}

属性设置

属性设置主题

/sys/{ProductKey}/{DeviceName}/thing/service/property/set

属性设置回复主题

/sys/{ProductKey}/{DeviceName}/thing/service/property/set_reply

属性设置消息格式

{
    "id": "",
    "productKey": "",
    "deviceName": "",
    "method": "thing.service.property.set",
    "version": "1.0",
    "timestamp": 1722325236749,
    "params": {}
}

属性获取

属性获取主题

/sys/{ProductKey}/{DeviceName}/thing/service/property/get

属性获取回复主题

/sys/{ProductKey}/{DeviceName}/thing/service/property/get_reply

属性获取消息格式

{
    "id": "",
    "productKey": "",
    "deviceName": "",
    "method": "thing.service.property.get",
    "version": "1.0",
    "timestamp": 1722325236749,
    "params": {}
}