From f848802ba7eea1fa9d521f938a7e3bdb35414ac7 Mon Sep 17 00:00:00 2001 From: R Date: Thu, 7 Aug 2025 00:53:37 +0100 Subject: [PATCH] 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 --- pybricksdev/connections/pybricks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pybricksdev/connections/pybricks.py b/pybricksdev/connections/pybricks.py index fcdfee9..b7091da 100644 --- a/pybricksdev/connections/pybricks.py +++ b/pybricksdev/connections/pybricks.py @@ -947,8 +947,8 @@ async def write_gatt_char(self, uuid: str, data, response: bool) -> None: await self._send_message(bytes([PybricksUsbOutEpMessageType.COMMAND]) + data) async def start_notify(self, uuid: str, callback: Callable) -> None: - await self._send_message(bytes([PybricksUsbOutEpMessageType.SUBSCRIBE, 1])) self._notify_callbacks[uuid] = callback + await self._send_message(bytes([PybricksUsbOutEpMessageType.SUBSCRIBE, 1])) async def _monitor_usb(self): loop = asyncio.get_running_loop()