Retrieving Channel Properties

A sensor channel is associated with properties such as channel availability status, data transmission rate, data format and so on. Also, each field in the data type supplied by a sensor channel can have its own properties. The channel properties can be retrieved using the CSensrvChannel::GetPropertyL() and CSensrvChannel::GetAllPropertiesL() functions.

Context

A channel property is referenced by its property id and an index. The parameters of the CSensrvChannel::GetPropertyL() are listed with their meanings in the following table.

Parameter Meaning
First parameter specifies the id of the property to retrieve.
Second parameter is an index that specifies the property to be retrieved, if there are several properties associated with a particular property id.
Third parameter is a TSensrvProperty that is passed by reference and populated by CSensrvChannel::GetPropertyL().

The following list shows the different possible values of the index :

  • When the property id is for a simple property, that is, there is only one property item for the id (for example, KSensrvPropIdChannelAccuracy), the second parameter must be specified as ESensrvSingleProperty.

  • 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. For details, see Array Properties.

  • 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 can use KSensrvPropIdDataRate as the property id and ESensrvArrayPropertyInfo as the index to retrieve the property item that contains this information.

Prerequisites

Before retrieving channel properties, you must open the sensor channel.

Steps

  1. Create an instance of TSensrvProperty.

    TSensrvProperty property;

    Each channel property is encapsulated by the TSensrvProperty class. Therefore, the details of the retrieved property can be accessed using the functions of the TSensrvProperty class.

  2. Use the CSensrvChannel::GetPropertyL() function to retrieve the property item for a particular property id. For example, to check for the accuracy of a channel, pass the KSensrvPropIdChannelAccuracy as a property id.

    ...
    
    CSensrvChannel* iSensorChannel;
    ....
    iSensorChannel->GetPropertyL( KSensrvPropIdChannelAccuracy,
                                      KSensrvItemIndexNone,
                                      property );
    
    ....

    Note: You can retrieve all the properties associated with a particular sensor channel using the

    CSensrvChannel::GetAllPropertiesL() function.

Next actions

  • End the session with the sensor channel using the CSensrvChannel::CloseChannel() function.
  • You can set the required channel properties. For details, see Setting Channel Properties.