bluetooth icon indicating copy to clipboard operation
bluetooth copied to clipboard

Internal Characteristic.Write calls CharacteristicConfig.WriteEvent which could lead to an infinite loop

Open skast96 opened this issue 3 years ago • 1 comments

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.

skast96 avatar Feb 24 '22 15:02 skast96

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.

StupidRepo avatar Apr 26 '25 23:04 StupidRepo