aboutsummaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2021-08-03 21:50:19 +0200
committerlonkaars <loek@pipeframe.xyz>2021-08-03 21:50:19 +0200
commit1bfd3543a7989e325c756547960b99d0d3eaed07 (patch)
treef5cfaa8cb3f3ac8a9876bace7f1c6156e7e6ceb4 /main.py
parentd30c6279efe1e534780f6dfd4ccefcf82bf3c0c1 (diff)
more crash catch
Diffstat (limited to 'main.py')
-rw-r--r--main.py7
1 files 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")