The channel properties can be configured using the CSensrvChannel::SetProperty() function.
Before setting channel properties, you must open the sensor channel.
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, TSensrvAccelerometerAxisData::Index::iAxisX, 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 } } else { //Accelerometer x-axis is already inactive }
End the session with the sensor channel using the CSensrvChannel::CloseChannel() function.