-
Notifications
You must be signed in to change notification settings - Fork 0
/
collect.py
executable file
·49 lines (38 loc) · 1.48 KB
/
collect.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/bin/env python
# was at some point loosely based on bglib_test_scanner.py released under MIT license by Jeff Rowberg, who also works for BlueGiga
# (c) 2014 Productize <[email protected]>
import sys, time, datetime
from PySide import QtGui, QtCore
from PySide.QtCore import Qt
from data import UUID
from ble import BLE, ActivityThread
def print_scan_response(ble, args):
(name, data) = ble.data_to_string(args['data'])
#if not 'Hum' in name: return
print "gap_scan_response",
t = datetime.datetime.now()
disp_list = []
disp_list.append("%ld.%03ld" % (time.mktime(t.timetuple()), t.microsecond/1000))
disp_list.append("rssi: %d" % args["rssi"])
disp_list.append("type: %d" % args["packet_type"])
disp_list.append("from: %s" % ''.join(['%02X' % b for b in args["sender"][::-1]]))
disp_list.append("adt: %d" % args["address_type"])
disp_list.append("bond: %d" % args["bond"])
disp_list.append("name: %s data: %s" % (name, data))
print ' '.join(disp_list)
def run():
import signal
QtCore.QCoreApplication.setOrganizationName("productize")
QtCore.QCoreApplication.setOrganizationDomain("productize.be")
QtCore.QCoreApplication.setApplicationName("BTLE tool")
app = QtGui.QApplication(["BTLE tool"])
signal.signal(signal.SIGINT, signal.SIG_DFL)
baud_rate = 115200
ble = BLE(baud_rate)
ble.start()
ct = ActivityThread(ble)
ble.scan_response.connect(lambda x: print_scan_response(ble, x))
ct.start()
return app.exec_()
if __name__ == '__main__':
run()