Reading Remote SDP Service Attributes

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.

How to read service attributes

As with a service search, service attribute search results are returned through asynchronous callbacks to an MSdpAgentNotifier interface, which the querier must implement.

Basic Procedure

The steps to read attributes are as follows:

  1. Create a CSdpAttrIdMatchList object in which to specify the attributes to be retrieved (called the match list).

  2. 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.

  3. Start the query by calling CSdpAgent::AttributeRequestL() . As well as the match list, specify the record handle of interest.

Reading Remote Attributes

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:

  1. 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);
            
  2. Add an attribute ID to match list.

             
              
             
             matchList->AddL(TAttrRange(0x1000));
            
  3. Set the match list on the agent.

             
              
             
             agent->AttributeRequestL(serviceHandle, *matchList);
    
    CleanupStack::PopAndDestroy(); //matchList
            

Note

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.

Where next?

The complete set of Service Discovery Agent tutorials are shown below:

Also refer to the Bluetooth Service Discovery Agent Overview and the Bluetooth SDP Overview for additional background information.