Skip to content

timeout and state of advertising & keyboard leds info #98

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
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
12 changes: 11 additions & 1 deletion adafruit_ble/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,18 @@ def __init__(self, adapter=None):
self._current_advertisement = None
self._connection_cache = {}

def start_advertising(self, advertisement, scan_response=None, interval=0.1):
def start_advertising(
self, advertisement, scan_response=None, interval=0.1, timeout=None
):
"""
Starts advertising the given advertisement.

:param buf scan_response: scan response data packet bytes.
If ``None``, a default scan response will be generated that includes
`BLERadio.name` and `BLERadio.tx_power`.
:param float interval: advertising interval, in seconds
:param int timeout: advertising timeout in seconds.
If None, no timeout.
"""
advertisement_bytes = bytes(advertisement)
scan_response_bytes = b""
Expand All @@ -184,6 +188,7 @@ def start_advertising(self, advertisement, scan_response=None, interval=0.1):
scan_response=scan_response_bytes,
connectable=advertisement.connectable,
interval=interval,
timeout=0 if timeout is None else timeout,
)

def stop_advertising(self):
Expand Down Expand Up @@ -321,3 +326,8 @@ def tx_power(self, value):
def address_bytes(self):
"""The device address, as a ``bytes()`` object of length 6."""
return self._adapter.address.address_bytes

@property
def advertising(self):
"""The advertising state"""
return self._adapter.advertising
5 changes: 5 additions & 0 deletions adafruit_ble/services/standard/hid.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,11 @@ def __init__(self, service, report_id, usage_page, usage, *, max_length):
initial_value=struct.pack("<BB", self._report_id, _REPORT_TYPE_OUTPUT),
)

@property
def report(self):
"""The HID OUT report"""
return self._characteristic.value


_ITEM_TYPE_MAIN = const(0)
_ITEM_TYPE_GLOBAL = const(1)
Expand Down