SDP Service in Symbian

Source: Internet
Author: User

In fact, SDP is a very simple protocol. The key is to understand the concept. To be honest, the concept here is indeed very messy.

Service: A service is an entity of a service class. used to provide information and execute an action. it can be composed of software, hardware, or a combination of the two. the Service handle attribute represents its key attribute.

Service record: stores information about a service. A service record is composed of a service attribute list.

Service Class: each service is an instance of a service class. The service class definition defines all the attributes contained in the service record. It is also represented by UUID.

Service attribute: describes a feature of a service. The attribute ID (16 bit) and attribute value are composed of two parts.

Attribute ID: 16 bits, that is, two bytes. The service class of the Service determines the meaning of the attribute ID in the service record of the service.

Attribute Value: a data element.

Service browsing group: The browsegrouplist attribute in the service record. the value of this attribute is a uuid list. the UUID of the browsing group is saved. if a service belongs to a browsing group, its browsegrouplist attribute contains the uuid of the browsing group.
Groupid defines a browsing group. It is also a property value.

The above are the core concepts of SDP. the analogy is that each service record is a service definition. however, the service class does not need service records for actual definition. they are all directly used in properties. because these services are defined by sig (the Bluetooth Special Interest Group (SIG. for their UUID, see assigned numbers. however, Custom Service browsing groups must be defined by service records.

The following two attributes are required for each record:
Servicerecordhandle: 32-bit. This attribute of the Service Record of the SDP Service is 0x0000 0000.
Serviceclassidlist: This attribute determines the service class to which the service is represented by the service record.

When the serviceclassidlist attribute of a service record contains servicediscoveryserverserviceclassid, the service record is the definition of an SDP Service. Its Service handle is fixed 0x00000000.
When the serviceclassidlist attribute of a service record contains browsegroupdescriptorserviceclassid, the service record is defined as a browsing group. This service record uses the groupid attribute to define the uuid of the Service browsing group.
When the serviceclassidlist attribute of a service record contains publicbrowseroot, the service belongs to the public browsing root directory.

Servicediscoveryserverserviceclassid = 0x1000
Browsegroupdescriptorserviceclassid = 0x1001
Publicbrowseroot = 0x1002 (Note: In the new assigned numbers file of www.mongoth.org, publicbrowseroot has been changed to publicbrowsegroup)
 
 
# Include <btsdp. h> // sdpdatabase. Lib
Static const tint kserialclassid = 0x1101;
Static const tint kchannel = 1; // Channel
Static const tint kuidbtadvertiserappvalue = {0xeff55b8b };
 
_ Partition (kservicename, "serial ");
_ Translate (kservicedescription, "Serial Transfer ");
 
PRIVATE: // data

Rsdp isdpsession;

Rsdpdatabase isdpdatabase;

Tsdpservrecordhandle irecord;

 
 
Void cbtappview: startadvertiserl ()
{
If (! Iisconnected)
{
User: leaveiferror (isdpsession. Connect ());
// If (isdpsession. Connect ()! = Kerrnone)
// Panic (ebtadvertiserfailedtoopensession );
If (isdpdatabase. Open (isdpsession )! = Kerrnone)
Panic (ebtadvertiserfailedtoopendatabase );
Iisconnected = etrue;
}
Isdpdatabase. createservicerecordl (kserialclassid, irecord );
 
Csdpattrvaluedes * protocoldescriptorlist =
Csdpattrvaluedes: newdesl (null );
Cleanupstack: pushl (protocoldescriptorlist );

Protocoldescriptorlist
-> Startlistl () // list of protocols required for this method
-> Builddesl ()
-> Startlistl ()
-> Builduuidl (kl2cap)
-> Endlistl ()
-> Builddesl ()
-> Startlistl ()
-> Builduuidl (krfcomm)
-> Builduintl (tbuf8 <1> (kchannel ))
-> Endlistl ()
-> Endlistl ();

Isdpdatabase. updateattributel (
Irecord, ksdpattridprotocoldescriptorlist, * protocoldescriptorlist );
Cleanupstack: popanddestroy (protocoldescriptorlist );

// Add a unique ID to the record
Isdpdatabase. updateattributel (irecord,
Ksdpattridserviceid,
Kuidbtadvertiserappvalue );
// Add a name to the record
Isdpdatabase. updateattributel (irecord,
Ksdpattridbaseprimarylanguage +
Ksdpattridoffsetservicename,
Kservicename );

// Add a description to the record
Isdpdatabase. updateattributel (irecord,
Ksdpattridbaseprimarylanguage +
Ksdpattridoffsetservicedescription,
Kservicedescription );
}
 
Cbtappview ::~ Cbtappview ()
{
If (isadvertising ())
{
Stopadvertiser ();
}
Isdpdatabase. Close ();
Isdpsession. Close ();
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.