From f8b9dd9128acd8bcd561fe3090bde13a0a4306cd Mon Sep 17 00:00:00 2001 From: aventari Date: Tue, 28 Oct 2025 16:43:46 -0700 Subject: [PATCH] Update gattc_linux.go to properly unsubscribe from notifications using dbus call --- gattc_linux.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/gattc_linux.go b/gattc_linux.go index 0202e985..bbf96ac0 100644 --- a/gattc_linux.go +++ b/gattc_linux.go @@ -277,12 +277,19 @@ func (c *DeviceCharacteristic) EnableNotifications(callback func(buf []byte)) er if c.property == nil { return nil } - - err := c.adapter.bus.RemoveMatchSignal(c.propertiesChangedMatchOption) + // Make the D-Bus call to stop notifications on the characteristic. + stopNotifyErr := c.characteristic.Call("org.bluez.GattCharacteristic1.StopNotify", 0).Err + // Still clean up other resources if there was an error + removeSignalErr := c.adapter.bus.RemoveMatchSignal(c.propertiesChangedMatchOption) c.adapter.bus.RemoveSignal(c.property) close(c.property) c.property = nil - return err + + // If there were errors, prioritize notify err + if stopNotifyErr == nil { + return removeSignalErr + } + return stopNotifyErr } }