forked from mikepurvis/sixad
-
Notifications
You must be signed in to change notification settings - Fork 2
/
sixad-helper
executable file
·36 lines (34 loc) · 975 Bytes
/
sixad-helper
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
#!/usr/bin/env bash
# check if sixpair was running the last 5 seconds
# and abort if it is true.
# retry limit = 5s
if [ -f /tmp/sixpair.tmp ]; then
oldtimestamp=`cat /tmp/sixpair.tmp`
secondsDiff=$(( `date '+%Y%m%d%H%M%S'` - $oldtimestamp ))
if [ $secondsDiff -lt 5 ]; then
exit 1
fi
fi
params="$1"
if hciconfig | grep -q "hci0"; then
# Check if sixad is running
if ps -e | grep -q "sixad-bin"; then
# activate bt dongle if necessary
if !(hciconfig | grep -q "RUNNING"); then
hciconfig hci0 up
fi
# Make bt dongle discoverable
if !(hciconfig | grep -q "PSCAN"); then
hciconfig hci0 pscan
fi
if [[ "$params" == "sixpair" ]]; then
# Write bt dongle's mac address into controller
date '+%Y%m%d%H%M%S' > /tmp/sixpair.tmp
/usr/sbin/sixpair
fi
else
echo "sixad is not running!"
exit 1
fi
fi
exit 0