36 lines
876 B
Go
36 lines
876 B
Go
package mqtt
|
|
|
|
import "fmt"
|
|
|
|
const (
|
|
Topic_IotServiceState string = "/%s/%s/iotss"
|
|
Topic_IotLog string = "/%s/%s/iotlog"
|
|
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)
|
|
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]
|
|
}
|
|
|
|
func GetQdTopic() string {
|
|
return topicMap[Topic_IotQd]
|
|
}
|
|
|
|
func GetCjTopic() string {
|
|
return topicMap[Topic_IotCj]
|
|
}
|