BluetoothUUID
BluetoothUUID 介面是 Web Bluetooth API 的一部分,它提供了一種方法,可以透過名稱在藍牙 SIG 維護的 登錄檔中查詢通用唯一識別符號 (UUID) 值。
描述
UUID 字串是 128 位 UUID,例如 00001818-0000-1000-8000-00805f9b34fb。藍牙登錄檔除了包含 16 位或 32 位別名和名稱外,還包含由這些 UUID 標識的描述符、服務和特性列表。
BluetoothUUID 介面提供了檢索這些 128 位 UUID 的方法。
靜態方法
BluetoothUUID.canonicalUUID()實驗性-
當傳入 16 位或 32 位 UUID 別名時,返回 128 位 UUID。
BluetoothUUID.getCharacteristic()實驗性-
當傳入名稱或 16 位或 32 位 UUID 別名時,返回代表已註冊特性的 128 位 UUID。
BluetoothUUID.getDescriptor()實驗性-
當傳入名稱或 16 位或 32 位 UUID 別名時,返回代表已註冊描述符的 UUID。
BluetoothUUID.getService()實驗性-
當傳入名稱或 16 位或 32 位 UUID 別名時,返回代表已註冊服務的 UUID。
示例
在以下示例中,將返回並列印到控制檯的 UUID 代表名為 device_information 的服務。
js
let result = BluetoothUUID.getService("device_information");
console.log(result); // "0000180a-0000-1000-8000-00805f9b34fb"
規範
| 規範 |
|---|
| Web 藍牙 # bluetoothuuid |
瀏覽器相容性
載入中…