aboutsummaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
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")