diff -r 4d198a32ac7d -r d4809db37847 plugins/org.symbian.tools.wrttools.doc.WebDeveloper/html/GUID-6FBE64B7-0949-4AAE-B835-52B276540A59.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/plugins/org.symbian.tools.wrttools.doc.WebDeveloper/html/GUID-6FBE64B7-0949-4AAE-B835-52B276540A59.html Thu Aug 19 17:48:04 2010 -0700 @@ -0,0 +1,95 @@ + + +Accessing +data from the physical sensors of a device

Accessing +data from the physical sensors of a device

+

The Sensor Service +API allows widgets to access data provided by the +physical sensors of a device. The data from a given sensor is mapped to one +or more sensor channels, which the API can listen to. The available sensors +depend on the device. You can use the Sensor Service to create widgets that:

+
    +
  • Search for sensor channels available on a device

  • +
  • Listen for data provided by one or more sensor channels

    +
  • +
  • Retrieve information about sensor channel properties

    +
  • +
+

Sensor information involves the following concepts:

+
    +
  • Sensor is a physical sensor on a device (a piece of +hardware combined with a software plugin). A single sensor can provide multiple +sensor channels, such as a raw data channel and event channels, or incorporate +multiple sensor readings into a single sensor channel.

  • +
  • Sensor property is a configuration value of a sensor. +The property affects all sensor channels that draw data from the sensor.

    +
  • +
  • Channel is an abstraction of a physical sensor. Data +from one physical sensor can be mapped to multiple sensor channels.

    +
  • +
  • Channel property is a configuration value of a sensor +channel. The property affects all clients listening to the channel.

    +
  • +
+

Accessing the API and supported methods

+

To create a service +object for the Sensor Service API, use Service.Sensor to +identify the service provider and ISensor to identify +the supported interface:

+ +
var so = device.getServiceObject("Service.Sensor", "ISensor");
+

The ISensor interface provides the following methods:

+
    +
  • FindSensorChannel()

    + +

    Use the FindSensorChannel() method to search for +sensor channels available on the device.

    + +
  • +
  • RegisterForNotification()

    + +

    Use the RegisterForNotification() method to receive +data from one sensor channel.

    + +
  • +
  • Cancel()

    + +

    Use the Cancel() method to stop receiving data +provided by a RegisterForNotification() call.

    + +
  • +
  • GetChannelProperty()

    + +

    Use the GetChannelProperty() method to retrieve +information about a sensor channel property.

    + +
  • +
+
+

Using the service in a widget

+

To access sensor data on a device using the Sensor Service API:

+
    +
  1. Create a service +object for the API using device.getServiceObject().

    +
  2. +
  3. Define the +tasks you want to perform and choose the correct methods for them.

    +
  4. +
  5. Optionally, +define how you want the results filtered.

  6. +
  7. Define methods +to process the results.

  8. +
  9. Retrieve the +results using the methods from step 2. Use asynchronous methods together with callback().

    +
  10. +
  11. Process the +results using the methods defined in step 4.

  12. +
+

For the complete source of a sample widget that demonstrates how to +use this service, see the +full example.

+
+
\ No newline at end of file