You can implement a data listener to receive data from the sensors. Based on the data received, you can perform specific actions on the Symbian device. For example, if you receive information from the sensor about the distance between the device and the user then based on this information, you can disable or enable the loudspeaker mode on the Symbian device.
Before listening for sensor channel data, you must open the sensor channel .
The following example shows how to handle the double tapping data notification that is received.
Check the channel type of the received data and then receive the data object using the CSensrvChannel::GetData() function. The aCount parameter provides the details about the number of data objects in the channels receiving buffer. This number can be zero if the buffering period is used when data listening is started. The aDataLost parameter provides the details about the number of the lost data objects. For example, in heavy load situations.
void CTestClass::DataReceived( CSensrvChannel& aChannel, TInt aCount, TInt aDataLost ) { if ( aChannel.GetChannelInfo().iChannelType == KSensrvChannelTypeIdAccelerometerDoubleTappingData ) { TSensrvTappingData tappingData; TPckg <TSensrvTappingData> tappingPackage( tappingData ); aChannel.GetData( tappingPackage ); } }
End the session with the sensor channel using the CSensrvChannel::CloseChannel() function.
Copyright ©2010 Nokia Corporation and/or its subsidiary(-ies).
All rights
reserved. Unless otherwise stated, these materials are provided under the terms of the Eclipse Public License
v1.0.