Bluetooth SDP Introduction

Source: Internet
Author: User
Tags error handling uuid

SDP, service Discovery Protocol, Services Discovery Protocol 1. Concept

The SDP provides a way to discover services and the properties of those available services, but it does not provide a mechanism to take advantage of these services.

The schema is Client-server mode, as shown in the following figure


SDP Server maintains a list of service records, with each entry containing information about the service.
SDP client obtains service record information from SDP server via SDP request

The client can use one of the services provided by the server by opening a separate connection

When the server service changes, the client must understand this information in other ways so that it can query through the SDP
At the same time, when the server is unavailable for some reason, the client can use the SDP to poll the server
When the server is no longer requesting it, the client can infer that the server is unavailable. 2. Service records (services record)

Each service is represented by a service record.
Each service record consists of a number of service attribute, as shown in the following figure


Uniquely identifies a service record in SDP server with service record handle
Service Record handle uses the 32-bit number to denote

Servicerecordstate and Servicedatabasestate attributes

In the service Record list, the server uses 0x00000000 to represent the SDP itself 3. Service Attribute

Each service attribute describes a single feature of a service, with the following examples


A service property contains two parts: Property ID and property value


The attribute ID is an 16-bit unsigned integer that distinguishes between different properties in the server, and the attribute ID also determines the semantics of the associated property value

The property value field length is variable and is determined by the associated property ID and Service record category 4. Service class

Each service is an instance of a service class
The service class defines all the attributes that are contained in the service record for that class
Each property defines the specified property ID, and the property values and attributes that are used are worth formatting
Service records contain properties for specific service classes and common service classes

Each service class is assigned a unique identifier
This service class identifier contains the attribute value of the Serviceclassidlist attribute, called the UUID 5. Service Lookup

Service lookup allows the client to obtain service record handles for a particular service record based on the attribute value that contains the service record (Service record Handle)

When an SDP client has a service record handle, it can request a specific property value

SDP does not provide service record lookups based on arbitrary attribute values, only provides UUID-based lookups
The UUID 5.1 uuid that can be used to search for important properties of the service that are represented as

The UUID is a 128-bit value, and the Bluetooth base UUID value is 0X00000000-0000-1000-8000-00805F9B34FB
Other defined UUID refer to <UUID>

To simplify the utility, we use the 16-bit and 32bit uuid to represent the real UUID, 5.2 Service Search mode (Patterns)

Service Search mode uses the UUID list to locate matching service records 6. Service Browsing

SDP provides a service-based shared attribute mechanism for browsing services, which is known as Browsegrouplist

The client browses the server's services by creating a service search pattern that contains the UUID that represents the root browse group 7. Data Representation

SDP uses data element to represent data (property ID, property ID range, property value)

A data cell is a typed representation of a data that consists of two fields: the header field and the data field

The header field contains two parts: type descriptor (descriptor) and size descriptor (sizes descriptor)
A data field is a sequence of bytes whose length is specified by a size descriptor, meaning that the 7.1 type descriptor is specified by the type descriptor

The type of the data cell is represented by the type descriptor of the 5-bit, which contains the high five bits of the first byte in the header field.
The following are the types that are already defined


7.2 Size Descriptor

The size descriptor of the data unit contains the lower three bits of the first byte in the header field
It is represented as the size index, followed by 0/8/16/32bits
The size index is encoded as follows


7.3 Data Unit Instances


8. Description of the agreement

SDP using the Request/response model
Each of these transactions (Transaction) contains a request protocol data unit (PDU) and a response PDU

SDP uses L2CAP as the transport protocol, after establishing the connection and issuing the SDP request
No additional request can be issued at a given time until the response of the request has been received.

Transmission using Big-endian, high-first low- 8.1 PDU format

The SDP PDU contains a header and a parameters

Header contains three fields: PDU ID, Transaction ID, parameterlength


Where the header three fields have the following meanings, respectively


8.2 Partial responses and continuation State


8.3 error Handling

When a server considers that the request format of the client is incorrect or otherwise causes no suitable response
Should respond to a sdp_errorresponse PDU (PDU id=0x01)

At the same time, its parameters is Errorcode,errorcode details as follows


8.4 Service Lookup Transactions

Servicesearch Transaction 8.4.1 sdp_servicesearchrequest PDU

The parameters of the Sdp_servicesearchrequest PDU (PDU id=0x02) includes
Servicesearchpattern, Maximumservicerecordcount, continuationstate

Servicesearchpattern (size:varies):

Value Parametr Description
Data Element Sequence Servicesearchpattern is a sequence of data units, each of which is a UUID and the number of cells is 1~12

Maximumservicerecordcount (Size:2 Bytes):

Value Parametr Description
N Maximumservicerecordcount is a 16-bit number that specifies the maximum service record handle that can be returned, the value range: 0X0001~0XFFFF

Continuationstate (size:1~17 Bytes):

Value Parametr Description
Continuation state Continuationstate is a 8-bit number n, and the subsequent n bytes is the continuation state information, and the range of n is 0~16,0 indicates that there is no continuation state
8.4.2 Sdp_servicesearchresponse PDU

The parameters of the Sdp_servicesearchresponse PDU (PDU id=0x03) includes
Totalservicerecordcount, Currentservicerecordcount, Servicerecordhandlelist, continuationstate 8.5 service Property Transactions

Serviceattribute Transaction 8.6 Service Properties Find Transactions

Servicesearchattribute Transaction

tip:8.4.2, 8.5 and 8.6 are defined in detail and are not covered here, see Specification 9 for details . Service attribute definition 9.1 Universal Attribute definition 9.2 Servicediscoveryserver Service class Attribute definitions 9.3 Browsegroupdescriptor service class Attribute Definitions

Tip:9 mainly describes the property id, attribute value type and property related descriptions, see specification for details

For more information about SDP, refer to the following article
< Overview of the SDP protocol for Bluetooth >
<SDP Protocol Translation (Part 1) >
<fts grab packet look at Bluetooth in SDP entire process >

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.