File tree 1 file changed +9
-3
lines changed
1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change 19
19
errNoWriteWithoutResponse = errors .New ("bluetooth: write without response not supported" )
20
20
errWriteFailed = errors .New ("bluetooth: write failed" )
21
21
errNoRead = errors .New ("bluetooth: read not supported" )
22
- errNoNotify = errors .New ("bluetooth: notify not supported" )
22
+ errNoNotify = errors .New ("bluetooth: notify/indicate not supported" )
23
23
errEnableNotificationsFailed = errors .New ("bluetooth: enable notifications failed" )
24
24
)
25
25
@@ -365,7 +365,8 @@ func (c *DeviceCharacteristic) Read(data []byte) (int, error) {
365
365
// notification with a new value every time the value of the characteristic
366
366
// changes.
367
367
func (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 ) {
369
370
return errNoNotify
370
371
}
371
372
@@ -403,7 +404,12 @@ func (c DeviceCharacteristic) EnableNotifications(callback func(buf []byte)) err
403
404
return err
404
405
}
405
406
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
+ }
407
413
if err != nil {
408
414
return err
409
415
}
You can’t perform that action at this time.
0 commit comments