Active Topics

 


Reply
Thread Tools
Posts: 183 | Thanked: 115 times | Joined on Nov 2007 @ Seattle, WA
#1
There's a number of programs and scripts floating around for desktop computers that can perform specific actions when a known bluetooth device is in range. One use is to automatically lock and unlock your computer when your cell phone leaves and enters the area of the computer, respectively, so that, as long as you keep your cell phone with you, the computer locks when you leave your desk and unlocks when you come back.
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?
 

The Following User Says Thank You to baksiidaa For This Useful Post:
free's Avatar
Posts: 739 | Thanked: 159 times | Joined on Sep 2007 @ Germany - Munich
#2
If you have linux and kde, it's by default in.
Kdebluetooth and bluez3.

I use it to lock my laptop when the nokia arrives but never thought about the opposite..

Did anybody port kdebluetooth on the device?


Found this also

Last edited by free; 2007-12-12 at 21:27.
 
free's Avatar
Posts: 739 | Thanked: 159 times | Joined on Sep 2007 @ Germany - Munich
#3
Yesterday I thought about this and made a 'quick and dirty' shell script:
Put this on the nokia::

PHP Code:
#/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 
You will need to grant your user the right to execute hcitool as root:
As root:
Code:
EDITOR=/bin/vi visudo
Add this line at the end of the file:
user ALL = NOPASSWD: /usr/bin/hcitool
If you do something stupid in this file, your device is good for reflashing, so take care.

This example uses xmms because that's the only one I know how to use, replace cmd1 and cmd2 by your favorite app!
Now what can be execute? Humm

Last edited by free; 2007-12-13 at 09:56.
 
Posts: 91 | Thanked: 4 times | Joined on Dec 2007
#4
how do i get hcitool on OS2008
 
Posts: 40 | Thanked: 43 times | Joined on Oct 2008
#5
I find there are a few things that don't work so well in this script. I am using it within ubuntu on my desktop, so perhaps that is part of the issue? Anyhow, here is a revised script with a few key changes:

1. It doesn't respond immediately to "too far" - it waits until the third consecutive reading. I found that in my setup, it was far too disruptive, since it occasionally detected "too far" without any real movement of the bluetooth device. I figure that if walking away from something, probably having three cycles is fine. On the flip side, on the first "near enough", it starts playing.

2. It uses RSSI instead of TPL. TPL seemed less responsive to the small distances over which I use the system.

3. Miscellaneous bash fixes, including "le" instead of "lte", since bash doesn't take "lte".

Code:
#/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:
allnameswereout's Avatar
Posts: 3,397 | Thanked: 1,212 times | Joined on Jul 2008 @ Netherlands
#6
BlueProximity. I've installed it on my laptop running Ubuntu but haven't tried it yet. Its a GNOME app (with a nice panel), so should be easy to get working in Maemo.
__________________
Goosfraba! All text written by allnameswereout is public domain unless stated otherwise. Thank you for sharing your output!
 

The Following User Says Thank You to allnameswereout For This Useful Post:
tz1's Avatar
Posts: 716 | Thanked: 236 times | Joined on Dec 2007
#7
Use l2ping (from bluez-utils-test) for the device. It will sit there and generally not interfere (see my minigpsd app thread for discussion). It will return 0 or 1 if it sees the device or not.

You can add a file with the following line to /etc/sudoers.d:

user ALL = NOPASSWD: /usr/bin/l2ping *

then do "update sudoers" as root - this will allow you to do

sudo /usr/bin/l2ping -t 1 -c 1 <btaddr>

e.g.

Code:
#!/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

Last edited by tz1; 2008-10-28 at 15:07. Reason: tab shifted and it posted before I was done
 
Posts: 1,424 | Thanked: 2,623 times | Joined on Jan 2011 @ Touring
#8
I saw this http://www.indiegogo.com/projects/th...-of-defense--3 and thought that we could use the above scripts with a bluetooth module of some sort. Ideally it would be a generic Bluetooth device, maybe a bluetooth-serial adapter which can later be connected to something useful, but which would not interrupt any service on the N900. I have the adapters around to connect to my headlight dynamo making in theory a bluetooth proximity gadget that is charged anytime I use the bike for more then a few meters.
SInce the last post in 2007 has there been any progress or threads on porting a bluetooth proximity alarm app?
We dont have USB 4.0 or the proprietary iPhone app for Cricket so this alternate idea is that you simply bluetooth ping the dumb puck attached to your bicycle and alarm if it gets stolen leaving your proximity, it means you can enjoy your coffee without having to watch the bike 100% of the time. If I had more arduino-fu I would connect an arduino and a brake solenoid to the rear wheel to lock up the bicycle if the bluetooth ping times out while in guard mode so I could rescue the bike on foot, maybe a loud alarm too. I think there are actually GSM modems with GPS for the arduino which is another alternate possibility so it could SMS its location.

Last edited by biketool; 2013-10-29 at 06:17.
 
Posts: 569 | Thanked: 462 times | Joined on Jul 2010 @ USA
#9
I have been wishing for something similar for the N900 for a long time.

I would love to be able to start certain programs on the N900 when the bluetooth dongle in my car is in range.
 
Posts: 1,424 | Thanked: 2,623 times | Joined on Jan 2011 @ Touring
#10
So for a dumb bluetooth 'puck' say for keeping track of a bicycle or briefcase there is a bluetooth to serial thing on ebay for about $4, $2 for a charge controller, and solder on an old mobile phone battery, everything for under $10 and stick instide a small plastic box with a charge port cut in it.
I think I will order the hardware and publish the .stl files for p3d printing a case once they come.
I would really like a nice QT app rather than the above scripts and a generic launcher.
Sourced from ebay auctions
1 - JY-MCU bluetooth to serial board $1.04(free int'l shipping)
1 - Micro USB 5V 1A Lithium Battery Charging Board $2.37(free int'l shipping)
1 - battery BL-5J (fake) $6.99(free int'l shipping)
1 - (five pack)switches $2.06 (free int'l shipping)
1 - plastic case(I plan to print one)

I imagine that this should be powerful enough for keeping tabs on a bicycle parked on a curb or rack when you are in a coffee shop or restaurant and should run for maybe a week on a charge, the charge board is smart so it wont overcharge the battery and has a microUSB port. The bluetooth gadget is actually a serial adapter so anything you want to serial TTY to can be connected say an arduino with a sound amp and siren or whatever.

Last edited by biketool; 2013-10-29 at 11:19.
 
Reply


 
Forum Jump


All times are GMT. The time now is 02:43.