Skip to content

Commit

Permalink
mqtt: update examples that use mqtt for updated notification signature
Browse files Browse the repository at this point in the history
Signed-off-by: deadprogram <[email protected]>
  • Loading branch information
deadprogram committed Apr 19, 2017
1 parent b97869e commit 311bfcf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions examples/mqtt_firmata_blink.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ func main() {
led := gpio.NewLedDriver(firmataAdaptor, "13")

work := func() {
mqttAdaptor.On("lights/on", func(data []byte) {
mqttAdaptor.On("lights/on", func(msg mqtt.Message) {
led.On()
})
mqttAdaptor.On("lights/off", func(data []byte) {
mqttAdaptor.On("lights/off", func(msg mqtt.Message) {
led.Off()
})
data := []byte("")
Expand Down
4 changes: 2 additions & 2 deletions examples/mqtt_ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ func main() {
mqttAdaptor := mqtt.NewAdaptor("tcp://test.mosquitto.org:1883", "pinger")

work := func() {
mqttAdaptor.On("hello", func(data []byte) {
mqttAdaptor.On("hello", func(msg mqtt.Message) {
fmt.Println("hello")
})
mqttAdaptor.On("hola", func(data []byte) {
mqttAdaptor.On("hola", func(msg mqtt.Message) {
fmt.Println("hola")
})
data := []byte("o")
Expand Down
12 changes: 6 additions & 6 deletions examples/ollie_mqtt.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func main() {
work := func() {
ollie.SetRGB(255, 0, 255)

mqttAdaptor.On("sensores/dial", func(data []byte) {
val, _ := strconv.Atoi(string(data))
mqttAdaptor.On("sensores/dial", func(msg mqtt.Message) {
val, _ := strconv.Atoi(string(msg.Payload()))

if val > 2000 {
ollie.SetRGB(0, 255, 0)
Expand All @@ -45,28 +45,28 @@ func main() {
ollie.SetRGB(255, 0, 0)
})

mqttAdaptor.On("rover/frente", func(data []byte) {
mqttAdaptor.On("rover/frente", func(msg mqtt.Message) {
ollie.Roll(40, FRENTE)
gobot.After(1*time.Second, func() {
ollie.Stop()
})
})

mqttAdaptor.On("rover/derecha", func(data []byte) {
mqttAdaptor.On("rover/derecha", func(msg mqtt.Message) {
ollie.Roll(40, DERECHA)
gobot.After(1*time.Second, func() {
ollie.Stop()
})
})

mqttAdaptor.On("rover/atras", func(data []byte) {
mqttAdaptor.On("rover/atras", func(msg mqtt.Message) {
ollie.Roll(40, ATRAS)
gobot.After(1*time.Second, func() {
ollie.Stop()
})
})

mqttAdaptor.On("rover/izquierda", func(data []byte) {
mqttAdaptor.On("rover/izquierda", func(msg mqtt.Message) {
ollie.Roll(40, IZQUIERDA)
gobot.After(1*time.Second, func() {
ollie.Stop()
Expand Down

0 comments on commit 311bfcf

Please sign in to comment.