Symbian3/SDK/Source/GUID-E25A5C1E-83D7-51D5-8F11-9C44C6CEEDCE.dita
changeset 0 89d6a7a84779
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Symbian3/SDK/Source/GUID-E25A5C1E-83D7-51D5-8F11-9C44C6CEEDCE.dita	Thu Jan 21 18:18:20 2010 +0000
@@ -0,0 +1,100 @@
+<?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 concept
+  PUBLIC "-//OASIS//DTD DITA Concept//EN" "concept.dtd">
+<concept id="GUID-E25A5C1E-83D7-51D5-8F11-9C44C6CEEDCE" xml:lang="en"><title>Starting
+as Controller</title><prolog><metadata><keywords/></metadata></prolog><conbody>
+<p>The controller is the device that sends commands to a target device. </p>
+<p><b>Intended Audience: </b> </p>
+<p>This tutorial is designed for Symbian licensees and 3rd party application
+developers. </p>
+<section><title>Using the Controller</title> <p>The following tasks will be
+covered in this tutorial: </p> <ul>
+<li id="GUID-E2D1E9EE-E004-5401-B714-F98544853EE6"><p>Starting a Connectionless
+controller </p> </li>
+<li id="GUID-869B57EB-77FE-52C3-A211-7DAEEA7E8EF5"><p>Starting a Connection-Oriented
+controller </p> </li>
+<li id="GUID-11CC8516-F861-505B-9AC3-9F851FDE0DFC"><p>Stopping a controller </p> </li>
+</ul> <p><b> Basic procedure</b> </p> <p>The high level steps to start a controller
+are: </p> <ul>
+<li id="GUID-BF89D59C-7A44-5AF1-B9CD-18E5F5182716"><p>Create the Controller
+interface </p> </li>
+<li id="GUID-E25EFF1D-4176-55D9-B180-610694CDD497"><p>Open a controller session
+on the server. This will either be: </p> <ul>
+<li id="GUID-3DCE1277-80CF-50E7-8039-1C2BCA5D264D"><p>Connectionless </p> <p>This
+would be enough to create a connectionless controller. </p> </li>
+<li id="GUID-D60CE56B-AEB3-5775-B6E7-DBE16FF0304F"><p>Connection-oriented </p> <p>If
+you are starting a connection-oriented controller you will need to know the
+following: </p> <ul>
+<li id="GUID-641DAE94-036F-5168-B6AE-91205E22D234"><p>Device address </p> </li>
+<li id="GUID-A37F327B-95D7-5A36-AAEF-E3BCCCC56DF6"><p>Bearer </p> </li>
+</ul> </li>
+</ul> </li>
+</ul> <note> Starting the Bluetooth stack and setting up the
+sockets, housekeeping tasks usually associated with Bluetooth components,
+are wrapped up and taken care of in the background by the Remote Control Framework.</note></section>
+<section><title>Starting a connectionless controller</title> <p>Create a controller
+interface by instantiating an interface selector using <xref href="GUID-81EE9382-D501-3FCE-ACD9-7BC5236FC462.dita#GUID-81EE9382-D501-3FCE-ACD9-7BC5236FC462/GUID-17C0EFFE-AEE4-31E6-97D6-701CFD3E761C"><apiname>CRemConInterfaceSelector::NewL()</apiname></xref>,
+as shown here: </p> <codeblock id="GUID-F7645600-01B3-5DFA-97AD-439CB492E132" xml:space="preserve">CRemConInterfaceSelector* iInterfaceSelector;
+iInterfaceSelector = CRemConInterfaceSelector::NewL();</codeblock> <p>Create
+a core remote control API controller and add the interface selector created
+above as shown here: </p> <codeblock id="GUID-7109464B-CFC1-52B8-8B8F-A0A4831B33DA" xml:space="preserve">CRemConCoreApiController* iCoreController;
+iCoreController = CRemConCoreApiController::NewL(*iInterfaceSelector, *this);</codeblock> <p>Open
+the interface created above using <xref href="GUID-81EE9382-D501-3FCE-ACD9-7BC5236FC462.dita#GUID-81EE9382-D501-3FCE-ACD9-7BC5236FC462/GUID-99C2BB74-BD7C-351E-91BD-CCC1D78C7A3C"><apiname>CRemConInterfaceSelector::OpenControllerL()</apiname></xref>. </p> <codeblock id="GUID-D054087B-AF55-5109-8EF0-804C96C1D979" xml:space="preserve">iInterfaceSelector-&gt;OpenControllerL();</codeblock> <p>The
+Target Selector Plugin (TSP) discovers the bearer and device address of target
+devices as required. </p> </section>
+<section><title>Starting a Connection-Oriented controller</title> <p>The first
+part of starting your Connection-Oriented controller is the same as that described
+above for starting a connectionless controller, but to go Connection-Oriented
+you will need to provide two additional pieces of information, the device
+address and the bearer. </p> <p>The following code, which constructs a <codeph>TUid</codeph>,
+shows how to set information about the AVRCP bearer (it may be different for
+other bearers): </p> <codeblock id="GUID-4F943A05-C97D-575D-B5A7-31B952A35ED8" xml:space="preserve">...
+ TUid iBearerUid;
+ RBuf8 iBearerData;
+ iBearerUid = TUid::Uid(KAvrcpBearerUid);</codeblock> <p>To get the device
+address you can either use the SDP, a notifier, or the following: </p> <codeblock id="GUID-6F1643E9-A37D-5BA6-B21B-E7553B894023" xml:space="preserve">GetDeviceAddressL()
+    {
+    // MTestManager iManager;
+    iManager.MtmWrite(
+    _L8( "Type device address and press enter\n0x" ) );
+    // Read address in unicode as human readable
+    TBuf&lt;12&gt; buf;
+    iManager.MtmRead( buf );
+    // Translate to machine readable
+    TBTDevAddr btAddr;
+    LEAVEIFERRORL( btAddr.SetReadable( buf ) );
+    // Store as 8 bit machine readable
+    iBearerData.Close();
+    iBearerData.CreateL( btAddr.Des() );
+    }</codeblock> <p> <note> The above uses test code. In a real application,
+you would need a UI instead of the console. </note></p> <p>Now that you have
+the device address and bearer information you can start the Connection-Oriented
+controller by adding the bearer and Bluetooth device address information to
+the <codeph>addr</codeph> using the <xref href="GUID-3A185192-2A36-33C6-9E09-A04B7BB2D896.dita#GUID-3A185192-2A36-33C6-9E09-A04B7BB2D896/GUID-5C3066AE-CDD1-35C0-89FE-23BCC8F8A44E"><apiname>TRemConAddress::BearerUid()</apiname></xref> and <xref href="GUID-3A185192-2A36-33C6-9E09-A04B7BB2D896.dita#GUID-3A185192-2A36-33C6-9E09-A04B7BB2D896/GUID-AE43EDDD-511F-332C-962A-365AB027D42C"><apiname>TRemConAddress::Addr()</apiname></xref> functions
+as follows: </p> <codeblock id="GUID-7D3E3A30-CDB2-5C14-8811-46F305278A44" xml:space="preserve">TRemConAddress addr;
+addr.BearerUid() = iBearerUid;
+addr.Addr() = iBearerData;
+iInterfaceSelector-&gt;GoConnectionOrientedL( addr );</codeblock> <p>The <xref href="GUID-81EE9382-D501-3FCE-ACD9-7BC5236FC462.dita#GUID-81EE9382-D501-3FCE-ACD9-7BC5236FC462/GUID-88822BD1-4274-3A3D-994D-494081653B19"><apiname>CRemConInterfaceSelector::GoConnectionOrientedL()</apiname></xref> function
+makes the controller Connection-Oriented. </p> <p><b>Switching to Connectionless </b> </p> <p>It
+is possible to switch a Connection-Oriented controller to connectionless if
+necessary. The <xref href="GUID-81EE9382-D501-3FCE-ACD9-7BC5236FC462.dita#GUID-81EE9382-D501-3FCE-ACD9-7BC5236FC462/GUID-ACCD72A4-4273-3CAD-9032-D8460748E15C"><apiname>CRemConInterfaceSelector::GoConnectionlessL()</apiname></xref> is
+used as shown here: </p> <codeblock id="GUID-0F07E60F-77F5-5291-BAF4-19E85689EDDA" xml:space="preserve">iInterfaceSelector-&gt;GoConnectionlessL();</codeblock> <p>Of
+course you can also switch back to a Connection-Oriented controller as needed. </p> </section>
+<section><title>Stopping a controller</title> <p>To stop your controller use: </p> <codeblock id="GUID-9C8B2A81-0F45-5C17-94AB-AE235C596A58" xml:space="preserve">delete iInterfaceSelector;</codeblock> </section>
+<section><title>What's next?</title> <ul>
+<li id="GUID-8E3BD584-32D3-595B-ABBC-8BE2209C5E7F"><p><xref href="GUID-C4A072E1-4385-5C98-98C1-56F297132F11.dita">Remote
+Control Basics</xref>  </p> </li>
+<li id="GUID-F460D9E7-AAC2-59E6-887D-D000A3A9771D"><p><xref href="GUID-8E25E84C-E8F3-50B2-82E5-0611A341ED27.dita">Starting
+as Target</xref>  </p> </li>
+<li id="GUID-516B6F7D-FC2A-58DA-BECA-279CBB4C5F10"><p><xref href="GUID-7DDF477A-1744-589A-82CB-3CB32D56D7CE.dita">Commands
+and Responses</xref>  </p> </li>
+</ul> </section>
+</conbody></concept>
\ No newline at end of file