Compartilhar via


SDP Search Sample (Compact 2013)

3/26/2014

The Sdpsearch sample demonstrates using the COM routines from Btdrt.dll to parse a Service Discovery Protocol (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. 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. For a detailed description of the SDP format, see "Service Discovery Protocol (SDP)" in the Core Specification v2.1 + EDR, Bluetooth web site.

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 Bluetooth Core 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.

The compiled sample generates an executable, Btagconfig.exe.

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

Tasks

Samples for Implementing Bluetooth in an OS

Reference

BthNsLookupServiceNext