Skip to content

Instantly share code, notes, and snippets.

@ksahnine
Created April 10, 2016 17:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ksahnine/3ed9e5ee7825c92f02b4a553e8f6a4b6 to your computer and use it in GitHub Desktop.
Save ksahnine/3ed9e5ee7825c92f02b4a553e8f6a4b6 to your computer and use it in GitHub Desktop.
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