Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluez characteristic callback #44

Merged
merged 1 commit into from
May 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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