SDP Search Sample

The sdpsearch sample demonstrates using the COM routines from Btdrt.dll to parse an SDP response.

BthNsLookupServiceNext fills in the passed-in buffer with the record. This record is inserted exactly as the server sent it, in raw binary form, determined by the SDP Specification. This format is difficult to work with directly, so Microsoft provides COM objects that automatically parse the SDP raw format into a tree that can be easily traversed and manipulated.

In this sample, the data buffer is the result of a BthNsLookupServiceNext call after querying a server using a ServiceAttribute request. This buffer contains information about the service's RFCOMM channel identifier. The code walks through the tree until it finds the values it is looking for.

Implementation

ServiceAndAttributeSearchParse is called to convert the raw SDP ServiceAttribute response (hard coded to be an FTP service running on RFCOMM channel ID 10, in this example) into an array of ISdpRecord elements.

Each ISdpRecord represents a different record. ServiceAndAttributeSearchParse relies on the COM API to check the validity of the response and to convert the response with the ISdpStream->Validate and ISdpStream->VerifySequenceOf methods. It retrieves the records from the stream using the RetrieveRecords method.

Note   BthNsLookupServiceNext does NOT check for valid SDP responses before returning the buffer to the user application. The application must verify that the data the server has returned to it is valid using the Validate and VerifySequenceOf methods or a similar check.

Each record is searched for the service's RFCOMM channel. The SDP Specification describes the format of SDP_ATTRIB_PROTOCOL_DESCRIPTOR_LIST (0x4) attribute. This information is used to walk through various subdata element sequences in the protocol list.

Sample Location

%_WINCEROOT%\Public\Common\Oak\Drivers\Bluetooth\Sample\Sdpsearch

**Note   **This sample application has not been thoroughly tested and is not intended for production use.

See Also

Bluetooth | Bluetooth Samples | BthNsLookupServiceNext

 Last updated on Thursday, April 08, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.