Setting Channel Properties

The channel properties can be configured using the CSensrvChannel::SetProperty() function.


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


  1. Create a TSensrvProperty property object for setting the KSensrvPropIdDataRate property using the TSensrvProperty(const TSensrvPropertyId,const TInt,const TInt) constructor.

    TInt val=2;
    TSensrvProperty sensrvProperty(KSensrvPropIdDataRate,KSensrvItemIndexNone,val);
  2. Set the KSensrvPropIdDataRate property value by passing the property object that you created to CSensrvChannel::SetProperty().

    CSensrvChannel* channel;
    TInt ret;


The following example explains how to set the x-axis of accelerometer channel status from activated to deactivated.

The axis active property KSensrvPropIdAxisActive is first retrieved using the CSensrvChannel::GetPropertyL() function. If the axis is active, the new deactivated value is set in the retrieved property object. Then the channel is updated with this updated property object by using the CSensrvChannel::SetProperty() function.

TSensrvProperty property;
    TInt err( KErrNone );
    TInt axisActive( 0 );
    iSensorChannel->GetPropertyL( KSensrvPropIdAxisActive,
                                  property );
    property.GetValue( axisActive );
    if( 1 == axisActive )
        property.SetValue( 0 ); // A value other than 1 means that sensor axis is deactivated.
        err = iSensorChannel->SetProperty( property );
        if( KErrNone == err )
            //Accelerometer x-axis was successfully deactivated
        //Accelerometer x-axis is already inactive

Next actions

End the session with the sensor channel using the CSensrvChannel::CloseChannel() function.