Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Duda committed Oct 17, 2024
2 parents 6420570 + 8073b41 commit 1d556f1
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 31 deletions.
21 changes: 14 additions & 7 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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
Binary file added Bleak_logo2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 6 additions & 2 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0
`Unreleased`_
=============

`0.22.3`_ (2024-10-05)
======================

Changed
-------
* In bleak.backends.winrt.util the SetTimer, KillTimer and CoGetApartmentType functions define their own prototype and don't change ctypes' global state anymore
* Don't change ctypes' global state ``bleak.backends.winrt.util``.
* Improved performance of BlueZ backend when there are many adapters.
* Added support for Python 3.13.
* **BREAKING CHANGE** Android backend do not request permissions in background. ``request_permissions()`` has to be called explicitly.
Expand Down Expand Up @@ -1045,7 +1048,8 @@ Fixed
* Bleak created.


.. _Unreleased: https://github.com/hbldh/bleak/compare/v0.22.2...develop
.. _Unreleased: https://github.com/hbldh/bleak/compare/v0.22.3...develop
.. _0.22.3: https://github.com/hbldh/bleak/compare/v0.22.2...v0.22.3
.. _0.22.2: https://github.com/hbldh/bleak/compare/v0.22.1...v0.22.2
.. _0.22.1: https://github.com/hbldh/bleak/compare/v0.22.0...v0.22.1
.. _0.22.0: https://github.com/hbldh/bleak/compare/v0.21.1...v0.22.0
Expand Down
14 changes: 7 additions & 7 deletions README.rst
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
=====
bleak
Bleak
=====

.. figure:: https://raw.githubusercontent.com/hbldh/bleak/master/Bleak_logo.png
:target: https://github.com/hbldh/bleak
:alt: Bleak Logo
:scale: 50%


.. image:: https://github.com/hbldh/bleak/workflows/Build%20and%20Test/badge.svg
:target: https://github.com/hbldh/bleak/actions?query=workflow%3A%22Build+and+Test%22
:alt: Build and Test
Expand All @@ -26,6 +20,12 @@ bleak
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black

.. container::

.. image:: Bleak_logo2.png
:target: https://github.com/hbldh/bleak
:alt: Bleak Logo

Bleak is an acronym for Bluetooth Low Energy platform Agnostic Klient.

* Free software: MIT license
Expand Down
2 changes: 1 addition & 1 deletion bleak/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ async def write_gatt_char(
data: Buffer,
response: bool = None,
) -> None:
"""
r"""
Perform a write operation on the specified GATT characteristic.
There are two possible kinds of writes. *Write with response* (sometimes
Expand Down
3 changes: 2 additions & 1 deletion bleak/backends/p4android/defs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 13 additions & 10 deletions bleak/backends/p4android/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,33 +97,36 @@ 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,
Permission.ACCESS_COARSE_LOCATION,
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
2 changes: 1 addition & 1 deletion bleak/uuids.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
1 change: 1 addition & 0 deletions examples/kivy/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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 <henrik.blidh@nedomkull.com>"]
license = "MIT"
Expand Down Expand Up @@ -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"
Expand Down

0 comments on commit 1d556f1

Please sign in to comment.