2023-12-15 18:08:06 +08:00
|
|
|
|
package mqtt
|
|
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
|
|
const (
|
2023-12-19 16:15:21 +08:00
|
|
|
|
// IOT服务状态主题,第一个参数为应用编号,第二个参数为客户端编号
|
2023-12-15 18:08:06 +08:00
|
|
|
|
Topic_IotServiceState string = "/%s/%s/iotss"
|
2023-12-19 16:15:21 +08:00
|
|
|
|
// IOT服务启动(请求响应)主题,第一个参数为应用编号,第二个参数为客户端编号
|
|
|
|
|
Topic_IotServiceStart string = "/%s/%s/iotstart"
|
|
|
|
|
// IOT服务停止(请求响应)主题,第一个参数为应用编号,第二个参数为客户端编号
|
|
|
|
|
Topic_IotServiceStop string = "/%s/%s/iotstop"
|
|
|
|
|
// IOT日志服务(请求响应)主题,第一个参数为应用编号,第二个参数为客户端编号
|
|
|
|
|
Topic_IotLog string = "/%s/%s/iotlog"
|
|
|
|
|
// IOT驱动数据主题,第一个参数为应用编号,第二个参数为客户端编号
|
|
|
|
|
Topic_IotQd string = "/%s/%s/iotqd"
|
|
|
|
|
// IOT采集数据主题,第一个参数为应用编号,第二个参数为客户端编号
|
|
|
|
|
Topic_IotCj string = "/%s/%s/iotcj"
|
2023-12-15 18:08:06 +08:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
var topicMap = make(map[string]string, 4)
|
|
|
|
|
|
|
|
|
|
func BuildTopics(sysCode, iotCode string) {
|
|
|
|
|
topicMap[Topic_IotServiceState] = fmt.Sprintf(Topic_IotServiceState, sysCode, iotCode)
|
2023-12-20 14:05:07 +08:00
|
|
|
|
topicMap[Topic_IotServiceStart] = fmt.Sprintf(Topic_IotServiceStart, sysCode, iotCode)
|
|
|
|
|
topicMap[Topic_IotServiceStop] = fmt.Sprintf(Topic_IotServiceStop, sysCode, iotCode)
|
2023-12-18 15:34:10 +08:00
|
|
|
|
topicMap[Topic_IotLog] = fmt.Sprintf(Topic_IotLog, sysCode, iotCode)
|
2023-12-15 18:08:06 +08:00
|
|
|
|
topicMap[Topic_IotQd] = fmt.Sprintf(Topic_IotQd, sysCode, iotCode)
|
|
|
|
|
topicMap[Topic_IotCj] = fmt.Sprintf(Topic_IotCj, sysCode, iotCode)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func GetIotServiceStateTopic() string {
|
|
|
|
|
return topicMap[Topic_IotServiceState]
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-20 14:05:07 +08:00
|
|
|
|
func GetIotServiceStartTopic() string {
|
|
|
|
|
return topicMap[Topic_IotServiceStart]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func GetIotServiceStopTopic() string {
|
|
|
|
|
return topicMap[Topic_IotServiceStop]
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-19 16:15:21 +08:00
|
|
|
|
func GetLogReqTopic() string {
|
2023-12-18 15:34:10 +08:00
|
|
|
|
return topicMap[Topic_IotLog]
|
2023-12-15 18:08:06 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func GetQdTopic() string {
|
|
|
|
|
return topicMap[Topic_IotQd]
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func GetCjTopic() string {
|
|
|
|
|
return topicMap[Topic_IotCj]
|
|
|
|
|
}
|