Skip to content

Commit 364ba4b

Browse files
committed
pybricks.connections.pybricks: Fix calling write methods
Fix a missed change when we removed the `client` attribute. This was causing an AttributeError when calling `PybricksHub.write()` methods.
1 parent 8ef6542 commit 364ba4b

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
66

77
## [Unreleased]
88

9+
### Fixed
10+
- Fixed calling `PybricksHub.write()` methods.
11+
912
## [1.2.0] - 2025-07-11
1013

1114
### Added

pybricksdev/connections/pybricks.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ async def write(self, data: bytes) -> None:
362362
data: Any bytes-like object that will fit in a single BLE packet.
363363
"""
364364
if self._legacy_stdio:
365-
await self.client.write_gatt_char(NUS_RX_UUID, data, False)
365+
await self.write_gatt_char(NUS_RX_UUID, data, False)
366366
else:
367367
msg = bytearray([Command.WRITE_STDIN])
368368
msg.extend(data)
@@ -372,7 +372,7 @@ async def write(self, data: bytes) -> None:
372372
f"data is too big, limited to {self._max_write_size - 1} bytes"
373373
)
374374

375-
await self.client.write_gatt_char(PYBRICKS_COMMAND_EVENT_UUID, msg, True)
375+
await self.write_gatt_char(PYBRICKS_COMMAND_EVENT_UUID, msg, True)
376376

377377
async def write_string(self, value: str) -> None:
378378
"""
@@ -622,9 +622,9 @@ async def send_block(data: bytes) -> None:
622622
# BOOST Move hub has fixed MTU of 23 so we can only send 20
623623
# bytes at a time
624624
for c in chunk(data, 20):
625-
await self.client.write_gatt_char(NUS_RX_UUID, c, False)
625+
await self.write_gatt_char(NUS_RX_UUID, c, False)
626626
else:
627-
await self.client.write_gatt_char(NUS_RX_UUID, data, False)
627+
await self.write_gatt_char(NUS_RX_UUID, data, False)
628628

629629
msg = await asyncio.wait_for(
630630
self.race_disconnect(queue.get()), timeout=0.5

0 commit comments

Comments
 (0)