Bluetooth profile and UUID of Android

Source: Internet
Author: User

In Android, several commonly used Bluetooth profiles are: spp (Serial Port profile), a2dp (Advanced Audio distribution profile), and avrcp (audio/video remote control profile), hid (Human Interface Device profile), HFP (hands-free profile ). Among them, media is highly correlated with a2dp and avrcp, which is often used for data communication.

Concept of Bluetooth Profile

Profile defines a Bluetooth-based application. Each profile specification mainly includes developer interfaces, message formats and standards (such as audio compression), and components using the Bluetooth protocol stack. Each profile corresponds to a uuid. The Bluetooth UUID concept is similar to the port concept in TCP/IP. Each UUID runs a service.

Bluetooth uses the Service Discovery Protocol (SDP) to discover the profiles supported by the pairing device. In the SDP servie daemon of the bluetooth device, information such as the supported service list and connected session is saved. The SDP client uses this information to discover and identify the profile.

In particular, the basic profile in Bluetooth includes the Generic Access Profile (GAP) and the above SDP. In addition, SPP is usually used as the basis for the implementation of other profiles.

Bluetooth UUID Concept

The concept of UUID is widely used. It is a distributed concept (more specifically, a local model ?) Id generation method. Each profile corresponds to one or more UUID (different UUID in the same profile also corresponds to different services ).

The UUID of the profile defined in Bluetooth SIG is generated as follows:

Base_uuid + uuid16 <96 or base_uuid + uuid32 <96

The base_uuid is:

BASE_UUID00000000-0000-1000-8000-00805F9B34FB

Therefore, the pre-defined UUID of Bluetooth SIG is only in the last 32 bits (actually 96 ~ 112 bits. For example,

A2DP_UUID0000110B-0000-1000-8000-00805F9B34FB

In the logcat type of Android, the string of 00805f9b34fb is often seen.

Different profile implementations for Android

In Bluetooth Linux, there is an official library bluez, but it seems to be a closed source.

SPP

SPP is the only fully open Bluetooth profile for Android. In offical tutorial, it also uses strongswan -0000-1000-8000-00805f9b34fb as the uuid of spp.

In fact, SPP communication is a basic method. UUID can be customized completely, but both devices must share the uuid in advance.

In specific implementation, the SPP programming method is very similar to the Linux TCP socket. Some common problems such as processing after the client is connected, and opening another thread are very similar.

A2dp

A2dp is a profile used for audio and multimedia. In Android, it already contains the APIS corresponding to a2dp (mostly @ hide ). You must use the reflection method to obtain the corresponding API.

The correspondence between related APIs and Android API level is summarized later.

Hid

Hid is the input and output of the standard keyboard and mouse. For example, you can use this profile to implement some simple remote key control.

The event Capturing Method of Android hid is the same as that of backkey. You can use the onkey of view. onkeylistener to capture the corresponding keycode.

Avrcp

Avrcp mainly corresponds to some media playback control, which can basically be equivalent to hid, such as the volume key and playback volume key on the PC's "Multimedia keyboard.

The avrcp event can be considered as a special case of HID. the specific meaning of the key is defined in the keybord layout of Android.

HFP

Profile frequently used in vehicle-mounted models.

The audio part is similar to a2dp. Devices that support HFP and a2dp are automatically connected when Bluetooth is enabled.

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.