|
|
@@ -78,11 +78,12 @@ func (b *ParamMQTTBridge) publish(param *Param) {
|
|
78
|
78
|
|
|
79
|
79
|
// TODO(michaelh): listen on connect.
|
|
80
|
80
|
if !b.listening {
|
|
81
|
|
- b.listening = b.adaptor.OnTopic(b.prefix+"/#", b.recv)
|
|
|
81
|
+ b.listening = b.adaptor.On(b.prefix+"/#", b.recv)
|
|
82
|
82
|
}
|
|
83
|
83
|
}
|
|
84
|
84
|
|
|
85
|
|
-func (b *ParamMQTTBridge) recv(topic string, data []byte) {
|
|
|
85
|
+func (b *ParamMQTTBridge) recv(msg mqtt.Message) {
|
|
|
86
|
+ topic := msg.Topic()
|
|
86
|
87
|
if !strings.HasSuffix(topic, "/set") {
|
|
87
|
88
|
return
|
|
88
|
89
|
}
|
|
|
@@ -97,7 +98,7 @@ func (b *ParamMQTTBridge) recv(topic string, data []byte) {
|
|
97
|
98
|
|
|
98
|
99
|
// Parse the data to a number or string.
|
|
99
|
100
|
var next interface{}
|
|
100
|
|
- value := string(data)
|
|
|
101
|
+ value := string(msg.Payload())
|
|
101
|
102
|
fp, err := strconv.ParseFloat(value, 64)
|
|
102
|
103
|
|
|
103
|
104
|
if err == nil {
|