蓝牙 UUID 汇总

本文详细介绍了蓝牙服务发现协议(SDP)中的UUID,包括UUID的短形式、基UUID、协议标识符、浏览组标识符等。还列举了各种蓝牙服务类和配置文件的UUID,如音频/视频远程控制配置文件、基本打印配置文件、健康设备配置文件等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

分享一下我老师大神的人工智能教程!零基础,通俗易懂!http://blog.youkuaiyun.com/jiangjunshow

也欢迎大家转载本篇文章。分享知识,造福人民,实现我们中华民族伟大复兴!

               

service discovery

​​​Use Assigned Numbers in the Service Discovery Protocol (SDP) for searching for services, a browse group list, documentation URL, and an icon URL.

Service Discovery Protocol (SDP)

Universally Unique Identifier (UUID) short forms

The Bluetooth® Service Discovery Protocol (SDP) specification defines a way to represent a range of UUIDs (which are nominally 128 bits) in a shorter form. A reserved range of 232 values can be represented using 32 bits (denoted uuid32). Of these, a sub-range of 216 values can be represented using only 16 bits (denoted uuid16).

All values in the 232 range that are not assigned in this document are reserved pending future revisions of this document. In other words, no value in this range may be used except as specified in this or future revisions of this document. UUID values outside of this range can be allocated as described in [ISO-11578] for any purpose the allocator desires.

Base Universally Unique Identifier (UUID)

The Base UUID is used for calculating 128-bit UUIDs from "short UUIDs" (uuid16 and uuid32) as described in the SDP Specification. See Service Discovery Protocol (SDP) in the Bluetooth Core Specification.

NOTE: Currently all assigned short UUIDs are uuid16 types.

UUID Name UUID
BASE_UUID 00000000-0000-1000-8000-00805F9B34FB

Protocol Identifiers

The UUIDs in the following table shall be used only in the ProfileDescriptorList attribute.

Protocol Name UUID Protocol Specification
SDP 0x0001 Bluetooth Core Specification
UDP 0x0002 [NO USE BY PROFILES]
RFCOMM 0x0003 RFCOMM with TS 07.10
TCP 0x0004 [NO USE BY PROFILES]
TCS-BIN 0x0005 Telephony Control Specification / TCS Binary [DEPRECATED]
TCS-AT 0x0006 [NO USE BY PROFILES]
ATT 0x0007 Attribute Protocol
OBEX 0x0008 IrDA Interoperability
IP 0x0009 [NO USE BY PROFILES]
FTP 0x000A [NO USE BY PROFILES]
HTTP 0x000C [NO USE BY PROFILES]
WSP 0x000E [NO USE BY PROFILES]
BNEP 0x000F Bluetooth Network Encapsulation Protocol (BNEP)
UPNP 0x0010 Extended Service Discovery Profile (ESDP) [DEPRECATED]
HIDP 0x0011 Human Interface Device Profile (HID)
HardcopyControlChannel 0x0012 Hardcopy Cable Replacement Profile (HCRP)
HardcopyDataChannel 0x0014 See Hardcopy Cable Replacement Profile (HCRP)
HardcopyNotification 0x0016 Hardcopy Cable Replacement Profile (HCRP)
AVCTP 0x0017 Audio/Video Control Transport Protocol (AVCTP)
AVDTP 0x0019 Audio/Video Distribution Transport Protocol (AVDTP)
CMTP 0x001B Common ISDN Access Profile (CIP) [DEPRECATED]
MCAPControlChannel 0x001E Multi-Channel Adaptation Protocol (MCAP)
MCAPDataChannel 0x001F Multi-Channel Adaptation Protocol (MCAP)
L2CAP 0x0100 Bluetooth Core Specification
  (Max value 0xFFFF)  

Table 1: Protocol Identifiers and Names, Service Classes and Profile Identifiers

UUIDs in the following table, which have an allowed usage of Service Class may be used in the ServiceClassIDList universal attribute, but shall not be used in the BluetoothProfileDescriptorList attribute unless the Profile usage is also allowed per the table below. If a Service Class UUID is exposed in the SDP database of a product, then the product containing the SDP record shall comply with the specification that defines the service corresponding to the UUID.

UUIDs in the following table which have an allowed usage of Profile may be used in the BluetoothProfileDescriptorList universal attribute, but shall not be used in the ServiceClassIDList universal attribute unless the Service Class usage is also allowed per the table below.

For historical reasons, some UUIDs in Table 2 are used to identify profiles in a BluetoothProfileDescriptorList universal attribute as well as service classes in a ServiceClassIDList universal attribute. However, for new profiles, Service Class UUIDs shall not be used in a BluetoothProfileDescriptorList universal attribute and Profile UUIDs shall not be used in a ServiceClassIDList universal attribute.

Service Class Name UUID Specification Allowed Usage
ServiceDiscoveryServerServiceClassID 0x1000 Bluetooth Core Specification Service Class
BrowseGroupDescriptorServiceClassID 0x1001 Bluetooth Core Specification Service Class
SerialPort 0x1101 Serial Port Profile (SPP)
NOTE: The example SDP record in SPP v1.0 does not include a BluetoothProfileDescriptorList attribute, but some implementations may also use this UUID for the Profile Identifier.
Service Class/ Profile
LANAccessUsingPPP 0x1102 LAN Access Profile
[DEPRECATED]
NOTE: Used as both Service Class Identifier and Profile Identifier.
Service Class/ Profile
DialupNetworking 0x1103 Dial-up Networking Profile (DUN)
NOTE: Used as both Service Class Identifier and Profile Identifier.
Service Class/ Profile
IrMCSync 0x1104 Synchronization Profile (SYNC)
NOTE: Used as both Service Class Identifier and Profile Identifier.
Service Class/ Profile
OBEXObjectPush 0x1105 Object Push Profile (OPP)
NOTE:
### 蓝牙 UUID 的定义 UUID 是一种通用唯一标识符,通常由 128 位组成,在蓝牙技术中被广泛应用于唯一标识服务、特征值以及描述符。它使得设备能够在复杂的网络环境中正确识别并访问所需的服务和数据[^1]。 在蓝牙协议栈中,UUID 主要分为两种形式:标准 UUID 和自定义 UUID。标准 UUID 遵循特定格式 `{0000xxxx-0000-1000-8000-00805F9B34FB}`,其中 `xxxx` 表示具体的数值范围从 `0x0000` 到 `0xFFFE`,这些 UUID 已经预定义好,用于表示常见的蓝牙服务或特性[^2]。除此之外,开发者还可以创建自己的自定义 UUID 来满足特殊需求。 ### 蓝牙 UUID 的作用 UUID蓝牙通信中的主要职责在于区分不同的服务和服务内的不同特性 (Characteristics)。具体来说: - **Service UUID**: 它代表了一组功能的集合,例如健康监测、心率测量等。每个 Service 可能会包含多个 Characteristics。 - **Characteristic UUID**: 这些是实际的数据点,允许两个设备之间交换信息。比如温度传感器可能有一个 Characteristic 提供当前环境温度的读数[^3]。 当一个蓝牙设备广播其存在时,其他设备可以通过扫描该设备发布的 Service UUIDs 找到感兴趣的服务,并进一步探索可用的 Characteristics。 ### 如何使用 Bluetooth UUID? 为了利用蓝牙 UUID 实现跨平台互操作性,开发人员需遵循以下原则: 1. 如果应用涉及标准化的功能,则应采用官方推荐的标准 UUID; 2. 对于专有的应用程序逻辑,可以选择注册新的私有空间下的 UUID 或者完全随机生成一个新的全局唯一的 ID; 3. 开发过程中务必保持一致性——即在整个生命周期内始终如一地分配相同的 UUID 给相同类型的资源; 下面是一个简单的 Python 示例展示如何解析已知的 BLE 设备及其 services/characteristics: ```python import asyncio from bleak import BleakScanner, BleakClient async def run(): devices = await BleakScanner.discover() for d in devices: print(d) async with BleakClient(d.address) as client: svcs = await client.get_services() for service in svcs: print(f"\tService {service.uuid}:") characteristics = service.characteristics for char in characteristics: print(f"\t\tChar {char.uuid}") loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) loop.run_until_complete(run()) ``` 上述脚本展示了如何发现附近的蓝牙低功耗(BLE)装置并通过遍历它们所提供的各个 Services 和 Characteristics 来打印出对应的 UUID 值。 #### 注意事项 尽管短版本(16-bit 或 32-bit)更易于记忆也更加紧凑,但在某些情况下仅支持完整的 128-bit 形式才能确保绝对无冲突的独特性。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值