Skip to content

Commit 9b84ee4

Browse files
ArcaneNibbledlech
authored andcommitted
pybricksdev.connections.pybricks: Set callback before sending subscribe
This makes sure that the initial status update will be handled and not dropped. This message contains important information such as the currently active program slot. Suggested-by: David Lechner <[email protected]>
1 parent f529636 commit 9b84ee4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

pybricksdev/connections/pybricks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,8 +947,8 @@ async def write_gatt_char(self, uuid: str, data, response: bool) -> None:
947947
await self._send_message(bytes([PybricksUsbOutEpMessageType.COMMAND]) + data)
948948

949949
async def start_notify(self, uuid: str, callback: Callable) -> None:
950-
await self._send_message(bytes([PybricksUsbOutEpMessageType.SUBSCRIBE, 1]))
951950
self._notify_callbacks[uuid] = callback
951+
await self._send_message(bytes([PybricksUsbOutEpMessageType.SUBSCRIBE, 1]))
952952

953953
async def _monitor_usb(self):
954954
loop = asyncio.get_running_loop()

0 commit comments

Comments
 (0)