Connecting to the service discovery database

Bluetooth services are registered to the service discovery database.

How to connect to the service discovery database

The first step in registering a service to the service discovery database is establishing a connection to the database.

Basic Procedure

To use the service discovery database, a client must:

  1. Create a session to the database object, RSdp , and open a connection.

  2. Create a subsession to the database object, RSdpDatabase , and open it. A client can have multiple subsessions open if required. (Sessions and subsessions are part of Symbian platform's architecture for interprocess communication: see Client/Server Overview ).

  3. Close subsessions and sessions when they are no longer needed.

Connecting to the database

The following example shows how to connect to the database:

  • Create and open a session to the database

             
              
             
             RSdp sdp;
    User::LeaveIfError(sdp.Connect());
            
  • Create and open a subsession

             
              
             
             RSdpDatabase sdpSubSession;
    User::LeaveIfError(sdpSubSession.Open(sdp));
            
  • Cleanup

             
              
             
             sdpSubSession.Close();
    sdp.Close();
            
Note: If all sessions to the SDP database are closed, then the database is closed. Any application that offers a service should therefore keep a handle to the database as long as it is offering the service.

Where next?

The complete set of Service Discovery Database tutorials are shown below:

  1. Connecting to the service discovery database - This document

  2. Handling SDP attributes

  3. Registering Services

  4. Setting service record attributes

  5. SDP Service records and attributes

Also refer to the Bluetooth Service Discovery Database overview and the Bluetooth SDP Overview for additional background information.