diff options
author | lonkaars <loek@pipeframe.xyz> | 2021-08-03 21:50:19 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2021-08-03 21:50:19 +0200 |
commit | 1bfd3543a7989e325c756547960b99d0d3eaed07 (patch) | |
tree | f5cfaa8cb3f3ac8a9876bace7f1c6156e7e6ceb4 /main.py | |
parent | d30c6279efe1e534780f6dfd4ccefcf82bf3c0c1 (diff) |
more crash catch
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -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") |