forked from auracaster/bumble_mirror
Compare commits
1 Commits
gbg/improv
...
gbg/proxy-
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7fa2eb7658 |
@@ -346,8 +346,11 @@ class CharacteristicAdapter:
|
|||||||
async def read_decoded_value(self):
|
async def read_decoded_value(self):
|
||||||
return self.decode_value(await self.wrapped_characteristic.read_value())
|
return self.decode_value(await self.wrapped_characteristic.read_value())
|
||||||
|
|
||||||
async def write_decoded_value(self, value):
|
async def write_decoded_value(self, value, with_response=False):
|
||||||
return await self.wrapped_characteristic.write_value(self.encode_value(value))
|
return await self.wrapped_characteristic.write_value(
|
||||||
|
self.encode_value(value),
|
||||||
|
with_response
|
||||||
|
)
|
||||||
|
|
||||||
def encode_value(self, value):
|
def encode_value(self, value):
|
||||||
return value
|
return value
|
||||||
|
|||||||
@@ -184,8 +184,8 @@ class Client:
|
|||||||
# Wait until we can send (only one pending command at a time for the connection)
|
# Wait until we can send (only one pending command at a time for the connection)
|
||||||
response = None
|
response = None
|
||||||
async with self.request_semaphore:
|
async with self.request_semaphore:
|
||||||
assert(self.pending_request is None)
|
assert self.pending_request is None
|
||||||
assert(self.pending_response is None)
|
assert self.pending_response is None
|
||||||
|
|
||||||
# Create a future value to hold the eventual response
|
# Create a future value to hold the eventual response
|
||||||
self.pending_response = asyncio.get_running_loop().create_future()
|
self.pending_response = asyncio.get_running_loop().create_future()
|
||||||
|
|||||||
@@ -164,6 +164,17 @@ async def test_characteristic_encoding():
|
|||||||
await async_barrier()
|
await async_barrier()
|
||||||
assert characteristic.value == bytes([124])
|
assert characteristic.value == bytes([124])
|
||||||
|
|
||||||
|
v = await cp.read_value()
|
||||||
|
assert v == 124
|
||||||
|
await cp.write_value(125, with_response=True)
|
||||||
|
await async_barrier()
|
||||||
|
assert characteristic.value == bytes([125])
|
||||||
|
|
||||||
|
cd = DelegatedCharacteristicAdapter(c, encode=lambda x: bytes([x // 2]))
|
||||||
|
await cd.write_value(100, with_response=True)
|
||||||
|
await async_barrier()
|
||||||
|
assert characteristic.value == bytes([50])
|
||||||
|
|
||||||
last_change = None
|
last_change = None
|
||||||
|
|
||||||
def on_change(value):
|
def on_change(value):
|
||||||
|
|||||||
Reference in New Issue
Block a user