The Following User Says Thank You to baksiidaa For This Useful Post: | ||
|
2007-12-12
, 21:18
|
|
Posts: 739 |
Thanked: 159 times |
Joined on Sep 2007
@ Germany - Munich
|
#2
|
|
2007-12-13
, 09:53
|
|
Posts: 739 |
Thanked: 159 times |
Joined on Sep 2007
@ Germany - Munich
|
#3
|
#/bin/sh
# Script to execute a command when going too far and one when being near enough from the other adapter
# When going too far
cmd1="xmms -u"
# When going too near
cmd2="xmms -p"
# The other endpoint
badr="01:02:03:04:05:06"
# Threshold level
lvl="-4"
# On startup, if the device is close enough, don't execute anything
on=1
sudo hcitool cc ${badr}
sleep 1
while /bin/true
do
l=`sudo hcitool tpl ${badr} | tail -1 | cut -f 2 -d':'
# echo "Power=$l"
if [ "$l" -gt $lvl ] && [ $on == 1 ]
then
echo "Too far"
${cmd1}
on=0
elif [ "$l" -lte $lvl ] && [ $on == 0 ]
then
echo "Near enough"
${cmd2}
on=1
fi
sleep 3
done
EDITOR=/bin/vi visudo
user ALL = NOPASSWD: /usr/bin/hcitool
|
2007-12-28
, 18:40
|
Posts: 91 |
Thanked: 4 times |
Joined on Dec 2007
|
#4
|
|
2008-10-20
, 20:20
|
Posts: 40 |
Thanked: 43 times |
Joined on Oct 2008
|
#5
|
#/bin/bash # Script to execute a command when going too far and one when being near enough from the other adapter # When going too far cmd1="rhythmbox-client --pause" # When going too near cmd2="rhythmbox-client --play" # The other endpoint badr="00:19:1D:AB:98:23" # Threshold level lvl="-4" # On startup, if the device is close enough, don't execute anything on=1 smooth=0 while /bin/true do l=`hcitool rssi ${badr} | tail -1 | cut -f 2 -d':'` # echo "Power=$l" if [ "$l" -le $lvl ] && [ $on == 1 ] then if [ $smooth == 2 ] then echo "Too far" ${cmd1} on=0 smooth=0 else echo "Are we too far?" let smooth=smooth+1 fi elif [ "$l" -gt $lvl ] then if [ $on == 0 ] then echo "Near enough" ${cmd2} on=1 else smooth=0 fi fi sleep 3 done
The Following User Says Thank You to tarek For This Useful Post: | ||
|
2008-10-20
, 21:18
|
|
Posts: 3,397 |
Thanked: 1,212 times |
Joined on Jul 2008
@ Netherlands
|
#6
|
The Following User Says Thank You to allnameswereout For This Useful Post: | ||
|
2008-10-28
, 15:04
|
|
Posts: 716 |
Thanked: 236 times |
Joined on Dec 2007
|
#7
|
#!/bin/sh $BTADDR=<address> while true; do #(device near state - add commands) while sudo /usr/bin/l2ping -t 1 -c 1 $BTADDR >/dev/null 2>/dev/null; do sleep 15 done #(device away state - add commands) until sudo /usr/bin/l2ping -t 1 -c 1 $BTADDR >/dev/null 2>/dev/null; do sleep 3 done done
|
2013-10-29
, 05:46
|
Posts: 1,423 |
Thanked: 2,620 times |
Joined on Jan 2011
@ Touring
|
#8
|
|
2013-10-29
, 06:55
|
Posts: 569 |
Thanked: 462 times |
Joined on Jul 2010
@ USA
|
#9
|
|
2013-10-29
, 11:11
|
Posts: 1,423 |
Thanked: 2,620 times |
Joined on Jan 2011
@ Touring
|
#10
|
To get to the point, I was wondering if there was a good use for such a program/applet on my internet tablet. One I can think of is to unmute the speakers and play an alarm if my cell phone goes out of range, which in effect would sound an alarm if I put down my N800 somewhere and forgot to take it when I left (presuming I didn't leave my cell phone as well).
Does anyone have any ideas about other practical uses of bluetooth proximity detection? Has anyone played with it on their tablet?