-
Notifications
You must be signed in to change notification settings - Fork 174
Description
on Linux, DeviceCharacteristic.EnableNotifications calls WatchProperties and StartNotify on gatt.GattCharacteristic1.
but (as #106 noted) it doesn't call StopNotify nor UnwatchProperties.
this means the goroutine spawned by WatchProperties isn't properly closed nor collected.
(and it seems to me, client code can't call EnableNotifications again, once the first set of notifications has been collected.
another Device has to be created and connected anew)
the current API doesn't seem to easily allow for early cancellation of notifications either.
bluez seems to inject a poison pill (a nil value) into the channel and close it when UnwatchProperties is called.
so we'd need to drain that channel inside EnableNotifications.
to achieve proper goroutine collection and support early cancellation, we could either:
- modify the signature of the callback function to return an
errorand specify a special value for early cancellation, or - modify the signature of
EnableNotificationsto take an additional parameter (either acontext.Contextorchan struct{}) so user could notify us when to callStopNotify+UnwatchProperties
WDYT ?
(I don't know how to handle this for other platforms/OSes)