#David Evans, Yard Mapper, March 8, 2016 import magFunctions import time magFunctions.init_magnetometer()#You must run this before running magnetometer print magFunctions.read_bearing() time.sleep(1) while(True): bearing = magFunctions.read_bearing() #get the magnetometer bearing print bearing time.sleep(1);#Take a rest
dev_id = 0 #file = open('logfile', 'w') 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) magFunctions.init_magnetometer() while True: print "------------------" print datetime.datetime.now() returnedList = blescan.parse_events(sock, 5) # print "----------" + datetime.datetime.now() print datetime.datetime.now() print magFunctions.read_bearing() # print datetime.datetime.now() # print returnedList[0]; for beacon in returnedList: print datetime.datetime.now() # print magFunctions.read_bearing() # t = type(beacon)