Getting channel properties

A sensor channel can have many properties, for example: channel availability status, the rate at which data is transmitted from the sensor, and the format in which data is transmitted. Also, each field in the data type supplied by a sensor channel can have its own properties.

You must first open a channel before getting its properties.

Each channel property is encapsulated by the TSensrvProperty class. Use CSensrvChannel::GetPropertyL() to retrieve the property item for a particular property id and the methods of TSensrvProperty to access the details of the retrieved property. Some properties can also be set as well as retrieved.

A property is referenced by the property id plus an index. The first parameter of GetPropertyL() specifies the id of the property to retrieve. The second parameter is an index that specifies which particular property to retrieve if there are several properties associated with a particular property id. The third parameter is a TSensrvProperty that is passed by reference and populated by GetPropertyL(). The following list shows the different possible values of the index :
  1. When the property id is for a simple property, i.e. there is only one property item for the id, the second parameter must be specified as ESensrvSingleProperty. For example the property id KSensrvPropIdChannelAccuracy only has one property.

  2. When the given property id has an array of TSensrvProperty items, the index parameter indicates which item in the array to retrieve. One such case is when you want to retrieve a property of a particular data field that is supplied by the channel. For example, if you want to find out if the X axis of the accelerometer is enabled you must specify KSensrvPropIdAxisActive as the property id, and TSensrvAccelerometerAxisData::iAxisX as the index. See Using array properties for more information.

  3. When the given property id has an array of TSensrvProperty items, information about the array can be retrieved by specifying ESensrvArrayPropertyInfo as the index parameter. For example, when a channel can provide data at discrete data rates, the information for each data rate is stored in a TSensrvProperty item. You would use KSensrvPropIdDataRate as the property id and ESensrvArrayPropertyInfo as the index to retrieve the property item that contains this information. See the KSensrvPropIdDataRate specification for more information about this property.

Note:

GetPropertyL() leaves with KErrNotSupported if the channel does not support the requested property. It will also leave with KErrNotSupported if the requested property index is not defined as channel item property.

The following example shows how to check the accuracy of a channel.

    #include <sensrvchannel.h>
    #include <sensrvgeneralproperties.h>
        ...
    TSensrvProperty property;
    TReal propertyValue( 0 );

    iSensorChannel->GetPropertyL( KSensrvPropIdChannelAccuracy,
                                  KSensrvItemIndexNone,
                                  property );

    // KSensrvPropIdChannelAccuracy has type TReal as specified in sensrvgeneralproperties.h.
    // You can also check the type of a property at runtime using the PropertyType() method.
    if( property.PropertyType() == ESensrvRealProperty )
        {
        property.GetValue( propertyValue );
        }