Skip to content

Commit

Permalink
Merge pull request #44 from kevincar/41-bluez-characteristic-callback
Browse files Browse the repository at this point in the history
Bluez characteristic callback
  • Loading branch information
kevincar authored May 17, 2021
2 parents 5965572 + 42fb838 commit 3854a28
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion bless/backends/bluezdbus/characteristic.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ async def init(self, service: "BlessGATTServiceBlueZDBus"):
@property
def value(self) -> bytearray:
"""Get the value of the characteristic"""
return self._value
return bytearray(self._value)

@value.setter
def value(self, val: bytearray):
Expand Down
10 changes: 6 additions & 4 deletions bless/backends/bluezdbus/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from uuid import UUID

from typing import Optional, Dict, Any, cast
from typing import Optional, Dict, Any, cast, List

from asyncio import AbstractEventLoop
from twisted.internet.asyncioreactor import AsyncioSelectorReactor # type: ignore
Expand Down Expand Up @@ -223,23 +223,25 @@ def update_value(self, service_uuid: str, char_uuid: str) -> bool:
characteristic.value = cur_value
return True

def read(self, char: BlueZGattCharacteristic) -> bytearray:
def read(self, char: BlueZGattCharacteristic) -> List[int]:
"""
Read request.
This re-routes the the request incomming on the dbus to the server to
be re-routed to the user defined handler
Note: the BlueZ App handles the data as a list of ints
Parameters
----------
char : BlueZGattCharacteristic
The characteristic passed from the app
Returns
-------
bytearray
List[int]
The value of the characteristic
"""
return self.read_request(char.uuid)
return list(self.read_request(char.uuid))

def write(self, char: BlueZGattCharacteristic, value: bytearray):
"""
Expand Down

0 comments on commit 3854a28

Please sign in to comment.