-
Notifications
You must be signed in to change notification settings - Fork 2
/
btdevice.py
54 lines (39 loc) · 1.22 KB
/
btdevice.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
52
53
54
from bt_proximity import BluetoothRSSI
import time
import sys
from transfer_playback import *
#BT_ADDR = '20:A6:0C:B4:2B:61' # You can put your Bluetooth address here
def print_usage():
print(
"Usage: python test_address.py <bluetooth-address> [number-of-requests]")
def detector(device_id, BT_ADDR, NUM_LOOP):
avg = 0
if len(sys.argv) > 1:
addr = sys.argv[1]
elif BT_ADDR:
addr = BT_ADDR
else:
print_usage()
return
if len(sys.argv) == 3:
num = int(sys.argv[2])
else:
num = NUM_LOOP
btrssi = BluetoothRSSI(addr=addr)
for i in range(0, num):
#print (btrssi.request_rssi())
a = str(btrssi.request_rssi()).replace(',', '').replace('(', '').replace(')', '')
print (a)
if a == "None":
print("not in range")
elif int(a) > 9:
print ("aarush pagal hai")
avg += 1
elif int(a) < 9:
print ("akki pagal hai")
avg = 0
if avg >= 3:
avg = 0
print ("aarush and jasman pagal hai")
transferplayback()
time.sleep(0.25)