Example #1
0
File: objects.go Project: ecc1/ble
func main() {
	conn, err := ble.Open()
	if err != nil {
		log.Fatal(err)
	}
	conn.Print(os.Stdout)
}
Example #2
0
File: pair.go Project: ecc1/ble
func main() {
	if len(os.Args) != 2 {
		log.Fatalf("Usage: %s UUID", os.Args[0])
	}
	conn, err := ble.Open()
	if err != nil {
		log.Fatal(err)
	}
	device, err := conn.Discover(0, os.Args[1])
	if err != nil {
		log.Fatal(err)
	}
	if !device.Connected() {
		err = device.Connect()
		if err != nil {
			log.Fatal(err)
		}
	} else {
		log.Printf("%s: already connected", device.Name())
	}
	if !device.Paired() {
		err = device.Pair()
		if err != nil {
			log.Fatal(err)
		}
	} else {
		log.Printf("%s: already paired", device.Name())
	}
}
Example #3
0
File: adapter.go Project: ecc1/ble
func main() {
	conn, err := ble.Open()
	if err != nil {
		log.Fatal(err)
	}
	adapter, err := conn.GetAdapter()
	if err != nil {
		log.Fatal(err)
	}
	adapter.Print(os.Stdout)
}
Example #4
0
File: discover.go Project: ecc1/ble
func main() {
	conn, err := ble.Open()
	if err != nil {
		log.Fatal(err)
	}
	uuids := os.Args[1:]
	device, err := conn.Discover(0, uuids...)
	if err != nil {
		log.Fatal(err)
	}
	device.Print(os.Stdout)
}