Skip to content

Instantly share code, notes, and snippets.

@BK1031
Last active July 11, 2024 11:22
Show Gist options
  • Save BK1031/359f1c8e365dc258945827a3901c4442 to your computer and use it in GitHub Desktop.
Save BK1031/359f1c8e365dc258945827a3901c4442 to your computer and use it in GitHub Desktop.
racecar_analytics subscribe mqtt handlers with byte decoding
func SubscribeECU() {
Client.Subscribe("ingest/ecu", 0, func(client mqtt.Client, msg mqtt.Message) {
ecu := ECUFromBytes(msg.Payload()) // add this
fmt.Printf("[MQ] Received ecu message: %v\n", ecu)
})
}
func SubscribeBattery() {
Client.Subscribe("ingest/battery", 0, func(client mqtt.Client, msg mqtt.Message) {
battery := BatteryFromBytes(msg.Payload()) // add this
fmt.Printf("[MQ] Received battery message: %v\n", battery)
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment