func main() { d, err := gatt.NewDevice(option.DefaultClientOptions...) if err != nil { log.Fatalf("Failed to open device, err: %s\n", err) return } // Register handlers. d.Handle(gatt.PeripheralDiscovered(onPeriphDiscovered)) d.Init(onStateChanged) select {} }
func main() { flag.Parse() if len(flag.Args()) != 1 { log.Fatalf("usage: %s [options] peripheral-id\n", os.Args[0]) } d, err := gatt.NewDevice(option.DefaultClientOptions...) if err != nil { log.Fatalf("Failed to open device, err: %s\n", err) return } // Register handlers. d.Handle( gatt.PeripheralDiscovered(onPeriphDiscovered), gatt.PeripheralConnected(onPeriphConnected), gatt.PeripheralDisconnected(onPeriphDisconnected), ) d.Init(onStateChanged) <-done fmt.Println("Done") }