Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Detect the presence of a Bluetooth device (See related posts)

This example shows how to check for the presence of a mobile phone. The code was based on the article 'Implementing Bluetooth Proximity Detection with Asterisk, Part II' http://snipr.com/1vvi5 [nerdvittles.com]

#!/usr/bin/ruby
#file: whereib.rb

deviceid = '00:0E:6D:29:38:EB'
devicename = 'Nokia 6600'

count = 0
while count < 1
  if `hcitool name #{deviceid}`.chomp == devicename 
    puts devicename + ' IN RANGE'
    puts Time.now
  else
    puts devicename + ' OUT OF RANGE'
    puts Time.now
  end
  sleep 7
end  

You need to create an account or log in to post comments to this site.


Click here to browse all 5140 code snippets

Related Posts