prototooth/examples/advertisement/main.go

31 lines
536 B
Go

package main
import (
"time"
"git.tcp.direct/kayos/prototooth"
)
var adapter = bluetooth.DefaultAdapter
func main() {
must("enable BLE stack", adapter.Enable())
adv := adapter.DefaultAdvertisement()
must("config adv", adv.Configure(bluetooth.AdvertisementOptions{
LocalName: "Go Bluetooth",
}))
must("start adv", adv.Start())
println("advertising...")
for {
// Sleep forever.
time.Sleep(time.Hour)
}
}
func must(action string, err error) {
if err != nil {
panic("failed to " + action + ": " + err.Error())
}
}