Fix Reach services discovery
- Use github.com/grandcat/zeroconf lib instead of github.com/oleksandr/bonjour
This commit is contained in:
41
example/discovery/main.go
Normal file
41
example/discovery/main.go
Normal file
@ -0,0 +1,41 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"log"
|
||||
"time"
|
||||
|
||||
"forge.cadoles.com/Pyxis/orion/emlid"
|
||||
)
|
||||
|
||||
var (
|
||||
timeout = 5 * time.Second
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.DurationVar(&timeout, "timeout", timeout, "mDNS scan timeout")
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
flag.Parse()
|
||||
|
||||
log.Println("Searching for ReachRS services on network...")
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
|
||||
services, err := emlid.Discover(ctx)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
for _, s := range services {
|
||||
log.Println("Found:")
|
||||
log.Printf(" Name: '%s'", s.Name)
|
||||
log.Printf(" Hosts: %s", s.AddrV4)
|
||||
log.Printf(" Port: '%d'", s.Port)
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user