Windows7 Sensor & Location Platform


Published on

  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Windows7 Sensor & Location Platform

  1. 1. Windows 7 Deep Dive LabSensor & Location Platform<br />Dennis Loktionov<br />July 16, 2009<br />
  2. 2.
  3. 3.
  4. 4. Agenda<br />Windows 7 Sensor & Location Platform<br /><ul><li>Introduction
  5. 5. Sensor Platform Architecture
  6. 6. Working with the Sensor API
  7. 7. Location Platform Architecture
  8. 8. Working with the Location API
  9. 9. Demos</li></ul>Questions<br />
  10. 10. Introduction<br />Definition<br />Sensors measure a physical phenomenon or a physical interaction<br />Sensor Types<br />Ambient Light Sensors (ALS)<br />Accelerometers<br />Location Sensors<br />GPS, Wi-Fi /cell tower triangulation, IP Geolocation<br />Proximity Sensors<br />Temperature Sensors<br />Biometric Sensor*<br />Others (Human presence, RFID)<br />
  11. 11. Limitations of Sensors Today<br />Sensors are integrated as vertical solutions<br />Applications need to know sensor hardware specifics<br />Limited adoption and scope<br />Sensors are exposed as virtual COM ports<br />Exclusive application access<br />Not secure<br />Proprietary data formats (NMEA, others)<br />
  12. 12. Sensor Platform Overview<br />Unified Driver Model for all types of sensors<br />Physical sensors (e.g., GPS devices, Light Sensors)<br />Logical sensor (e.g., Wi-Fi triangulation resolver)<br />Standard APIs for accessing sensors<br />COM-based Sensor API<br /> Works with drivers using the sensor class extension<br />Benefits<br />Implements native support for sensor and location devices on Windows<br />No need to target vendor-specific APIs or to know hardware specifics<br />Consistent interface for all sensor types<br />Privacy and security<br />
  13. 13. Sensor Platform Architecture<br />Application<br />Application<br />Location and Other Sensors Control Panel<br />Sensor API<br />User<br />System<br />Sensor class extension<br />UMDF sensor driver<br />Sensor<br />device<br />This is a partial diagram of the Sensor and Location Platform, showing only sensor-related parts<br />
  14. 14. Privacy and Access Control<br /><ul><li>Location data is considered private
  15. 15. Legal term: Personally identifiable information (PII)
  16. 16. User consent is required to share data
  17. 17. All sensors are disabled by default
  18. 18. Administrator rights required to enable a sensor
  19. 19. Sensors are configured on a per-user basis (not per application)
  20. 20. Enable Sensors dialog box </li></ul> is invoked by applications<br />
  21. 21. Sensor API Architecture<br />COM-based API (includes Sensorsapi.h and Sensors.h)<br />Consists of these main interfaces:<br />ISensorManager<br />Sensor enumeration, attachment event, request permissions<br />ISensor<br />Get and set properties, get report, events (new report, detachment, state change, custom) and more<br />ISensorDataReport<br />Get sensor data report data fields<br />
  22. 22. Sensor API Architecture<br />
  23. 23. Sensors Explained<br />Enumerated via category and type GUIDs <br />Category represents what is being sensed (for example, environment, location, motion, electrical systems)<br />Type represents how it is being sensed (for example, by thermometer, GPS, accelerometer, voltage)<br />Properties<br />Read-only (such as model) or read-write (such as report interval).<br />Sensors may have custom properties<br />Data<br />Get (sensor-specific) data report object synchronously (not recommended) or asynchronously (events)<br />Events<br />State change, leave (detach), data updated, custom<br />State<br />Is sensor working properly? Do you have access?<br />
  24. 24. Enumerating Sensors<br />#include &lt;sensorsapi.h&gt;<br />#include &lt;sensors.h&gt;<br />HRESULT hr;<br />CComPtr&lt;ISensorManager&gt; pSensorManager;<br />pSensorManager.CoCreateInstance(CLSID_SensorManager);<br />CComPtr&lt;ISensorCollection&gt; pALSCollection;<br />CComPtr&lt;ISensor&gt; pALSSensor;<br />// Get all the ALS sensors on the system<br />pSensorManager-&gt;GetSensorsByType(SENSOR_TYPE_AMBIENT_LIGHT, &pALSCollection);<br />hr = pSensorManager-&gt;RequestPermissions(<br /> 0, // Owner window <br /> pALSCollection, // Collection of sensors requiring permissions<br /> TRUE); // Modal flag<br />if(SUCCEEDED(hr))<br />{<br /> pALSCollection-&gt;GetAt(0, &pALSSensor);<br />}<br />
  25. 25. Getting Current Light Level<br />STDMETHODIMP CALSEventSink::OnDataUpdated(<br /> ISensor* pSensor, ISensorDataReport* pNewData)<br /> {<br />PROPVARIANT lightLevel; <br />PropVariantInit(&lightLevel); <br />// Get the sensor reading from the ISensorDataReport object<br />pNewData-&gt;GetSensorValue(SENSOR_DATA_TYPE_LIGHT_LEVEL_LUX, &lightLevel);<br />// Extract the float value from the PROPVARIANT object<br />float luxValue = V_FLOAT(lightLevel);<br />// Normalize the light sensor data<br />double lightNormalized = ::pow(luxValue, 0.4) / 100.0;<br />// Handle UI changes based on the normalized LUX data <br />// which ranges from 0.0 - 1.0 for a lux range of<br />// 0 lux to 100,000 lux, this method represents such a <br />// handler that would be implemented in your application <br />UpdateUI(lightNormalized); <br />PropVariantClear(&lightLevel);<br />return S_OK;<br /> }<br />
  26. 26. Sensor .NET Wrapper Architecture<br />
  27. 27. Sensor .NET Wrapper Architecture<br /><ul><li>Sensor is an abstract base class with a derived type for each sensor type
  28. 28. Derived types can add properties and events</li></li></ul><li>Sensor .NET Wrapper Architecture<br /><ul><li>SensorDataReport also has a derived type for each sensor type
  29. 29. Provides a strongly-typed way to access data</li></li></ul><li>Ambient Light Sensor (ALS)<br />Measure light intensity in LUX (lumens per square meter)<br />Windows 7 includes class driver support for ACPI light sensors<br />Working with OEMs to integrate light sensors into notebooks<br />Adaptive brightness feature supported by Windows 7<br />OS automatically adjusts display backlight<br />Light-aware applications can use these sensors to optimize UI content for various lighting conditions<br />Demo…<br />
  30. 30. Sensor Development Kit<br /><ul><li>Based on Freescale JM Badge Board
  31. 31. Sensors
  32. 32. Ambient light sensor
  33. 33. 3D Accelerometer
  34. 34. Dual touch strip sensors
  35. 35. Developer tools
  36. 36. Sample firmware code
  37. 37. Sample driver code
  38. 38. Diagnostic and sample applications
  39. 39. Sensor Diagnostic Tool
  40. 40. Light-aware MSDN Reader
  41. 41. Marble game
  42. 42. Demo…</li></li></ul><li>Location Platform Overview<br />Single API call to answer “Where am I?”<br />Provider (such as: GPS, IP resolver, Wi-Fi) independent<br />Synchronous and asynchronous models<br />Script or automation compatible<br />Automatic transition between providers<br />Most accurate providers have priority<br />Concurrent access for multiple applications<br />Default location<br />Provided by user as fallback when no other sources are available<br />
  43. 43. Location-Awareness Opportunities<br />Useful local information<br />Location based search for points of interest<br />Mapping/navigation based on current location <br />PC recovery service<br />Social networking: Where are my friends and family?<br />Others…<br />
  44. 44. Location Platform API Overview<br />The Windows 7 Location API is built on top of the Sensor API<br />COM-based API (includes Locationapi.h)<br />It is a high-level abstraction<br />Leverages sensors which provide location information<br />Some sensors (location providers) may be logical <br />Ex: Wi-Fi hotspot triangulation<br />
  45. 45. Location Platform Architecture<br />Gadget or script<br />Application<br />Application<br />Location API<br />Location IDispatch Interface<br />Sensor API<br />User<br />Location and Other Sensors Control Panel<br />System<br />Sensor class extension<br />Sensor class extension<br />UMDF sensor driver<br />UMDF sensor driver<br />Sensor<br />device<br />Logical location sensor<br />(Triangulation)<br />
  46. 46. Configuring Default Location<br />
  47. 47. Location API Architecture<br />
  48. 48. Types of Location Data<br />Geographic data (ILatLongReport)<br />Latitude, longitude, altitude, associated error required<br />Most common format<br />Best format for precise location<br />Can reverse geo-code later<br />Civic address (ICivicAddressReport)<br />Zip code, country required<br />Most human readable<br />Best for ‘rough’ location estimates, street directions<br />Demo…<br />
  49. 49. 3D Bing Maps & Location Platform <br />Demo…<br />
  50. 50. Summary<br />Sensor Platform overview & architecture<br />Native Sensor API<br />Managed Sensor API wrapper<br />Native Location API<br />Types of location data, default location<br />Managed Location API wrapper<br />
  51. 51. Questions ?<br />Q&A<br />
  52. 52. The End. Fin. Конец.<br />THANKS<br />