108 lines
6.1 KiB
Java
108 lines
6.1 KiB
Java
package com.maibu.mqtt;
|
|
|
|
|
|
public class MqttTopic {
|
|
|
|
/** @deprecated 通用设备主题,建议使用 MOWER_* 系列主题 */
|
|
public static final String DEVICE_STATUS_TOPIC = "device/%s/realTimeMessage";
|
|
/** @deprecated 通用设备主题,建议使用 MOWER_* 系列主题 */
|
|
public static final String DEVICE_TASK_STATUS_TOPIC = "task/%s/status";
|
|
/** @deprecated 通用设备主题,建议使用 MOWER_* 系列主题 */
|
|
public static final String DEVICE_TASK_ARRIVE_TOPIC = "task/%s/arrive";
|
|
/** @deprecated 通用设备主题,建议使用 MOWER_* 系列主题 */
|
|
public static final String DEVICE_ERROR_PUSH_TOPIC = "device/%s/error";
|
|
|
|
/** 产品标识:割草机 */
|
|
public static final String MOWER_PRODUCT = "mower";
|
|
|
|
// ==================== 设备连接与状态 ====================
|
|
/** 设备上线/下线事件上报(设备->平台),对应 TCP 0x03 connect */
|
|
public static final String MOWER_STATUS_POST = "mower/%s/event/status/post";
|
|
/** 状态变更确认回复(平台->设备) */
|
|
// public static final String MOWER_STATUS_REPLY = "mower/%s/event/status/reply";
|
|
|
|
// ==================== 实时运行数据 ====================
|
|
/** 实时运行数据上报:电压/速度/温度/位置等(设备->平台),对应 TCP 0x02 status */
|
|
public static final String MOWER_REALTIME_POST = "mower/%s/property/realtime/post";
|
|
|
|
// ==================== 心跳保活 ====================
|
|
/** 设备心跳上报(设备->平台),对应 TCP 0xFF heartbeat */
|
|
public static final String MOWER_HEARTBEAT_POST = "mower/%s/event/heartbeat/post";
|
|
/** 心跳确认回复(平台->设备) */
|
|
public static final String MOWER_HEARTBEAT_REPLY = "mower/%s/event/heartbeat/reply";
|
|
|
|
// ==================== 参数配置 ====================
|
|
/** 下发读取配置请求(平台->设备),对应 TCP 0x05 readConfig */
|
|
public static final String MOWER_CONFIG_GET = "mower/%s/action/config/get";
|
|
/** 下发配置修改指令(平台->设备),对应 TCP 0x06 writeConfig */
|
|
public static final String MOWER_CONFIG_SET = "mower/%s/action/config/set";
|
|
/** 配置读取/修改响应(设备->平台) */
|
|
public static final String MOWER_CONFIG_REPLY = "mower/%s/action/config/reply";
|
|
|
|
// ==================== 远程控制 ====================
|
|
/** 远程控制指令下发:前进/后退/转向/割草等(平台->设备),对应 TCP 0x00 remoteControl */
|
|
public static final String MOWER_CONTROL_SET = "mower/%s/action/control/set";
|
|
|
|
// /** 控制指令响应(设备->平台) */
|
|
// public static final String MOWER_CONTROL_REPLY = "mower/%s/action/control/reply";
|
|
|
|
// ==================== 任务管理 ====================
|
|
/** 路径规划下发(平台->设备),对应 TCP 0x01 path */
|
|
public static final String MOWER_TASK_ROUTE_SET = "mower/%s/task/route/set";
|
|
public static final String MOWER_TASK_ROUTE_POST = "mower/%s/task/route/post";
|
|
/** 启动任务执行(平台->设备),对应 TCP 0x12 interaction */
|
|
public static final String MOWER_TASK_STATUS_SET = "mower/%s/task/status/set";
|
|
// /** 暂停任务(平台->设备) */
|
|
// public static final String MOWER_TASK_PAUSE_SET = "mower/%s/task/pause/set";
|
|
// /** 继续任务(平台->设备) */
|
|
// public static final String MOWER_TASK_RESUME_SET = "mower/%s/task/resume/set";
|
|
// /** 取消任务(平台->设备) */
|
|
// public static final String MOWER_TASK_CANCEL_SET = "mower/%s/task/cancel/set";
|
|
// /** 到达路径点上报(设备->平台) */
|
|
public static final String MOWER_TASK_POINT_POST = "mower/%s/task/point/post";
|
|
/** 任务状态变更上报:执行中/暂停/完成等(设备->平台) */
|
|
public static final String MOWER_TASK_STATUS_POST = "mower/%s/task/status/post";
|
|
/** 任务完成上报(设备->平台) */
|
|
public static final String MOWER_TASK_FINISH_POST = "mower/%s/task/finish/post";
|
|
|
|
// ==================== 错误告警 ====================
|
|
/** 设备错误告警上报:电机故障/传感器异常等(设备->平台) */
|
|
public static final String MOWER_ERROR_POST = "mower/%s/event/error/post";
|
|
|
|
// ==================== OTA 固件升级 ====================
|
|
// /** 下发 OTA 升级指令(平台->设备) */
|
|
// public static final String MOWER_OTA_UPGRADE_SET = "mower/%s/ota/upgrade/set";
|
|
// /** OTA 升级进度上报(设备->平台) */
|
|
// public static final String MOWER_OTA_PROGRESS_POST = "mower/%s/ota/progress/post";
|
|
// /** OTA 升级结果上报(设备->平台) */
|
|
// public static final String MOWER_OTA_RESULT_POST = "mower/%s/ota/result/post";
|
|
|
|
// ==================== 设备信息 ====================
|
|
// /** 查询设备信息(平台->设备) */
|
|
// public static final String MOWER_INFO_DEVICE_GET = "mower/%s/info/device/get";
|
|
// /** 设备信息响应(设备->平台) */
|
|
// public static final String MOWER_INFO_DEVICE_REPLY = "mower/%s/info/device/reply";
|
|
/** 设备版本信息上报(设备->平台) */
|
|
// public static final String MOWER_INFO_VERSION_POST = "mower/%s/info/version/post";
|
|
|
|
// ==================== 通配符订阅 ====================
|
|
/** 订阅所有设备的状态变更事件 */
|
|
public static final String MOWER_WILDCARD_STATUS = "mower/+/event/status/post";
|
|
/** 订阅所有设备的实时运行数据 */
|
|
public static final String MOWER_WILDCARD_REALTIME = "mower/+/property/realtime/post";
|
|
/** 订阅所有设备的错误告警 */
|
|
public static final String MOWER_WILDCARD_ERROR = "mower/+/event/error/post";
|
|
/** 订阅所有设备的任务状态变更 */
|
|
public static final String MOWER_WILDCARD_TASK_STATUS = "mower/+/task/status/post";
|
|
|
|
/**
|
|
* 格式化 Topic 模板,将 %s 替换为设备ID
|
|
*
|
|
* @param template Topic 模板,如 {@link #MOWER_REALTIME_POST}
|
|
* @param deviceId 设备ID
|
|
* @return 格式化后的完整 Topic
|
|
*/
|
|
public static String formatTopic(String template, String deviceId) {
|
|
return String.format(template, deviceId);
|
|
}
|
|
} |