Querying for Sensor Channels

You can retrieve a list of sensor channels that are available for a particular sensor type. Once you get the list of sensor channels that are active, you can perform any required operations such as configuring sensor channel properties, controlling sensor channels and so on.

Steps

  1. Create an instance of TSensrvChannelInfo and set the required channel type as the search criteria. For example, to query for all double tapping channels provided by accelerometer sensor, set the channel type as KSensrvChannelTypeIdAccelerometerDoubleTappingData.

    TSensrvChannelInfo channelInfo;
    channelInfo.iChannelType = KSensrvChannelTypeIdAccelerometerDoubleTappingData;
  2. Create an instance of CSensrvChannelFinder class and use the CSensrvChannelFinder::FindChannelsL() function to query for available sensor channels.

    CSensrvChannelFinder* finder = CSensrvChannelFinder::NewL();
    finder->FindChannelsL(channelList, searchParameters);
  3. Create an instance of RSensrvChannelInfoList to store the list of sensor channels.

    RSensrvChannelInfoList channelInfoList;

Results

The channelInfoList contains all the double tapping channels that are found. If several matching channels are found, you can select the required channel by examining the content of channel information objects inside channelInfoList.

Example

This following code shows how to find double tapping channels for accelerometer sensor:

.....
......
/Construct a channel finder.
    CSensrvChannelFinder* channelFinder;
    channelFinder = CSensrvChannelFinder::NewL();
    CleanupStack::PushL( channelFinder );
    
    // to store 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 does not support double tapping channel or
        //there are several double tapping channels.
        }
    else
        {
        //double tapping channel found 
        }
.....
....