Use ReachView 2.24.X broadcast API
Some checks failed
Pyxis/orion/pipeline/head There was a failure building this commit
Some checks failed
Pyxis/orion/pipeline/head There was a failure building this commit
This commit is contained in:
58
cmd/broadcast/main.go
Normal file
58
cmd/broadcast/main.go
Normal file
@ -0,0 +1,58 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"forge.cadoles.com/Pyxis/orion/emlid"
|
||||
"forge.cadoles.com/Pyxis/orion/emlid/reachview"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
)
|
||||
|
||||
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()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
events, err := c.Broadcast(ctx)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
for e := range events {
|
||||
log.Printf("received event: %s", spew.Sdump(e))
|
||||
}
|
||||
|
||||
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
|
||||
|
||||
}
|
Reference in New Issue
Block a user