Slight improvements
This commit is contained in:
@@ -75,11 +75,18 @@ func subscribe(client mqtt.Client, topic string, handler mqtt.MessageHandler) {
|
||||
}
|
||||
}
|
||||
|
||||
func onConnect(client mqtt.Client) {
|
||||
log.Print("Subscribing to command topics")
|
||||
subscribe(client, "spider/command/ping", onPing)
|
||||
subscribe(client, "spider/command/set_camera_xy", onSetCameraXY)
|
||||
}
|
||||
|
||||
func main() {
|
||||
opts := mqtt.NewClientOptions()
|
||||
opts.AddBroker(broker)
|
||||
opts.SetClientID("spider-host-client")
|
||||
opts.SetResumeSubs(true)
|
||||
opts.SetOnConnectHandler(onConnect)
|
||||
client := mqtt.NewClient(opts)
|
||||
|
||||
token := client.Connect()
|
||||
@@ -88,10 +95,6 @@ func main() {
|
||||
log.Fatalf("Error connecting to MQTT broker: %v\n", token.Error())
|
||||
}
|
||||
|
||||
log.Print("Subscribing to command topics")
|
||||
subscribe(client, "spider/command/ping", onPing)
|
||||
subscribe(client, "spider/command/set_camera_xy", onSetCameraXY)
|
||||
|
||||
InitBattery()
|
||||
InitServo()
|
||||
|
||||
|
||||
@@ -52,6 +52,7 @@ func InitServo() {
|
||||
}
|
||||
// Halt the controllers to stop any current movement
|
||||
ServosOff()
|
||||
log.Print("Started servos")
|
||||
}
|
||||
|
||||
func ServosOff() {
|
||||
|
||||
Reference in New Issue
Block a user