Skip to content

Commit

Permalink
add send_raw_command
Browse files Browse the repository at this point in the history
  • Loading branch information
khusmann committed Dec 24, 2024
1 parent fbca538 commit 5d13055
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/benlink/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,11 @@ def device_uuid(self) -> str:
def is_connected(self) -> bool:
return self._is_connected

async def send_raw_command(self, command: bytes) -> None:
"""For debugging - Use at your own risk!"""
self._assert_conn()
await self._conn.send_raw_command(command)

async def battery_voltage(self) -> float:
self._assert_conn()
return await self._conn.get_battery_voltage()
Expand Down
8 changes: 6 additions & 2 deletions src/benlink/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,17 @@ async def disconnect(self) -> None:
self._handlers.clear()
await self._client.disconnect()

async def send_command(self, command: CommandMessage) -> None:
async def send_raw_command(self, command: bytes) -> None:
"""Send a raw command - use at your own risk"""
await self._client.write_gatt_char(
RADIO_WRITE_UUID,
command_message_to_bytes(command),
command,
response=True
)

async def send_command(self, command: CommandMessage) -> None:
await self.send_raw_command(command_message_to_bytes(command))

async def send_command_expect_reply(self, command: CommandMessage, expect: t.Type[ReplyMessageT]) -> ReplyMessageT | MessageReplyError:
queue: asyncio.Queue[ReplyMessageT |
MessageReplyError] = asyncio.Queue()
Expand Down

0 comments on commit 5d13055

Please sign in to comment.