Follow-Me Phoning: Implementing Bluetooth Proximity Detection with Asterisk, Part I

This is the first in a series of articles that will provide step-by-step instructions for implementing Bluetooth Proximity Detection. We’re going to focus on using it with Asterisk®@Home, a terrific PBX which also happens to be free. But your imagination is really the only limitation. At the very least, when we’re finished, you’ll be able to walk out of your home or office carrying your bluetooth phone or headset and have your Asterisk server automatically transfer your incoming calls to your cellphone. And, when you return carrying your bluetooth phone or headset, Asterisk will automatically cancel the call transfers and reactivate delivery of incoming calls to the designated phones in your home or office. As simple as this concept may sound, the devil is in the details. So we want to spend today warning you of all the minefields that lie ahead and telling you what hardware you’ll need to make things work. If you hurry, you can implement the whole system for just over $50, and we’ll show you how to do it without even owning a bluetooth cellphone. In subsequent articles, we’ll put the pieces together and get a basic system working. Then we’ll add more bells and whistles and give you some implementation and deployment suggestions. You’ll quickly come to appreciate how Bluetooth Proximity Detection can be used to implement all sorts of other features. When we’re finished, you’ll also appreciate the potential of bluetooth to revolutionize the workplace. And it goes far beyond your phone system. Imagine an automated IN/OUT message board in businesses such as real estate or the advertising potential to tailor TV display ads in stores based upon not only your presence but also the type of cellphone you are carrying. Your office can even kiss its old punch clock goodbye when we’re finished. For those with new Cadillac or Mercedes automobiles, you can unlock your car and start it just by approaching the vehicle with your “key” still in your pocket. So where do we start?

NOTE: This article has been updated to take advantage of TrixBox, freePBX, and the iPhone. For the current article, click here.

Overview. The basic idea behind proximity detection is that we run a software application on a computer to “watch” for approaching people. We then want it to do something when you (or a customer) gets within range. How do it know? Well, in our case, this is where Bluetooth comes in. Unlike motion detectors which can’t tell the difference between a human and a gorilla, bluetooth devices all have a unique MAC address just like a network card. And most bluetooth devices also have a name. So long as the bluetooth device is configured to advertise its presence, we can detect when it is within range and when it’s not. That’s the second major difference between bluetooth and traditional motion detectors. Ever been in a public restroom or an office when all the lights went out because everybody was sitting too still for too long? So motion detectors have some limitations. Bluetooth doesn’t. In case you’ve been living under a rock for the past six years, bluetooth is a wireless communications protocol that uses short range radio frequency to connect devices into wireless personal area networks (PANs). The most common Class II 2.5mW devices have a range of 32 feet (10 meters). Class I devices have a range of up to 100 meters. Most bluetooth cellphones, headsets, and computer peripherals such as mice and keyboards are Class II devices. If you want more background, go here.


Prerequisites. For our proximity detection project, we’re going to connect a bluetooth network adapter to an Asterisk@Home box and make it our master. That simply means we’re going to use this network adapter to look for other bluetooth devices within range. The only limitation is you can’t have your Asterisk@Home box shoved in a closet in the basement if you want this to work. It will need to be within 30 feet or so of where you’ll be when you’re at home or in the office. If this doesn’t work for you, then here’s an alternative. Just get in the habit of putting your cellphone or bluetooth headset down near your Asterisk@Home box when you’re “in” and take it with you when you’re “out.” Many offices, particularly in the real estate business, have a receptionist with agent mailboxes immediately beside or behind the receptionist desk. Just put your Asterisk box with its bluetooth adapter under the receptionist’s desk and leave your cellphone or wireless headset in your mailbox whenever you return to the office. The adapter we recommend which is quirk-free is dLink’s DBT-120. You can find them on the net for about $30, but you can usually beat that price by watching the Sunday circulars for computer and office depot/max stores in your area … if you don’t mind mail-in rebates. But, do you really want the PBX for your whole office sitting under the receptionist’s desk? Probably not. But don’t worry, we’ve got some other tricks up our sleeve so keep reading.


We keep mentioning a headset so we won’t keep you in suspense any longer. You don’t need a bluetooth cellphone to make our proximity detection project work. A bluetooth wireless headset works just as well. In fact, it works better! And you’ll have a great addition to your computer system and cellphone as an added bonus. Cellphones have a nasty habit of putting themselves in sleep mode very quickly when not in use to conserve battery power. The only problem is that most, if not all, cellphone makers turn off the bluetooth adapter when they activate sleep mode because they’re all so short-sighted that the only thing they think you use bluetooth for is to talk to your wireless headset or exchange files with your PC. Stupid! Bluetooth headsets on the other hand are always on listening for a call. The one we like has a rated standby time of 200 hours between battery charges so it’s perfect for this project. These devices typically cost anywhere from $50 to $100 but, if you hurry, there’s a vendor selling our favorite, the Plantronics M3000, for under $20. Here’s the link at PriceGrabber. Don’t wait. They’re never this cheap, and this vendor only has 50 of them. And Buy.com has a similar unit from IOgear for about the same price once you factor in the cost of shipping. Will you need to wear your bluetooth headset and look like a Nerd to make this work? Not at all. Just turn it on, stuff it in your pocket, and call it a key.

Now let’s address the computer issues. First, your machine obviously needs USB adapter support so you have a place to plug in your bluetooth adapter. Second, we need a machine that can run software that can detect bluetooth devices. Having spent a week scouring the Internet and testing various products which touted their bluetooth proximity detection, let me save you some time. If you are fortunate enough to have a Sony Ericsson phone with bluetooth, some of the commercial products such as BluePhoneElite for the Mac or Salling Clicker for Mac or Windows work great for proximity detection. There’s even an open source product, Romeo for the Mac, that works. If you have a single-tasking Palm device including the Treo 650 cellphone, don’t waste your time. And bluetooth headsets aren’t detected at all by any of the products. This is primarily because proximity detection was considered a gee-whiz extra in most of these products so it’s not implemented very well. The good news is that, if you happen to have a bluetooth cellphone that does work with one of these products, it might make proximity detection more practical because you could handle the proximity interaction with your desktop machine instead of with your telephone system’s PBX. But, who cares. We just want it to work.


So where does that leave us on the computer front? The bottom line is you’re going to need a Linux machine and a fairly current version of the Linux operating system to get the bluetooth tools installed that we need. As luck would have it, the new Asterisk@Home 2.0 beta release works great … and it’s free. And it automatically installs CentOS/4, the free knock-off of RedHat’s commercial Enterprise Linux 4. Because Asterisk@Home is free and will run on any old clunker PC, you may want to install the Asterisk@Home 2.0 beta on a dedicated machine and just use it for proximity detection. This solves the colocation problem with your main PBX, and it has the added benefit of reducing the load on your primary Asterisk server. The other terrific benefit of this approach is you’ll have a hot standby system for your main PBX, and we’ll integrate that into our tutorials one of these days, too. When your one and only Asterisk@Home box dies, do you really want to be without phone service? Keep in mind that proximity detection also takes some horsepower because we’ll be running a script once a minute to see who’s in and who’s not. And, no, Asterisk@Home 1.5 won’t work. Believe me, we’ve tried and it was just about as frustrating as trying to use a Treo 650 for proximity detection. A total bust!

Well, that covers the basics and provides you the information you’ll need to start assembling the pieces for the proximity detection project. We’ll leave it to you to get your bluetooth hardware ordered and to get your Asterisk@Home 2.0 beta up and running before moving on to Chapters 2 and 3.


Some Recent Nerd Vittles Articles of Interest…

Be Sociable, Share!

19 Responses to “Follow-Me Phoning: Implementing Bluetooth Proximity Detection with Asterisk, Part I”

  1. Blair says:

    I just got a new in box Plantronics m3000 on Ebay for $21.99.
    I am not up to speed for this tutorial, but I needed to get a bluetooth headset for my new Crackberry 7250.

    My asterisk server will probably end up in a closet in my basement since that is where all the Cat 5e terminates. (and the server sounds like a mac truck idling)

    I am in the process of setting up a sff touchscreen pc for my kitchen running debian 3.1.(for x-10 and misterhouse) Could I use this pc for my bluetooth proximity detector?
    Also, are there any security concerns with implementing bluetooth into a home Lan?

    Thanks for all the great info, and keep up the good work.

    Regards,
    Blair

    [WM: Go ahead and follow along with us with an install on the machine destined for your basement closet. You may be surprised by the range of the Bluetooth devices. I was. I haven't played with Debian 3.1, but I think yum is bundled in the distribution so the installation steps will be almost identical. That's the beauty of Linux. And the system will also tell you whether there are dependency problems it can't resolve. So you'll know very quickly whether it'll fly or not. Good luck!]

  2. Erik Pettersson says:

    Ok, this idea is cool. But.

    Check out http://www.plutohome.com which does this and aaaaaalot of more stuff (advanced tv-functionality, asterisk, bluetooth, cellphone interaction, control your house and some security control systems. Check it out already!!!)
    Also under a semi-free license!

    It’s really worth checking out, I don’t know how DIY it is tho’

  3. This sounds cool, so somebody figured out howto get something like my star-com-system (http://www.mulliner.org/collin/startrekcom.php) to work :-)

  4. pvh says:

    Is there any way to use the cell phone as a trunk line to Asterisk? This way nights and weekends are free as are cell-to-cell calls.

    [WM: Take a look at Dock-n-Talk. We haven't tried it personally, but it seems to do what you want when used in conjunction with a Sipura ATA.]

  5. JPE says:

    Check this out. I have it making calls out over asterisk very basically. Cant get the inbound working though….. http ://www.thetechguide.com/howto/asterisk/chanbluetooth.html

    J.P.

  6. Russ says:

    You can get a box from Aleen Tech that plugs into an analog port off of a standard PBX. The box requires a SIM chip from Cingular or Sprint so you’d need a 2nd account, but you can program any PBX to dial out over the box by setting it up as a line or extension. The box is only $300 but are you saving enough on your monthlies? Cingular’s family plan has a second account for $6.95 in CA, so its pretty cheap if you only talk nights and weekends.

  7. Jerome says:

    I am new to this. Do you have any information on how to set up an asterisk Server and where do I get the software.

    [WM: Go here to download the software and read our Newbie's Guide on installing it.]

  8. Tom says:

    Salling is great but you should try Bluetooth Remote Control which has the same features at a much lower price.

  9. Tom says:

    I am using Bluetooth Remote Control at Bluetooth Shareware.

    It has a load of features but not proximity but that shall be added in the next release according to the developers!

  10. Norm says:

    re: you can?ǨѢt have your Asterisk@Home box shoved in a closet in the basement

    Don’t be too worried if your server has to be tucked beneath a desk, or between a couple of filing cabinets. Just use a 6 or 12 foot USB extension cable, and stick the USB Bluetooth adapter on the end of it. Then you can position the adapter in a more optimum location where it has a better chance of establish a “line-of-sight”. Bluetooth operates in same 2.4GHZ “junk band” as WiFi, some cordless phones, etc, so good antenna position will help tremendously with range and performance.

  11. clint says:

    You could always use a Single Port USB wall plate. This could be mounted to your ceiling around the office entry with a USB extension back to your server room.

    They sell a USB wall plate for $10 at: http://www.datapro.net/products/70200.html

  12. Eric says:

    As far as the bluetooth unit having to be 30 some-odd feed from the user and it taking up a significant amount of cpu/memory to run that script:

    Don’t they make a usb bluetooth adapter that has an antennae on a cord rather then just jutting out the back of the pc’s usb port? There are a few wireless cards like this, where it either has a hardwired or removable coax cord to the antennae. If you could get a bluetooth device to attach to the asterisk box that had this, you could probably just run the line over cat 5 and put the ant right near where the users are in their little cube farm or what have you. So, in installations where the pbx is down in the basement or in a server room or telco room, this would solve that problem. Can that be done?

    A lot of us are doing commercial asterisk installs on glorified servers; ie desktops that are quite fast and have more power and memory then you technically need for asterisk. The reason is, you’re selling a new phone system so you can’t really show up with your 486 dx4 from college. But, doing it at home on clunker hardware for an enthusiast would probably require the second box. But, in a comemrcial environment, I’d argue having one box do it would be fine.

  13. John Dias says:

    I have a use for proximity detection that goes beyond mere household convenience, and is instead related to safety and security. I have read about how some women will file a restraining order against a man, making him subject to arrest if he goes near her. But then, to punish the man (who may very well be complying with the order), the woman seeks him out (stalks him) and finds him in a place she expects him to be (like a supermarket), keeps nearby but out of his sight, and then uses her cell phone to call the police and accuse the poor guy of violating his restraining order to keep away from her. She seeks him out, then acts like she’s a victim of his “alleged” stalking. A law-abiding man would honor the restraining order and should not be punished for doing so; a crazed lunatic would violate his restraining order anyway, which makes you wonder how effective restraining orders are against truly threatening people.

    If only the poor guy could utilize Bluetooth proximity detection to see if the woman who is accusing him is in range. If his cell phone alerts him “she’s near by! Get the hell out of here!” then he can leave before he is falsely accused of violating his “no contact” order.

    Alternatively, proximity detection could be useful for a woman who legitimately fears another person stalking her and simply wants to escape him.

    Could Bluetooth proximity technology be useful for these purposes? How could it be implemented without carrying a full-on PC computer around with you? Assuming both the stalker and the stalked both have Bluetooth turned on in their cell phones, could this work?

  14. John Dias says:

    I have answered my own question. You can detect the proximity of any active Bluetooth device if you have a Series 60 cell phone (see s60.com for examples), and you install a program called Bluetracker (available for $5.50 at Handango.com):

    http://www.handango.com/ampp/store/PlatformProductDetail.jsp?siteId=308&jid=2CB3E77X5A2B36A8B53C542D9E27DFC8&platformId=4&productType=2&catalog=0&sectionId=0&productId=176674

    John Dias
    Founder, DontMakeHerMad.com
    http://www.dontmakehermad.com/

    “Hell hath no fury like a false allegation”

  15. Fadi says:

    I must realize a wireless connection between a GSM’s phone and asterisk via WLAN or Bluetooth…
    In other words, a mobile(GSM phone) as of its entry in the zone of cover of my Wlan or the zone of cover of my Bluetooth, whitch is connected to Asterisk, must be able to receive and emit Voip calls.(using a GSM cell phone like an Asterisk’s endpoint).
    Between my GSM cell phone and Asterisk, all calls must be transmit over WLAN or Bluetooth.
    for this i must program the mobile(GSM cell phone) so that it detects the Wlan or Blutooth network and to be recorded on asterisk to receive calls from asterisk and via wlan/bluetooth detected.
    do you have an idea how I must proceed to achieve this goal?
    Asterisk — WLAN or Bluetooth —- GSM Phone ——> other IP Phone

  16. Mary Hartman says:

    I watched as a woman took what I was told was a Bluetooth device up to a payphone where I had just placed some calls. She punched some numbers into the device and then punched some numbers into the phone. She then held the phone receiver and the device together, as if the device was recording something. Do you have any idea what it was and what she was doing? It looked like the cartoon drawing at the top of this site, but black.

  17. Henry says:

    Mary, a traditional telphone network takes any touch tones it hears and uses them just as if you dialed a number on the keypad. So if you made a recording of the sound of dialing your home phone number and then you played the recording back on a public pay phone, the phone would dial the number. That is not always true or obvious with VOIP/SIP phones because it depends on a lot of other variables how they behave.

    My guess is that the woman you saw has a device that plays the touch tones. She could have an address book with phone numbers in it and just press the “John Doe” button to have it make the pay phone call John Doe. She was probably recording touch tones too. Maybe from some voicemail service that tells her who called by playing back the touchtone version of the number in the caller id of the voice mail message.

  18. Maricela Ylonen says:

    Thank you for this blog article.In fact looking forward to reading more. Great.

  19. Latia Bapties says:

    Bluetooth headsets are very convenient too use since they do not use clumsy wiring.

Leave a Reply

Ringbinder theme by Themocracy