<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DZone Snippets: rfcomm code</title>
    <link>http://snippets.dzone.com/posts</link>
    <pubDate>Wed, 23 Jul 2008 23:52:11 GMT</pubDate>
    <description>DZone Snippets: rfcomm code</description>
    <item>
      <title>Using Ruby to detect Bluetooth proximity</title>
      <link>http://snippets.dzone.com/posts/show/5536</link>
      <description>This Ruby script uses the  hcitool and rfcomm to detect the proximity of a bluetooth enabled mobile phone. The signal strength in this script will return a value from 0 to 10, 0 is near and 10 is far, otherwise if there is no connection it will keep on trying.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;deviceid = '00:12:D1:E6:57:BE' &lt;br /&gt;range = ''&lt;br /&gt;count = 0&lt;br /&gt;while count &lt; 1&lt;br /&gt;  # assuming the bt device is already connected get the signal strength value.&lt;br /&gt;  range = `hcitool rssi #{deviceid}`.chomp&lt;br /&gt;  if  range.length &gt; 0&lt;br /&gt;    puts range[/\w+$/]&lt;br /&gt;  else&lt;br /&gt;    puts 'connecting to the bluetooth device ...'&lt;br /&gt;    Thread.new{`rfcomm connect 0 #{deviceid}`}&lt;br /&gt;  end&lt;br /&gt;	&lt;br /&gt;  sleep 7&lt;br /&gt;end&lt;br /&gt;&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;warning (11-Jul-2008): I've  found Thread.new to be causing a problem, it appears not to remove itself from the process queue when  it is no longer required.</description>
      <pubDate>Sun, 25 May 2008 10:57:00 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5536</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>Simple Bluetooth Proximity</title>
      <link>http://snippets.dzone.com/posts/show/5528</link>
      <description>Following on from my earlier investigation into bluetooth proximity, I wanted something which returned a value which could be used to determine distance. The output from hcitool rssi ranges from 0 for close object down to -10 for far away objects.&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;rfcomm connect 0 00:12:D1:E6:57:BE&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;hcitool rssi 00:12:D1:E6:57:BE&lt;br /&gt;&lt;/code&gt;&lt;br /&gt;&lt;br /&gt;Proximity Results:&lt;br /&gt;-4 ..  0  : Bedroom - nearest to my bed&lt;br /&gt;-4 .. -6  : Hallway&lt;br /&gt;-8 .. -9  : Livingroom - on the computer desk&lt;br /&gt;-9 .. -10 : Livingroom - nearest to the window&lt;br /&gt;</description>
      <pubDate>Tue, 20 May 2008 22:39:59 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/5528</guid>
      <author>jrobertson (James Robertson)</author>
    </item>
    <item>
      <title>PyS60 - SendFile</title>
      <link>http://snippets.dzone.com/posts/show/3040</link>
      <description>// Send File over Bluetooth&lt;br /&gt;&lt;br /&gt;&lt;code&gt;&lt;br /&gt;from appuifw import *&lt;br /&gt;from e32socket import *&lt;br /&gt;&lt;br /&gt;try:&lt;br /&gt;    phone = bt_obex_discover()&lt;br /&gt;    file = query(u'File Selection', 'text')&lt;br /&gt;    bt_obex_send_file(phone[0], phone[1].values()[0], file)&lt;br /&gt;    note(u'File Sent')&lt;br /&gt;except Exception, error:&lt;br /&gt;    note(unicode(error), 'error')&lt;br /&gt;&lt;/code&gt;</description>
      <pubDate>Sun, 26 Nov 2006 21:12:40 GMT</pubDate>
      <guid>http://snippets.dzone.com/posts/show/3040</guid>
      <author>whitetiger ()</author>
    </item>
  </channel>
</rss>
