55import bleak .backends .bluezdbus .defs as defs # type: ignore
66
77from dbus_next import DBusError # type: ignore
8+ from dbus_next .aio import ProxyInterface # type: ignore
89from dbus_next .constants import PropertyAccess # type: ignore
910from dbus_next .service import ServiceInterface , method , dbus_property # type: ignore
1011from dbus_next .signature import Variant # type: ignore
1112from enum import Enum
12- from typing import List , TYPE_CHECKING , Any , Dict
13+ from typing import List , TYPE_CHECKING , Any , Dict , cast
1314
1415from .descriptor import BlueZGattDescriptor , DescriptorFlags # type: ignore
16+ from .device import Device1
1517from .session import NotifySession # type: ignore
1618
1719if TYPE_CHECKING :
@@ -111,7 +113,7 @@ def NotifyAcquired(self) -> "b": # type: ignore # noqa: F821
111113 return len (self ._subscribed_centrals ) > 0
112114
113115 @method () # noqa: F722
114- def ReadValue (self , options : "a{sv}" ) -> "ay" : # type: ignore # noqa: F722 F821 N802 E501
116+ async def ReadValue (self , options : "a{sv}" ) -> "ay" : # type: ignore # noqa: F722 F821 N802 E501
115117 """
116118 Read the value of the characteristic.
117119 This is to be fully implemented at the application level
@@ -126,6 +128,12 @@ def ReadValue(self, options: "a{sv}") -> "ay": # type: ignore # noqa: F722 F821
126128 bytes
127129 The bytes that is the value of the characteristic
128130 """
131+ device_path : str = options ["device" ]
132+ device_interface : ProxyInterface = Device1 .get_device (
133+ self ._service .bus , device_path
134+ )
135+ device : Device1 = cast (Device1 , device_interface )
136+ options ["central_id" ] = await device .get_address ()
129137 f = self ._service .app .Read
130138 if f is None :
131139 raise NotImplementedError ()
@@ -144,6 +152,12 @@ def WriteValue(self, value: "ay", options: "a{sv}"): # type: ignore # noqa
144152 options : Dict
145153 Some options for you to select from
146154 """
155+ device_path : str = options ["device" ]
156+ device_interface : ProxyInterface = Device1 .get_device (
157+ self ._service .bus , device_path
158+ )
159+ device : Device1 = cast (Device1 , device_interface )
160+ options ["central_id" ] = device .get_address ()
147161 f = self ._service .app .Write
148162 if f is None :
149163 raise NotImplementedError ()
@@ -176,14 +190,14 @@ async def AcquireNotify(self, options: "a{sv}") -> "hq": # type: ignore # noqa
176190 f = self ._service .app .StartNotify
177191 if f is None :
178192 raise NotImplementedError ()
179- f (self , {"device" : address })
193+
194+ f (self , session )
180195 self ._subscribed_centrals [address ] = session
181196
182197 async def close_rx ():
183198 logger .debug ("Closing RX" )
184199 await asyncio .sleep (2 )
185200 os .close (rx )
186- # asyncio.get_running_loop().call_soon_threadsafe(os.close, rx)
187201
188202 asyncio .create_task (close_rx ())
189203 return [rx , mtu ]
@@ -194,7 +208,7 @@ async def ReleaseNotify(self, session: NotifySession):
194208 f = self ._service .app .StopNotify
195209 if f is None :
196210 raise NotImplementedError ()
197- f (self , { "device" : address } )
211+ f (self , session )
198212 del self ._subscribed_centrals [address ]
199213
200214 @method ()
@@ -214,7 +228,7 @@ def StartNotify(self): # noqa: N802
214228 f = self ._service .app .StartNotify
215229 if f is None :
216230 raise NotImplementedError ()
217- f (self , {})
231+ f (self , None ) # type: ignore
218232 self ._notifying_calls += 1
219233
220234 @method ()
@@ -229,7 +243,7 @@ async def StopNotify(self): # noqa: N802
229243 f = self ._service .app .StopNotify
230244 if f is None :
231245 raise NotImplementedError ()
232- f (self , {})
246+ f (self , {}) # type: ignore
233247 self ._notifying_calls -= 1
234248
235249 def update_value (self ) -> None :
0 commit comments