You will normally connect to a device to perform a specific task over Bluetooth. Connecting to any random device is not sensible. A better way is to check that the device you are about to establish a connection with is able to provide the required functionality. This document discusses the service discovery options.
There are two ways to inquire about the services on offer on a remote device, they are:
Use MajorClassOfDevice() to examine the class of device attribute when making an address inquiry.
Use the Bluetooth Service Discovery Protocol (SDP) Agent APIs.
Examining the Class of Device
A broad indicator of the services provided can be read from the class of device. This could be used, for example, to decide the appropriate icon with which to represent a device to the user. The class of device is got through TInquirySockAddr::MajorClassOfDevice()
after an address inquiry.
How it works:
When the service discovery provided by the class of device is not adequate to determine which device to select, use the SDP Agent, discussed below.
Using the Bluetooth SDP Agent
The Bluetooth SDP database contains information about the services available on a device. Service discovery queries can be used on each device found to establish if it is a suitable choice. SDP queries are performed through the Bluetooth Service Discovery Agent Overview.
You can use the SDP Agent to discover the services available on a device and to look up specific attributes of a service. Several tutorials exist to show how the SDP Agent is used. See Bluetooth Service Discovery Agent Overview for more information.