From 0af23d4280ed6c997166e712a47b1179ff6a8980 Mon Sep 17 00:00:00 2001 From: Shin'ichiro Kawasaki Date: Sun, 14 Jun 2020 11:52:12 +0900 Subject: [PATCH] BLEThread.run: Reduce notification wait time from 1s to 1ms Now notification wait has 1 second timeout. This might be too long for Lego Boost. Reduce it to 1 millisecond. If BLE device does not send out any notification, bluepy-scratch-link wait for 1 second and during this wait, write or read message from Scratch is not sent to Boost. This is not an issue for micro:bit since micro:bit sends out notifications frequently, the notification wait completes before 1 second timeout. It was reported that Lego Boost has a few seconds latency between Scratch motor control command execution to Lego Boost motor move. To try out smaller timeout, reduce the value. Signed-off-by: Shin'ichiro Kawasaki --- scratch_link.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scratch_link.py b/scratch_link.py index 99f7717..eacafe6 100755 --- a/scratch_link.py +++ b/scratch_link.py @@ -361,7 +361,7 @@ class BLESession(Session): logger.debug("getting lock for waitForNotification") with self.session.lock: logger.debug("before waitForNotification") - self.session.perip.waitForNotifications(1.0) + self.session.perip.waitForNotifications(0.0001) logger.debug("after waitForNotification") logger.debug("released lock for waitForNotification") except Exception as e: