This commit is contained in:
Daniel Pollithy 2017-08-30 17:49:54 +02:00
parent 714ff7381c
commit 50c32fea27
5 changed files with 37 additions and 16 deletions

View File

@ -102,7 +102,7 @@ def protocol(address):
sock.close()
if __name__ == '__main__':
def run():
connecting = True
while connecting:
nearby_devices = bluetooth.discover_devices(lookup_names=True)
@ -125,3 +125,7 @@ if __name__ == '__main__':
connecting = False
time.sleep(settings.BT_SLEEP)
if __name__ == '__main__':
run()

View File

@ -1,4 +1,13 @@
# run two threads
# 1) the bluetooth connector
# 2) the website listener
from multiprocessing import Process
import client
import drone_poller
def run():
p = Process(target=drone_poller.run)
p.start()
client.run()
if __name__ == '__main__':
run()

19
drone_poller.py Normal file
View File

@ -0,0 +1,19 @@
import urllib
import json
import time
import settings
url = 'http://google.de'
def run():
while True:
response = urllib.urlopen(url)
data = json.loads(response.read())
print(data)
time.sleep(settings.WEBSITE_POLLING_SLEEP)
if __name__ == '__main__':
run()

View File

@ -1,11 +0,0 @@
# this file checks in a given interval a http endpoint for booking the drone should make
import urllib
import json
import settings
while True:
url = 'http://localhost:8080/drone/{}/bookings'.format(settings.CLIENT_ETHEREUM_ADDRESS)
response = urllib.urlopen(url)
data = json.loads(response.read())
print data

View File

@ -8,7 +8,7 @@ RASPY_BT_ADDRESS = 'B8:27:EB:76:09:0B'
DEMO = False
WEBSITE_POLLING_SLEEP = 1 # seconds
WEBSITE_POLLING_SLEEP = 5 # seconds
BT_SLEEP = 0.01 # seconds
DISTANCE_SLEEP = 0.1