<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" media="screen" href="/styles/xslt/rss.xslt"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:c9="http://channel9.msdn.com">
<channel>
	<title>Channel 9</title>
    <atom:link rel="self" type="application/rss+xml" href="http://channel9.msdn.com/Niners/c4f.Andy-Konkol/Posts/RSS"></atom:link>
    <itunes:summary></itunes:summary>
    <itunes:author>Microsoft</itunes:author>
    <itunes:subtitle></itunes:subtitle>
    <image>
      <url>http://mschnlnine.vo.llnwd.net/d1/Dev/App_Themes/C9/images/feedimage.png</url>
      <title>Channel 9</title>
      <link>http://channel9.msdn.com/Niners/c4f.Andy-Konkol/Posts</link>
    </image>
    <itunes:image href=""></itunes:image>
    <itunes:category text="Technology"></itunes:category>
    <description>Channel 9 keeps you up to date with the latest news and behind the scenes info from Microsoft that developers love to keep up with. From LINQ to SilverLight – Watch videos and hear about all the cool technologies coming and the people behind them.</description>
    <link>http://channel9.msdn.com/Niners/c4f.Andy-Konkol/Posts</link>
    <language>en</language>
    <pubDate>Sat, 25 May 2013 01:54:12 GMT</pubDate>
    <lastBuildDate>Sat, 25 May 2013 01:54:12 GMT</lastBuildDate>
    <generator>Rev9</generator>
    <c9:totalResults>1</c9:totalResults>
    <c9:pageCount>1</c9:pageCount>
    <c9:pageSize>25</c9:pageSize>
  <item>
      <title>BlueBoss - Bluetooth Proximity Detection</title>
      <description><![CDATA[
<h3>Summary:</h3>
<p><strong></strong>Bluetooth is now found in a variety of devices and enable the user to use wireless accessories.&nbsp; The Bluetooth protocol allows a user to “discover” any device that is in proximity to your Bluetooth radio.&nbsp; Why not see who is in proximity
 to you?&nbsp; Why not have the presence of a device execute programs or alert you?</p>
<p>Andy Konkol – <u><a href="http://copyandwaste.com/">http://copyandwaste.com</a></u></p>
<p>&nbsp;</p>
<p><strong>Hardware:</strong></p>
<ul>
<li>
<p>Bluetooth radio (USB dongle)</p>
</li><li>
<p>SMA Female Jack</p>
</li><li>
<p>SMA male to N-male pigtail</p>
</li><li>
<p>2.4 GHz antenna (with N-female connector)</p>
</li></ul>
<p><strong>Software:</strong></p>
<ul>
<li>
<p><u><a href="http://www.microsoft.com/express/samples/c4fdevkit/default.aspx">Coding4fun Developer Kit</a></u></p>
</li><li>
<p><u><a href="http://www.codeproject.com/KB/miscctrl/RobMisNotifyWindow.aspx">Robert Misiak's Notify Window</a></u></p>
</li></ul>
<p><strong>Download:</strong> </p>
<ul>
<li>
<p><a href="http://www.codeplex.com/blueboss/Release/ProjectReleases.aspx?ReleaseId=14662">Source / Binary Download</a></p>
</li></ul>
<p><u></u></p>
<h3><strong>Bluetooth and Hardware:</strong></h3>
<br>
<p><strong></strong>Bluetooth was designed for devices to communicate wirelessly over short distances.&nbsp; However, with a very simple hardware modification you can extend the range of your Bluetooth radio with standard 2.4ghz antennas used in wireless networking
 (802.11 a/b/g). </p>
<p>Modifying Bluetooth dongles to accept external antennas is documented all over the Internet.&nbsp; In principle it is very easy: find the antenna lead and solder on a connector/antenna.&nbsp; I purchased a very cheap Bluetooth USB dongle on eBay and opened the casing.&nbsp;
 After finding the antenna trace on the circuit board I soldered on a SMA Female connector to it.&nbsp; After soldering the antenna jack in place I slipped a 3 inch chunk of heatshrink and heated it to cover the exposed circuit board.&nbsp; Now I had a Bluetooth radio
 that accepts external antennas. Adding an antenna simply increases the range of your radio, allowing you to “see” devices from a farther distance.
</p>
<p>To connect an external antenna to the dongle I needed to use a connector converter called a pigtail.&nbsp; I used a SMA male to N-male pigtail.&nbsp; I connected one end of the pigtail to my dongle and the other to an omni-directional 9dbi panel antenna that had an
 N-female connector.</p>
<p><a href="http://ecn.channel9.msdn.com/o9/c4fcontent/migration/8658548/IMG_20701.jpg"><img title="IMG_2070[1]" height="180" alt="IMG_2070[1]" src="http://ecn.channel9.msdn.com/o9/c4fcontent/migration/8658548/IMG_20701_thumb.jpg" width="240" border="0"></a>
<a href="http://ecn.channel9.msdn.com/o9/c4fcontent/migration/8658548/IMG_20711.jpg"><img title="IMG_2071[1]" height="180" alt="IMG_2071[1]" src="http://ecn.channel9.msdn.com/o9/c4fcontent/migration/8658548/IMG_20711_thumb.jpg" width="240" border="0"></a>
</p>
<h3><strong>Software:</strong></h3>
<br>
<p><strong></strong>To take advantage of my newly modified hardware I needed to download the Coding4Fun Toolkit.&nbsp; Included in the toolkit is an API for Bluetooth devices.&nbsp; This API allows you to do a wide variety of things with your Bluetooth radio but I focused
 on two methods from the ServiceAndDeviceDiscovery library: DiscoverAllDevices and DiscoverDeviceByName.
</p>
<p>DiscoverAllDevices allows you to “scan” the airwaves on the 2.4 GHz band and report back what devices your radio sees.
</p>
<p>DiscoverDeviceByName allows you to scan for a particular device with a specified name and report back if it is present or not.</p>
<p><b><i></i></b></p>
<pre class="csharpcode"><span class="kwrd">private</span> <span class="kwrd">bool</span> DevicePresent()
{
    BluetoothDeviceServicesManager workerBTMgr = <span class="kwrd">new</span> BluetoothDeviceServicesManager();
    Device workerDevice = workerBTMgr.DiscoverDeviceByName(_watchItem.DeviceName);

    <span class="kwrd">return</span> (workerDevice != <span class="kwrd">null</span>);
}

<span class="kwrd">public</span> <span class="kwrd">void</span> Run(String Operation)
{
    <span class="kwrd">switch</span> (Operation)
    {
        <span class="kwrd">case</span> <span class="str">&quot;SingleDevice&quot;</span>:
            <span class="kwrd">if</span> (DevicePresent())
            {
                _parentForm.Invoke(_parentForm.AddToDeviceSeenList, <span class="kwrd">new</span> <span class="kwrd">object</span>[] { _watchItem });
            }
            <span class="kwrd">else</span>
            {
                _parentForm.Invoke(_parentForm.RemoveFromDeviceSeenList, <span class="kwrd">new</span> <span class="kwrd">object</span>[] { _watchItem });
            }
            <span class="kwrd">break</span>;
        <span class="kwrd">case</span> <span class="str">&quot;AllDevices&quot;</span>:
            BluetoothDeviceServicesManager workerBTMgr = <span class="kwrd">new</span> BluetoothDeviceServicesManager();
            List&lt;Device&gt; Devices = workerBTMgr.DiscoverAllDevices();
            _parentForm.Invoke(_parentForm.ThreadUpdateDiscoverBox, <span class="kwrd">new</span> <span class="kwrd">object</span>[] { Devices });
            <span class="kwrd">break</span>;
    }
}</pre>
<p>Both of these methods require that the device you are scanning for is in discoverable mode (which most manufacturers enable by default).&nbsp; Using the two methods described above I was able to tell if a device is in proximity. And ultimately enabling me create
 alerts and execute programs based on what device is present. </p>
<p>To perform device discovery and not have my UI lag I had to create two worker threads.&nbsp; One worker thread to discover all devices and display it under my devices listbox, and another to discover devices by name specified in the “watchlist.”&nbsp; I am not an
 expert at multi-threaded programs but I managed to implement them without any major headaches.</p>
<h3>User Interface:</h3>
<p>Since the “Add to watchlist” and “Edit” buttons essentially do the same thing, I decided to overload a windows form.&nbsp; I also wanted to keep track of the parent form and disable it when the WatchItemForm was shown.
</p>
<p>The second overload allows me to fill in the form control's text based on the data that is already set for the WatchItem that has been selected (the Edit button).&nbsp;
</p>
<pre class="csharpcode"><span class="kwrd">public</span> WatchItemForm(Form1 f, String DeviceName)
{
    InitializeComponent();
    <span class="kwrd">this</span>._parentForm = f;
    lblDeviceName.Text = DeviceName;
}

<span class="kwrd">public</span> WatchItemForm(Form1 f, WatchItem item)
{
    InitializeComponent();
    <span class="kwrd">this</span>._parentForm = f;

    lblDeviceName.Text = item.DeviceName;
    tbxPicturePath.Text = item.ImagePath;
    tbxProgramPath.Text = item.ProgramPath;
    <span class="kwrd">this</span>._parentForm.Enabled = <span class="kwrd">true</span>;
}</pre>
<style type="text/css">
<!--
.csharpcode, .csharpcode 
	{font-size:small;
	color:black;
	font-family:consolas,"Courier New",courier,monospace;
	background-color:#ffffff}
.csharpcode 
	{margin:0em}
.csharpcode .rem
	{color:#008000}
.csharpcode .kwrd
	{color:#0000ff}
.csharpcode .str
	{color:#006080}
.csharpcode .op
	{color:#0000c0}
.csharpcode .preproc
	{color:#cc6633}
.csharpcode .asp
	{background-color:#ffff00}
.csharpcode .html
	{color:#800000}
.csharpcode .attr
	{color:#ff0000}
.csharpcode .alt
	{background-color:#f4f4f4;
	width:100%;
	margin:0em}
.csharpcode .lnum
	{color:#606060}
-->
</style>
<p>I wanted to have a pop up notify window similar to outlook and was able to find Robert Misiak's
<a href="http://www.codeproject.com/KB/miscctrl/RobMisNotifyWindow.aspx">NotifyWindow</a>. This is a very simple library which allows you to create pop up notify windows very easily. I edited
<strong>NotifyWindow</strong> to include a “picturepath” variable as well as picturebox on the form. As you can see creating a
<strong>NotifyWindow</strong> is quite easy:</p>
<pre class="csharpcode"><span class="kwrd">public</span> <span class="kwrd">void</span> NotifyDeviceWindow(WatchItem x)
{
    NotifyWindow nw;
    nw = <span class="kwrd">new</span> NotifyWindow();
    <span class="rem">//validate Alert Message</span>
    <span class="kwrd">if</span> (x.AlertMessage == <span class="kwrd">null</span>)
    {
        nw.Text = x.DeviceName;
    }
    <span class="kwrd">else</span>
    {
        nw.Text = x.AlertMessage;
    }
    <span class="rem">//validate picture</span>
    <span class="kwrd">if</span> (x.ImagePath != <span class="kwrd">null</span>)
    {
        FileInfo imgfile = <span class="kwrd">new</span> FileInfo(x.ImagePath);
        <span class="kwrd">if</span> (imgfile.Exists)
        {
            nw.PicturePath = x.ImagePath;
        }
        <span class="kwrd">else</span>
        {
            MessageBox.Show(<span class="str">&quot;Image does not exist&quot;</span>);
        }
    }
    nw.Notify();

    <span class="kwrd">if</span> (x.ProgramPath != <span class="kwrd">null</span>)
    {
        RunProcess(x.ProgramPath);
    }
}</pre>
<style type="text/css">
<!--
.csharpcode, .csharpcode 
	{font-size:small;
	color:black;
	font-family:consolas,"Courier New",courier,monospace;
	background-color:#ffffff}
.csharpcode 
	{margin:0em}
.csharpcode .rem
	{color:#008000}
.csharpcode .kwrd
	{color:#0000ff}
.csharpcode .str
	{color:#006080}
.csharpcode .op
	{color:#0000c0}
.csharpcode .preproc
	{color:#cc6633}
.csharpcode .asp
	{background-color:#ffff00}
.csharpcode .html
	{color:#800000}
.csharpcode .attr
	{color:#ff0000}
.csharpcode .alt
	{background-color:#f4f4f4;
	width:100%;
	margin:0em}
.csharpcode .lnum
	{color:#606060}
-->
</style>
<p><strong>Process Flow/Software Operation:</strong></p>
<ol>
<li>User clicks the “Discover” button, a thread is spawned which enumerates all Bluetooth devices in proximity
</li><li>Thread finishes and updates the Devices listbox </li><li>User selects a discovered device and clicks “Add to watchlist” A watch item form is spawned and asks you for an alert message, a picture path, and an executable path
</li><li>User clicks save , a WatchItem object is created and added to the watchList object
</li><li>A timer starts and every 10 seconds a thread is spawned to discover that device by name
</li><li>If the device is discovered, it is added to the “deviceSeenList” and a notify alert is sent and the executable is executed.
</li><li>If that device is still present after the next timer click, no notification is sent, If that device is not present it is removed from the “deviceSeenList”
</li></ol>
<h3>Screenshots:</h3>
<p><a href="http://ecn.channel9.msdn.com/o9/c4fcontent/migration/8658548/bbmain1.jpg"><img title="bb-main[1]" height="319" alt="bb-main[1]" src="http://ecn.channel9.msdn.com/o9/c4fcontent/migration/8658548/bbmain1_thumb.jpg" width="470" border="0"></a>&nbsp;&nbsp;
<br>
&nbsp;<a href="http://ecn.channel9.msdn.com/o9/c4fcontent/migration/8658548/bbwatchitem1.jpg"><img title="bb-watchitem[1]" height="210" alt="bb-watchitem[1]" src="http://ecn.channel9.msdn.com/o9/c4fcontent/migration/8658548/bbwatchitem1_thumb.jpg" width="257" border="0"></a>
<a href="http://ecn.channel9.msdn.com/o9/c4fcontent/migration/8658548/bbnotify_11.jpg"><img title="bb-notify_1[1]" height="173" alt="bb-notify_1[1]" src="http://ecn.channel9.msdn.com/o9/c4fcontent/migration/8658548/bbnotify_11_thumb.jpg" width="226" border="0"></a>
</p>
<ol>
</ol>
 <img src="http://m.webtrends.com/dcs1wotjh10000w0irc493s0e_6x1g/njs.gif?dcssip=channel9.msdn.com&dcsuri=http://channel9.msdn.com/Niners/c4f.Andy-Konkol/Posts/RSS&WT.dl=0&WT.entryid=Entry:RSSView:ae26329a3b09479683289e7600cf21c3">]]></description>
      <comments>http://channel9.msdn.com/coding4fun/articles/BlueBoss-Bluetooth-Proximity-Detection</comments>
      <itunes:summary>
Summary:
Bluetooth is now found in a variety of devices and enable the user to use wireless accessories.&amp;nbsp; The Bluetooth protocol allows a user to “discover” any device that is in proximity to your Bluetooth radio.&amp;nbsp; Why not see who is in proximity
 to you?&amp;nbsp; Why not have the presence of a device execute programs or alert you? 
Andy Konkol – http://copyandwaste.com 
&amp;nbsp; 
Hardware: 


Bluetooth radio (USB dongle) 

SMA Female Jack 

SMA male to N-male pigtail 

2.4 GHz antenna (with N-female connector) 

Software: 


Coding4fun Developer Kit 

Robert Misiak&#39;s Notify Window 

Download:  


Source / Binary Download 

 
Bluetooth and Hardware:

Bluetooth was designed for devices to communicate wirelessly over short distances.&amp;nbsp; However, with a very simple hardware modification you can extend the range of your Bluetooth radio with standard 2.4ghz antennas used in wireless networking
 (802.11 a/b/g).  
Modifying Bluetooth dongles to accept external antennas is documented all over the Internet.&amp;nbsp; In principle it is very easy: find the antenna lead and solder on a connector/antenna.&amp;nbsp; I purchased a very cheap Bluetooth USB dongle on eBay and opened the casing.&amp;nbsp;
 After finding the antenna trace on the circuit board I soldered on a SMA Female connector to it.&amp;nbsp; After soldering the antenna jack in place I slipped a 3 inch chunk of heatshrink and heated it to cover the exposed circuit board.&amp;nbsp; Now I had a Bluetooth radio
 that accepts external antennas. Adding an antenna simply increases the range of your radio, allowing you to “see” devices from a farther distance.
 
To connect an external antenna to the dongle I needed to use a connector converter called a pigtail.&amp;nbsp; I used a SMA male to N-male pigtail.&amp;nbsp; I connected one end of the pigtail to my dongle and the other to an omni-directional 9dbi panel antenna that had an
 N-female connector. 


 
Software:

To take advantage of my newly modified hardware I needed to download the </itunes:summary>
      <link>http://channel9.msdn.com/coding4fun/articles/BlueBoss-Bluetooth-Proximity-Detection</link>
      <pubDate>Thu, 26 Jun 2008 19:09:42 GMT</pubDate>
      <guid isPermaLink="false">http://channel9.msdn.com/coding4fun/articles/BlueBoss-Bluetooth-Proximity-Detection</guid>
      <media:thumbnail url="http://ecn.channel9.msdn.com/o9/c4f/images/8658548_100.jpg" height="75" width="100"></media:thumbnail>
      <media:thumbnail url="http://ecn.channel9.msdn.com/o9/c4f/images/8658548_220.jpg" height="165" width="220"></media:thumbnail>      
      <dc:creator>Andy Konkol</dc:creator>
      <itunes:author>Andy Konkol</itunes:author>
      <slash:comments>12</slash:comments>
      <wfw:commentRss>http://channel9.msdn.com/coding4fun/articles/BlueBoss-Bluetooth-Proximity-Detection/RSS</wfw:commentRss>
      <category>Hardware</category>
      <category>Productivity</category>
      <category>utility</category>
      <category>Windows</category>
    </item>    
</channel>
</rss>