File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 1919 errNoWriteWithoutResponse = errors .New ("bluetooth: write without response not supported" )
2020 errWriteFailed = errors .New ("bluetooth: write failed" )
2121 errNoRead = errors .New ("bluetooth: read not supported" )
22- errNoNotify = errors .New ("bluetooth: notify not supported" )
22+ errNoNotify = errors .New ("bluetooth: notify/indicate not supported" )
2323 errEnableNotificationsFailed = errors .New ("bluetooth: enable notifications failed" )
2424)
2525
@@ -365,7 +365,8 @@ func (c *DeviceCharacteristic) Read(data []byte) (int, error) {
365365// notification with a new value every time the value of the characteristic
366366// changes.
367367func (c DeviceCharacteristic ) EnableNotifications (callback func (buf []byte )) error {
368- if c .properties & genericattributeprofile .GattCharacteristicPropertiesNotify == 0 {
368+ if (c .properties & genericattributeprofile .GattCharacteristicPropertiesNotify == 0 ) &&
369+ (c .properties & genericattributeprofile .GattCharacteristicPropertiesIndicate == 0 ) {
369370 return errNoNotify
370371 }
371372
@@ -403,7 +404,12 @@ func (c DeviceCharacteristic) EnableNotifications(callback func(buf []byte)) err
403404 return err
404405 }
405406
406- writeOp , err := c .characteristic .WriteClientCharacteristicConfigurationDescriptorAsync (genericattributeprofile .GattClientCharacteristicConfigurationDescriptorValueNotify )
407+ var writeOp * foundation.IAsyncOperation
408+ if c .properties & genericattributeprofile .GattCharacteristicPropertiesNotify != 0 {
409+ writeOp , err = c .characteristic .WriteClientCharacteristicConfigurationDescriptorAsync (genericattributeprofile .GattClientCharacteristicConfigurationDescriptorValueNotify )
410+ } else {
411+ writeOp , err = c .characteristic .WriteClientCharacteristicConfigurationDescriptorAsync (genericattributeprofile .GattClientCharacteristicConfigurationDescriptorValueIndicate )
412+ }
407413 if err != nil {
408414 return err
409415 }
You can’t perform that action at this time.
0 commit comments