97532eaed4
Signed-off-by: deadprogram <ron@hybridgroup.com>
31 lines
527 B
Go
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())
|
|
}
|
|
}
|