diff -r 000000000000 -r 89d6a7a84779 Symbian3/SDK/Source/GUID-60EE22AA-402D-4FC2-9AD1-B3AEF822E8DC.dita --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/SDK/Source/GUID-60EE22AA-402D-4FC2-9AD1-B3AEF822E8DC.dita Thu Jan 21 18:18:20 2010 +0000 @@ -0,0 +1,98 @@ + + + + + +Receiving +Channel Data based on ConditionsConditional listening enables you to receive sensor data feeds +based on a specific condition. For example, you can choose to receive sensor +feeds that are only movement specific. +

Before listening +for channel data, you must open +the sensor channel.

+ +Create channel condition +items using CSensrvChannelCondition constructor. These +conditions can be used to filter the sensor data feeds. +//Comparison values needed for condition +... +TInt firstNumber=45; +HBufC8 *firstBufNumber=NULL; +InetProtTextUtils::ConvertIntToDescriptorL(firstNumber,firstBufNumber); +CleanupStack::PushL(firstBufNumber); + +TInt secondNumber=150; +HBufC8 *secondBufNumber=NULL; +InetProtTextUtils::ConvertIntToDescriptorL(secondNumber,secondBufNumber); +CleanupStack::PushL(secondBufNumber); + +//Creates a SingleLimit Condition with a GreaterThan operator +CSensrvChannelCondition *firstCondition = CSensrvChannelCondition::NewL(ESensrvSingleLimitCondition,ESensrvOperatorGreaterThan,1,*firstBufNumber); + +//Creates a SingleLimit Condition with a LessThan operator +CSensrvChannelCondition *secondCondition = CSensrvChannelCondition::NewL(ESensrvSingleLimitCondition,ESensrvOperatorLessThan,2,*secondBufNumber); + +Create a channel +condition set using CSensrvChannelConditionSet constructor. +Add the condition items to the condition set using the CSensrvChannelConditionSet::AddConditionL() function. +//Creates a ConditionSet with ConditionType OR + CSensrvChannelConditionSet *ConditionSet=CSensrvChannelConditionSet::NewLC(ESensrvAndConditionSet); + + //Add channel1 and channel2 to conditonset + ConditionSet->AddChannelConditionL(firstCondition); + ConditionSet->AddChannelConditionL(secondCondition); + +Add the condition +set to the required channel using the CSensrvChannel::AddConditionL() function. +CSensrvChannel* channel; +channel->AddConditionL(*ConditionSet); + + +Create a condition +listener implementation for the MSensrvChannelConditionListener interface, +which listens for sensor data feeds based on CSensrvChannelConditionSet. +class ConditionListener:public MSensrvChannelConditionListener + { + public: + void ConditionMet(CSensrvChannel &aChannel, CSensrvChannelConditionSet &aChannelConditionSet, TDesC8 &avalue) + { + ... + //Implementation + } + void ConditionError(CSensrvChannel &aChannel, TSensrvErrorSeverity aError) + { + ... + //Implementation + } + void GetChannelConditionListenerInterfaceL(TUid aInterfaceUid, TAny *&aInterface) + { + ... + //Implementation + } + }; + +Start conditional +listening by passing an instance of the condition listener implementation, +using the CSensrvChannel::StartConditionListeningL() function. +//Instance of the condition listener implementation +ConditionListener conditionListener; +... +channel->StartConditionListeningL(conditionListener,1,1); +... + +Once you get the +required sensor data feeds from the sensor channel based on the conditions +set, you can stop conditional listening using the CSensrvChannel::StopConditionListening() function. +channel->StopConditionListening(); + + + +

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

+
\ No newline at end of file