Skip to content

设备的消息和主题 ​

参数名数据类型是否必须备注
idString是消息ID
productKeyString是ProductKey
deviceNameString是DeviceName
methodString是消息类型
versionString是消息版本号
timestampLong是消息时间戳
paramsObject是消息数据

id

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

productKey

ProductKey 产品添加成功后可获得

deviceName

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

method

toml
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

上报消息格式样例

json
{
	"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

上报消息格式

json
{
	"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

服务调用消息格式

json
{
	"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

属性设置消息格式

json
{
	"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

属性获取消息格式

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