SDP Search and Record Generator Sample (Windows CE 5.0)
The Bthnscreate sample utility (bthnscreate.exe) creates an SDP record or sets up an SDP Service, Attribute, or Service and Attribute search based on information stored in a human-readable file.
In verbose mode, C code that creates the record or performs the search is automatically generated. This can be useful if you know most of the parameters needed for a particular service beforehand, but must determine others at run time.
Note In files, all numeric values are represented in decimal format. 128-bit UUIDs are represented in hexadecimal format.
The following command is used to create a record.
bthnscreate [-verbose] -record fileName
If the -verbose flag is set, C code that creates the record is generated. This code creates the appropriate COM objects to parse a record, write the record into a binary stream, and then call WSASetService with the appropriate parameters.
Note WSASetService behaves identically to BthNsSetService.
The file name consists of SDP record elements. Each element has the following format.
[attribute id] [type] [value]
Attribute id is the attribute identifier for the SDP record, value is the data itself, and type is the representation of this value. Data sequences and alternatives are represented as a series of [type] [value] pairs terminated by the "END" string.
Example record file format
; Simple data file 1 SEQUENCE ; Sequences contain one or more elements. UUID16 30000 UUID32 4000000 UUID128 12345678-ABCD-AF12-8800-12345678EF12 END 119 UINT16 19
More examples are in the sample directory and end in the .rec extension.
In all 3 search cases, when C code is generated, it is left to the application to determine what the Bluetooth address should be, and also how to parse the response the server returns.
Service Search Creation
The following command is used to create a service search.
bthnscreate [-verbose] -service fileName
If the -verbose flag is set, C code is generated to setup the UUIDs and call the SDP lookup functions.
The file format consists entirely of UUIDs. Each element has the following format.
Type must be either UUID32, UUID16, or UUID128.
The following example code for a search file format searches for 3 UUIDs.
UUID128 12345678-ABCD-AF12-8800-12345678EF12 UUID16 30000 UUID32 4000000
Attribute Search Creation
The following command is used to create an attribute search.
bthnscreate [-verbose] -attribute fileName
If the -verbose flag is set, C code is generated to setup the attribute identifier structure and call the SDP lookup functions. The application is responsible for passing in the search handle to the SDP lookup. This search handle is obtained from the SDP service search.
File format contains attribute identifier pairs that specify the attribute range for which to retrieve information. The first number is the low attribute value and the second number is the high attribute value. To query only one attribute, set the low and high attribute numbers to the same value.
The following example attribute file finds all attributes for a service between 1 to 100, and 119.
1 100 119 119
Service Attribute Search Creation
The following command is used to create a service attribute search.
bthnscreate [-verbose] -service_attribute fileName
If the -verbose flag is set, C code is generated to create the UUIDs, attribute list, and call the SDP lookup functions.
The first part of the file contains the UUID format. The UUID list is terminated by an "END" string. The attribute list follows the "END" string.
UUID128 12345678-ABCD-AF12-8800-12345678EF12 UUID16 30000 UUID32 4000000 END 1 100 119 119
**Note **This sample application has not been thoroughly tested and is not intended for production use.
Send Feedback on this topic to the authors