Symbian3/SDK/Source/GUID-4B709839-8EEF-4AD2-9868-9AF0176B1E5B.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 11 Jun 2010 12:39:03 +0100
changeset 8 ae94777fff8f
parent 7 51a74ef9ed63
child 13 48780e181b38
permissions -rw-r--r--
Week 23 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 2714, Bug 462.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE task
  PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="GUID-4B709839-8EEF-4AD2-9868-9AF0176B1E5B" xml:lang="en"><title>Using
Sensor Channels APIs</title><shortdesc>The Sensor Channel establishes a data exchange connection between
the sensor framework and hardware using the sensor channel APIs.</shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
<steps id="GUID-4DD07DEC-6017-4237-BE46-1D69E5FBD744-GENID-1-10-1-9-1-1-6-1-4-1-4-1-3-1">
<step id="GUID-9A69E5AD-E938-4092-A8C2-CB65C37C8962-GENID-1-10-1-9-1-1-6-1-4-1-4-1-3-1-1"><cmd>Include the library <b>SensrvClient.lib</b> in
your <b>.mmp</b> file.</cmd>
</step>
<step id="GUID-4F637EBD-BD56-44FA-A984-E93CC4B2B3B6"><cmd>Include the following
header files, as they are required for accessing sensor channels regardless
of the channel type: </cmd>
<info><ul>
<li><p>sensrvchannel.h</p></li>
<li><p>sensrvchannelinfo.h</p></li>
<li><p>sensrvtypes.h</p></li>
<li><p>sensrvchannelfinder.h</p></li>
<li><p>sensrvdatalistener.h</p></li>
</ul></info>
</step>
<step id="GUID-F5BC52B6-67DD-4F59-889B-C5DE4C69029B"><cmd>Retrieve details
about the required sensor channel. For details. see <xref href="GUID-44FDDA27-1A5D-42B5-8DE0-D9E88EB75C93.dita">Querying
for Sensor Channels</xref>.</cmd>
</step>
<step id="GUID-FBBD3A8B-F240-4DC0-B516-3A51FDD86A88"><cmd>Connect to the sensor
by opening a connection with the sensor channel.</cmd>
<substeps id="GUID-C9E5B9FC-C637-4DEB-AAAF-E38C6CD9A18A">
<substep id="GUID-CA2CFF9C-3168-4060-AC39-8CB6FBA4BCA2"><cmd>Create an instance
of <codeph>CSensrvChannel</codeph> and specify the instance of <codeph>TSensrvChannelInfo</codeph> returned
by <xref href="GUID-5F108D03-C8A6-3EF9-B103-2E8916633602.dita#GUID-5F108D03-C8A6-3EF9-B103-2E8916633602/GUID-E58BAF1B-57AA-3E85-A4F9-8C6C29043FBD"><apiname>CSensrvChannelFinder::FindChannelsL()</apiname></xref>, as a parameter
in the <codeph>NewL()</codeph> constructor.</cmd>
<stepxmp><codeblock xml:space="preserve"> CSensrvChannel* sensorChannel;
 sensorChannel = CSensrvChannel::NewL(channelInfoList[0]);// channelInfoList is
//   returned by the CSensrvChannelFinder::FindChannelsL()funtion</codeblock></stepxmp>
</substep>
<substep id="GUID-30E6033F-E316-4BDB-AF22-2369463DF709"><cmd>Open the sensor
channel using <xref href="GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844.dita#GUID-22DC917F-D833-3531-AB2D-A6E2D52EF844/GUID-277A4940-2E5E-3E8E-AB61-552CD2375F3C"><apiname>CSensrvChannel::OpenChannelL()</apiname></xref> function.</cmd>
<stepxmp><codeblock xml:space="preserve">channel-&gt;OpenChannelL();</codeblock></stepxmp>
</substep>
</substeps>
</step>
<step id="GUID-7A414271-040C-4107-B047-9416747C66A6"><cmd>Perform any of the
following operations:</cmd>
<info><ul>
<li><xref href="GUID-BA0D9DA9-3B54-4964-A4D6-9ADA4DEB7231.dita">Receive data from
sensors</xref></li>
<li><xref href="GUID-09E44FE5-6BEE-49FF-8BBF-CBB3C066EE10.dita">Listen for channel
changes</xref></li>
<li><xref href="GUID-83630B57-D842-4B60-8AF0-D2965251DE29.dita">Retrieve channel
properties</xref></li>
<li><xref href="GUID-0CA7F22E-59D7-4D65-9D6C-735E4E0F0454.dita">Set channel properties</xref></li>
<li><xref href="GUID-E93EE459-8CF4-42A1-B06C-E78E56FD25A0.dita">Listen for channel
property changes</xref></li>
<li><xref href="GUID-60EE22AA-402D-4FC2-9AD1-B3AEF822E8DC.dita">Receive channel
data based on conditions</xref></li>
</ul></info>
</step>
<step id="GUID-61840C55-476C-4DC3-A946-A440330B9DE5"><cmd>Close the channel.</cmd>
<info><codeblock xml:space="preserve">channel-&gt;CloseChannel();</codeblock><note type="important"> A
channel must be closed when not required, as it reduces power consumption
of the Symbian device. An open sensor channel keeps the device processor active
each time data arrives. Therefore, the processor does not change to idle state
even when the device user is not performing any operations on the device.</note></info>
</step>
</steps>
</taskbody></task>