::: tip 什么是Topic
Topic作为所有设备发布和订阅之间最重要的传输中介,所有具有MQTT通信能力的设备(网关设备或者子设备),都能通过对应的Topic实现消息的发送和接收
:::
Topic格式
Topic由多个段组成,各个段的说明如图所示:
已有的Topic段:
固定部分 |
产品id |
设备id。可为网关id,也可为子设备id |
固定部分 |
模块 |
响应/动作/gateway(按需) |
sys |
{product_id} |
{device_id} |
thing |
heart:心跳 |
up:上报 |
|
|
|
|
ntp:校时 |
set:写值 |
|
|
|
|
properties:属性 |
response:响应 |
|
|
|
|
service:服务 |
geteway:网关 |
|
|
|
|
event:事件 |
|
|
|
|
|
status:状态 |
|
Topic列表
此处是平台内置的Topic列表
| 功能 | Topic | 发布者 | 订阅者 | 说明 |
| --- | --- | --- | --- | --- |
| 属性上报 | sys/{product_id}/{device_id}/thing/properties/up | 网关/设备 | 平台 | 无 |
| 属性上报回复 | sys/{product_id}/{device_id}/thing/properties/up/response | 平台 | 网关/设备 | 无 |
| 批量属性上报 | sys/{product_id}/{device_id}/thing/properties/gateway/up | 网关/设备 | 平台 | 无 |
| 批量属性上报回复 | sys/{product_id}/{device_id}/thing/properties/gateway/up/response | 平台 | 网关/设备 | 无 |
| 属性查询全量 | sys/{product_id}/{device_id}/thing/properties/gateway/get/all | 平台 | 网关/设备 | 无 |
| 属性写值 | sys/{product_id}/{device_id}/thing/properties/set | 平台 | 网关/设备 | 无 |
| 属性写值回复 | sys/{product_id}/{device_id}/thing/properties/set/response | 网关/设备 | 平台 | 无 |
| 属性查询 | sys/{product_id}/{device_id}/thing/properties/get | 平台 | 网关/设备 | 无 |
| 属性查询回复 | sys/{product_id}/{device_id}/thing/properties/get/response | 网关/设备 | 平台 | 无 |
| 功能 | Topic | 发布者 | 订阅者 | 说明 |
| --- | --- | --- | --- | --- |
| 服务下发 | sys/{product_id}/{device_id}/thing/service/set | 网关/设备 | 平台 | 无 |
| 服务下发回复 | sys/{product_id}/{device_id}/thing/service/set/response | 平台 | 网关/设备 | 无 |
| 功能 | Topic | 发布者 | 订阅者 | 说明 |
| --- | --- | --- | --- | --- |
| 事件上报 | sys/{product_id}/{device_id}/thing/event/up | 网关/设备 | 平台 | 无 |
| 事件上报回复 | sys/{product_id}/{device_id}/thing/event/up | 平台 | 网关/设备 | 无 |
| 功能 | Topic | 发布者 | 订阅者 | 说明 |
| --- | --- | --- | --- | --- |
| 心跳 | sys/{product_id}/{device_id}/thing/heart | 网关/设备 | 平台 | 无 |
| 心跳回复 | sys/{product_id}/{device_id}/thing/heart/response | 平台 | 网关/设备 | 无 |
| 时间校准 | sys/{product_id}/{device_id}/thing/ntp | 网关/设备 | 平台 | 无 |
| 时间校准回复 | sys/{product_id}/{device_id}/thing/ntp/response | 网关/设备 | 平台 | 无 |
| 获取设备信息 | sys/{product_id}/{device_id}/thing/device_info/get | 网关/设备 | 平台 | 无 |
| 获取设备信息回复 | sys/{product_id}/{device_id}/thing/device_info/get/response | 平台 | 网关/设备 | 无 |