-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
29 lines (25 loc) · 931 Bytes
/
app.py
File metadata and controls
29 lines (25 loc) · 931 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
from os import environ
import time
from gattlib import DiscoveryService
from upm import pyupm_grove as grove
from upm import pyupm_grovespeaker as upmGrovespeaker
for i in range(0, 5):
try:
service = DiscoveryService("hci0")
break
except:
time.sleep(.25)
while True:
devices = service.discover(5)
led = grove.GroveLed(int(environ.get('LED_COLOR', 2)))
mySpeaker = upmGrovespeaker.GroveSpeaker(int(environ.get('SPEAKER_PIN', 8)))
for address, name in devices.items():
if name.startswith('edison') or address.startswith('58:A8:39:00'):
print("Edison detected - name: {}, address: {}".format(name, address))
# Turn the LED on and off 10 times, pausing 1/4 second
# between transitions
for i in range(0, 10):
led.on()
mySpeaker.playAll()
led.off()
time.sleep(.5)