bluetooth/examples/advertisement/main.go
deadprogram 97532eaed4 domain: use custom domain for go.mod and examples
Signed-off-by: deadprogram <ron@hybridgroup.com>
2020-09-09 16:04:40 +02:00

31 lines
527 B
Go

package main
import (
"time"
"tinygo.org/x/bluetooth"
)
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())
}
}