diff --git a/.readthedocs.yml b/.readthedocs.yml index 614cce70..2a0a8534 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -7,9 +7,21 @@ version: 2 # Set the version of Python and other tools you might need build: - os: ubuntu-22.04 + os: ubuntu-24.04 tools: - python: "3.9" + python: "3.12" + jobs: + post_create_environment: + # Install poetry + # https://python-poetry.org/docs/#installing-manually + - pip install poetry + post_install: + # Install dependencies with 'docs' dependency group + # https://python-poetry.org/docs/managing-dependencies/#dependency-groups + # VIRTUAL_ENV needs to be set manually for now. + # See https://github.com/readthedocs/readthedocs.org/pull/11152/ + - VIRTUAL_ENV=$READTHEDOCS_VIRTUALENV_PATH poetry install --only docs + # Build documentation in the docs/ directory with Sphinx sphinx: @@ -18,8 +30,3 @@ sphinx: # If using Sphinx, optionally build your docs in additional formats such as PDF formats: - pdf - -# Optionally declare the Python requirements required to build your docs -python: - install: - - requirements: docs/requirements.txt diff --git a/Bleak_logo2.png b/Bleak_logo2.png new file mode 100644 index 00000000..748ad6e9 Binary files /dev/null and b/Bleak_logo2.png differ diff --git a/CHANGELOG.rst b/CHANGELOG.rst index f712cded..3a8658e2 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -10,9 +10,12 @@ and this project adheres to `Semantic Versioning None: - """ + r""" Perform a write operation on the specified GATT characteristic. There are two possible kinds of writes. *Write with response* (sometimes diff --git a/bleak/backends/p4android/defs.py b/bleak/backends/p4android/defs.py index c1d894d0..a839c320 100644 --- a/bleak/backends/p4android/defs.py +++ b/bleak/backends/p4android/defs.py @@ -36,7 +36,8 @@ BLEAK_JNI_NAMESPACE + ".PythonBluetoothGattCallback" ) -VERSION = autoclass('android.os.Build$VERSION') +VERSION = autoclass("android.os.Build$VERSION") + class ScanFailed(enum.IntEnum): ALREADY_STARTED = ScanCallback.SCAN_FAILED_ALREADY_STARTED diff --git a/bleak/backends/p4android/utils.py b/bleak/backends/p4android/utils.py index 0bcd09b3..ec1da99c 100644 --- a/bleak/backends/p4android/utils.py +++ b/bleak/backends/p4android/utils.py @@ -97,20 +97,21 @@ def _result_state_unthreadsafe(self, failure_str, source, data): # send it on the event thread raise exception + async def request_permissions(permissions: Optional[List[str]] = None) -> None: loop = asyncio.get_running_loop() permission_acknowledged = loop.create_future() + def handle_permissions(permissions, grantResults): if any(grantResults): - loop.call_soon_threadsafe( - permission_acknowledged.set_result, grantResults - ) + loop.call_soon_threadsafe(permission_acknowledged.set_result, grantResults) else: loop.call_soon_threadsafe( permission_acknowledged.set_exception( BleakError("User denied access to " + str(permissions)) ) ) + if permissions is None: permissions = [ Permission.ACCESS_FINE_LOCATION, @@ -118,12 +119,14 @@ def handle_permissions(permissions, grantResults): Permission.ACCESS_BACKGROUND_LOCATION, ] if defs.VERSION.SDK_INT >= 31: - permissions.extend([ - Permission.BLUETOOTH_SCAN, - Permission.BLUETOOTH_CONNECT, - ]) + permissions.extend( + [ + Permission.BLUETOOTH_SCAN, + Permission.BLUETOOTH_CONNECT, + ] + ) request_android_permissions( - permissions, - handle_permissions, - ) + permissions, + handle_permissions, + ) await permission_acknowledged diff --git a/bleak/uuids.py b/bleak/uuids.py index 2730e506..1e91aacc 100644 --- a/bleak/uuids.py +++ b/bleak/uuids.py @@ -1066,7 +1066,7 @@ "e95d9775-251d-470a-a062-fa1922dfa9a8": "MicroBit Event Data", "e95d23c4-251d-470a-a062-fa1922dfa9a8": "MicroBit Client Requirements", "e95d5404-251d-470a-a062-fa1922dfa9a8": "MicroBit Client Events", - "e95d93b0-251d-470a-a062-fa1922dfa9a8": "MicroBit DFU Control Service" "", + "e95d93b0-251d-470a-a062-fa1922dfa9a8": "MicroBit DFU Control Service", "e95d93b1-251d-470a-a062-fa1922dfa9a8": "MicroBit DFU Control", "e95d6100-251d-470a-a062-fa1922dfa9a8": "MicroBit Temperature Service", "e95d1b25-251d-470a-a062-fa1922dfa9a8": "MicroBit Temperature Period", diff --git a/examples/kivy/main.py b/examples/kivy/main.py index b0fd349e..20856550 100644 --- a/examples/kivy/main.py +++ b/examples/kivy/main.py @@ -41,6 +41,7 @@ def on_stop(self): async def example(self): if os.environ.get("P4A_BOOTSTRAP") is not None: from bleak.backends.p4android.utils import request_permissions + await request_permissions() while self.running: try: diff --git a/poetry.lock b/poetry.lock index 1502fd2c..dc89670d 100644 --- a/poetry.lock +++ b/poetry.lock @@ -1160,4 +1160,4 @@ test = ["big-O", "jaraco.functools", "jaraco.itertools", "jaraco.test", "more-it [metadata] lock-version = "2.0" python-versions = ">=3.8,<3.14" -content-hash = "d6a83c8e26778000e1189a9497dbc4adba6b439c489b4ee59be66a412d68aac2" +content-hash = "22885f16b59e72fb2bcf6fd88c81cabc7d48ebb05555f12375226200ca26c61e" diff --git a/pyproject.toml b/pyproject.toml index 0a5c9a94..19559eef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "bleak" -version = "0.22.2" +version = "0.22.3" description = "Bluetooth Low Energy platform Agnostic Klient" authors = ["Henrik Blidh "] license = "MIT" @@ -42,6 +42,7 @@ dbus-fast = { version = ">=1.83.0, < 3", markers = "platform_system == 'Linux'" [tool.poetry.group.docs.dependencies] Sphinx = "^5.1.1" sphinx-rtd-theme = "^1.0.0" +tomli = "^2.0.1" [tool.poetry.group.lint.dependencies] black = ">=24.3,<25.0"