mirror of
https://github.com/DanielPollithy/bluetooth_drone.git
synced 2025-10-16 11:45:38 +00:00
d3.js
This commit is contained in:
parent
714ff7381c
commit
50c32fea27
@ -102,7 +102,7 @@ def protocol(address):
|
|||||||
|
|
||||||
sock.close()
|
sock.close()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
def run():
|
||||||
connecting = True
|
connecting = True
|
||||||
while connecting:
|
while connecting:
|
||||||
nearby_devices = bluetooth.discover_devices(lookup_names=True)
|
nearby_devices = bluetooth.discover_devices(lookup_names=True)
|
||||||
@ -125,3 +125,7 @@ if __name__ == '__main__':
|
|||||||
connecting = False
|
connecting = False
|
||||||
|
|
||||||
time.sleep(settings.BT_SLEEP)
|
time.sleep(settings.BT_SLEEP)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
run()
|
||||||
15
drone.py
15
drone.py
@ -1,4 +1,13 @@
|
|||||||
# run two threads
|
from multiprocessing import Process
|
||||||
# 1) the bluetooth connector
|
import client
|
||||||
# 2) the website listener
|
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
19
drone_poller.py
Normal 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()
|
||||||
@ -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
|
|
||||||
@ -8,7 +8,7 @@ RASPY_BT_ADDRESS = 'B8:27:EB:76:09:0B'
|
|||||||
DEMO = False
|
DEMO = False
|
||||||
|
|
||||||
|
|
||||||
WEBSITE_POLLING_SLEEP = 1 # seconds
|
WEBSITE_POLLING_SLEEP = 5 # seconds
|
||||||
|
|
||||||
BT_SLEEP = 0.01 # seconds
|
BT_SLEEP = 0.01 # seconds
|
||||||
DISTANCE_SLEEP = 0.1
|
DISTANCE_SLEEP = 0.1
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user