|
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-4B709839-8EEF-4AD2-9868-9AF0176B1E5B" xml:lang="en"><title>Using |
|
13 Sensor Channels APIs</title><shortdesc>The Sensor Channel establishes a data exchange connection between |
|
14 the sensor framework and hardware using the sensor channel APIs.</shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody> |
|
15 <steps id="GUID-4DD07DEC-6017-4237-BE46-1D69E5FBD744-GENID-1-7-1-8-1-1-8-1-4-1-5-1-3-1"> |
|
16 <step id="GUID-9A69E5AD-E938-4092-A8C2-CB65C37C8962-GENID-1-7-1-8-1-1-8-1-4-1-5-1-3-1-1"><cmd>Include the library <b>SensrvClient.lib</b> in |
|
17 your <b>.mmp</b> file.</cmd> |
|
18 </step> |
|
19 <step id="GUID-4F637EBD-BD56-44FA-A984-E93CC4B2B3B6"><cmd>Include the following |
|
20 header files, as they are required for accessing sensor channels regardless |
|
21 of the channel type: </cmd> |
|
22 <info><ul> |
|
23 <li><p>sensrvchannel.h</p></li> |
|
24 <li><p>sensrvchannelinfo.h</p></li> |
|
25 <li><p>sensrvtypes.h</p></li> |
|
26 <li><p>sensrvchannelfinder.h</p></li> |
|
27 <li><p>sensrvdatalistener.h</p></li> |
|
28 </ul><p>In addition to these, include the |
|
29 necessary header files based on the type of channel to be used. For information |
|
30 about channel-specific header files, see <xref href="GUID-F1935106-C730-4C64-A19A-0FC04F0E7121.dita">Types |
|
31 of Sensor Channels</xref>.</p></info> |
|
32 </step> |
|
33 <step id="GUID-F5BC52B6-67DD-4F59-889B-C5DE4C69029B"><cmd>Retrieve details |
|
34 about the required sensor channel. For details. see <xref href="GUID-44FDDA27-1A5D-42B5-8DE0-D9E88EB75C93.dita">Querying |
|
35 for Sensor Channels</xref>.</cmd> |
|
36 </step> |
|
37 <step id="GUID-FBBD3A8B-F240-4DC0-B516-3A51FDD86A88"><cmd>Connect to the sensor |
|
38 by opening a connection with the sensor channel.</cmd> |
|
39 <substeps id="GUID-C9E5B9FC-C637-4DEB-AAAF-E38C6CD9A18A"> |
|
40 <substep id="GUID-CA2CFF9C-3168-4060-AC39-8CB6FBA4BCA2"><cmd>Create an instance |
|
41 of <codeph>CSensrvChannel</codeph> and specify the instance of <codeph>TSensrvChannelInfo</codeph> returned |
|
42 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 |
|
43 in the <codeph>NewL()</codeph> constructor.</cmd> |
|
44 <stepxmp><codeblock xml:space="preserve"> CSensrvChannel* sensorChannel; |
|
45 sensorChannel = CSensrvChannel::NewL(channelInfoList[0]);// channelInfoList is |
|
46 // returned by the CSensrvChannelFinder::FindChannelsL()funtion</codeblock></stepxmp> |
|
47 </substep> |
|
48 <substep id="GUID-30E6033F-E316-4BDB-AF22-2369463DF709"><cmd>Open the sensor |
|
49 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> |
|
50 <stepxmp><codeblock xml:space="preserve">channel->OpenChannelL();</codeblock></stepxmp> |
|
51 </substep> |
|
52 </substeps> |
|
53 </step> |
|
54 <step id="GUID-7A414271-040C-4107-B047-9416747C66A6"><cmd>Perform any of the |
|
55 following operations:</cmd> |
|
56 <info><ul> |
|
57 <li><xref href="GUID-BA0D9DA9-3B54-4964-A4D6-9ADA4DEB7231.dita">Receive data from |
|
58 sensors</xref></li> |
|
59 <li><xref href="GUID-09E44FE5-6BEE-49FF-8BBF-CBB3C066EE10.dita">Listen for channel |
|
60 changes</xref></li> |
|
61 <li><xref href="GUID-83630B57-D842-4B60-8AF0-D2965251DE29.dita">Retrieve channel |
|
62 properties</xref></li> |
|
63 <li><xref href="GUID-0CA7F22E-59D7-4D65-9D6C-735E4E0F0454.dita">Set channel properties</xref></li> |
|
64 <li><xref href="GUID-E93EE459-8CF4-42A1-B06C-E78E56FD25A0.dita">Listen for channel |
|
65 property changes</xref></li> |
|
66 <li><xref href="GUID-60EE22AA-402D-4FC2-9AD1-B3AEF822E8DC.dita">Receive channel |
|
67 data based on conditions</xref></li> |
|
68 </ul></info> |
|
69 </step> |
|
70 <step id="GUID-61840C55-476C-4DC3-A946-A440330B9DE5"><cmd>Close the channel.</cmd> |
|
71 <info><codeblock xml:space="preserve">channel->CloseChannel();</codeblock><note type="important"> A |
|
72 channel must be closed when not required, as it reduces power consumption |
|
73 of the Symbian device. An open sensor channel keeps the device processor active |
|
74 each time data arrives. Therefore, the processor does not change to idle state |
|
75 even when the device user is not performing any operations on the device.</note></info> |
|
76 </step> |
|
77 </steps> |
|
78 </taskbody></task> |