Skip to content

Commit

Permalink
Issue #311 Clean resources properly when disable notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Raif Gabdullin committed Dec 23, 2024
1 parent 5cc5c45 commit af79422
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion gattc_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ func (c DeviceCharacteristic) WriteWithoutResponse(p []byte) (n int, err error)
// changes.
//
// Users may call EnableNotifications with a nil callback to disable notifications.
func (c DeviceCharacteristic) EnableNotifications(callback func(buf []byte)) error {
func (c *DeviceCharacteristic) EnableNotifications(callback func(buf []byte)) error {
switch callback {
default:
if c.property != nil {
Expand Down Expand Up @@ -280,6 +280,7 @@ func (c DeviceCharacteristic) EnableNotifications(callback func(buf []byte)) err

err := c.adapter.bus.RemoveMatchSignal(c.propertiesChangedMatchOption)
c.adapter.bus.RemoveSignal(c.property)
close(c.property)
c.property = nil
return err
}
Expand Down

0 comments on commit af79422

Please sign in to comment.