mqtt

package
v0.0.0-...-6752d0c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 9, 2022 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPublishHandler MQTT.MessageHandler = func(c MQTT.Client, msg MQTT.Message) {
	topic := msg.Topic()
	device := config.GetConfig().Device
	topic = strings.Replace(topic, device.ProductKey+"/"+device.DeviceName, "{pk}/{dn}", 1)
	log.Debug("topic = ", topic)
	log.Debug("payload = ", string(msg.Payload()))

	if strings.Contains(topic, "/sys/{pk}/{dn}/rrpc/request/") {
		RRpcHandle(c, topic, string(msg.Payload()))
		return
	}

	switch topic {
	case "/sys/{pk}/{dn}/thing/config/push":
		config.SaveParamsYaml(msg.Payload())
	default:
		log.Warn("miss topic = ", topic)
	}
}

Functions

func Publish

func Publish(c MQTT.Client, topic string, msg string) MQTT.Token

func RRpcHandle

func RRpcHandle(c MQTT.Client, topic string, payload string)

func Subscribe

func Subscribe(c MQTT.Client, topic string) MQTT.Token

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL