Skip to content

Commit

Permalink
Merge pull request #232 from hbldh/release/v0.7.0
Browse files Browse the repository at this point in the history
Release of version 0.7.0 of bleak.
  • Loading branch information
hbldh authored Jun 30, 2020
2 parents 9c87ac0 + 6780ccb commit 5e8f8de
Show file tree
Hide file tree
Showing 48 changed files with 1,018 additions and 392 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
exclude:
- os: windows-latest
python-version: 3.8
- os: macos-latest
python-version: 3.5
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand Down
8 changes: 8 additions & 0 deletions .pyup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
update: all
pin: True
branch: develop
schedule: "every day"
search: True
assignees:
- hbldh
branch_prefix: pyup/
2 changes: 2 additions & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ Development Lead

Contributors
------------

* David Lechner <david@pybricks.com>
121 changes: 105 additions & 16 deletions HISTORY.rst → CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,34 +1,114 @@
=======
History
=======

0.6.4 (2020-05-20)
------------------
=========
Changelog
=========

All notable changes to this project will be documented in this file.

The format is based on `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`_,
and this project adheres to `Semantic Versioning <https://semver.org/spec/v2.0.0.html>`_.


`0.7.0`_ (2020-06-30)
---------------------

Added
~~~~~

* Better feedback of communication errors to user in .NET backend and implementing error details proposed in #174.
* Two devices example file to use for e.g. debugging.
* Detection/discovery callbacks in Core Bluetooth backend ``Scanner`` implemented.
* Characteristic handle printout in ``service_explorer.py``.
* Added scanning filters to .NET backend's ``discover`` method.

Changed
~~~~~~~

* Replace ``NSRunLoop`` with dispatch queue in Core Bluetooth backend. This causes callbacks to be dispatched on a
background thread instead of on the main dispatch queue on the main thread. ``call_soon_threadsafe()`` is used to synchronize the events
with the event loop where the central manager was created. Fixes #111.
* The Central Manager is no longer global in the Core Bluetooth backend. A new one is created for each
``BleakClient`` and ``BleakScanner``. Fixes #206 and #105.
* Merged #167 and reworked characteristics handling in Bleak. Implemented in all backends;
bleak now uses the characteristics' handle to identify and keep track of them.
Fixes #139 and #159 and allows connection for devices with multiple instances
of the same characteristic UUIDs.
* In ``requirements.txt`` and ``Pipfile``, the requirement on ``pythonnet``
was bumped to version 2.5.1, which seems to solve issues described in #217 and #225.
* Renamed ``HISTORY.rst`` to ``CHANGELOG.rst`` and adopted
the `Keep a Changelog <https://keepachangelog.com/en/1.0.0/>`_ format.
* Python 3.5 support from macOS is officially removed since pyobjc>6 requires 3.6+
* Pin ``pyobjc`` dependencies to use at least version 6.2. (PR #194)
* Pin development requirement on `bump2version` to version 1.0.0
* Added ``.pyup.yml`` for Pyup
* Using CBManagerState constants from pyobj instead of integers.

Removed
~~~~~~~

* Removed documentation note about not using new event loops in Linux. This was fixed by #143.
* ``_central_manager_delegate_ready`` was removed in macOS backend.
* Removed the ``bleak.backends.bluez.utils.get_gatt_service_path`` method. It is not used by
bleak and possibly generates errors.

Fixed
~~~~~

* Improved handling of the txdbus connection to avoid hanging of disconnection
clients in BlueZ backend. Fixes #216, #219 & #221.
* #150 hints at the device path not being possible to create as is done in the `get_device_object_path` method.
Now, we try to get it from BlueZ first. Otherwise, use the old fallback.
* Minor documentation errors corrected.
* ``CBManagerStatePoweredOn`` is now properly handled in Core Bluetooth.
* Device enumeration in ``discover``and ``Scanner`` corrected. Fixes #211
* Updated documentation about scanning filters.
* Added workaround for ``isScanning`` attribute added in macOS 10.13. Fixes #234.

`0.6.4`_ (2020-05-20)
---------------------

Fixed
~~~~~

* Fix for bumpversion usage

0.6.3 (2020-05-20)
------------------
`0.6.3`_ (2020-05-20)
---------------------

Added
~~~~~

* Building and releasing from Github Actions

0.6.2 (2020-05-15)
------------------
Removed
~~~~~~~

* Building and releasing on Azure Pipelines

`0.6.2`_ (2020-05-15)
---------------------

Added
~~~~~
* Added ``disconnection_callback`` functionality for Core Bluetooth (#184 & #186)
* Added ``requirements.txt``

Fixed
~~~~~
* Better cleanup of Bluez notifications (#154)
* Fix for ``read_gatt_char`` in Core Bluetooth (#177)
* Fix for ``is_disconnected`` in Core Bluetooth (#187 & #185)
* Added ``disconnection_callback`` functionality for Core Bluetooth (#184 & #186)
* Documentation fixes
* Added ``requirements.txt``

0.6.1 (2020-03-09)
------------------
`0.6.1`_ (2020-03-09)
---------------------

Fixed
~~~~~

* Including #156, lost notifications on macOS backend, which was accidentally missed on previous release.

0.6.0 (2020-03-09)
------------------
`0.6.0`_ (2020-03-09)
---------------------

* New Scanner object to allow for async device scanning.
* Updated ``txdbus`` requirement to version 1.1.1 (Merged #122)
Expand Down Expand Up @@ -149,3 +229,12 @@ History
------------------

* Bleak created.


.. _Unreleased: https://github.com/hbldh/bleak/compare/v0.7.0...develop
.. _0.7.0: https://github.com/hbldh/bleak/compare/v0.7.0...v0.6.4
.. _0.6.4: https://github.com/hbldh/bleak/compare/v0.6.3...v0.6.4
.. _0.6.3: https://github.com/hbldh/bleak/compare/v0.6.2...v0.6.3
.. _0.6.2: https://github.com/hbldh/bleak/compare/v0.6.1...v0.6.2
.. _0.6.1: https://github.com/hbldh/bleak/compare/v0.6.0...v0.6.1
.. _0.6.0: https://github.com/hbldh/bleak/compare/v0.5.1...v0.6.0
13 changes: 5 additions & 8 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,9 @@ Before you submit a pull request, check that it meets these guidelines:
2. If the pull request adds functionality, the docs should be updated. Put
your new functionality into a function with a docstring, and add the
feature to the list in README.rst.
3. The pull request should work for Python 3.5+.

Tips
----

To run a subset of tests::

$ py.test tests.test_bleak
3. The pull request should work for Python 3.5+ on the following platforms:
- Windows 10, version 16299 (Fall Creators Update) and greater
- Linux distributions with BlueZ >= 5.43
- OS X / macOS >= 10.11
4. Feel free to add your name to the ``AUTHORS.rst`` in the root of the project!

2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

MIT License

Copyright (c) 2019, Henrik Blidh
Copyright (c) 2020, Henrik Blidh

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

Expand Down
7 changes: 4 additions & 3 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ name = "pypi"

[packages]
txdbus = {version = ">=1.1.1", sys_platform = "== 'linux'"}
pyobjc = {version = "*", sys_platform = "== 'darwin'"}
pyobjc-framework-CoreBluetooth = {version = "*", sys_platform = "== 'darwin'"}
pythonnet = {version = ">=2.3.0", sys_platform = "== 'win32'"}
pyobjc-core = {version = ">=6.2", sys_platform = "== 'darwin'"}
pyobjc-framework-CoreBluetooth = {version = ">=6.2", sys_platform = "== 'darwin'"}
pyobjc-framework-libdispatch = {version = ">=6.2", sys_platform = "== 'darwin'"}
pythonnet = {version = ">=2.5.1", sys_platform = "== 'win32'"}

[dev-packages]
pytest = "*"
Expand Down
3 changes: 0 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,6 @@ bleak
:target: https://github.com/hbldh/bleak/actions?query=workflow%3A%22Build+and+Test%22
:alt: Build and Test

.. image:: https://dev.azure.com/hbldh/github/_apis/build/status/hbldh.bleak?branchName=master
:target: https://dev.azure.com/hbldh/github/_build/latest?definitionId=4&branchName=master

.. image:: https://img.shields.io/pypi/v/bleak.svg
:target: https://pypi.python.org/pypi/bleak

Expand Down
2 changes: 1 addition & 1 deletion bleak/__version__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# -*- coding: utf-8 -*-

__version__ = "0.6.4"
__version__ = "0.7.0"
29 changes: 26 additions & 3 deletions bleak/backends/bluezdbus/characteristic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from uuid import UUID
from typing import Union, List

Expand Down Expand Up @@ -25,6 +26,8 @@
# "authorize"
}

_handle_regex = re.compile('/char([0-9a-fA-F]*)')


class BleakGATTCharacteristicBlueZDBus(BleakGATTCharacteristic):
"""GATT Characteristic implementation for the BlueZ DBus backend"""
Expand All @@ -35,11 +38,28 @@ def __init__(self, obj: dict, object_path: str, service_uuid: str):
self.__path = object_path
self.__service_uuid = service_uuid

# The `Handle` attribute is added in BlueZ Release 5.51. Empirically,
# it seems to hold true that the "/charYYYY" that is at the end of the
# DBUS path actually is the desired handle. Using regex to extract
# that and using as handle, since handle is mostly used for keeping
# track of characteristics (internally in bleak anyway).
self._handle = self.obj.get("Handle")
if not self._handle:
_handle_from_path = _handle_regex.search(self.path)
if _handle_from_path:
self._handle = int(_handle_from_path.groups()[0], 16)
self._handle = int(self._handle)

@property
def service_uuid(self) -> str:
"""The uuid of the Service containing this characteristic"""
return self.__service_uuid

@property
def handle(self) -> int:
"""The handle of this characteristic"""
return self._handle

@property
def uuid(self) -> str:
"""The uuid of this characteristic"""
Expand All @@ -65,11 +85,14 @@ def descriptors(self) -> List:
return self.__descriptors

def get_descriptor(
self, _uuid: Union[str, UUID]
self, specifier: Union[int, str, UUID]
) -> Union[BleakGATTDescriptor, None]:
"""Get a descriptor by UUID"""
"""Get a descriptor by handle (int) or UUID (str or uuid.UUID)"""
try:
return next(filter(lambda x: x.uuid == _uuid, self.descriptors))
if isinstance(specifier, int):
return next(filter(lambda x: x.handle == specifier, self.descriptors))
else:
return next(filter(lambda x: x.uuid == str(specifier), self.descriptors))
except StopIteration:
return None

Expand Down
Loading

0 comments on commit 5e8f8de

Please sign in to comment.