Handling SDP results

Clients that make service and attribute queries through [[[ERROR: [NOKX000E] Unable to find definition for key reference 'MSdpAgentNotifier']]]CSdpAgent must implement the [[[ERROR: [NOKX000E] Unable to find definition for key reference 'MSdpAgentNotifier']]]MSdpAgentNotifier interface to handle the responses.

How to create an object to handle inquiry results

There are two kinds of results that require handling, they are:

  • Service Search Results, and

  • Attribute Read Results

We will examine a simple handling example for both kinds below.

Note: Queries are asynchronous.

Handling service search results

When a service search request completes, it calls the [[[ERROR: [NOKX000E] Unable to find definition for key reference 'MSdpAgentNotifier']]]NextRecordRequestComplete():

virtual void NextRecordRequestComplete(TInt aError, TSdpServRecordHandle aHandle, TInt aTotalRecordsCount)

aHandle gives the service record handle of the matching service, and can be used in a subsequent attribute query. aTotalRecordsCount gives the total number of matching records.

Handling attribute read results

When an attribute request completes, each single attribute is returned with its attribute ID using [[[ERROR: [NOKX000E] Unable to find definition for key reference 'MSdpAgentNotifier']]]AttributeRequestResult().

virtual void AttributeRequestResult(TSdpServRecordHandle aHandle, TSdpAttributeID aAttrID, CSdpAttrValue* aAttrValue)

The ID of the attribute is given in aAttrID, and the attribute value itself in aAttrValue. You can find the type of the attribute through aAttrValue->Type(), cast aAttrValue on this base to the correct subclass of [[[ERROR: [NOKX000E] Unable to find definition for key reference 'MSdpAgentNotifier']]]CSdpAttrValue: for example, if the type is [[[ERROR: [NOKX000E] Unable to find definition for key reference 'MSdpAgentNotifier']]]ETypeBoolean, you can cast aAttrValue to a [[[ERROR: [NOKX000E] Unable to find definition for key reference 'MSdpAgentNotifier']]]CSdpAttrValueBoolean.

When there are no more attributes to be returned, [[[ERROR: [NOKX000E] Unable to find definition for key reference 'MSdpAgentNotifier']]]AttributeRequestComplete() is called.

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.