diff --git a/scratch_link.py b/scratch_link.py index ad2bc1a..7ab4e7f 100755 --- a/scratch_link.py +++ b/scratch_link.py @@ -433,7 +433,9 @@ class BLESession(Session): self.status = self.DONE if self.perip: logger.info(f"disconnect to BLE peripheral: {self.perip}") - self.perip.disconnect() + with self.lock: + self.perip.disconnect() + self.perip = None def __del__(self): self.close()