Symbian3/SDK/Source/GUID-2373A158-C18A-51B5-BE9A-6B8F7FC63A35.dita
author Dominic Pinkman <dominic.pinkman@nokia.com>
Fri, 13 Aug 2010 16:47:46 +0100
changeset 14 578be2adaf3e
parent 0 89d6a7a84779
permissions -rw-r--r--
Week 32 contribution of PDK documentation content. See release notes for details. Fixes bug Bug 3582

<?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 xml:lang="en" id="GUID-2373A158-C18A-51B5-BE9A-6B8F7FC63A35"><title>Registering Services</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>Services must be registered in the SDP database before they can be found by an SDP Agent query. </p> <section><title>How to register a service in the database</title> <p>After <xref href="GUID-B75BD3DE-9C2E-5429-B55B-891462B92795.dita">connecting to the SDP database</xref>, a service record can be created. You do this by supplying the UUID for the service class of the record. As the service class may be a single UUID or a list of UUIDs in the form of a DES, there are two overloaded functions. </p> <p>The steps to register a service are as follows: </p> <ol id="GUID-AFA9213B-869F-5DDB-9572-181F4B058626"><li id="GUID-CD2C1B73-F3C0-5A9E-AA50-7E29B7D9C84E"><p>Create a blank service record object, <xref href="GUID-9DDF886B-1556-30A2-A417-1919BA6D255A.dita"><apiname>TSdpServRecordHandle</apiname></xref>. </p> </li> <li id="GUID-60B2CB64-CAC7-5FF6-88B3-84D32A9C05F5"><p>If the service class attribute should be a single UUID, create and set a <xref href="GUID-FAD6BB78-84B7-335A-9D9C-3ADE7CF0958F.dita"><apiname>TUUID</apiname></xref> object. If the attribute should be a list of UUIDs, create a attribute list object, <xref href="GUID-7AF08589-F6E5-36A1-AD2C-84D3CB877451.dita"><apiname>CSdpAttrValueDES</apiname></xref> or <xref href="GUID-74C4154F-9C20-3C23-86EB-D4B602E79DC1.dita"><apiname>CSdpAttrValueDEA</apiname></xref>, and call <xref href="GUID-3DC9CB25-E55D-38E6-8940-B3320EF7E9DD.dita#GUID-3DC9CB25-E55D-38E6-8940-B3320EF7E9DD/GUID-F073DB29-EF75-3D5D-A6D9-D7BC9ABFB4C3"><apiname>MSdpElementBuilder::BuildUUIDL()</apiname></xref> repeatedly to add UUIDs to the list. </p> </li> <li id="GUID-BD149ABF-42AD-5B2F-AF55-4FDF317B0D5A"><p>Call <xref href="GUID-FC133F0F-C9E8-30CB-B2FE-8AC9F7F802AC.dita#GUID-FC133F0F-C9E8-30CB-B2FE-8AC9F7F802AC/GUID-1B940D59-432C-3460-80E4-09A5CBE0FD49"><apiname>RSdpDatabase::CreateServiceRecordL()</apiname></xref> on an open subsession. On return, the record handle object holds a handle to the service record. </p> </li> </ol> </section> <section><title>Registering a single service class</title> <p>The following example creates a service record with a single service class. </p> <ol id="GUID-41928671-1E4F-56FD-99E1-3F8FCF2343AA"><li id="GUID-B6A06A7A-D068-5929-8E5C-315656738811"><p>Create blank record handle </p> <codeblock id="GUID-B51ED203-67B5-57AB-A29A-E757DF1364AF" xml:space="preserve">// Assumes sdpSession is an open session to the database
TSdpServRecordHandle recordHandle = 0;</codeblock> </li> <li id="GUID-E1AB9D3B-DDEB-50A0-A92A-B541FD6341C1"><p>Create the service class UUIDs </p> <codeblock id="GUID-298CDC04-2834-5865-81BD-B794CEDE7DCF" xml:space="preserve">TUUID uuid(0x20000);</codeblock> </li> <li id="GUID-1E51A67C-5E03-5CE9-B7C0-F17C1C74CC50"><p>Enter record into the database </p> <codeblock id="GUID-8BB40857-9D30-5197-9C8A-9D65D2785244" xml:space="preserve">sdpSubSession.CreateServiceRecordL(uuid, recordHandle);</codeblock> </li> </ol> </section> <section><title>Registering a service class list</title> <p>The following example creates a service record with a list of service classes. </p> <ol id="GUID-C8474C59-C646-521E-AE94-DF156211002A"><li id="GUID-B435DA33-BC38-5659-9F18-05EE93E6B2C5"><p>Create a blank record handle </p> <codeblock id="GUID-97417E17-47DA-53B8-899A-556B79F7A2A9" xml:space="preserve">TSdpServRecordHandle recordHandle = 0;</codeblock> </li> <li id="GUID-50FA6B1F-101C-523A-966B-FD818EB34BE4"><p>Create a list of service class UUIDs </p> <codeblock id="GUID-EA278AE6-7486-556D-BDBE-DEC42C4C0E23" xml:space="preserve">CSdpAttrValueDES* UUIDlist = CSdpAttrValueDES::NewDESL(NULL);
CleanupStack::PushL(UUIDlist);
UUIDlist
    -&gt;StartListL()
        -&gt;BuildUUIDL(TUUID(TUint32(0x20002000)))
        -&gt;BuildUUIDL(TUUID(TUint32(0x11112222), TUint32(0x33334444), 
                              TUint32(0x55556666), TUint32(0x77778888)))
        -&gt;BuildUUIDL(TUUID(TUint32(0x40000)))
    -&gt;EndListL();
</codeblock> </li> <li id="GUID-3204B6B6-46AD-5C3E-A586-A1494B7C6D0B"><p>Enter record into the database </p> <codeblock id="GUID-558C43FB-FBDE-58BA-87CD-E0900A4EBFB9" xml:space="preserve">sdpSubSession.CreateServiceRecordL(*UUIDlist, recordHandle);
CleanupStack::PopL(); // UUIDlist</codeblock> </li> </ol> <p><b>Note </b> </p> <p>The examples shows UUIDs of varying length. Both 16- and 32-bit integers may be used, which are assumed to be offsets from the Bluetooth base UUID. </p> </section> <section><title>Where next?</title> <p>The complete set of Service Discovery Database tutorials are shown below: </p> <ol id="GUID-1ADEBB09-347F-53DD-8CD0-355BA707D7BA"><li id="GUID-9B76001A-F7EE-5FC7-8F87-A9B5143AE36A"><p> <xref href="GUID-B75BD3DE-9C2E-5429-B55B-891462B92795.dita">Connecting to the service discovery database</xref>  </p> </li> <li id="GUID-E5587A96-B45F-590F-BCA0-4AD46B293C5B"><p> <xref href="GUID-E2A2FA2A-5D9A-56FE-B7E5-69CCBC656BB9.dita">Handling SDP attributes</xref>  </p> </li> <li id="GUID-82C85B76-5E78-507A-A61A-44B228528063"><p> <b>Registering Services</b> - This document </p> </li> <li id="GUID-DA18FDFD-CDAD-559C-8B7C-F075F9178F03"><p> <xref href="GUID-33210C48-3198-51BC-9970-8B29F711A8E2.dita">Setting service record attributes</xref>  </p> </li> <li id="GUID-196905A6-7D11-535D-87C0-F75C5F686F0A"><p> <xref href="GUID-ED342E6B-A4A3-576B-8934-7E7C049837F0.dita">SDP Service records and attributes</xref>  </p> </li> </ol> <p>Also refer to the <xref href="GUID-E5893C4A-024A-53A7-805F-68989382DC3F.dita">Bluetooth Service Discovery Database overview</xref> and the <xref href="GUID-8451102A-8E68-5C86-9E40-D53183E32261.dita">Bluetooth SDP Overview</xref> for additional background information. </p> </section> </conbody></concept>