1 import logging
2 log = logging.getLogger("modules.Phone")
3
4 import thread
5
6 import threading
7 import bluetooth
8 import time
9
10 import conduit
11
12 UNKNOWN_VALUE = "Unknown"
13
15 SLEEP_TIME = 20
16 SLEEP = 0.1
18 threading.Thread.__init__(self)
19 self._found = {}
20 self._cancelled = False
21 self._foundLock = threading.Lock()
22
24
25
26 self._foundLock.acquire()
27 if address not in self._found:
28 log.info("Thread %s Found Phone: %s" % (thread.get_ident(),address))
29 self._found[address] = {"name":name}
30 self._foundLock.release()
31
37
40
42 self._cancelled = True
43
46 bluetooth.DeviceDiscoverer.__init__(self)
47 self.parent = parent
48
50 '''
51 Called when device is iscovered, checks device is phone
52 '''
53 log.info("Bluetooth Device Discovered: %s@%s" % (name,address))
54 major_class = ( device_class & 0xf00 ) >> 8
55
56
57 if major_class == 2:
58 self.parent.found_phone(address, name)
59
61 log.debug("Bluetooth Search Complete")
62