From fe363b98fbd9066a312614c47b5b3d896cf683de Mon Sep 17 00:00:00 2001 From: Alexis Couvreur Date: Fri, 3 Oct 2025 22:15:09 -0400 Subject: [PATCH 1/2] feat(gattc): add CanSendWriteWithoutResponse for darwin --- gattc_darwin.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/gattc_darwin.go b/gattc_darwin.go index 2d737dad..ba16e3e3 100644 --- a/gattc_darwin.go +++ b/gattc_darwin.go @@ -199,8 +199,9 @@ func (c DeviceCharacteristic) Write(p []byte) (n int, err error) { // WriteWithoutResponse replaces the characteristic value with a new value. The // call will return before all data has been written. A limited number of such -// writes can be in flight at any given time. This call is also known as a -// "write command" (as opposed to a write request). +// writes can be in flight at any given time. +// You can use CanSendWriteWithoutResponse to check if you can send more writes. +// This call is also known as a "write command" (as opposed to a write request). func (c DeviceCharacteristic) WriteWithoutResponse(p []byte) (n int, err error) { c.service.device.prph.WriteCharacteristic(p, c.characteristic, false) @@ -227,6 +228,11 @@ func (c DeviceCharacteristic) GetMTU() (uint16, error) { return uint16(c.service.device.prph.MaximumWriteValueLength(false)), nil } +// CanSendWriteWithoutResponse returns the MTU for the characteristic. +func (c DeviceCharacteristic) CanSendWriteWithoutResponse() bool { + return c.service.device.prph.CanSendWriteWithoutResponse() +} + // Read reads the current characteristic value. func (c *deviceCharacteristic) Read(data []byte) (n int, err error) { c.readChan = make(chan error) From 6b21611f009a4f1ecaae21c0757a1797fb2fd0aa Mon Sep 17 00:00:00 2001 From: Alexis Couvreur Date: Fri, 3 Oct 2025 22:26:13 -0400 Subject: [PATCH 2/2] fix doc --- gattc_darwin.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gattc_darwin.go b/gattc_darwin.go index ba16e3e3..c2b01e78 100644 --- a/gattc_darwin.go +++ b/gattc_darwin.go @@ -228,7 +228,11 @@ func (c DeviceCharacteristic) GetMTU() (uint16, error) { return uint16(c.service.device.prph.MaximumWriteValueLength(false)), nil } -// CanSendWriteWithoutResponse returns the MTU for the characteristic. +// CanSendWriteWithoutResponse returns whether a WriteWithoutResponse can be sent +// at this time. If this returns false, you must wait for some time before +// sending another WriteWithoutResponse. This is typically because the internal +// buffer is full. You can use this to implement your own flow control when +// sending many WriteWithoutResponse calls in a row. func (c DeviceCharacteristic) CanSendWriteWithoutResponse() bool { return c.service.device.prph.CanSendWriteWithoutResponse() }