bluetooth
bluetooth copied to clipboard
Internal Characteristic.Write calls CharacteristicConfig.WriteEvent which could lead to an infinite loop
Hello,
I have a specific case where the call of Characteristic.Write can lead to a infinite loop. A write call updates a UART device with new values. The UART device sends back the acknowledgement of those values, which I set to the newest characteristic value, which I can only set with Characteristic.Write. This leads to an infinite loop.
I forked the repository and added this
// UpdateValue replaces the characteristic value with a new value without handling write callbacks
func (c *Characteristic) UpdateValue(p []byte) (n int, err error) {
if len(p) == 0 {
return 0, nil // nothing to do
}
c.handle.Properties.Value = p
c.handle.DBusProperties().Instance().Set(c.handle.Interface(), "Value", dbus.MakeVariant(p))
return len(p), nil
}
I wanted to know if that happened to anyone else and if there is a better way to solve that issue.
Hello, I am having this issue too. This is really annoying and I'm honestly not sure why this is happening in base TGO Bluetooth in the first place. It seems silly tbh.