package main import ( "context" "flag" "log" "time" "forge.cadoles.com/Pyxis/orion/emlid" "forge.cadoles.com/Pyxis/orion/emlid/reachview" ) var ( host = "192.168.42.1" ) func init() { flag.StringVar(&host, "host", host, "ReachRS module host") } func main() { flag.Parse() c := connect() defer c.Close() log.Println("updating base manual position") // 42["apply configuration",{"base mode":{"base coordinates":{"coordinates":["0","0","0"],"antenna offset":{"up":"0","east":"0","north":"0"},"format":"llh","mode":"fix-and-hold","accumulation":"2"}}}] config := &reachview.Configuration{ BaseMode: &reachview.BaseMode{ BaseCoordinates: &reachview.BaseCoordinates{ Coordinates: []*string{ reachview.String("2"), reachview.String("0"), reachview.String("0"), }, AntennaOffset: &reachview.AntennaOffset{ East: reachview.String("0"), North: reachview.String("0"), Up: reachview.String("2"), }, Format: reachview.BaseCoordinatesFormatLLH, Mode: reachview.String("manual"), }, }, } applyConfiguration(c, config) log.Println("done") } func connect() *reachview.Client { c := reachview.NewClient( emlid.WithEndpoint(host, 80), ) log.Printf("connecting to module '%s'", host) if err := c.Connect(); err != nil { log.Fatal(err) } log.Println("connected") return c } func applyConfiguration(c *reachview.Client, config *reachview.Configuration) { ctx, applyConfCancel := context.WithTimeout(context.Background(), 20*time.Second) defer applyConfCancel() result, _, err := c.ApplyConfiguration(ctx, config) if err != nil { log.Fatal(err) } if result != reachview.ConfigurationApplySuccess { log.Fatal("configuration update failed !") } log.Println("restarting rtklib") if err := c.RestartRTKLib(); err != nil { log.Fatal(err) } }