2023-12-15 18:08:06 +08:00
|
|
|
package mqtt
|
|
|
|
|
|
|
|
import "fmt"
|
|
|
|
|
|
|
|
const (
|
|
|
|
Topic_IotServiceState string = "/%s/%s/iotss"
|
2023-12-18 15:34:10 +08:00
|
|
|
Topic_IotLog string = "/%s/%s/iotlog"
|
2023-12-15 18:08:06 +08:00
|
|
|
Topic_IotQd string = "/%s/%s/iotqd"
|
|
|
|
Topic_IotCj string = "/%s/%s/iotcj"
|
|
|
|
)
|
|
|
|
|
|
|
|
var topicMap = make(map[string]string, 4)
|
|
|
|
|
|
|
|
func BuildTopics(sysCode, iotCode string) {
|
|
|
|
topicMap[Topic_IotServiceState] = fmt.Sprintf(Topic_IotServiceState, 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]
|
|
|
|
}
|
|
|
|
|
|
|
|
func GetCmdTopic() 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]
|
|
|
|
}
|