<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Sensor &amp; Location Platform Team Blog</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/sensorslocation/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/sensorslocation/feed.xml</link>
    <description />
    <lastBuildDate>Wed, 17 Apr 2019 03:25:40 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>Using an Accelerometer to Build a Game Controller</title>
      <link>https://docs.microsoft.com/archive/blogs/sensorslocation/using-an-accelerometer-to-build-a-game-controller</link>
      <pubDate>Tue, 29 Jun 2010 17:00:00 GMT</pubDate>
      <dc:creator><![CDATA[sensblog]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sensorslocation/2010/06/29/using-an-accelerometer-to-build-a-game-controller/</guid>
      <description><![CDATA[The XNA team created their XNA Game Studio to simplify the creation of games for: Windows, the Xbox...]]></description>
      <content:encoded><![CDATA[<p align="justify"><span style="font-family: Calibri; font-size: small;">The XNA team created their XNA Game Studio to simplify the creation of games for: Windows, the Xbox 360, the Zune, and the Windows Phone 7 Series. The Game Studio includes the XNA Framework--a set of managed libraries that are designed for game development. Version 3.1 allows you to create games for the PC, the Xbox 360, and the Zune while version 4.0 adds support for the Windows Phone 7 Series.</span></p>
<p align="justify"><span style="font-family: Calibri; font-size: small;">The XNA Game Studio is designed to work with Microsoft Visual Studio&mdash;and allows you to write games in C#. </span></p>
<p align="justify"><span style="font-family: Calibri; font-size: small;">If Visual Studio 2008 is installed on your PC, you can download XNA Game Studio 3.1 from the </span><a href="https://creators.xna.com/en-US/downloads"><span style="font-family: Calibri; font-size: small;">XNA creator&rsquo;s club site</span></a><span style="font-family: Calibri; font-size: small;">. And, once you download the Game Studio, you&rsquo;ll find a sample game under the &hellip;\Visual Studio 2008\Templates\ProjectTemplates\Visual C#\XNA Game Studio 3.0 folder. This sample game, RacingGameWindows, is a complete auto racing game that runs on a PC or the Xbox 360. The game allows the user to customize their car, to choose the level of difficulty for the track, and to race a pace car. The game includes rich sound and lighting features. And, the game also includes code that responds to the physics of the car and the track&mdash;creating realistic responses, for example, to over-acceleration or under-steering.</span></p>
<p align="justify"><span style="font-family: Calibri; font-size: small;">In its default state, the game accepts input from the keyboard, the mouse, or an Xbox 360 controller. For example, with the keyboard, the user can accelerate the car by pressing the up-arrow (&uarr;) or slow the car down by pressing the down-arrow (&darr;); the user can steer left by pressing the left-arrow (&larr;) and steer right by pressing the right-arrow (&rarr;).</span></p>
<p align="justify"><span style="font-family: Calibri; font-size: small;">With minor additions to three source files, and using the Sensor and Location platform, we were able to add support for another input device: a dual-axis accelerometer. The updates to the source files consisted of: 1 new line in the file basegame.cs, 13 new lines in the file carphysics.cs, and 46 new lines in the file input.cs. (Minimal changes when you consider the number of lines of new code.)</span></p>
<p align="justify"><span style="font-family: Calibri; font-size: small;">Once support for the Sensor platform was added, the user can control the car by moving an accelerometer in their hand. When they tilt the accelerometer along its positive Y-axis, the car accelerates, when they tilt the accelerometer along the negative Y-axis, the car slows down. When they tilt the accelerometer along the positive X-axis, the car steers to the right; when they tilt the accelerometer along the negative X-axis, the car steers to the left.</span></p>
<p align="justify"><span style="font-family: Calibri; font-size: small;">The following screenshot shows a user controlling their car using a circuit board that contains the Memsic dual-axis accelerometer:</span></p>
<p><img height="264" width="350" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/30/82/metablogapi/4503.image_5BA4906A.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-30-82-metablogapi/4503.image_5F00_5BA4906A.png" alt="image" border="0" title="image" style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" /> </p>
<p align="justify"><span style="font-family: Calibri; font-size: small;">The circuit board in the previous illustration was built using the Memsic dual-axis accelerometer and the Parallax BASIC Stamp 2 programmable microcontroller. Both of these components, the circuit board itself, and the USB-to-Serial cable (in the picture) can be ordered from the </span><a href="https://www.parallax.com/"><span style="font-family: Calibri; font-size: small;">Parallax Corporation</span></a><span style="font-family: Calibri; font-size: small;"> in Rocklin, California. To help you get started building the circuit, we&rsquo;ve provided a whitepaper that you can download from </span><a href="https://code.msdn.microsoft.com/motionsensor/Release/ProjectReleases.aspx?ReleaseId=3935"><span style="font-family: Calibri; font-size: small;">here</span></a><span style="font-family: Calibri; font-size: small;">. (You can download sample firmware files from this same location).</span></p>
<p align="justify"><span style="font-family: Calibri; font-size: small;">So, you&rsquo;re probably asking, how does the accelerometer data reach the racing game? Good question. The linkage between the sensor device and the Sensor API is a sample driver which you can download from </span><a href="https://code.msdn.microsoft.com/motionsensor/Release/ProjectReleases.aspx?ReleaseId=3935"><span style="font-family: Calibri; font-size: small;">here</span></a><span style="font-family: Calibri; font-size: small;">. This driver &ldquo;listens&rdquo; for input from the accelerometer and passes that input to the Sensor API. By invoking Sensor API methods and properties in the racing game, we are able to monitor changes in the sensor state and use this data to control the car.</span></p>
<p align="justify"><span style="font-family: Calibri; font-size: small;">We&rsquo;ve provided a whitepaper that describes the necessary changes to the racing game. In addition, we&rsquo;ve provided the three updated source files and a COM Interop that allows you to access the Sensor platform through .Net. You can download the documentation, the updated source files and the COM interop, using the Downloads tab on our </span><a href="https://code.msdn.microsoft.com/GameController"><span style="font-family: Calibri; font-size: small;">Build Your Own Game Controller</span></a><span style="font-family: Calibri; font-size: small;"> page on the MSDN Code Gallery.</span></p>
<p><span style="font-family: Calibri; font-size: small;">-- Sensor &amp; Location Platform Team</span></p>
<p><span style="font-family: Calibri; font-size: small;">This posting is provided "AS IS" with no warranties and confers no rights.</span></p>]]></content:encoded>
    </item>
    <item>
      <title>Making Sense of Sensor Permissions</title>
      <link>https://docs.microsoft.com/archive/blogs/sensorslocation/making-sense-of-sensor-permissions</link>
      <pubDate>Fri, 25 Jun 2010 11:00:00 GMT</pubDate>
      <dc:creator><![CDATA[sensblog]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sensorslocation/2010/06/25/making-sense-of-sensor-permissions/</guid>
      <description><![CDATA[In this, my first Sensor and Location Team Blog post, I will discuss sensor permissions.
I&rsquo;ll...]]></description>
      <content:encoded><![CDATA[<p align="justify"><span style="font-family: Calibri; font-size: small;">In this, my first Sensor and Location Team Blog post, I will discuss sensor permissions.</span></p>
<p align="justify"><span style="font-family: Calibri; font-size: small;">I&rsquo;ll cover:</span></p>
<p align="justify"><span style="font-family: Calibri; font-size: small;">&middot; Clearing up some confusion around sensors and devices</span></p>
<p align="justify"><span style="font-family: Calibri; font-size: small;">&middot; What are sensor permissions</span></p>
<p align="justify"><span style="font-family: Calibri; font-size: small;">&middot; What permissions permits</span></p>
<p align="justify"><span style="font-family: Calibri; font-size: small;">&middot; How the sensor platform uses permissions</span></p>
<p align="justify"><span style="font-family: Calibri; font-size: small;">The players in this post are shown in the following diagram:</span></p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/30/82/metablogapi/5460.clip_image002_5F09763A.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-30-82-metablogapi/5460.clip_5F00_image002_5F00_5F09763A.png"><span style="font-family: Verdana; font-size: small;"></span></a></p>
<p><img height="171" width="450" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/30/82/metablogapi/0268.clip_image002_thumb_72704A38.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-30-82-metablogapi/0268.clip_5F00_image002_5F00_thumb_5F00_72704A38.png" alt="clip_image002" border="0" title="clip_image002" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" /></p>
<p><a></a><a></a></p>
<p align="justify"><b><span style="font-family: cal; font-size: small;">A Point of Confusion:</span></b></p>
<p align="justify"><span style="font-family: cal; font-size: small;">Before going into the world of sensor permissions I want to first clear up a misconception around the use of the word <b>&lsquo;sensor&rsquo;</b> in our platform. </span></p>
<p align="justify"><span style="font-family: cal; font-size: small;">If you haven&rsquo;t done so, take a look at the<b> Location and Other Sensors Control Panel</b> (internally we just call it the Sensors CPL &ndash; a quick short-cut is to simply enter <b>sensors</b> in the start menu search box). This is where you enable a sensor. In reality when you enable a sensor you are really enabling access to a <b><span style="text-decoration: underline;">device</span></b>. </span></p>
<p align="justify"><span style="font-family: cal; font-size: small;">But why is it that the device manager indicates that the device is enabled when the Sensors CPL says it is disabled? They aren&rsquo;t really contradicting each other; it is just that the sensor platform uses the term <b>&lsquo;enabled&rsquo;</b> to mean that access to sensor data is allowed (more about this below).</span></p>
<p align="justify"><span style="font-family: cal; font-size: small;">The vast majority of devices implement only one sensor per device so enabling a sensor is atomic &ndash; one permission for the single sensor device. However new devices may have multiple sensors per device. For such a device granting permission to the sensor in the Sensors CPL is actually going to grant permission to all the sensors on the device. The device with multiple sensors will appear as a single sensor device in the Sensors CPL (for example it could be called <b>&ldquo;Sensor Array&rdquo;</b>) even though it will actually expose more than one sensor. You need to be aware that permissions apply to all the sensors on a device. An example of this can be seen on the </span><a href="https://www.freescale.com/webapp/sps/site/prod_summary.jsp?code=JMBADGE2008-B"><span style="font-family: cal; font-size: small;">Sensor Development Kit</span></a><span style="font-family: cal; font-size: small;"> sold by Freescale. Okay, back to the scheduled blog.</span></p>
<p align="justify"><b><span style="font-family: cal; font-size: small;">What Are Sensor Permissions?</span></b></p>
<p align="justify"><span style="font-family: cal; font-size: small;">Sensor permissions control the flow of data between the Sensor Class Extension (which a device driver must have in order to talk to the sensor platform) and the Sensor API. </span></p>
<p align="justify"><b><span style="font-family: cal; font-size: small;">What Do Sensor Permission Permit?</span></b></p>
<p align="justify"><span style="font-family: cal; font-size: small;">So why have sensor permissions? It comes down to <b>P</b>ersonally <b>I</b>dentifiable <b>I</b>nformation or PII. You don&rsquo;t want to expose personal details by default. Your location based on location sensors or health data (e.g. blood sugar levels based on some as yet developed sensor) are examples of sensor data that expose PII. Once the data is available it can be made available to all apps &ndash; some of which could broadcast the data to others. To allow you, the user, to secure your personal data an opt-in model is used. Once you install a new sensor device you need to decide who can get access to the data. You can grant access to all users to the sensor data by checking the check box on the CPL main page or you can go to the User Settings page and choose which users are enabled to access sensor data. The latter is useful in case you don&rsquo;t want another user of the computer to access sensor data. An example is allowing yourself access to your location but not allowing your children to get (and broadcast) their location from their account. </span></p>
<p align="justify"><span style="font-family: cal; font-size: small;">The sensor platform uses SIDs (security identifiers) to identify users. Associated with the SID is an enable flag. There can be multiple SID/flag pairs depending upon how the permissions were set up in the User Settings page. The sensor permissions are stored in the registry with the format shown in the picture below for a root enumerated sensor:</span></p>
<p>&nbsp;</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/30/82/metablogapi/2388.clip_image004_6986365B.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-30-82-metablogapi/2388.clip_5F00_image004_5F00_6986365B.png">
<p><span style="font-family: Verdana; font-size: small;"></span></p>
<a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/30/82/metablogapi/3005.clip_image004_590846FE.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-30-82-metablogapi/3005.clip_5F00_image004_5F00_590846FE.png"><img height="240" width="223" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/30/82/metablogapi/5852.clip_image004_thumb_2DC3AFF7.png" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/CommunityServer-Blogs-Components-WeblogFiles/00-00-01-30-82-metablogapi/5852.clip_5F00_image004_5F00_thumb_5F00_2DC3AFF7.png" alt="clip_image004" border="0" title="clip_image004" style="border-right-width: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; margin-left: 0px; border-left-width: 0px; margin-right: 0px" /></a><a></a><a></a></a></p>
<p align="justify"><span style="font-family: cal; font-size: small;">Okay so I&rsquo;ve established that sensor permissions determine who (which user accounts) gets access to potentially PII sensor data but you can still access certain sensor data even if the sensor is not enabled. What is going on here? The key here is that sensor data is divided into <b>sensor properties</b> and <b>sensor data fields</b>. <b>Only sensor data fields are protected using sensor permissions.</b> If you develop a device driver for a sensor make sure you keep this in mind. Always place PII data in data fields only so users can turn off access to the data. This division between properties and data fields is enforced by the Sensor Class Extension.</span></p>
<p align="justify"><b><span style="font-family: cal; font-size: small;">How the Sensor Platform Uses Permissions</span></b></p>
<p align="justify"><span style="font-family: cal; font-size: small;">Device drivers must instantiate the Sensor Class Extension in order to integrate with the sensor platform. The diagram at the top of this post shows the Sensor API talking with the Sensor Class Extension. In reality the Sensor API communicates with the driver via DeviceIoControl() as exposed by IPortableDevice::SendCommand(). To address a sensor the sensor object ID, which is exposed via the WPD_OBJECT_ID property, is passed into SendCommand(). When the driver receives the command the call is forwarded to the Sensor Class Extension. When the Sensor API needs to get sensor data, as opposed to getting sensor properties, the sensor object ID is pre-pended with a string that the Sensor Class Extension uses to identify a sensor data field call. In this case the Sensor Class Extension checks the sensor permissions against the SID of the calling process. If the enable flag is set for that SID the Sensor Class Extension calls ISensorDriver::OnGetSupportedDataFields() and/or ISensorDriver::OnGetDataFields() passing in the actual sensor ID. When the Sensor API needs sensor properties the actual sensor ID is passed to the Sensor Class Extension which then calls the appropriate ISensorDriver call without doing permission checks.</span></p>
<p align="justify"><span style="font-family: cal; font-size: small;">So what goes on when you enable a sensor? (I know, I know, I said &lsquo;enable a sensor&rsquo; but I get lazy) The CPL tracks changes in the checkbox states. When there is a change the Apply button is enabled. The <b>User Settings Page</b> works in the same way. Once the Apply button is clicked the magic of UAC (User Account Control) allows the CPL to forward the device path, the SID and the enable flag to an elevated process (dllhost.exe) for each changed checkbox. The process needs to be elevated because data will be written to HKEY_LOCAL_MACHINE. The elevation of privilege provides a level of security since only someone with administrator access can make changes. The code that is executed in dllhost uses a library that maintains sensor permissions - this is the Sensor Permissions Manager. This is shown above just under the Sensors CPL.</span></p>
<p align="justify"><span style="font-family: cal; font-size: small;">The Sensor Permissions Manager is used by the Sensors CPL not only to set sensor permissions in the registry but also to get sensor permissions from all sensor devices. The Sensor Permissions Manager can get all the information it needs from the registry so the CPL doesn&rsquo;t need to talk to any devices. Even if the device is no longer connected to the computer the device registry is still present until the device driver is uninstalled. This means that you can change sensor permissions on a device that is not even connected.</span></p>
<p align="justify"><span style="font-family: cal; font-size: small;">So how does a loaded sensor driver (i.e. in memory and running) know that the permissions have changed? In this case the Sensor Permission Manager communicates with the device. Using IPortableDevice::SendCommand() the Sensor Permission Manager sends a command to the driver which forwards it to the Sensor Class Extension. The command identifier tells the Sensor Class Extension that the permissions for the device have changed which causes the Sensor Class Extension to query the sensor permissions. There isn&rsquo;t anything a device driver author needs to do to enable this synchronization (other than include the Sensor Class Extension) so this behavior comes for free.</span></p>
<p align="justify"><span style="font-family: cal; font-size: small;">I hope you&rsquo;ve found this informative. Many thanks go to other members of our team that helped proof-read this blog and made this </span><a name="_GoBack"></a><span style="font-family: cal; font-size: small;">complex topic easier to follow.</span></p>
<p align="justify"><span style="font-family: cal; font-size: small;">Thanks for reading,</span></p>
<p align="justify"><span style="font-family: cal; font-size: small;">Kevin</span></p>
<p align="justify"><span style="font-family: cal; font-size: small;">This posting is provided "AS IS" with no warranties and confers no rights.</span></p>]]></content:encoded>
    </item>
    <item>
      <title>Understanding Access Denied when working with ISensor::GetState() and ISensor::GetProperty()</title>
      <link>https://docs.microsoft.com/archive/blogs/sensorslocation/understanding-access-denied-when-working-with-isensorgetstate-and-isensorgetproperty</link>
      <pubDate>Tue, 27 Apr 2010 17:00:00 GMT</pubDate>
      <dc:creator><![CDATA[sensblog]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sensorslocation/2010/04/27/understanding-access-denied-when-working-with-isensorgetstate-and-isensorgetproperty/</guid>
      <description><![CDATA[In last week’s blog post we provided best practice guidance for Sensor State management in...]]></description>
      <content:encoded><![CDATA[<p></p>  <p align="justify"><font size="3" face="Calibri">In </font><a href="https://blogs.msdn.com/sensorslocation/archive/2010/04/13/state-transition-in-location-drivers-best-practices.aspx"><font size="3" face="Calibri">last week’s blog post</font></a><font size="3" face="Calibri"> we provided best practice guidance for Sensor State management in Location Sensors. At the bottom of that post we mention that </font><a href="https://msdn.microsoft.com/en-us/library/dd318905(v=VS.85).aspx"><font size="3" face="Calibri">SENSOR_STATE_ACCESS_DENIED</font></a><font size="3" face="Calibri"> is reserved and should only be used by the Platform. As a follow-on post we wanted to briefly dig into an issue that some customers have reported related to SENSOR_STATE_ACCESS_DENIED. </font></p>  <p align="justify"><font size="3" face="Calibri">As mentioned above - this blog topic is actually based on a question from one of our customers. The customer in question, a driver developer, had noticed that if access was denied to their sensor in the Location and Other Sensors Control Panel that they could get different answers for Sensor State depending on where they asked the question in the Sensor API.</font></p>  <p align="justify"><font size="3" face="Calibri">Let’s take the following scenario:</font></p>  <p align="left"><font size="3" face="Calibri">1. You have a Sensor Device running on your machine.</font></p>  <p align="left"><font size="3" face="Calibri">2. You know the device is currently reporting a Sensor State of </font><a href="https://msdn.microsoft.com/en-us/library/dd318905(v=VS.85).aspx"><font size="3" face="Calibri">SENSOR_STATE_READY</font></a></p>  <p align="left"><font size="3" face="Calibri">3. You open the Location and Other Sensors Control Panel.</font></p>  <p align="left"><font size="3" face="Calibri">4. You disable access to your sensor device.</font></p>  <p align="justify"><font size="3" face="Calibri">Now here is where it can get interesting. When you call the following two methods you might expect to get the same response for the state of your sensor – but you don’t:</font></p>  <ul>   <li>     <div align="left"><font size="3" face="Calibri">Calling </font><a href="https://msdn.microsoft.com/en-us/library/dd318878(v=VS.85).aspx"><font size="3" face="Calibri">ISensor::GetState()</font></a><font size="3" face="Calibri"> will return the state of SENSOR_STATE_ACCESS_DENIED.</font></div>   </li> </ul>  <p align="left"><font size="3" face="Calibri"></font></p>  <ul>   <li>     <div align="left"><font size="3" face="Calibri">Calling </font><a href="https://msdn.microsoft.com/en-us/library/dd318876(v=VS.85).aspx"><font size="3" face="Calibri">ISensor::GetProperty()</font></a><font size="3" face="Calibri"> with an input Property Key of </font><a href="https://msdn.microsoft.com/en-us/library/dd318991(v=VS.85).aspx"><font size="3" face="Calibri">SENSOR_PROPERTY_STATE</font></a><font size="3" face="Calibri"> will return SENSOR_STATE_READY.</font></div>   </li> </ul>  <p align="justify"><font size="3" face="Calibri">The driver partner mentioned above asked the question: Why?</font></p>  <p align="justify"><font size="3" face="Calibri">To answer this question we need to briefly discuss where permissions are managed in the Sensor API. I should note that this will be a very brief discussion on permissions management. We expect to have additional posts coming that dig into the subject of permissions in greater detail.</font></p>  <p align="justify"><b><font size="3" face="Calibri">A brief introduction into Permissions: </font></b></p>  <p align="justify"><font size="3" face="Calibri">In an earlier blog post we provided this diagram as an example for how the Sensor Platform is designed:</font></p>  <p><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="clip_image002[4]" border="0" alt="clip_image002[4]" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sensorslocation/WindowsLiveWriter/UnderstandingAccessDeniedwhenworkingwith_8BB0/clip_image002%5B4%5D_1.png" original-url="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/UnderstandingAccessDeniedwhenworkingwith_8BB0/clip_image002%5B4%5D_1.png" width="433" height="274" /></p>  <p align="justify"><font size="3" face="Calibri">As you can see in this diagram the Sensors Class Extension and the Sensor API both talk to the Location and Other Sensors Control Panel. The Sensors Class Extension working with the Location and Other Sensors Control Panel provide the permissions infrastructure for the Platform. When you change permissions in the Location and Other Sensors Control Panel the Sensor API, working with the Sensor Class Extension, will stop granting access to that device. In this way the Sensor Class Extension serves as a kind-of “gate keeper” for accessing sensor devices. </font></p>  <p align="justify"><font size="3" face="Calibri">In the example scenario above when you asked the Sensor API for the sensors state via a call to ISensor::GetState() you were essentially asking the platform what state it understood the sensor to be in. In this case, because the platform knows the sensor is Access Denied, it will return a state of SENSOR_STATE_ACCESS_DENIED. Because permissions are managed separate from device properties the platform in this case needs supersede the Sensor State from the device and return SENSOR_STATE_ACCESS_DENIED. Alternatively, when you make a call to ISensor::GetProperty() for property SENSOR_PROPERTY_STATE you are requesting a property directly from the sensor. The Sensor Device, which does not know the platform has denied access to the Sensor, will return its current Sensor State. </font></p>  <p align="justify"><font size="3" face="Calibri">We understand that this nuance in Platform behavior has caused some confusion. We will evaluate this in the future.</font></p>  <p align="justify"><b><font size="3" face="Calibri">So which method should you use to access Sensor State?</font></b></p>  <p align="justify"><font size="3" face="Calibri">The guidance we have for application developers is that if you need access to Sensor State then request the state from ISensor::GetState(). Calling ISensor::GetState() will insure that you have the most accurate representation of State from a Sensor Platform perspective.</font></p>  <p align="justify"><font size="3" face="Calibri">-- Sensor &amp; Location Platform Team</font></p>  <p align="justify"><font size="3" face="Calibri">This posting is provided &quot;AS IS&quot; with no warranties and confers no rights.</font></p>]]></content:encoded>
    </item>
    <item>
      <title>State Transition in Location Drivers : Best practices</title>
      <link>https://docs.microsoft.com/archive/blogs/sensorslocation/state-transition-in-location-drivers-best-practices</link>
      <pubDate>Tue, 13 Apr 2010 17:00:00 GMT</pubDate>
      <dc:creator><![CDATA[sensblog]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sensorslocation/2010/04/13/state-transition-in-location-drivers-best-practices/</guid>
      <description><![CDATA[This post will be talking about best practices for handling state to get the best behaviors from the...]]></description>
      <content:encoded><![CDATA[<p align="justify"><font size="3" face="Calibri">This post will be talking about best practices for handling state to get the best behaviors from the Location API. Before reviewing our best practice guidance we recommend you read up on “</font><a href="https://msdn.microsoft.com/en-us/library/ff545919(v=VS.85).aspx"><font size="3" face="Calibri">Writing a Location Sensor Driver</font></a><font size="3" face="Calibri">”.</font></p>  <p align="justify"><font size="3" face="Calibri">With information above in mind, let’s now talk about best practices for handling state transition in a location driver. This is not meant to replace the Managing State Transitions section of the document mentioned above, it’s meant to help a developer have a better understanding of how state usage was anticipated when used by the Location API.There are many logic decisions made by the API based on the sensor state, and this becomes even more important as multiple devices are added to the platform that it can make better decisions with drivers giving it fresh and accurate data.</font></p>  <p align="justify"><b><font size="3" face="Calibri">A new Sensor device enters: </font></b></p>  <p align="justify"><font size="3" face="Calibri">As a location sensor comes on-line, its initial status should be set to SENSOR_STATE_NO_DATA. With this state the Location API knows that you are a location provider that has no data, which allows the Location API to optimize it’s usage of other location providers of the same type.</font></p>  <p><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="clip_image002[4]" border="0" alt="clip_image002[4]" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sensorslocation/WindowsLiveWriter/StateTransitioninLocationDriversBestprac_DCF9/clip_image002%5B4%5D_1.png" original-url="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/StateTransitioninLocationDriversBestprac_DCF9/clip_image002%5B4%5D_1.png" width="433" height="81" /></p>  <p><b></b></p>  <p><b><font size="3" face="Calibri">Once a Sensor device is ready to provide data:</font></b></p>  <p align="justify"><font size="3" face="Calibri">Once the provider has been started up and has been able to get data (or not) from its hardware it can move into one of the following states:</font></p>  <p><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="clip_image004" border="0" alt="clip_image004" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sensorslocation/WindowsLiveWriter/StateTransitioninLocationDriversBestprac_DCF9/clip_image004_3.png" original-url="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/StateTransitioninLocationDriversBestprac_DCF9/clip_image004_3.png" width="433" height="251" /></p>  <p align="justify"><font size="3" face="Calibri">Some expected uses for error states:</font></p>  <p align="justify">   <table border="1" cellspacing="0" cellpadding="0"><tbody>       <tr>         <td valign="top">           <p><font size="3" face="Calibri">SENSOR_STATE_READY</font></p>         </td>          <td valign="top">           <p><font size="3" face="Calibri">Sensor driver is able to provide new location reports with complete and accurate data.</font><font size="3" face="Calibri">For example, a Wi-Fi or cellular provider is connected and working, or a GPS sensor has a fix.</font></p>         </td>       </tr>        <tr>         <td valign="top">           <p><font size="3" face="Calibri">SENSOR_STATE_NOT_AVAILABLE</font></p>         </td>          <td valign="top">           <p><font size="3" face="Calibri">The location provider is not available. </font><font size="3" face="Calibri">For example, a Wi-Fi provider has no access to the Internet. A GPS sensor could be in this state if no signal is available.</font></p>         </td>       </tr>        <tr>         <td valign="top">           <p><font size="3" face="Calibri">SENSOR_STATE_ERROR</font></p>         </td>          <td valign="top">           <p><font size="3" face="Calibri">The sensor has encountered a major error. The sensor can recover from this state, but the time frame for recovery is not known.</font></p>         </td>       </tr>     </tbody></table> </p>  <p align="justify"><font size="3" face="Calibri">This is a just part of the full table that can be found in “</font><a href="https://msdn.microsoft.com/en-us/library/ff545919(v=VS.85).aspx"><font size="3" face="Calibri">Writing a Location Sensor Driver</font></a><font size="3" face="Calibri">”.</font></p>  <p align="justify"><b><font size="3" face="Calibri">Once a Sensor device has data:</font></b></p>  <p align="justify"><font size="3" face="Calibri">Once a sensor has moved into a SENSOR_STATE_READY and has provided valid data to the platform it’s recognized as legitimate source to get location data from. </font></p>  <p align="justify"><font size="3" face="Calibri">Once the driver is up and running it may need to transition back to one of these other states to indicate a change in what the driver will be able to provide to the Location Platform:</font></p>  <p><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="clip_image006" border="0" alt="clip_image006" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sensorslocation/WindowsLiveWriter/StateTransitioninLocationDriversBestprac_DCF9/clip_image006_3.png" original-url="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/StateTransitioninLocationDriversBestprac_DCF9/clip_image006_3.png" width="433" height="253" /></p>  <p align="justify"><b><font size="3" face="Calibri">What about SENSOR_STATE_INITIALIZING:</font></b></p>  <p align="justify"><font size="3" face="Calibri">SENSOR_STATE_INITIALIZING is not meant to be the all-purpose initializing state; instead it is used for a more limited scope. The Location API expects devices in SENSOR_STATE_INITIALIZING to provide data, but if the sensor has invalid data or no data, it may be ignored by the API.</font></p>  <p align="justify"><font size="3" face="Calibri">SENSOR_STATE_INITIALIZING would be best used by a GPS type device. </font></p>  <p align="justify"><font size="3" face="Calibri">A hypothetical example: </font></p>  <p align="justify"><font size="3" face="Calibri">A hypothetical GPS Device requires 4 satellites before it would consider its provided data to be of expected accuracy. But it could still provide lower accuracy data with only 3 satellites. In this situation the driver could go into an initializing state once it has 3 satellites with less accurate data. Once the device has a fix on 4 or more satellites and has recovered its accuracy then it could return to SENSOR_STATE_READY.</font></p>  <p align="justify"><font size="3" face="Calibri">Also if the device lost satellites and was back down to 3, it could change SENSOR_STATE_INITIALIZING once more.</font></p>  <p align="justify"><font size="3" face="Calibri">So the device’s transition could look like this:</font></p>  <p><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="clip_image002[6]" border="0" alt="clip_image002[6]" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sensorslocation/WindowsLiveWriter/StateTransitioninLocationDriversBestprac_DCF9/clip_image002%5B6%5D_1.png" original-url="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/StateTransitioninLocationDriversBestprac_DCF9/clip_image002%5B6%5D_1.png" width="533" height="93" /></p>  <p align="justify"><b><font size="3" face="Calibri">States to not use: </font></b></p>  <p align="justify"><font size="3" face="Calibri">If you are to look at the Sensor State Enumeration page you will find there is SENSOR_STATE_ACCESS_DENIED. This is a reserved state for the API and it should not be used by the driver. Please refer to “</font><a href="https://msdn.microsoft.com/en-us/library/ff545708(v=VS.85).aspx"><font size="3" face="Calibri">Sensor State Enumeration</font></a><font size="3" face="Calibri">” to get a look at all the reserved states.</font></p>  <p align="justify"><font size="3" face="Calibri">As stated at the beginning, this is the anticipated use of the states by the Location API. While you can use them in other ways, you might find that the Location API behaves unexpectedly. In these cases I hope that understanding what Location API expects will help you in your design. </font></p>  <p></p>  <p align="justify"><font size="3" face="Calibri">-- Sensor &amp; Location Platform Team</font></p>  <p align="justify"><font size="3" face="Calibri">This posting is provided &quot;AS IS&quot; with no warranties and confers no rights.</font></p>]]></content:encoded>
    </item>
    <item>
      <title>Developing Your First Sensor Driver – Part 2</title>
      <link>https://docs.microsoft.com/archive/blogs/sensorslocation/developing-your-first-sensor-driver-part-2</link>
      <pubDate>Tue, 30 Mar 2010 17:00:00 GMT</pubDate>
      <dc:creator><![CDATA[sensblog]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sensorslocation/2010/03/30/developing-your-first-sensor-driver-part-2/</guid>
      <description><![CDATA[In the last blog post we investigated the fundamental characteristics of a sensor driver (properties...]]></description>
      <content:encoded><![CDATA[<p align="justify"><font size="3" face="Calibri">In the last blog post we investigated the fundamental characteristics of a sensor driver (properties and data fields) and how the Sensor Class Extension interacts with them. Here we will expand the basic driver template to include raising events and managing clients. A client is an application that has requested a connection to the driver through the class extension.</font></p>  <p align="justify"><font size="3" face="Calibri">This blog post will focus on the </font><a href="https://msdn.microsoft.com/en-us/library/dd835071.aspx"><font size="3" face="Calibri">Time Sensor Sample</font></a><font size="3" face="Calibri"> from the Windows Driver Kit. In general this driver creates a thread that periodically requests data from the ‘device’ (just the system time), and posts it to the class extension. This differs from the skeleton sample examined previously, which merely responds to synchronous data requests. Let’s look at the following code snippet from <i>_EventThreadProc</i> in CSampleEvents to illustrate this additional functionality. Note some comments have been modified.</font></p>  <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">   <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">     <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #008000">// </span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> <span style="color: #008000">// Fetching data and posting an event, </span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> <span style="color: #008000">// from _EventThreadProc, lines 193 - 225 </span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span> <span style="color: #008000">// </span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>&#160; </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span> CComPtr&lt;IPortableDeviceValues&gt; spEventParams;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span> CComPtr&lt;IPortableDeviceKeyCollection&gt; spKeys;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>             </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span> <span style="color: #0000ff">if</span>(SUCCEEDED(hr))</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span> {            </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>     <span style="color: #008000">// Use the Ddi class to create the key collection.</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>     hr = pThis-&gt;m_pDdi-&gt;OnGetSupportedDataFields(</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span>         g_wszSensorID, &amp;spKeys);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span>&#160; </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span> <span style="color: #0000ff">if</span>(SUCCEEDED(hr))</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span> {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum18">  18:</span>     CComPtr&lt;IWDFFile&gt; spTemp;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum19">  19:</span>&#160; </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum20">  20:</span>     <span style="color: #008000">// Get the data fields.</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum21">  21:</span>     hr = pThis-&gt;m_pDdi-&gt;OnGetDataFields(</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum22">  22:</span>         spTemp, g_wszSensorID, spKeys, &amp;spEventParams);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum23">  23:</span> }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum24">  24:</span>&#160; </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum25">  25:</span> <span style="color: #0000ff">if</span>(SUCCEEDED(hr))</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum26">  26:</span> {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum27">  27:</span>     <span style="color: #008000">// Add the data event property key.</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum28">  28:</span>     hr = spEventParams-&gt;SetGuidValue(</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum29">  29:</span>         SENSOR_EVENT_PARAMETER_EVENT_ID, </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum30">  30:</span>         SENSOR_EVENT_DATA_UPDATED);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum31">  31:</span>             </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum32">  32:</span> <span style="color: #0000ff">if</span>(SUCCEEDED(hr))</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum33">  33:</span> {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum34">  34:</span>     <span style="color: #008000">// Post the event.</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum35">  35:</span>     hr = pThis-&gt;PostDataEvent(spEventParams);                </pre>
<!--CRLF--></div>
</div>

<p align="justify"><font size="3" face="Calibri">In the first two blocks of code, we get a list of supported data fields and populate an IPortableDeviceValues collection with their current values. <i>OnGetDataFields</i> is the same method the class extension would call into if a client requested data on demand. Next we set the event type using the event property key. Setting the correct type is important because clients can register to be notified of specific types of events. For example an application may care about a new data event but not a state change event. The sensor and location platform defines several event property keys and types, which can be seen at </font><a href="https://msdn.microsoft.com/en-us/library/dd318922(VS.85).aspx"><font size="3" face="Calibri">MSDN</font></a><font size="3" face="Calibri">. Finally we call into the <i>PostDataEvent</i> helper method to signal the class extension. Here is this method in its entirety.</font></p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum1">   1:</span> <span style="color: #008000">// Post a data updated event, lines 148 - 170</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum2">   2:</span> HRESULT CSampleEvents::PostDataEvent(IPortableDeviceValues* pValues)</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum3">   3:</span> {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum4">   4:</span>     HRESULT hr = (NULL == m_spSensorCXT) ? E_UNEXPECTED : S_OK ;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum5">   5:</span>&#160; </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum6">   6:</span>     <span style="color: #0000ff">if</span> (SUCCEEDED(hr))</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum7">   7:</span>     {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum8">   8:</span>               CComPtr&lt;IPortableDeviceValuesCollection&gt; </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum9">   9:</span>                   spValuesCollection;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum10">  10:</span>         hr = spValuesCollection.CoCreateInstance(</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum11">  11:</span>             CLSID_PortableDeviceValuesCollection);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum12">  12:</span>&#160; </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum13">  13:</span>         <span style="color: #0000ff">if</span> (SUCCEEDED(hr))</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum14">  14:</span>         {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum15">  15:</span>             hr = spValuesCollection-&gt;Add(pValues);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum16">  16:</span>&#160; </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum17">  17:</span>             <span style="color: #0000ff">if</span> (SUCCEEDED(hr))</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum18">  18:</span>             {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum19">  19:</span>                 hr = m_spSensorCXT-&gt;PostEvent(</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum20">  20:</span>                     g_wszSensorID, spValuesCollection);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum21">  21:</span>             }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum22">  22:</span>         }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum23">  23:</span>     }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum24">  24:</span>&#160; </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum25">  25:</span>     <span style="color: #0000ff">return</span> hr;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060" id="lnum26">  26:</span> }</pre>
<!--CRLF--></div>
</div>

<p align="justify"><font size="3"><font face="Calibri"><i>PostDataEvent</i> simply takes the data field values, adds them to an IPortableDeviceValeus collection, and posts the collection to the Sensor Class Extension. The extension will notify appropriate clients of new data.</font></font></p>

<p align="justify"><font size="3" face="Calibri">The Sensor Class Extension also informs a sensor driver of client connection and subscription changes through several methods: <i>OnClientConnect</i>, <i>OnClientDisconnect</i>, On <i>ClientSubscribeToEvents</i>, and <i>OnClientUnsubscribeFromEvents</i>. These enable a driver to adjust its activity accordingly (such as disabling device sampling when no client is connected or adjusting event frequency). For instance, the Time Sensor Sample keeps track of client applications in a Clients list, which it uses to update the driver’s report interval.</font></p>

<p align="justify"><font size="3" face="Calibri">To wrap up, these simple additions allow a sensor driver can take advantage of events in the sensor and location platform. This event-driven model can improve performance in both the driver and client applications. For more information about sensor driver events, take a look </font><a href="https://msdn.microsoft.com/en-us/library/ff545385.aspx"><font size="3" face="Calibri">here</font></a><font size="3" face="Calibri">. Best of luck!</font></p>

<p align="justify"><font size="3" face="Calibri">-- Sensor &amp; Location Platform Team</font></p>

<p align="justify"><font size="3" face="Calibri">This posting is provided &quot;AS IS&quot; with no warranties and confers no rights.</font></p>]]></content:encoded>
    </item>
    <item>
      <title>Developing Your First Sensor Driver – Part 1</title>
      <link>https://docs.microsoft.com/archive/blogs/sensorslocation/developing-your-first-sensor-driver-part-1</link>
      <pubDate>Tue, 23 Mar 2010 17:00:00 GMT</pubDate>
      <dc:creator><![CDATA[sensblog]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sensorslocation/2010/03/23/developing-your-first-sensor-driver-part-1/</guid>
      <description><![CDATA[The Windows Driver Kit (WDK) is a great place to get started when writing your first sensor driver....]]></description>
      <content:encoded><![CDATA[<p align="justify"><font size="3" face="Calibri">The Windows Driver Kit (WDK) is a great place to get started when writing your first sensor driver. In this post we will take a look at the </font><a href="https://msdn.microsoft.com/en-us/library/dd445419.aspx"><font size="3" face="Calibri">Sensor Driver Skeleton Sample</font></a><font size="3" face="Calibri">, which provides a basic sensor driver template. A future post will investigate the </font><a href="https://msdn.microsoft.com/en-us/library/dd835071.aspx"><font size="3" face="Calibri">Time Sensor Sample</font></a><font size="3" face="Calibri"> to learn about incorporating events. If you have the WDK installed, the source is located under &lt;WDK Install Path&gt;\src\SensorsAndLocation. For more in-depth information, the </font><a href="https://msdn.microsoft.com/en-us/library/aa973523.aspx"><font size="3" face="Calibri">WDK Sensor Devices</font></a><font size="3" face="Calibri"> section of MSDN includes a design guide, valuable sensor references, and information about the two sensor driver samples.</font></p>  <p align="justify"><font size="3" face="Calibri">Three of the four classes in the skeleton sample (CMyDriver, CMyDevice, and CMyQueue) implement various User-Mode Driver Framework (UMDF) interfaces. In these we initialize the device, configure the IO queue, and create the class extension and device driver interface (DDI). Head over to MSDN for more information about </font><a href="https://msdn.microsoft.com/en-us/library/aa510983.aspx"><font size="3" face="Calibri">UMDF</font></a><font size="3" face="Calibri">.</font></p>  <p align="justify"><font size="3" face="Calibri">The remainder of this post will focus on the fourth class, CSensorDdi, which implements the </font><a href="https://msdn.microsoft.com/en-us/library/cc974560.aspx"><font size="3" face="Calibri">ISensorDriver</font></a><font size="3" face="Calibri"> interface. This class emulates access to hardware devices and handles communication with the sensor class extension. Your first step – determine the properties and data fields your sensor supports. Properties describe a sensor device, while data fields describe sensor-generated data. Take a look at the code snippets below from SensorDDI.cpp.</font></p>  <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">   <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">     <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Sensor properties, lines 26-51</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">const</span> PROPERTYKEY g_SupportedCommonProperties[] =</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">{</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    WPD_OBJECT_ID,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    WPD_OBJECT_PERSISTENT_UNIQUE_ID,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    WPD_OBJECT_PARENT_ID,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    WPD_OBJECT_NAME,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    WPD_OBJECT_FORMAT,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    WPD_OBJECT_CONTENT_TYPE,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    WPD_OBJECT_CAN_DELETE,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">};</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">const</span> PROPERTYKEY g_SupportedTemperatureProperties[] =</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">{</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    SENSOR_PROPERTY_TYPE,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    SENSOR_PROPERTY_STATE,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    SENSOR_PROPERTY_MIN_REPORT_INTERVAL,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    SENSOR_PROPERTY_CURRENT_REPORT_INTERVAL,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    SENSOR_PROPERTY_PERSISTENT_UNIQUE_ID,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    SENSOR_PROPERTY_MANUFACTURER, </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    SENSOR_PROPERTY_MODEL,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    SENSOR_PROPERTY_SERIAL_NUMBER,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    SENSOR_PROPERTY_FRIENDLY_NAME,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    SENSOR_PROPERTY_DESCRIPTION, </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    SENSOR_PROPERTY_CONNECTION_TYPE,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    WPD_FUNCTIONAL_OBJECT_CATEGORY,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">};</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Sensor data fields, lines 69-73</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">const</span> PROPERTYKEY g_SupportedTemperatureDataFields[] =</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">{</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    SENSOR_DATA_TYPE_TIMESTAMP,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    SENSOR_DATA_TYPE_TEMPERATURE_CELSIUS,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">};</pre>
<!--CRLF--></div>
</div>

<p align="justify"><font size="3" face="Calibri">These properties and data fields describe the mock temperature sensor. The g_SupportedCommonProperties array holds properties shared by all sensors for this driver, while the other two are temperature-sensor specific. Note that these strings and associated GUIDs can be user-defined, but they must be shared and understood between the driver and client applications to be useful. The sensor platform defines a set of </font><a href="https://msdn.microsoft.com/en-us/library/cc974542.aspx"><font size="3" face="Calibri">constants</font></a><font size="3" face="Calibri"> for sensor drivers, which can also be found in &lt;WDK Install Path&gt;\inc\api\Sensors.h.</font></p>

<p align="justify"><font size="3" face="Calibri">We initialize each sensor by storing its properties and data fields into collections for future reference. The following code from InitializeTemperatureSensor demonstrates adding our temperature properties to the m_pSupportedTemperatureSensorProperties collection and setting some default values. A similar collection is maintained for the data field values.</font></p>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Add temperature sensor property keys, lines 161-165</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">for</span> (DWORD dwIndex=0;    </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    dwIndex&lt;ARRAYSIZE(g_SupportedTemperatureProperties); </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    dwIndex++)</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">{</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    m_pSupportedTemperatureSensorProperties-&gt;Add(</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        g_SupportedTemperatureProperties[dwIndex]);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">}</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Add temperature sensor property values, lines 184-186</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">m_pTemperatureSensorPropertyValues-&gt;SetGuidValue(</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    WPD_FUNCTIONAL_OBJECT_CATEGORY, SENSOR_CATEGORY_ENVIRONMENTAL);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">m_pTemperatureSensorPropertyValues-&gt;SetGuidValue(</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    SENSOR_PROPERTY_TYPE, SENSOR_TYPE_ENVIRONMENTAL_TEMPERATURE);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">m_pTemperatureSensorPropertyValues-&gt;SetStringValue(</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    SENSOR_PROPERTY_MANUFACTURER, DEVICE_MANUFACTURER_VALUE);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">...</pre>
<!--CRLF--></div>
</div>

<p align="justify"><font size="3" face="Calibri">Once the CSensorDdi initialization is finished, the sensor class extension loads and calls OnGetSupportedSensorObjects. Here we report each sensor to the class extension and provide its supported properties. The final step is to enable the driver in the control panel so that it can be accessed by client applications. A quick note – although we are describing each sensor separately, permissions are granted at the driver level and cannot be set for specific sensors.</font></p>

<p align="justify"><font size="3" face="Calibri">With our driver initialized and sensor values defined, let’s take a look at some key callback methods of the ISensorDriver interface. </font></p>

<ul>
  <li>
    <div align="left"><font size="3" face="Calibri">OnClientConnect, OnClientDisconnect, OnClientSubscribeToEvents, OnClientUnsubscribeFromEvents</font></div>
  </li>
</ul>

<p align="justify"><font size="3" face="Calibri">These methods inform the driver of client application activity. The driver can use this information to optimize reporting of state change and data values.</font></p>

<ul>
  <li>
    <div align="left"><font size="3" face="Calibri">OnGetSupportedProperties, OnGetSupportedDataFields, OnGetSupportedEvents</font></div>
  </li>
</ul>

<p align="justify"><font size="3" face="Calibri">These methods provide the sensor class extension with access to a sensor’s supported properties, data fields, and events. Remember those collections we populated earlier? This is how each sensor exposes its functionality. Recall we will talk about events in a future blog post.</font></p>

<ul>
  <li>
    <div align="justify"><font size="3" face="Calibri">OnGetProperties, OnSetProperties, OnGetDataFields</font></div>
  </li>
</ul>

<p align="justify"><font size="3" face="Calibri">These methods expose the property and data field values that client applications will likely care about. OnSetProperties allows an application to update settable properties, such as a sensor’s report interval.</font></p>

<p align="justify"><font size="3" face="Calibri">OnGetDataFields returns a sensor’s data field values. These could be from a cached copy or requested from the device on demand. In our sample the default values stored in the m_pTemperatureSensorDataFieldValues collection are returned for each supported data field.</font></p>

<p align="justify"><font size="3" face="Calibri">That’s it! While this skeleton sample offers minimal functionality, hopefully you now have a better understanding of the driver architecture and its interaction with the sensor class extension. Starting with some simple modifications to the properties and data fields, your driver will be up and running in no time. One more thing – the </font><a href="https://code.msdn.microsoft.com/SensorsAndLocation/Release/ProjectReleases.aspx?ReleaseId=2359"><font size="3" face="Calibri">Sensor Diagnostic Tool</font></a><font size="3" face="Calibri"> offers a great mechanism for interacting with your driver during development.</font></p>

<p align="justify"><font size="3" face="Calibri">Good luck and stay tuned for the follow-up post.</font></p>

<p align="justify"><font size="3" face="Calibri">-- Sensor &amp; Location Platform Team</font></p>

<p align="justify"><font size="3" face="Calibri">This posting is provided &quot;AS IS&quot; with no warranties and confers no rights.</font></p>]]></content:encoded>
    </item>
    <item>
      <title>Overview of Adaptive Brightness in Windows 7</title>
      <link>https://docs.microsoft.com/archive/blogs/sensorslocation/overview-of-adaptive-brightness-in-windows-7</link>
      <pubDate>Tue, 09 Mar 2010 17:00:00 GMT</pubDate>
      <dc:creator><![CDATA[sensblog]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sensorslocation/2010/03/09/overview-of-adaptive-brightness-in-windows-7/</guid>
      <description><![CDATA[So you just got yourself a new laptop. Congratulations! Did you notice that it has an Ambient Light...]]></description>
      <content:encoded><![CDATA[<p align="justify"><font size="3" face="Calibri">So you just got yourself a new laptop. Congratulations! Did you notice that it has an Ambient Light Sensor (ALS)? With Windows 7, we’re seeing more and more laptops coming to market with built in ALS. How does Windows 7 take advantage of this sensor? How can you tap into it? How do I see it reflected in the system settings? Where is this little gizmo on the machine? We’ll answer some of these questions in this post…     <br /></font></p> <font size="3" face="Calibri"></font>  <h5><font size="3" face="Calibri">Where can I find the ALS on my machine ?</font></h5>  <p align="justify"><font size="3" face="Calibri">Can you find where the ALS is exposed on your laptop? Sometimes it’s obvious other times it’s not. You have to know what you’re looking for. Most of the time the ALS is behind some translucent or dark glass. Here is what an ALS chip looks like:</font></p>  <p><img style="border-bottom: 0px; border-left: 0px; display: inline; margin-left: 0px; border-top: 0px; margin-right: 0px; border-right: 0px" title="image" border="0" alt="image" align="right" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sensorslocation/WindowsLiveWriter/OverviewofAdaptiveBrightnessinWindows7_EF34/image_15.png" original-url="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/OverviewofAdaptiveBrightnessinWindows7_EF34/image_15.png" width="211" height="244" /> <img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sensorslocation/WindowsLiveWriter/OverviewofAdaptiveBrightnessinWindows7_EF34/image_8.png" original-url="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/OverviewofAdaptiveBrightnessinWindows7_EF34/image_8.png" width="244" height="215" /> </p>  <p>&#160;</p>  <p><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sensorslocation/WindowsLiveWriter/OverviewofAdaptiveBrightnessinWindows7_EF34/image_14.png" original-url="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/OverviewofAdaptiveBrightnessinWindows7_EF34/image_14.png" width="433" height="325" /> </p>  <p><font size="3" face="Calibri">I’ll leave it as an exercise to you to find the ALS chip on your computer. </font><font size="3" face="Calibri">Don’t feel bad if you don’t find it. When one of the first prototype computers that had an ALS implemented arrived it took us about an hour to find it. We weren’t sure if the chip was on the exposed motherboard of prototype board or if the vender hid it behind some dark glass on the monitor. It was a real challenge since we need do measurements on the ALS’s response to various light levels and not knowing where it was made that a bit challenging. We finally found it on the motherboard… Finding the power button was a whole different story on this prototype… you had to be there.</font></p>  <h5><font size="3" face="Calibri">How does Windows 7 use the ALS?</font></h5>  <p align="justify"><font size="3" face="Calibri">New with Windows 7 is the Adaptive Brightness feature. This feature is built on top of our Sensor Platform. This feature will adjust the screen brightness according to the ambient light level. If the ambient light level gets darker then the screen brightness decreases; if the ambient light level increases then the screen brightness increases. This solves the problem of when you resume your computer the morning after a late night of hardcore programming only to discover that the screen is so dark that you’re having a hard time reading it. As an added bonus it helps to extend battery life. As the day turned to night you invariably used the Mobility Center to adjust your screen brightness making it darker and darker as the room grew darker and darker. (Win – X will open the Mobility Center).</font> </p>  <p align="justify"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sensorslocation/WindowsLiveWriter/OverviewofAdaptiveBrightnessinWindows7_EF34/image_3.png" original-url="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/OverviewofAdaptiveBrightnessinWindows7_EF34/image_3.png" width="533" height="266" /> </p>  <p align="justify"><font size="3" face="Calibri">This is where the Adaptive Brightness feature takes over. The feature makes use of the built in ALS. The ALS needs to be enabled before Adaptive Brightness will work. Let’s open the <b>Location and Other Sensors CPL</b>. Quick access to this Control Panel (CPL) is achieved by pressing the Windows Key and typing “sensors”.</font></p>  <p align="justify"><img style="border-bottom: 0px; border-left: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px" title="image" border="0" alt="image" src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sensorslocation/WindowsLiveWriter/OverviewofAdaptiveBrightnessinWindows7_EF34/image_11.png" original-url="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/OverviewofAdaptiveBrightnessinWindows7_EF34/image_11.png" width="533" height="375" /> </p>  <p align="justify"><font size="3" face="Calibri">If the Light Sensor is not enabled then perhaps we can have a dramatic unveiling of this feature by trying to enable the Light Sensor in a dark room. Enable the Light Sensor then click Apply. We’ll cover the inner workings of this CPL in another post. For now let’s just use it to enable our Light Sensor. </font><font size="3" face="Calibri">Did you notice the screen darken? That’s the Adaptive Brightness feature at work for you.</font></p>  <p><font size="3" face="Calibri">Remember that this ALS is exposed not only to the Adaptive Brightness feature in Windows but is also exposed via the Sensor Platform. In a future post we’ll go through some simple code to find the ALS Sensor, setup an event on the sensor and output the resulting light level detected. Soon you could be writing applications that make use of this built in sensor.</font> </p> <font size="3" face="Calibri"></font>  <p align="justify"><font size="3" face="Calibri">-- Sensor &amp; Location Platform Team</font></p>  <p align="justify"><font size="3" face="Calibri">This posting is provided &quot;AS IS&quot; with no warranties and confers no rights.</font></p>]]></content:encoded>
    </item>
    <item>
      <title>The Parallax Introduction to Sensors Kit</title>
      <link>https://docs.microsoft.com/archive/blogs/sensorslocation/the-parallax-introduction-to-sensors-kit</link>
      <pubDate>Wed, 03 Mar 2010 17:00:00 GMT</pubDate>
      <dc:creator><![CDATA[sensblog]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sensorslocation/2010/03/03/the-parallax-introduction-to-sensors-kit/</guid>
      <description><![CDATA[Accelerometers, motion-sensors, distance-sensors, and compasses. What do these sensors have in...]]></description>
      <content:encoded><![CDATA[<P align=justify><FONT size=3 face=Calibri>Accelerometers, motion-sensors, distance-sensors, and compasses. What do these sensors have in common? They compose the <I>Introduction to Sensors Kit</I> that the Parallax Corporation sells for $79.99. Purchase this </FONT><A href="https://www.parallax.com/Store/Sensors/tabid/86/Default.aspx" mce_href="https://www.parallax.com/Store/Sensors/tabid/86/Default.aspx"><FONT size=3 face=Calibri>kit</FONT></A><FONT size=3 face=Calibri>, a programmable microcontroller like the </FONT><A href="https://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/ProductID/1/List/1/Default.aspx?SortField=UnitCost,ProductName" mce_href="https://www.parallax.com/Store/Microcontrollers/BASICStampModules/tabid/134/ProductID/1/List/1/Default.aspx?SortField=UnitCost,ProductName"><FONT size=3 face=Calibri>Parallax BS2</FONT></A><FONT size=3 face=Calibri>, a </FONT><A href="https://www.parallax.com/StoreSearchResults/tabid/768/List/0/SortField/4/ProductID/122/Default.aspx?txtSearch=Project+Board" mce_href="https://www.parallax.com/StoreSearchResults/tabid/768/List/0/SortField/4/ProductID/122/Default.aspx?txtSearch=Project+Board"><FONT size=3 face=Calibri>kit board</FONT></A><FONT size=3 face=Calibri>, and a serial cable and you’re ready to explore the Sensor platform for Windows 7.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>Below is a screenshot of the Passive Infrared (PIR) or motion sensor running on a Parallax HomeWork board:</FONT></P>
<P align=justify>&nbsp;<IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: block; FLOAT: none; MARGIN-LEFT: auto; BORDER-TOP: 0px; MARGIN-RIGHT: auto; BORDER-RIGHT: 0px" title=image border=0 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sensorslocation/WindowsLiveWriter/TheParallaxIntroductiontoSensorsKit_B6A0/image_3.png" original-url="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/TheParallaxIntroductiontoSensorsKit_B6A0/image_3.png" width=386 height=355 mce_src="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/TheParallaxIntroductiontoSensorsKit_B6A0/image_3.png"> </P>
<P align=justify><FONT size=3 face=Calibri>The Parallax BS2 (BasicStamp 2) is a programmable microcontroller that you code with Parallax PBASIC. This microcontroller has the following features:</FONT></P>
<P align=justify><FONT size=3 face=Calibri>· 20MHz processor</FONT></P>
<P align=justify><FONT size=3 face=Calibri>· 32 bytes RAM</FONT></P>
<P align=justify><FONT size=3 face=Calibri>· 2KB EEPROM (able to hold ~500 PBASIC instructions)</FONT></P>
<P align=justify><FONT size=3 face=Calibri>· 16 I/O pins</FONT></P>
<P align=justify><FONT size=3 face=Calibri>· 5 VDC with 3mA draw while running</FONT></P>
<P align=justify><FONT size=3 face=Calibri><STRONG>Sensor Applications in .NET</STRONG></FONT></P>
<P align=justify><FONT size=3 face=Calibri>With very little code, you’ll begin to see the rich power of the Sensor platform. For example, the below screenshot was taken from a simple C# .NET application that graphs the output for the Memsic 2-axis accelerometer:</FONT></P>
<P><IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: block; FLOAT: none; MARGIN-LEFT: auto; BORDER-TOP: 0px; MARGIN-RIGHT: auto; BORDER-RIGHT: 0px" title=clip_image001 border=0 alt=clip_image001 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sensorslocation/WindowsLiveWriter/TheParallaxIntroductiontoSensorsKit_B6A0/clip_image001_thumb.jpg" original-url="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/TheParallaxIntroductiontoSensorsKit_B6A0/clip_image001_thumb.jpg" width=437 height=234 mce_src="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/TheParallaxIntroductiontoSensorsKit_B6A0/clip_image001_thumb.jpg"></P>
<P align=justify><FONT size=3 face=Calibri>This application was written with just 100 lines of code. And, below is a screenshot of another application that renders compass output in real-time:</FONT></P>
<P><IMG style="BORDER-BOTTOM: 0px; BORDER-LEFT: 0px; DISPLAY: block; FLOAT: none; MARGIN-LEFT: auto; BORDER-TOP: 0px; MARGIN-RIGHT: auto; BORDER-RIGHT: 0px" title=clip_image002 border=0 alt=clip_image002 src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sensorslocation/WindowsLiveWriter/TheParallaxIntroductiontoSensorsKit_B6A0/clip_image002_3.jpg" original-url="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/TheParallaxIntroductiontoSensorsKit_B6A0/clip_image002_3.jpg" width=326 height=324 mce_src="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/TheParallaxIntroductiontoSensorsKit_B6A0/clip_image002_3.jpg"></P>
<P align=justify><FONT size=3 face=Calibri>This application contained a little more code (closer to 200 lines); however, even 200 lines is a remarkably small footprint for an application that renders real-time data from a remote device.</FONT></P>
<P align=justify><FONT size=3 face=Calibri><STRONG>How do I get started ?</STRONG></FONT></P>
<P align=justify><FONT size=3 face=Calibri>That depends: If you’re a hardware type, building the circuit will be a piece of cake. But, creating the driver (the interface between the sensor hardware and Windows) might be a challenge. Same goes for application developer: If you know your way around .Net, you might find it a challenge to write the driver or build the hardware. Driver developers will probably have the least difficulty of all. </FONT></P>
<P align=justify><FONT size=3 face=Calibri>But, we’ve tried to simplify the process for everyone. We’ve provided a sample driver that supports all four sensors in the kit. And, we’ve provided sample firmware for the four devices as well as a simple .Net application that demonstrates the use of the Sensor platform for the Passive Infrared (PIR) sensor.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>You’ll find the sample driver, firmware, PIR application, and a descriptive whitepaper on the MSDN Code Gallery </FONT><A href="https://code.msdn.microsoft.com/motionsensor" mce_href="https://code.msdn.microsoft.com/motionsensor"><FONT size=3 face=Calibri>here</FONT></A><FONT size=3 face=Calibri>. </FONT></P>
<P align=justify><FONT size=3 face=Calibri>You’ll find a sample application that demonstrates real-time graphing of accelerometer data on the MSDN Code Gallery </FONT><A href="https://code.msdn.microsoft.com/MSChartAccelerometer" mce_href="https://code.msdn.microsoft.com/MSChartAccelerometer"><FONT size=3 face=Calibri>here</FONT></A><FONT size=3 face=Calibri>.</FONT></P>
<P align=justify><FONT size=3 face=Calibri><STRONG>Where can I find out more ?</STRONG></FONT></P>
<P align=justify><FONT size=3 face=Calibri>· To learn more about the programmable microcontrollers and sensors offered by Parallax, see the </FONT><A href="https://go.microsoft.com/fwlink/?linkid=154730" mce_href="https://go.microsoft.com/fwlink/?linkid=154730"><FONT size=3 face=Calibri>Parallax</FONT></A><FONT size=3 face=Calibri> Web site.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>· For information about the Sensor API, see </FONT><A href="https://go.microsoft.com/fwlink/?linkid=178391" mce_href="https://go.microsoft.com/fwlink/?linkid=178391"><FONT size=3 face=Calibri>Sensor API</FONT></A><FONT size=3 face=Calibri> in the Win32 and COM Development section MSDN.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>· For information about Sensor Drivers, see </FONT><A href="https://go.microsoft.com/fwlink/?linkid=178392" mce_href="https://go.microsoft.com/fwlink/?linkid=178392"><FONT size=3 face=Calibri>Sensor Devices</FONT></A><FONT size=3 face=Calibri> in the Windows Driver Kit (WDK) section of MSDN.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>· To download a free version of Visual C# 2008 Express, see this </FONT><A href="https://www.microsoft.com/express/Downloads/" mce_href="https://www.microsoft.com/express/Downloads/"><FONT size=3 face=Calibri>Downloads</FONT></A><FONT size=3 face=Calibri> page on the Microsoft site.</FONT></P><FONT size=3 face=Calibri>
<P><FONT size=3 face=Calibri>-- Sensor &amp; Location Platform Team</FONT></P>
<P><I><FONT size=3 face=Calibri>This posting is provided "AS IS" with no warranties and confers no rights.</FONT></I></P></FONT>
<P align=justify><FONT size=3 face=Calibri></FONT></P>]]></content:encoded>
    </item>
    <item>
      <title>Introducing Location in .NET 4.0</title>
      <link>https://docs.microsoft.com/archive/blogs/sensorslocation/introducing-location-in-net-4-0</link>
      <pubDate>Tue, 23 Feb 2010 17:00:00 GMT</pubDate>
      <dc:creator><![CDATA[sensblog]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sensorslocation/2010/02/23/introducing-location-in-net-4-0/</guid>
      <description><![CDATA[The .NET Framework 4.0 RC, which is integrated with Visual Studio 2010, is now available for...]]></description>
      <content:encoded><![CDATA[<p></p>  <p align="justify"><font size="3" face="Calibri">The .NET Framework 4.0 RC, which is integrated with </font><a href="https://msdn.microsoft.com/en-us/vstudio/dd582936.aspx"><font size="3" face="Calibri">Visual Studio 2010</font></a><font size="3" face="Calibri">, is now available for </font><a href="https://msdn.microsoft.com/en-us/vstudio/dd582936.aspx"><font size="3" face="Calibri">download</font></a><font size="3" face="Calibri">. This release of the .NET Framework 4 provides a managed location API in the </font><a href="https://msdn.microsoft.com/en-us/library/system.device.location(VS.100).aspx"><font size="3" face="Calibri">System.Device.Location</font></a><font size="3" face="Calibri"> namespace that allow .NET developers to access location data from the Windows 7 Sensors &amp; Location platform.&#160; If you are familiar with the Location classes from .NET Framework 4 Beta 2, note that this API has been refactored in RC with </font><a href="https://blogs.msdn.com/gavingear/archive/2009/12/09/upcoming-changes-for-system-device-location-in-net-4-rc-web-release.aspx"><font size="3" face="Calibri">changes described here</font></a><font size="3" face="Calibri">.</font></p>  <p align="justify"><font size="3" face="Calibri">The managed Location API is built on top of the C++/COM API described in the previous post, so it uses the same mechanism to simplify access to location data by automatically returning data from the best location source it identifies on the computer. However, the methods in the managed API do not correspond exactly to methods in the COM API. The root location object for the .NET Framework 4 Location API, </font><a href="https://msdn.microsoft.com/en-us/library/system.device.location.geocoordinatewatcher(VS.100).aspx"><font size="3" face="Calibri">GeoCoordinateWatcher</font></a><font size="3" face="Calibri">, supplies location data based on latitude and longitude coordinates. Either the </font><a href="https://msdn.microsoft.com/en-us/library/system.device.location.geocoordinatewatcher.start(VS.100).aspx"><font size="3" face="Calibri">Start</font></a><font size="3" face="Calibri"> or </font><a href="https://msdn.microsoft.com/en-us/library/system.device.location.geocoordinatewatcher.trystart(VS.100).aspx"><font size="3" face="Calibri">TryStart</font></a><font size="3" face="Calibri"> method must be called to initiate the acquisition of data, after which the location data is accessed either by accessing the </font><a href="https://msdn.microsoft.com/en-us/library/system.device.location.geocoordinatewatcher.position(VS.100).aspx"><font size="3" face="Calibri">Position</font></a><font size="3" face="Calibri"> property or by subscribing to the </font><a href="https://msdn.microsoft.com/en-us/library/system.device.location.geocoordinatewatcher.positionchanged(VS.100).aspx"><font size="3" face="Calibri">PositionChanged</font></a><font size="3" face="Calibri"> event. In location-aware applications that require continuous updates, such as a navigation application, you’ll want to subscribe to the <b>PositionChanged</b> event. For applications that only require accessing the location once, such as for pre-populating form fields or tagging a file with location metadata, you can get the location from the <b>Position </b>property or by subscribing to the <b>PositionChanged</b> event, getting the location from the first event, and then calling </font><a href="https://msdn.microsoft.com/en-us/library/system.device.location.geocoordinatewatcher.stop(VS.100).aspx"><font size="3" face="Calibri">Stop</font></a><font size="3" face="Calibri"> to stop receiving further events. The </font><a href="https://msdn.microsoft.com/en-us/library/system.device.location.geocoordinatewatcher.status(VS.100).aspx"><font size="3" face="Calibri">Status</font></a><font size="3" face="Calibri"> property indicates whether a location sensor is initializing, ready to supply new data, or if no location data is available from any sensor. You can subscribe to the </font><a href="https://msdn.microsoft.com/en-us/library/system.device.location.geocoordinatewatcher.statuschanged(VS.100).aspx"><font size="3" face="Calibri">StatusChanged</font></a><font size="3" face="Calibri"> event for status updates. </font></p>  <p align="justify"><font size="3" face="Calibri">To get you started using the managed Location API, let’s look at a couple of simple location-aware programs that access the location property or subscribe to updates when the location or location status changes.&#160; For each of these examples, you’ll want to add a reference to <b>System.Device</b> in your Visual Studio 2010 project, and add a using statement for the <b>System.Device.Location</b> namespace to your code.&#160; The first example gets the location from the <b>Position</b> property, and the second gets the location and status by subscribing to events.</font></p>  <h4><font face="Calibri">Example 1: Accessing the Position Property</font></h4>  <div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">   <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">     <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Accessing the Position Property</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">using</span> System;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">using</span> System.Device.Location; <span style="color: #008000">// Add a reference to System.Device.dll</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">namespace</span> LocationPropertyExample</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">{</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">class</span> Program</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> Main(<span style="color: #0000ff">string</span>[] args)</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            GetLocationProperty();</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> GetLocationProperty()</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            GeoCoordinateWatcher watcher = <span style="color: #0000ff">new</span> GeoCoordinateWatcher();</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            </pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">             <span style="color: #008000">// Initiate acquisition of location data, so that we </span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">             <span style="color: #008000">// can get location coordinates from the Position property.</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">             <span style="color: #008000">// 1. If we don’t have access to the location sensors, </span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">             <span style="color: #008000">// the user will be prompted with a permission dialog.</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">             <span style="color: #008000">// 2. If we have permissions, following this call, we can </span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">             <span style="color: #008000">//    access location data from the Position property, </span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">             <span style="color: #008000">//    and we'll get PositionChanged events if we have set</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">             <span style="color: #008000">//    up an event handler.</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            watcher.TryStart(<span style="color: #0000ff">false</span>, <span style="color: #008000">// Do not suppress permissions prompt.</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">               TimeSpan.FromMilliseconds(1000)); <span style="color: #008000">// Wait 1000 ms to start.</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            GeoCoordinate coord = watcher.Position.Location;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">if</span> (coord.IsUnknown != <span style="color: #0000ff">true</span>)</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                Console.WriteLine(<span style="color: #006080">&quot;Lat: {0}, Long: {1}&quot;</span>,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    coord.Latitude,</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    coord.Longitude);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">else</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                Console.WriteLine(<span style="color: #006080">&quot;Unknown latitude and longitude.&quot;</span>);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">}</pre>
<!--CRLF--></div>
</div>
<font size="3" face="Calibri"></font>

<p></p>

<p></p>

<h4><font face="Calibri">Example 2: Subscribing to PositionChanged and StatusChanged Events</font></h4>

<div style="border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px" id="codeSnippetWrapper">
  <div style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px" id="codeSnippet">
    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #008000">// Subscribing to Location Events</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">using</span> System;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">using</span> System.Device.Location; <span style="color: #008000">// Add a reference to System.Device.dll </span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #0000ff">namespace</span> LocationEventExample</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">{</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    <span style="color: #0000ff">class</span> Program</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> Main(<span style="color: #0000ff">string</span>[] args)</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            Console.WriteLine(<span style="color: #006080">&quot;Displaying location updates. Press any key to exit...&quot;</span>);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #008000">// GeoCoordinateWatcher is the root object for the .NET 4 Location API</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            GeoCoordinateWatcher locationWatcher;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #008000">// Initialize the GeoCoordinateWatcher with default accuracy settings</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            locationWatcher = <span style="color: #0000ff">new</span> GeoCoordinateWatcher();</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #008000">// Subscribe to updates when the location changes</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            locationWatcher.PositionChanged += <span style="color: #0000ff">new</span> EventHandler&lt;GeoPositionChangedEventArgs&lt;GeoCoordinate&gt;&gt;(locationWatcher_PositionChanged);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #008000">// Subscribe to updates when the status changes.</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #008000">// The Status property indicates whether a location sensor is </span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #008000">// initializing, ready to supply new data, or if location data is not  </span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #008000">// available from any sensor. </span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            watcher.StatusChanged += <span style="color: #0000ff">new</span> EventHandler&lt;GeoPositionStatusChangedEventArgs&gt; (locationWatcher_StatusChanged);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #008000">// Initiate acquisition of location data, so that we </span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #008000">// get PositionChanged events.</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #008000">// 1. If we don’t have access to the location sensors, the user will </span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #008000">//    prompted with a dialog to grant or deny permission.</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #008000">// 2. If we have permissions, following this call, we'll be able to </span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #008000">//    access location data, and we'll get PositionChanged events if</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #008000">//    we have set up an event handler</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            locationWatcher.Start();</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            Console.ReadKey();</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> locationWatcher_PositionChanged(<span style="color: #0000ff">object</span> sender, GeoPositionChangedEventArgs&lt;GeoCoordinate&gt; e)</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #008000">// Output the new location coordinate to the console if present</span></pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">if</span> (e.Position.Location != GeoCoordinate.Unknown)</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                Console.WriteLine(</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    <span style="color: #006080">&quot;Latitude:  &quot;</span> + e.Position.Location.Latitude.ToString() +</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    <span style="color: #006080">&quot; Longitude: &quot;</span> + e.Position.Location.Longitude.ToString());</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">        }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">       <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> locationWatcher_StatusChanged(<span style="color: #0000ff">object</span> sender, GeoPositionStatusChangedEventArgs e)</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">       {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            <span style="color: #0000ff">switch</span> (e.Status)</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            {</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">case</span> GeoPositionStatus.Initializing:</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    Console.WriteLine(<span style="color: #006080">&quot;Working on location fix&quot;</span>);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    <span style="color: #0000ff">break</span>;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">case</span> GeoPositionStatus.Ready:</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    Console.WriteLine(<span style="color: #006080">&quot;Have location&quot;</span>);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    <span style="color: #0000ff">break</span>;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">case</span> GeoPositionStatus.NoData:</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    Console.WriteLine(<span style="color: #006080">&quot;No data&quot;</span>);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    <span style="color: #0000ff">break</span>;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">&#160;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                <span style="color: #0000ff">case</span> GeoPositionStatus.Disabled:</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    Console.WriteLine(<span style="color: #006080">&quot;Disabled&quot;</span>);</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">                    <span style="color: #0000ff">break</span>;</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">            }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">       }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">    }</pre>
<!--CRLF-->

    <pre style="border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: white; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &#39;Courier New&#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px">}</pre>
<!--CRLF--></div>
</div>

<p><font size="3" face="Calibri">-- Sensor &amp; Location Platform Team</font></p>

<p><i><font size="3" face="Calibri">This posting is provided &quot;AS IS&quot; with no warranties and confers no rights.</font></i></p>]]></content:encoded>
    </item>
    <item>
      <title>The Sensor and Location Drill Down – Part 3: The Location API</title>
      <link>https://docs.microsoft.com/archive/blogs/sensorslocation/the-sensor-and-location-drill-down-part-3-the-location-api</link>
      <pubDate>Wed, 10 Feb 2010 17:00:00 GMT</pubDate>
      <dc:creator><![CDATA[sensblog]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/sensorslocation/2010/02/10/the-sensor-and-location-drill-down-part-3-the-location-api/</guid>
      <description><![CDATA[Over the last few weeks we have been providing an introduction to the Sensor and Location Platform...]]></description>
      <content:encoded><![CDATA[<P align=justify><FONT size=3 face=Calibri>Over the last few weeks we have been providing an introduction to the Sensor and Location Platform by examining each component in the platform in greater detail.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>We started first with an overview of the </FONT><A href="https://blogs.msdn.com/sensorslocation/archive/2009/12/15/sensor-location-platform-the-50-000-foot-view.aspx" mce_href="https://blogs.msdn.com/sensorslocation/archive/2009/12/15/sensor-location-platform-the-50-000-foot-view.aspx"><FONT size=3 face=Calibri>Sensor and Location Platform</FONT></A><FONT size=3 face=Calibri>.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>This was followed up with a drill down in the </FONT><A href="https://blogs.msdn.com/sensorslocation/archive/2010/01/12/the-sensor-and-location-platform-drill-down-part-1-the-sensor-ddi.aspx" mce_href="https://blogs.msdn.com/sensorslocation/archive/2010/01/12/the-sensor-and-location-platform-drill-down-part-1-the-sensor-ddi.aspx"><FONT size=3 face=Calibri>Sensor DDI or Device Driver Interface</FONT></A><FONT size=3 face=Calibri>.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>Next we examined the </FONT><A href="https://blogs.msdn.com/sensorslocation/archive/2010/01/27/the-sensor-and-location-drill-down-part-2-the-sensor-api.aspx" mce_href="https://blogs.msdn.com/sensorslocation/archive/2010/01/27/the-sensor-and-location-drill-down-part-2-the-sensor-api.aspx"><FONT size=3 face=Calibri>Sensor API</FONT></A><FONT size=3 face=Calibri> and how it fits into the Sensor and Location Platform.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>As the final post in this series we will be examining the Location API. The Location API, as described in the introduction post (</FONT><A href="https://blogs.msdn.com/sensorslocation/archive/2009/12/15/sensor-location-platform-the-50-000-foot-view.aspx" mce_href="https://blogs.msdn.com/sensorslocation/archive/2009/12/15/sensor-location-platform-the-50-000-foot-view.aspx"><FONT size=3 face=Calibri>link</FONT></A><FONT size=3 face=Calibri>) sits on top of the sensor and location “API stack”. That is to say that the Location API is really a client of the Sensor API and the framework provided by the Sensor DDI. As a refresher – here is a diagram of the Location Platform:</FONT></P>
<P><IMG style="BORDER-RIGHT-WIDTH: 0px; DISPLAY: inline; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px" title=image border=0 alt=image src="https://msdnshared.blob.core.windows.net/media/TNBlogsFS/BlogFileStorage/blogs_msdn/sensorslocation/WindowsLiveWriter/TheSensorandLocationDrillDownPart3TheLoc_FFF7/image_3.png" original-url="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/TheSensorandLocationDrillDownPart3TheLoc_FFF7/image_3.png" width=533 height=300 mce_src="https://blogs.msdn.com/blogfiles/sensorslocation/WindowsLiveWriter/TheSensorandLocationDrillDownPart3TheLoc_FFF7/image_3.png"></P>
<P align=justify><FONT size=3 face=Calibri>There are a few important notes to cover about the Location API Layer in this diagram. The first is that the Location API is actually a collection of two API’s. A COM API which is accessible via native C++ applications and an IDispatch or “scripting” API. The IDispatch API provides access to Location in script enabled environments like the Windows Scripting Host and Active X controls. As an example – it’s possible to write a Sidebar Gadget (as identified in the diagram above) that can access Location via the IDispatch API interface.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>What may not be clear in this diagram is that a “Location Sensor” is really just a Sensor that provides Location information. The location sensor data that is available from the Location API is also available, in a more basic format, from the Sensor API. </FONT></P>
<P align=justify><FONT size=3 face=Calibri>This may make you ask – what does the Location API do for you? The Location API is designed to focus on making access to location information easier. Two specific guiding goals are important to drill into:</FONT></P>
<P align=justify><FONT size=3 face=Calibri>- Simplify access to location sources (i.e. location sensors).</FONT></P>
<P align=justify><FONT size=3 face=Calibri>- Simplify accessing location information from location sensors.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>Let’s examine each of those goals in isolation:</FONT></P>
<P align=justify><FONT size=3 face=Calibri>First, simplifying access to location sources: At any given time you may have one or more location sensors on your machine (</FONT><A href="https://windows.microsoft.com/en-us/windows7/Set-a-geographic-location-for-your-computer" mce_href="https://windows.microsoft.com/en-us/windows7/Set-a-geographic-location-for-your-computer"><FONT size=3 face=Calibri>default location</FONT></A><FONT size=3 face=Calibri> + some other location sensor like a GPS sensor). If you were to access these location sensors directly from the Sensor API you would need to talk to all available location sensors and make some determination about which sensor is likely to provide the location data you want. The Location API does the work, internally, to identify and use the location sensor which appears to be most accurate and reliable.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>Second, simplify accessing location information from location sensors: A location sensor is just a sensor. As such you can access the location sensors information from the Sensor API. However, the Sensor API is designed to provide generalized access to all forms of sensor devices on your machine. As a result accessing data from sensors usually requires a several steps. Take a look at our last blog post on the Sensor API to get a quick overview of these steps (</FONT><A href="https://blogs.msdn.com/sensorslocation/archive/2010/01/27/the-sensor-and-location-drill-down-part-2-the-sensor-api.aspx" mce_href="https://blogs.msdn.com/sensorslocation/archive/2010/01/27/the-sensor-and-location-drill-down-part-2-the-sensor-api.aspx"><FONT size=3 face=Calibri>link</FONT></A><FONT size=3 face=Calibri>). The Location API automatically calls into the Sensor API and extracts location information for you. The Location API then presents the information in a format that is specifically suited for location data, such as </FONT><A href="https://msdn.microsoft.com/en-us/library/dd317673(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/dd317673(VS.85).aspx"><FONT size=3 face=Calibri>ILatLongReport</FONT></A><FONT size=3 face=Calibri> and </FONT><A href="https://msdn.microsoft.com/en-us/library/dd317669(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/dd317669(VS.85).aspx"><FONT size=3 face=Calibri>ICivicAddressReport</FONT></A><FONT size=3 face=Calibri>. The net effect is that it is generally much simpler to ask the Location API for location data instead of using the Sensor API.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>So, how do you access location data from the Location API? Let’s walk through a quick example using the COM Location API. Note - each step below will contain a link to the relevant document in MSDN.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>- First create an instance of the Location API by CoCreating </FONT><A href="https://msdn.microsoft.com/en-us/library/dd317737(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/dd317737(VS.85).aspx"><FONT size=3 face=Calibri>ILocation</FONT></A><FONT size=3 face=Calibri>.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>- Next, call ILocation-&gt;</FONT><A href="https://msdn.microsoft.com/en-us/library/dd317633(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/dd317633(VS.85).aspx"><FONT size=3 face=Calibri>RegisterForReports()</FONT></A><FONT size=3 face=Calibri> to register to receive ILocationReport’s (either an </FONT><A href="https://msdn.microsoft.com/en-us/library/dd317673(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/dd317673(VS.85).aspx"><FONT size=3 face=Calibri>ILatLongReport</FONT></A><FONT size=3 face=Calibri> or an </FONT><A href="https://msdn.microsoft.com/en-us/library/dd317669(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/dd317669(VS.85).aspx"><FONT size=3 face=Calibri>ICivicAddressReport</FONT></A><FONT size=3 face=Calibri>).</FONT></P>
<P align=justify><FONT size=3 face=Calibri>- When you call </FONT><A href="https://msdn.microsoft.com/en-us/library/dd317633(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/dd317633(VS.85).aspx"><FONT size=3 face=Calibri>RegisterForReports()</FONT></A><FONT size=3 face=Calibri> on an ILocation object you will register a call-back object which will be called when the Location API wants to notify you of changes in Location or Location Status. The callback object will need to implement the </FONT><A href="https://msdn.microsoft.com/en-us/library/dd317675(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/dd317675(VS.85).aspx"><FONT size=3 face=Calibri>ILocationEvents</FONT></A><FONT size=3 face=Calibri> interface to receive location events. When a location change occurs the </FONT><A href="https://msdn.microsoft.com/en-us/library/dd317615(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/dd317615(VS.85).aspx"><FONT size=3 face=Calibri>OnLocationChanged()</FONT></A><FONT size=3 face=Calibri> method, which will be implemented in your callback object, will get called with the updated ILatLongReport or ICivicAddressReport.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>- The </FONT><A href="https://msdn.microsoft.com/en-us/library/dd317615(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/dd317615(VS.85).aspx"><FONT size=3 face=Calibri>OnLocationChanged()</FONT></A><FONT size=3 face=Calibri> callback method will deliver to your callback object either an </FONT><A href="https://msdn.microsoft.com/en-us/library/dd317673(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/dd317673(VS.85).aspx"><FONT size=3 face=Calibri>ILatLongReport</FONT></A><FONT size=3 face=Calibri> or an </FONT><A href="https://msdn.microsoft.com/en-us/library/dd317669(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/dd317669(VS.85).aspx"><FONT size=3 face=Calibri>ICivicAddressReport</FONT></A><FONT size=3 face=Calibri>. Each report object provides methods to access the location information contained by the object. As an example you can access the latitude on an ILatLongReport by calling the </FONT><A href="https://msdn.microsoft.com/en-us/library/dd317611(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/dd317611(VS.85).aspx"><FONT size=3 face=Calibri>GetLatitude()</FONT></A><FONT size=3 face=Calibri> method. The </FONT><A href="https://msdn.microsoft.com/en-us/library/dd317611(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/dd317611(VS.85).aspx"><FONT size=3 face=Calibri>GetLatitude()</FONT></A><FONT size=3 face=Calibri> method will return a double which represents the current latitude for your location sensor.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>The Location API documentation on MSDN has an example which shows all of the above in steps in one location with a description for each object used. You can find that information </FONT><A href="https://msdn.microsoft.com/en-us/library/dd317735(VS.85).aspx" mce_href="https://msdn.microsoft.com/en-us/library/dd317735(VS.85).aspx"><FONT size=3 face=Calibri>here</FONT></A><FONT size=3 face=Calibri>.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>To summarize:</FONT></P>
<P align=justify><FONT size=3 face=Calibri>- The Location API sit’s at the top of the Sensor API stack and provides simplified access to location data.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>- To access Location you can either use the COM Location API interface in C++ or you can use the scripting interface.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>- To get location updates in your application all you need to do is create the Location API, register for reports and then handle location changes on your call back object.</FONT></P>
<P align=justify><FONT size=3 face=Calibri>A few final notes: The Location API team has been working over the last several months with the .NET CLR Team to build a Managed Location API which will ship in the next version of .NET. We are tremendously excited about having location exposed to developers via COM, Scripting and now .NET. You can find some initial information about the .NET Location API on Gavin’s blog (</FONT><A href="https://blogs.msdn.com/gavingear/archive/tags/.NET+4+Location/default.aspx" mce_href="https://blogs.msdn.com/gavingear/archive/tags/.NET+4+Location/default.aspx"><FONT size=3 face=Calibri>link</FONT></A><FONT size=3 face=Calibri>). Stay tuned here for more information!</FONT></P>
<P><FONT size=3 face=Calibri>-- Sensor &amp; Location Platform Team</FONT></P>
<P><I><FONT size=3 face=Calibri>This posting is provided "AS IS" with no warranties and confers no rights.</FONT></I></P>]]></content:encoded>
    </item>
  </channel>
</rss>