Skip to content

Instantly share code, notes, and snippets.

@lesp

lesp/test.py Secret

Created September 26, 2014 18:17
Show Gist options
  • Save lesp/403436f8fb80132b45b4 to your computer and use it in GitHub Desktop.
Save lesp/403436f8fb80132b45b4 to your computer and use it in GitHub Desktop.
# test BLE Scanning software
# jcs 6/8/2014
import blescan
import sys
#import bluetooth
import pygame
pygame.init()
pygame.mixer.init()
sound = "./ladder.ogg"
def play_sound(x):
pygame.mixer.music.load(x)
pygame.mixer.music.play(1)
while pygame.mixer.get_busy() == True:
continue
import bluetooth._bluetooth as bluez
dev_id = 0
try:
sock = bluez.hci_open_dev(dev_id)
print "ble thread started"
except:
print "error accessing bluetooth device..."
sys.exit(1)
blescan.hci_le_set_scan_parameters(sock)
blescan.hci_enable_le_scan(sock)
while True:
returnedList = blescan.parse_events(sock, 1)
print "----------"
for beacon in returnedList:
print beacon
beacon = beacon[0:17]
if beacon != "c7:b5:69:50:6a:fe":
print("SEARCHING")
else:
print("FOUND IT")
play_sound(sound)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment