|
||
The data for a service record is contained in attributes. Each attribute has a well-known ID, a type, and a value.
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.
As with a service search, service attribute search results are returned
through asynchronous callbacks to an MSdpAgentNotifier
interface, which the querier must implement.
The steps to read attributes are as follows:
Create a CSdpAttrIdMatchList
object in which
to specify the attributes to be retrieved (called the match list).
Add the attribute IDs to the match list using
CSdpAttrIdMatchList::AddL()
. IDs are wrapped in a
TAttrRange
type, which can specify a single attribute or a
range of IDs.
Start the query by calling
CSdpAgent::AttributeRequestL()
. As well as the match list,
specify the record handle of interest.
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:
Create a match list.
The following code fragements assume agent
is a
CSdpAgent
, and serviceHandle
a service record
handle
CSdpAttrIdMatchList* matchList = CSdpAttrIdMatchList::NewL();
CleanupStack::PushL(matchList);
Add an attribute ID to match list.
matchList->AddL(TAttrRange(0x1000));
Set the match list on the agent.
agent->AttributeRequestL(serviceHandle, *matchList);
CleanupStack::PopAndDestroy(); //matchList
CSdpAgent::AttributeRequestL()
is an overloaded
function. Some of the overloads allow you to supply an
MSdpElementBuilder
object: if it is supplied, then the
object will be called with each type found in the response.
The complete set of Service Discovery Agent tutorials are shown below:
Reading remote SDP service attributes - This document
Also refer to the Bluetooth Service Discovery Agent Overview and the Bluetooth SDP Overview for additional background information.