Skip to content

Commit

Permalink
Merge pull request #279 from hbldh/release/v0.8.0
Browse files Browse the repository at this point in the history
Release/v0.8.0
  • Loading branch information
hbldh authored Sep 14, 2020
2 parents 3c948ef + efc5011 commit aa54b08
Show file tree
Hide file tree
Showing 42 changed files with 1,192 additions and 476 deletions.
24 changes: 16 additions & 8 deletions BleakUWPBridge/BleakUWPBridge/Bridge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,36 @@

namespace BleakBridge
{
public class Bridge
public class Bridge: IDisposable
{
public Dictionary<Guid, TypedEventHandler<GattCharacteristic, GattValueChangedEventArgs>> callbacks;
public Dictionary<ushort, TypedEventHandler<GattCharacteristic, GattValueChangedEventArgs>> callbacks;

public Bridge()
{
callbacks = new Dictionary<Guid, TypedEventHandler<GattCharacteristic, GattValueChangedEventArgs>>();
callbacks = new Dictionary<ushort, TypedEventHandler<GattCharacteristic, GattValueChangedEventArgs>>();
}

public void Dispose()
{
callbacks.Clear();
}

#region Notifications

public void AddValueChangedCallback(GattCharacteristic characteristic, TypedEventHandler<GattCharacteristic, GattValueChangedEventArgs> callback)
{
this.callbacks[characteristic.Uuid] = callback;
this.callbacks[characteristic.AttributeHandle] = callback;
characteristic.ValueChanged += callback;
}

public void RemoveValueChangedCallback(GattCharacteristic characteristic, TypedEventHandler<GattCharacteristic, GattValueChangedEventArgs> callback)
public void RemoveValueChangedCallback(GattCharacteristic characteristic)
{
var stored_callback = this.callbacks[characteristic.Uuid];
this.callbacks.Remove(characteristic.Uuid);
characteristic.ValueChanged -= stored_callback;
if (this.callbacks.ContainsKey(characteristic.AttributeHandle))
{
var stored_callback = this.callbacks[characteristic.AttributeHandle];
this.callbacks.Remove(characteristic.AttributeHandle);
characteristic.ValueChanged -= stored_callback;
}
}

#endregion
Expand Down
10 changes: 5 additions & 5 deletions BleakUWPBridge/BleakUWPBridge/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Reflection;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;

Expand All @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BleakUWPBridge")]
[assembly: AssemblyCopyright("Copyright © Henrik Blidh 2018")]
[assembly: AssemblyCopyright("Copyright © Henrik Blidh 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -24,6 +24,6 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.4.0.0")]
[assembly: AssemblyFileVersion("0.4.0.0")]
[assembly: ComVisible(false)]
[assembly: AssemblyVersion("0.5.0.0")]
[assembly: AssemblyFileVersion("0.5.0.0")]
[assembly: ComVisible(false)]
47 changes: 46 additions & 1 deletion CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,49 @@ 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.8.0`_ (2020-09-02)
---------------------

Added
~~~~~

* Added ``find_device_by_address`` method to the ``BleakScanner`` interface, for stopping scanning
when a desired address is found.
* Implemented ``find_device_by_address`` in the .NET backend ``BleakScanner`` implementation and
switched its ``BleakClient`` implementation to use that method in ``connect``.
* Implemented ``find_device_by_address`` in the BlueZ backend ``BleakScanner`` implementation and
switched its ``BleakClient`` implementation to use that method in ``connect``.
* Implemented ``find_device_by_address`` in the Core Bluetooth backend ``BleakScanner`` implementation
and switched its ``BleakClient`` implementation to use that method in ``connect``.
* Added text representations of Protocol Errors that are visible in the .NET backend. Added these texts to errors raised.
* Added pairing method in ``BleakClient`` interface.
* Implemented pairing method in .NET backend.
* Implemented pairing method in the BlueZ backend.
* Added stumps and ``NotImplementedError`` on pairing in macOS backend.

Changed
~~~~~~~
* **BREAKING CHANGE** All notifications now have the characteristic's integer **handle** instead of its UUID as a
string as the first argument ``sender`` sent to notification callbacks. This provides the uniqueness of
sender in notifications as well.
* Version 0.5.0 of BleakUWPBridge, with some modified methods and implementing ``IDisposable``.
* Merged #224. All storing and passing of event loops in bleak is removed.
* Removed Objective C delegate compliance checks. Merged #253.

Fixed
~~~~~

* .NET backend loop handling bug entered by #224 fixed.
* Removed default ``DEBUG`` level set to bleak logger. Fixes #251.
* More coherency in logger uses over all backends. Fixes #258
* Attempted fix of #255 and #133: cleanups, disposing of objects and creating new ``BleakBridge`` instances each disconnect.
* Fixed some type hints and docstrings.
* Modified the ``connected_peripheral_delegate`` handling in macOS backend to fix #213 and #116.
* Merged #270, fixing a critical bug in ``get_services`` method in Core Bluetooth backend.
* Improved handling of disconnections and ``is_connected`` in BlueZ backend to fix #259.
* Fix for ``set_disconnected_callback`` on Core Bluetooth. Fixes #276.
* Safer `Core Bluetooth` presence check. Merged #280.

`0.7.1`_ (2020-07-02)
---------------------

Expand All @@ -22,6 +65,7 @@ Fixed
~~~~~

* Fix when characteristic updates value faster than asyncio schedule (#240 & #241)
* Incorrect ``MANIFEST.in`` corrected. (#244)


`0.7.0`_ (2020-06-30)
Expand Down Expand Up @@ -247,7 +291,8 @@ Fixed
* Bleak created.


.. _Unreleased: https://github.com/hbldh/bleak/compare/v0.7.1...develop
.. _Unreleased: https://github.com/hbldh/bleak/compare/v0.8.0...develop
.. _0.8.0: https://github.com/hbldh/bleak/compare/v0.8.0...v0.7.1
.. _0.7.1: https://github.com/hbldh/bleak/compare/v0.7.1...v0.7.0
.. _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
Expand Down
6 changes: 3 additions & 3 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ Connect to a Bluetooth device and read its model number:
address = "24:71:89:cc:09:05"
MODEL_NBR_UUID = "00002a24-0000-1000-8000-00805f9b34fb"
async def run(address, loop):
async with BleakClient(address, loop=loop) as client:
async def run(address):
async with BleakClient(address) as client:
model_number = await client.read_gatt_char(MODEL_NBR_UUID)
print("Model Number: {0}".format("".join(map(chr, model_number))))
loop = asyncio.get_event_loop()
loop.run_until_complete(run(address, loop))
loop.run_until_complete(run(address))
See examples folder for more code, for instance example code for connecting to a
Expand Down
10 changes: 5 additions & 5 deletions bleak/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@

_logger = logging.getLogger(__name__)
_logger.addHandler(logging.NullHandler())
_logger.setLevel(logging.DEBUG)
if bool(os.environ.get("BLEAK_LOGGING", False)):
FORMAT = "%(asctime)-15s %(name)-8s %(levelname)s: %(message)s"
handler = logging.StreamHandler(sys.stdout)
handler.setLevel(logging.DEBUG)
handler.setFormatter(logging.Formatter(fmt=FORMAT))
_logger.addHandler(handler)
_logger.setLevel(logging.DEBUG)

if platform.system() == "Linux":
if not _on_rtd:
Expand All @@ -51,10 +51,10 @@
BleakClientBlueZDBus as BleakClient,
) # noqa
elif platform.system() == "Darwin":
from Foundation import NSClassFromString

if NSClassFromString("CBPeripheral") is None:
raise BleakError("Bleak requires the CoreBluetooth Framework")
try:
from CoreBluetooth import CBPeripheral
except Exception as ex:
raise BleakError("Bleak requires the CoreBluetooth Framework") from ex

from bleak.backends.corebluetooth.discovery import discover # noqa
from bleak.backends.corebluetooth.scanner import (
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.7.1"
__version__ = "0.8.0"
4 changes: 2 additions & 2 deletions bleak/backends/bluezdbus/characteristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from bleak.backends.characteristic import BleakGATTCharacteristic
from bleak.backends.descriptor import BleakGATTDescriptor
from bleak.uuids import uuidstr_to_str


_GattCharacteristicsFlagsEnum = {
Expand Down Expand Up @@ -68,8 +69,7 @@ def uuid(self) -> str:
@property
def description(self) -> str:
"""Description for this characteristic"""
# No description available in DBus backend.
return ""
return uuidstr_to_str(self._uuid)

@property
def properties(self) -> List:
Expand Down
Loading

0 comments on commit aa54b08

Please sign in to comment.