Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions gattc_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (
"github.com/tinygo-org/cbgo"
)

var (
errCannotSendWriteWithoutResponse = errors.New("bluetooth: cannot send write without response (buffer full)")
)

// DiscoverServices starts a service discovery procedure. Pass a list of service
// UUIDs you are interested in to this function. Either a slice of all services
// is returned (of the same length as the requested UUIDs and in the same
Expand Down Expand Up @@ -199,9 +203,13 @@ 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).
func (c DeviceCharacteristic) WriteWithoutResponse(p []byte) (n int, err error) {
// writes can be in flight at any given time.
// If the client is not ready to send write without response requests at this time (e.g. because the internal buffer is full), an error is returned.
func (c DeviceCharacteristic) WriteWithoutResponse(p []byte) (int, error) {
if !c.service.device.prph.CanSendWriteWithoutResponse() {
return 0, errCannotSendWriteWithoutResponse
}

c.service.device.prph.WriteCharacteristic(p, c.characteristic, false)

return len(p), nil
Expand Down
Loading