jl-iot/mqtt/topic.go

36 lines
876 B
Go
Raw Normal View History

2023-12-15 18:08:06 +08:00
package mqtt
import "fmt"
const (
Topic_IotServiceState string = "/%s/%s/iotss"
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)
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 {
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]
}