-
Notifications
You must be signed in to change notification settings - Fork 295
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
117 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,39 @@ | ||
from typing import Union, List | ||
|
||
from bleak.backends.service import BleakGATTService | ||
from bleak.backends.characteristic import BleakGATTCharacteristic | ||
from bleak.backends.bluezdbus.characteristic import BleakGATTCharacteristicBlueZDBus | ||
|
||
|
||
class BleakGATTServiceBlueZDBus(BleakGATTService): | ||
"""GATT Service implementation for the BlueZ DBus backend""" | ||
|
||
def __init__(self, obj, path): | ||
super().__init__(obj) | ||
self.__characteristics = [] | ||
self.__path = path | ||
|
||
@property | ||
def uuid(self) -> str: | ||
"""The UUID to this service""" | ||
return self.obj["UUID"] | ||
|
||
@property | ||
def description(self) -> str: | ||
return super(BleakGATTServiceBlueZDBus, self).description | ||
|
||
@property | ||
def characteristics(self) -> List: | ||
def characteristics(self) -> List[BleakGATTCharacteristicBlueZDBus]: | ||
"""List of characteristics for this service""" | ||
return self.__characteristics | ||
|
||
def get_characteristic(self, _uuid) -> Union[BleakGATTCharacteristic, None]: | ||
def get_characteristic(self, _uuid) -> Union[BleakGATTCharacteristicBlueZDBus, None]: | ||
"""Get a characteristic by UUID""" | ||
raise NotImplementedError() | ||
|
||
def add_characteristic(self, characteristic: BleakGATTCharacteristicBlueZDBus): | ||
"""Add a :py:class:`~BleakGATTCharacteristicBlueZDBus` to the service. | ||
Should not be used by end user, but rather by `bleak` itself. | ||
""" | ||
self.__characteristics.append(characteristic) | ||
|
||
@property | ||
def path(self): | ||
"""The DBus path. Mostly needed by `bleak`, not by end user""" | ||
return self.__path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.