From 1bfd3543a7989e325c756547960b99d0d3eaed07 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Tue, 3 Aug 2021 21:50:19 +0200 Subject: more crash catch --- main.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index e00ab04..cf0642c 100644 --- a/main.py +++ b/main.py @@ -1,5 +1,5 @@ #!/bin/python3 -from bluepy.btle import Peripheral, ADDR_TYPE_PUBLIC +from bluepy.btle import Peripheral, ADDR_TYPE_PUBLIC, BTLEDisconnectError import threading import time import colorsys @@ -11,7 +11,10 @@ dev = None def verify_connection(): global dev while dev == None or dev.getState() == 'disc': - dev = Peripheral(mac, ADDR_TYPE_PUBLIC) + try: + dev = Peripheral(mac, ADDR_TYPE_PUBLIC) + except BTLEDisconnectError as e: + continue verify_connection() print("connected") -- cgit v1.2.3