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-1EA7B3A5-7A94-5E8F-A0A8-9CA417E14032"><title>Reading Remote SDP Service Attributes</title><prolog><metadata><keywords/></metadata></prolog><conbody><p>The data for a service record is contained in attributes. Each attribute has a well-known ID, a type, and a value. </p> <p>Attribute requests take service record handles found as a result of service searches and return attributes. You can limit the attributes returned to a specific attribute, or to a range of IDs. </p> <section><title>How to read service attributes</title> <p>As with a service search, service attribute search results are returned through asynchronous callbacks to an <xref href="GUID-AD76DB7F-CD45-3903-A07A-E94BE583CDB0.dita"><apiname>MSdpAgentNotifier</apiname></xref> interface, which the querier must implement. </p> <p><b>Basic Procedure</b> </p> <p>The steps to read attributes are as follows: </p> <ol id="GUID-57B7E72F-16E6-5304-B860-900325A5F403"><li id="GUID-46729165-B8B4-58E6-AD3F-59A33C2083F9"><p>Create a <xref href="GUID-7DA0506B-F2C1-374B-847F-8DF070BD2FE9.dita"><apiname>CSdpAttrIdMatchList</apiname></xref> object in which to specify the attributes to be retrieved (called the match list). </p> </li> <li id="GUID-AEFC4866-2957-573D-A65A-F705FD5F6EB8"><p>Add the attribute IDs to the match list using <xref href="GUID-7DA0506B-F2C1-374B-847F-8DF070BD2FE9.dita#GUID-7DA0506B-F2C1-374B-847F-8DF070BD2FE9/GUID-69FF9400-A3F9-3DCA-8231-8EAF019014F2"><apiname>CSdpAttrIdMatchList::AddL()</apiname></xref>. IDs are wrapped in a <xref href="GUID-E2E5E504-FB8E-38B3-80C8-C6C4946AD8C5.dita"><apiname>TAttrRange</apiname></xref> type, which can specify a single attribute or a range of IDs. </p> </li> <li id="GUID-81920A53-C0D4-57DF-BBDA-77FC6CDFA77B"><p>Start the query by calling <xref href="GUID-6A33D6A1-63C8-3A15-A2BC-5D08F07C5AB6.dita#GUID-6A33D6A1-63C8-3A15-A2BC-5D08F07C5AB6/GUID-5D0C3302-1D4B-3B55-94F8-29F97D74643A"><apiname>CSdpAgent::AttributeRequestL()</apiname></xref>. As well as the match list, specify the record handle of interest. </p> </li> </ol> <p><b>Reading Remote Attributes</b> </p> <p>The following code fragements may be used, in an appropriate context, to query a remote device's SDP database for the attribute indicated by the attribute UUID. The steps are given here: </p> <ol id="GUID-E445C4DC-DA70-5F68-A726-954D5B46C31B"><li id="GUID-2E12E6AA-E32B-55B4-98CA-2B8DBE654461"><p>Create a match list. </p> <p>The following code fragements assume <codeph>agent</codeph> is a <xref href="GUID-6A33D6A1-63C8-3A15-A2BC-5D08F07C5AB6.dita"><apiname>CSdpAgent</apiname></xref>, and <codeph>serviceHandle</codeph> a service record handle </p> <codeblock id="GUID-8BAF374C-EE7C-5255-A247-3087F041C584" xml:space="preserve">CSdpAttrIdMatchList* matchList = CSdpAttrIdMatchList::NewL();
CleanupStack::PushL(matchList);</codeblock> </li> <li id="GUID-9A72886D-4E70-53FE-B806-6B8F4338979A"><p>Add an attribute ID to match list. </p> <codeblock id="GUID-E2842F48-2567-582A-A3EB-ED431C965E12" xml:space="preserve">matchList->AddL(TAttrRange(0x1000));</codeblock> </li> <li id="GUID-11A32341-09A3-5A25-9CAC-2F1A682772D3"><p>Set the match list on the agent. </p> <codeblock id="GUID-90E25C49-23B6-542A-B590-65DFCD3F30CA" xml:space="preserve">agent->AttributeRequestL(serviceHandle, *matchList);
CleanupStack::PopAndDestroy(); //matchList</codeblock> </li> </ol> <p><b>Note </b> </p> <p> <codeph>CSdpAgent::AttributeRequestL()</codeph> is an overloaded function. Some of the overloads allow you to supply an <xref href="GUID-3DC9CB25-E55D-38E6-8940-B3320EF7E9DD.dita"><apiname>MSdpElementBuilder</apiname></xref> object: if it is supplied, then the object will be called with each type found in the response. </p> </section> <section><title>Where next?</title> <p>The complete set of Service Discovery Agent tutorials are shown below: </p> <ul><li id="GUID-96E64157-9833-538C-AA29-AE0AA0A2CD7F"><p> <xref href="GUID-275D7892-EEBD-5DBD-A9D7-F6A715B79659.dita">Querying the SDP database</xref> </p> </li> <li id="GUID-0FAD2FB2-A6BF-571B-9D4C-0AB05B4C8574"><p> <b>Reading remote SDP service attributes</b> - This document </p> </li> <li id="GUID-DE096F8B-F1F8-5AD5-BC9F-A698129CC59F"><p> <xref href="GUID-65F8675F-FF08-5707-BA5B-BF3B4B779393.dita">Handling SDP query results</xref> </p> </li> </ul> <p>Also refer to the <xref href="GUID-2F1C6B4C-2C23-5A35-A0D2-223EC6238F7D.dita">Bluetooth Service Discovery Agent 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>