From 4ff34bd957c35b8b2733a49f39b43849eeae20bf Mon Sep 17 00:00:00 2001 From: Daniel Pollithy Date: Tue, 29 Aug 2017 17:22:40 +0200 Subject: [PATCH] change --- client.py | 16 +++++++++++++--- settings.py | 1 + 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/client.py b/client.py index 343dc56..ef59deb 100644 --- a/client.py +++ b/client.py @@ -80,7 +80,8 @@ def protocol(address): sock.close() if __name__ == '__main__': - while True: + connecting = True + while connecting: nearby_devices = bluetooth.discover_devices(lookup_names=True) print("found %d devices" % len(nearby_devices)) @@ -88,6 +89,15 @@ if __name__ == '__main__': print(" %s - %s" % (address, name)) if address == settings.PEER_BT_ADDRESS: print("PEERING PARTNER FOUND") - protocol(address) + try: + protocol(address) + except bluetooth.btcommon.BluetoothError as (code, text): + if code == 104: + print(text) + print('That is o.k. I make a break and then we keep on') + time.sleep(settings.DRONE_REJECTED_RESTART_TIME) + else: + print('This error is not known. I stop connecting') + connecting = False - time.sleep(settings.BT_SLEEP) \ No newline at end of file + time.sleep(settings.BT_SLEEP) diff --git a/settings.py b/settings.py index c6680ba..496b2d7 100644 --- a/settings.py +++ b/settings.py @@ -7,6 +7,7 @@ BT_SLEEP = 0.01 # seconds DISTANCE_SLEEP = 0.1 CHARGING_TIME = 10 +DRONE_REJECTED_RESTART_TIME = 10 # eth CLIENT_ETHEREUM_ADDRESS = '0xde0b2sdsdsddddddddddddddddddddddddddddde'