Symbian3/SDK/Source/GUID-60EE22AA-402D-4FC2-9AD1-B3AEF822E8DC.dita
changeset 7 51a74ef9ed63
child 8 ae94777fff8f
equal deleted inserted replaced
6:43e37759235e 7:51a74ef9ed63
       
     1 <?xml version="1.0" encoding="utf-8"?>
       
     2 <!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
       
     3 <!-- This component and the accompanying materials are made available under the terms of the License 
       
     4 "Eclipse Public License v1.0" which accompanies this distribution, 
       
     5 and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
       
     6 <!-- Initial Contributors:
       
     7     Nokia Corporation - initial contribution.
       
     8 Contributors: 
       
     9 -->
       
    10 <!DOCTYPE task
       
    11   PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
       
    12 <task id="GUID-60EE22AA-402D-4FC2-9AD1-B3AEF822E8DC" xml:lang="en"><title>Receiving
       
    13 Channel Data based on Conditions</title><shortdesc>Conditional listening enables you to receive sensor data feeds
       
    14 based on a specific condition. For example, you can choose to receive sensor
       
    15 feeds that are only movement specific.</shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
       
    16 <prereq id="GUID-A4F41A1D-D093-418E-BA65-30C36DA0B0DA">       <p>Before listening
       
    17 for channel data, you must <xref href="GUID-4B709839-8EEF-4AD2-9868-9AF0176B1E5B.dita#GUID-4B709839-8EEF-4AD2-9868-9AF0176B1E5B/GUID-FBBD3A8B-F240-4DC0-B516-3A51FDD86A88">open
       
    18 the sensor channel</xref>.</p>      </prereq>
       
    19 <steps id="GUID-4DD07DEC-6017-4237-BE46-1D69E5FBD744-GENID-1-8-1-9-1-1-6-1-4-1-4-1-10-1-3-2">
       
    20 <step id="GUID-9A69E5AD-E938-4092-A8C2-CB65C37C8962-GENID-1-8-1-9-1-1-6-1-4-1-4-1-10-1-3-2-1"><cmd>Create channel condition
       
    21 items using <parmname>CSensrvChannelCondition</parmname> constructor. These
       
    22 conditions can be used to filter the sensor data feeds.</cmd>
       
    23 <stepxmp><codeblock xml:space="preserve">//Comparison values needed for condition
       
    24 ...
       
    25 TInt firstNumber=45;
       
    26 HBufC8 *firstBufNumber=NULL;
       
    27 InetProtTextUtils::ConvertIntToDescriptorL(firstNumber,firstBufNumber);
       
    28 CleanupStack::PushL(firstBufNumber);
       
    29 
       
    30 TInt secondNumber=150;
       
    31 HBufC8 *secondBufNumber=NULL;
       
    32 InetProtTextUtils::ConvertIntToDescriptorL(secondNumber,secondBufNumber);
       
    33 CleanupStack::PushL(secondBufNumber);
       
    34 
       
    35 //Creates a SingleLimit Condition with a GreaterThan operator
       
    36 CSensrvChannelCondition *firstCondition = CSensrvChannelCondition::NewL(ESensrvSingleLimitCondition,ESensrvOperatorGreaterThan,1,*firstBufNumber);
       
    37 
       
    38 //Creates a SingleLimit Condition with a LessThan operator
       
    39 CSensrvChannelCondition *secondCondition = CSensrvChannelCondition::NewL(ESensrvSingleLimitCondition,ESensrvOperatorLessThan,2,*secondBufNumber);</codeblock></stepxmp>
       
    40 </step>
       
    41 <step id="GUID-A94F1F87-9CD4-45E9-9FDA-B53E26C8F92D"><cmd>Create a channel
       
    42 condition set using <parmname>CSensrvChannelConditionSet</parmname> constructor.
       
    43 Add the condition items to the condition set using the <xref href="GUID-AF4BAE05-7111-3DF7-964D-C8A49D8F3D08.dita#GUID-AF4BAE05-7111-3DF7-964D-C8A49D8F3D08/GUID-84740BEB-2E6E-38E6-822B-9F6E4A55DF7D"><apiname>CSensrvChannelConditionSet::AddConditionL()</apiname></xref> function.</cmd>
       
    44 <stepxmp><codeblock xml:space="preserve">//Creates a ConditionSet with ConditionType OR 
       
    45     CSensrvChannelConditionSet *ConditionSet=CSensrvChannelConditionSet::NewLC(ESensrvAndConditionSet);
       
    46     
       
    47     //Add channel1 and channel2 to conditonset
       
    48     ConditionSet-&gt;AddChannelConditionL(firstCondition);
       
    49     ConditionSet-&gt;AddChannelConditionL(secondCondition);</codeblock></stepxmp>
       
    50 </step>
       
    51 <step id="GUID-E51A9E16-67C8-43AB-BBEF-99411A3EEE0F"><cmd>Add the condition
       
    52 set to the required channel using the <xref href="GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844.dita#GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844/GUID-006A659E-72F1-3D5D-8476-952619E3BA2F"><apiname>CSensrvChannel::AddConditionL()</apiname></xref> function.</cmd>
       
    53 <stepxmp><codeblock xml:space="preserve">CSensrvChannel* channel;
       
    54 channel-&gt;AddConditionL(*ConditionSet);   
       
    55 </codeblock></stepxmp>
       
    56 </step>
       
    57 <step id="GUID-47EED068-A9C7-4DCF-AF03-3803CECAE7C8"><cmd>Create a condition
       
    58 listener implementation for the <parmname>MSensrvChannelConditionListener</parmname> interface,
       
    59 which listens for sensor data feeds based on <parmname>CSensrvChannelConditionSet</parmname>.</cmd>
       
    60 <stepxmp><codeblock xml:space="preserve">class ConditionListener:public MSensrvChannelConditionListener
       
    61     {
       
    62     public:
       
    63         void ConditionMet(CSensrvChannel &amp;aChannel, CSensrvChannelConditionSet &amp;aChannelConditionSet, TDesC8 &amp;avalue)
       
    64         {
       
    65         ...
       
    66          //Implementation
       
    67         }
       
    68     void ConditionError(CSensrvChannel &amp;aChannel, TSensrvErrorSeverity aError)
       
    69         {
       
    70         ...
       
    71          //Implementation
       
    72         }
       
    73     void GetChannelConditionListenerInterfaceL(TUid aInterfaceUid, TAny *&amp;aInterface)
       
    74         {
       
    75         ...
       
    76          //Implementation
       
    77         }
       
    78     };</codeblock></stepxmp>
       
    79 </step>
       
    80 <step id="GUID-196F04E0-2A98-4479-8165-9A803823E6AD"><cmd>Start conditional
       
    81 listening by passing an instance of the condition listener implementation,
       
    82 using the <xref href="GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844.dita#GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844/GUID-4CA77329-E958-3568-B34D-1086AA34A334"><apiname>CSensrvChannel::StartConditionListeningL()</apiname></xref> function.</cmd>
       
    83 <stepxmp><codeblock xml:space="preserve">//Instance of the condition listener implementation
       
    84 ConditionListener conditionListener;   
       
    85 ...
       
    86 channel-&gt;StartConditionListeningL(conditionListener,1,1);
       
    87 ...</codeblock></stepxmp>
       
    88 </step>
       
    89 <step id="GUID-93BD0200-C12B-4AB1-9D23-F11AC54D39E6"><cmd>Once you get the
       
    90 required sensor data feeds from the sensor channel based on the conditions
       
    91 set, you can stop conditional listening using the <xref href="GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844.dita#GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844/GUID-78F64EA2-2901-3304-B4AE-B865D18772E8"><apiname>CSensrvChannel::StopConditionListening()</apiname></xref> function.</cmd>
       
    92 <stepxmp><codeblock xml:space="preserve">channel-&gt;StopConditionListening();
       
    93 </codeblock></stepxmp>
       
    94 </step>
       
    95 </steps>
       
    96 <postreq id="GUID-40C4B810-AD44-4A28-8C29-8A08E914970D"><p>End the session
       
    97 with the sensor channel using the <xref href="GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844.dita#GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844/GUID-0B8F50A6-2CA1-316A-82AB-AA026005E810"><apiname>CSensrvChannel::CloseChannel()</apiname></xref> function.</p></postreq>
       
    98 </taskbody></task>