Bluetooth and WSAQUERYSET for Service Inquiry

Bluetooth uses the WSAQUERYSET structure, with various functions, to facilitate the discovery of devices and services in the Bluetooth namespace, NS_BTH.

The WSALookupServiceBegin and WSALookupServiceNext functions use the WSAQUERYSET structure to obtain data about the service inquiry process. The following table describes how to set the member values in the WSAQUERYSET structure for this purpose.

Member Input to WSALookupServiceBegin Returned value from WSALookupServiceNext
dwSize Must be set to sizeof(WSAQUERYSET). sizeof(WSAQUERYSET) returned by system.
dwOutputFlags Not used. Not used.
lpszServiceInstanceName Not used. Display name of the service, converted as a UTF-8 encoded string from the default language encoding of the Bluetooth ServiceName SDP attribute. Returned if LUP_RETURN_NAME is specified.
lpServiceClassId Required. The most specific single Bluetooth UUID for the services for which the search is being conducted. For example, if this value is set to the UUID of the L2CAP protocol, it returns all services using the L2CAP protocol on the target device. If set to the UUID of a specific service, it would return only the instances of that service. Not used.
lpVersion Not used. Not used.
lpszComment Not used. Description of the service, converted as a UTF-8 encoded string from the default language encoding of the Bluetooth ServiceDescription SDP attribute. Returned if LUP_RETURN_COMMENT is specified.
dwNameSpace Must be NS_BTH. Returns NS_BTH.
lpNSProviderId Not used. Not used.
lpszContext Required. The Bluetooth Device Address with which to establish an SDP connection and query for services. This value must be a string that was converted by using the WSAAddressToString function call. If the local Bluetooth device address is provided, the local SDP database is searched. Not used.
dwNumberOfProtocols Not used. Not used.
lpafpProtocols Not used. Not used.
lpszQueryString Not used. Not used.
dwNumberOfCsAddrs Not used. Indicates the number of elements in the array of CSADDR_INFO structures.
lpcsaBuffer Not used. Pointer to a CSADDR_INFO structure whose LocalAddr.lpSockaddr member points to a SOCKADDR_BTH that contains the complete connectable address of the remote service, converted from the first entry of the Bluetooth ProtocolDescriptorList SDP attribute. Returned if LUP_RETURN_ADDR is specified.
lpBlob Optional. Pointer to a BTH_QUERY_SERVICE structure that contains advanced parameters to limit the results of the search. If provided, lpServiceClassId is ignored and cached queries do not succeed.
  • If a service search is performed: Pointer to a BLOB structure that returns the service handles. (BLOB.cbSize)/sizeof(ULONG) calculates the number of handles. BLOB.pBlobData is an array of ULONG values representing the service handles.
  • If an attribute or serviceAttribute search is performed: Pointer to a BLOB structure that returns the binary SDP record. BLOB.cbSize is the size of the binary SDP record. BLOB.pBlobData points to the record itself. The binary SDP record is necessary in many cases because only a limited number of SDP attributes are able to be converted to the WSAQUERYSET structure, and only default encoded UTF-8 strings are converted. Functions to assist in parsing the binary SDP record are provided in the Bluetooth Reference section.
  • Returned if LUP_RETURN_BLOB is specified.

 

Bluetooth and WSAQUERYSET for Set Service

Bluetooth and WSAQUERYSET for Device Inquiry

Bluetooth and BLOB

Bluetooth and WSALookupServiceBegin

Bluetooth and WSALookupServiceNext

Bluetooth Reference

BLOB

BTH_QUERY_SERVICE

CSADDR_INFO

SOCKADDR_BTH

WSAAddressToString

WSAQUERYSET

Windows Sockets