Skip to content

Commit

Permalink
Added force_indicate keyword argument for WinRT backend client's `s…
Browse files Browse the repository at this point in the history
…tart_notify` method.

Fixes hbldh#526
  • Loading branch information
hbldh committed Aug 12, 2021
1 parent c3afa7f commit 6c95846
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Added
~~~~~
* Allow 16-bit UUID string arguments to ``get_service()`` and ``get_characteristic()``.
* Added ``register_uuids()`` to augment the uuid-to-description mapping.
* Added ``force_notify`` keyword argument for WinRT backend client's ``start_notify`` method. Fixes #526.
* Added ``force_indicate`` keyword argument for WinRT backend client's ``start_notify`` method. Fixes #526.

Fixed
~~~~~
Expand Down
22 changes: 11 additions & 11 deletions bleak/backends/winrt/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -735,8 +735,8 @@ def callback(sender, data):
callback (function): The function to be called on notification.
Keyword Args:
force_notify (bool): If this is set to True, then Bleak will set up notification request instead of a
indication request, given that the characteristic supports notifications as well as indications.
force_indicate (bool): If this is set to True, then Bleak will set up a indication request instead of a
notification request, given that the characteristic supports notifications as well as indications.
"""
if inspect.iscoroutinefunction(callback):
Expand All @@ -760,22 +760,22 @@ def bleak_callback(s, d):
characteristic_obj = characteristic.obj
if (
characteristic_obj.characteristic_properties
& GattCharacteristicProperties.INDICATE
& GattCharacteristicProperties.NOTIFY
):
if kwargs.get("force_notify", False) and (
if kwargs.get("force_indicate", False) and (
characteristic_obj.characteristic_properties
& GattCharacteristicProperties.NOTIFY
& GattCharacteristicProperties.INDICATE
):
# If we want to force notify even when indicate is available, also check if the device
# actually supports notify as well.
cccd = GattClientCharacteristicConfigurationDescriptorValue.NOTIFY
else:
# If we want to force indicate even when notify is available, also check if the device
# actually supports indicate as well.
cccd = GattClientCharacteristicConfigurationDescriptorValue.INDICATE
else:
cccd = GattClientCharacteristicConfigurationDescriptorValue.NOTIFY
elif (
characteristic_obj.characteristic_properties
& GattCharacteristicProperties.NOTIFY
& GattCharacteristicProperties.INDICATE
):
cccd = GattClientCharacteristicConfigurationDescriptorValue.NOTIFY
cccd = GattClientCharacteristicConfigurationDescriptorValue.INDICATE
else:
cccd = GattClientCharacteristicConfigurationDescriptorValue.NONE

Expand Down

0 comments on commit 6c95846

Please sign in to comment.