This commit is contained in:
Daniel Pollithy 2017-08-29 17:22:40 +02:00
parent 4b64c3febf
commit 4ff34bd957
2 changed files with 14 additions and 3 deletions

View File

@ -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)
time.sleep(settings.BT_SLEEP)

View File

@ -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'