Symbian3/SDK/Source/GUID-834BD3BB-B39C-5EE9-8A62-9DC435930F95.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Tue, 20 Jul 2010 12:00:49 +0100
changeset 13 48780e181b38
parent 7 51a74ef9ed63
permissions -rw-r--r--
Week 28 contribution of SDK documentation content. See release notes for details. Fixes bugs Bug 1897 and Bug 1522.

<?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-834BD3BB-B39C-5EE9-8A62-9DC435930F95" xml:lang="en"><title>Handling
the Local Device Name</title><prolog><metadata><keywords/></metadata></prolog><conbody>
<p>Each Bluetooth device has a name for identifying the device to users or
applications. This document shows you how to get or set device names. </p>
<section id="GUID-62D2F4F0-C69E-4D51-904F-CEC8E7827740"><title>How to get
and set the local device name</title> <p>The local device name is read and
set through the <xref href="GUID-B16CAD6D-85B1-3482-AAC0-9BADEDB6ABDD.dita"><apiname>RHostResolver</apiname></xref> functions <xref href="GUID-B16CAD6D-85B1-3482-AAC0-9BADEDB6ABDD.dita"><apiname>GetHostName()</apiname></xref> and <xref href="GUID-B16CAD6D-85B1-3482-AAC0-9BADEDB6ABDD.dita"><apiname>SetHostName()</apiname></xref> respectively. </p> <p><b>Getting the Local Device Name</b> </p> <p>The following code shows how
to get the local name: </p> <ol id="GUID-B9D75B4C-8184-5E04-A805-422D1D86D1E1">
<li id="GUID-FBB8E853-7E12-40F7-9776-1DA124B79B27"><p>Link against the following
libraries:</p><codeblock xml:space="preserve">esock.lib
bluetooth.lib
sdpdatabase.lib
</codeblock></li>
<li id="GUID-34A055C7-6A4C-531B-8625-75539FBD6E3B"><p>Connect to the socket
server </p> <codeblock id="GUID-B398F8BC-F409-5A71-9051-8010FFF543D7" xml:space="preserve">RSocketServ socketServ;
User::LeaveIfError(socketServ.Connect());
TProtocolDesc pInfo;
_LIT(KL2Cap, "L2CAP");
User::LeaveIfError(socketServ.FindProtocol(KL2Cap,pInfo));</codeblock> </li>
<li id="GUID-52E77D28-A2BE-5FB7-A880-E71307832013"><p>Create and initialise
an <xref href="GUID-B16CAD6D-85B1-3482-AAC0-9BADEDB6ABDD.dita"><apiname>RHostResolver</apiname></xref> </p> <codeblock id="GUID-F53163E6-49F8-529A-9A9F-7BC76E0BD9F7" xml:space="preserve">RHostResolver hr;
User::LeaveIfError(hr.Open(socketServ,pInfo.iAddrFamily,pInfo.iProtocol));</codeblock> </li>
<li id="GUID-499255A3-BC66-5BC5-A37A-B883A0E4EE6A"><p>Get the local device
name </p> <codeblock id="GUID-F880ACBE-5184-5A64-A287-1C7560233D70" xml:space="preserve">THostName name;
TInt ret=hr.GetHostName(name);</codeblock> </li>
</ol> <p><b>Setting
the Local Device Name</b> </p> <p>Setting the device name differs only in
the final step, where you will use the <xref href="GUID-B16CAD6D-85B1-3482-AAC0-9BADEDB6ABDD.dita"><apiname>RHostResolver::SetHostName()</apiname></xref> function. </p> <codeblock id="GUID-091A827B-197A-5672-AFA0-69E329058762" xml:space="preserve">_LIT(KDeviceName,"myDeviceName");
TInt ret=hr.SetHostName(KDeviceName);</codeblock><note>  <xref href="GUID-4CF02002-FB24-376F-A84E-B26296539386.dita"><apiname>THostName</apiname></xref> is
a descriptor buffer of a suitable  minimum size.</note> </section>
<section id="GUID-0761E1CF-F1C1-4DD7-B8C5-04A1B0A59778"><title>Where Next?</title> <p>This
tutorial set takes you through all the steps involved in setting up and communicating
over a Bluetooth connection. </p> <ul>
<li id="GUID-CAA9C24D-4A3C-5D03-B6C7-EE21686BF869"><p> <xref href="GUID-70339E6A-63CD-5A74-846C-50771FDAC763.dita">Listening
for Incoming Bluetooth Connections</xref> </p> </li>
<li id="GUID-674A5D9A-4685-50F2-9FAC-36FA2E02F577"><p> <b>Handling the Local
Device Name</b> - This document </p> </li>
<li id="GUID-F3A7D62A-9FC8-5C74-8EF2-3E149FD81345"><p> <xref href="GUID-FDA7B932-B9C6-502D-8699-C18C8D86BCC6.dita">Performing
Low-level Configuration</xref> </p> </li>
<li id="GUID-518978F0-6BBD-5A63-936B-8640BBBBFC9A"><p> <xref href="GUID-5C63EF5C-826D-5838-BB7E-12FF4EA1DFCE.dita">Debugging
the Host Controller</xref> </p> </li>
<li id="GUID-D839475B-9640-5FE6-BD70-94002A0B1D3E"><p> <xref href="GUID-01A0682A-50B1-57AB-9939-6CC8FCCD782D.dita">Disconnecting
ACL links</xref> </p> </li>
</ul> </section>
</conbody></concept>