File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -277,12 +277,19 @@ func (c *DeviceCharacteristic) EnableNotifications(callback func(buf []byte)) er
277277 if c .property == nil {
278278 return nil
279279 }
280-
281- err := c .adapter .bus .RemoveMatchSignal (c .propertiesChangedMatchOption )
280+ // Make the D-Bus call to stop notifications on the characteristic.
281+ stopNotifyErr := c .characteristic .Call ("org.bluez.GattCharacteristic1.StopNotify" , 0 ).Err
282+ // Still clean up other resources if there was an error
283+ removeSignalErr := c .adapter .bus .RemoveMatchSignal (c .propertiesChangedMatchOption )
282284 c .adapter .bus .RemoveSignal (c .property )
283285 close (c .property )
284286 c .property = nil
285- return err
287+
288+ // If there were errors, prioritize notify err
289+ if stopNotifyErr == nil {
290+ return removeSignalErr
291+ }
292+ return stopNotifyErr
286293 }
287294}
288295
You can’t perform that action at this time.
0 commit comments