The following example shows how to find and open a double tapping channel.
You need to create an instance of CSensrvChannelFinder
is to be able to find channels. The found channels are stored to
the RSensrvChannelInfoList
type of object.
For example, to query all double tapping channels provided by the device,
set the channel type as KSensrvChannelTypeIdAccelerometerDoubleTappingData
in
the TSensrvChannelInfo
object
which is used as search criteria.
For all the sensor channel types to be used when searching, see Sensor channel types.
After calling the FindChannelsL()
method, channelInfoList
contains
all the found double tapping channels. If several matching channels are found,
you can select the channel you want by examining the content of channel information
objects inside channelInfoList
. For details on the content
of the channel information objects in channelInfoList
, see
the class documentation for TSensrvChannelInfo
.
To construct the CSensrvChannel
object
properly, you must use a channel information object from channelInfoList
as
a parameter for the NewL()
constructor.
After successful construction, you can open the channel with the OpenChannelL()
method. For an open channel, you can listen for
sensor data, set and get channel properties,
and add channel conditions.
When you don't need the channel any more, you must close it
using the CloseChannel()
method.
//Construct a channel finder. CSensrvChannelFinder* channelFinder; channelFinder = CSensrvChannelFinder::NewL(); CleanupStack::PushL( channelFinder ); //List of found channels. RSensrvChannelInfoList channelInfoList; //Create and fill channel search criteria. //In this example double tapping channel is searched. TSensrvChannelInfo channelInfo; channelInfo.iChannelType = KSensrvChannelTypeIdAccelerometerDoubleTappingData; //Find the double tapping channel channelFinder->FindChannelsL( channelInfoList, channelInfo ); CleanupStack::PopAndDestroy( channelFinder ); // finder not needed any more if( channelInfoList.Count() != 1 ) { //The device doesn't support double tapping channel or //there are several double tapping channels. } else { //double tapping channel found } //Open the double tapping channel. //When the channel object is created the channel info object //must be an object returned by CSensrvChannelFinder::FindChannelsL(). CSensrvChannel* sensorChannel; sensorChannel = CSensrvChannel::NewL( channelInfoList[ 0 ] ); CleanupStack::PushL( sensorChannel ); sensorChannel->OpenChannelL(); // //Double tapping channel is now open. //