Created
April 10, 2016 17:32
-
-
Save ksahnine/3ed9e5ee7825c92f02b4a553e8f6a4b6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import bluetooth | |
import yaml | |
# Pseudo code | |
def main(argv): | |
configFile = "devices.yml" | |
# Loads the configuration file | |
if os.path.isfile(configFile): | |
with open(configFile, 'r') as f: | |
conf = yaml.load(f) | |
while True: | |
for device in conf["devices"]: | |
result = bluetooth.lookup_name(device['addr'], timeout=timeout) | |
isNear = (result != None) | |
if ('isNear' not in device) or (device['isNear'] != isNear): | |
device['isNear'] = isNear | |
logger.log(logging.DEBUG, "%s: in" % device) | |
notify(tcpHost, tcpPort, device, logger) | |
time.sleep(delay) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment