-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathble_finder.py
51 lines (44 loc) · 1.43 KB
/
ble_finder.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
50
51
#!/usr/bin/env python
#----------------------------------------------
# ble_finder.py
# Authors: Troy Brown (@waveguyd) and Garrett Gee (@ggee)
# Developed for:
# http://hackerwarehouse.com / @hackerwarehouse
# http://hackerwarehouse.tv
#
# requirements:
# run from blue_hydra directory and rssi file output option enabled
# tailer module
#
# todo:
# foxhunting
# change last seen to dd:hh:mm:ss
#----------------------------------------------
import datetime, os
from time import sleep
import tailer
devices = [
['D5:3D:F4:CO:FF:EE', 'Ronalds tile tag', ''],
['CF:19:F8:0F:DE:AD', 'Gerrards tile tag', ''],
['FF:FF:C0:AF:BE:EF', 'Jasons iTAG', ''],
]
# threshold for reporting in seconds
#seenthreshold = 10
seenthreshold = 45
for line in tailer.follow(open("blue_hydra_rssi.log")):
for idx, (mac, name, lastseen) in enumerate(devices):
if mac in line:
currentseen = float(line.split()[0])
if lastseen:
lastseen = float(lastseen)
tdelta = datetime.datetime.fromtimestamp(currentseen) - datetime.datetime.fromtimestamp(lastseen)
tsec = tdelta.total_seconds()
if tsec >= seenthreshold:
print name + ' (' + mac + ') is nearby - last seen ' + str(tsec) + ' seconds ago'
# os.system('aplay ping.wav &')
else:
# first time seen
print name + ' (' + mac + ') is nearby'
# os.system('aplay ping.wav &')
# update last seen field with current timestamp
devices[idx][2] = currentseen