Handling SDP Attributes

SDP Database service records are made up of a number of attributes. The attributes identify information about the service such as the class of service, that is the general category to which the service belongs, the date on which the service record was first created, the service's UUID and more. See the SDP specification, link provided elsewhere, for more information. The only required attribute is the UUID for the service.

How to create and manipulate attributes

Symbian have identified a special pattern for creating and manipulating SDP attributes.

Attribute types

Attributes in service records can be one of fixed number of types. The API encapsulates each attribute type in a class, each of which is derived from CSdpAttrValue. The type is easily deducible from the name: e.g. CSdpAttrValueUint encapsulates an unsigned integer type attribute.

Complex Attributes

Complex attribute values are stored as lists of other elements; nested lists are allowed.

The list classes are:

  • CSdpAttrValueDEA: a Data element alternative, a data element whose data field is a sequence of data elements from which one data element is to be selected.

  • CSdpAttrValueDES: a Data element sequence, a data element whose data field is a sequence of data elements.

Both of these implement the MSdpElementBuilder interface, which supplies functions of the form Build type L() to add elements of the specified type to the list.

Creating a Protocol List Attribute

The following example builds a ProtocolDescriptorList attribute (attribute ID 0x0004), which is a list containing two nested lists.

  1. Create the list. (NULL indicates that the list is not itself in another list)

    CSdpAttrValueDES* attrValProt = CSdpAttrValueDES::NewDESL(NULL);
    CleanupStack::PushL(attrValProt);
  2. Build the first nested list. Notice the pattern used to push the new attribute value onto the service record.

    attrValProt
        ->StartListL()
            ->BuildDESL()
            ->StartListL()
                ->BuildUUIDL(TUUID(TUint16(0x0100))) // L2CAP
            ->EndListL()
  3. Build the second nested list.

      ->BuildDESL()
            ->StartListL()
                ->BuildUUIDL(TUUID(TUint16(0x0003))) // RFCOMM
                ->BuildUintL(TServAttrInt<TUint8>>(1)) // DLCI = 1
            ->EndListL()
        ->EndListL();

    Notice that all the code from the start of 2 above to the end of 3 is essentially a single long line of code. This is an example of the SDP pattern discussed earlier.

Note:

Where next?

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

  1. Connecting to the service discovery database

  2. Handling SDP attributes - This document

  3. Registering Services

  4. Setting service record attributes

  5. SDP Service records and attributes

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