To use sensor data from a channel, you must first find the channel and open it. See this list of sensor channels supported by the S60 platform.
The class CSensrvChannelFinder
provides functionality to find channels. The class CSensrvChannel
provides functionality to open and control
channels. For the classes in the sensor APIs, see Sensor
APIs class structure.
To use sensor data in your application with the sensor APIs, follow the steps below:
Include the library SensrvClient.lib
in
your .mmp
file.
Include the necessary header files based on the type of channel you want to use.
The below header files are required for accessing sensor channels regardless of the channel type, so you must include them:
If you need to know which sensor channels are supported on the target device, scan for the available channels.
For this, you must include the header files for all sensor channel types.
Once you know which sensor channel type you want to use, find and open the sensor channel.
Listen for sensor data on the channel and handle it in your application. Once you do not need to listen to the channel data any more, stop the listening.
Once you do not need to listen to the sensor channel any more, close the channel.
Note: Closing the channel when it is no longer needed is very important in terms of reducing power consumption in the device. This is because an open sensor channel keeps the device processor active each time data arrives, and the processor will not get to the idle state even if the device user was not doing anything else.
Figure: Sequence diagram: Finding a channel, opening a channel, receiving data, closing a channel.
The following use cases are optional, allowing you to use additional sensor channel features.
Scaling channel data (raw data channels only)
Compensating sensor data for device or display orientation (Nokia N97 SDK only)