Hello,
I am using your lib to create/manage a peripheral BLE device on an RPI 4.
It already works quite well, I can advertise and read/write with services and characteristics I defined. However, I would need to run a function each time a a Central device connects/disconnects to my RPI.
As I understood, the 'adapter.SetConnectHandler()' can be used for that, but it doesn't work for me.
Did I miss something ? My code is very similar to this example : https://github.com/tinygo-org/bluetooth/blob/v0.6.0/examples/circuitplay/main.go
adapter.SetConnectHandler(func(d` bluetooth.Addresser, c bool) {
connected = c
if !connected && !disconnected {
clearLEDS()
disconnected = true
}
if connected {
disconnected = false
}
})
must("enable BLE stack", adapter.Enable())
adv := adapter.DefaultAdvertisement()
must("config adv", adv.Configure(bluetooth.AdvertisementOptions{
LocalName: "TinyGo colors",
}))
must("start adv", adv.Start())
How do I (is it possible to ?) configure a handler that will be called each time a central device connects to my Linux (Raspbian) peripheral ?
Thank you !
Hello,
I am using your lib to create/manage a peripheral BLE device on an RPI 4.
It already works quite well, I can advertise and read/write with services and characteristics I defined. However, I would need to run a function each time a a Central device connects/disconnects to my RPI.
As I understood, the 'adapter.SetConnectHandler()' can be used for that, but it doesn't work for me.
Did I miss something ? My code is very similar to this example : https://github.com/tinygo-org/bluetooth/blob/v0.6.0/examples/circuitplay/main.go
How do I (is it possible to ?) configure a handler that will be called each time a central device connects to my Linux (Raspbian) peripheral ?
Thank you !