BluetoothRemoteGATTCharacteristic

可用性有限

此特性不是基線特性,因為它在一些最廣泛使用的瀏覽器中不起作用。

實驗性: 這是一項實驗性技術
在生產中使用此技術之前,請仔細檢查瀏覽器相容性表格

安全上下文: 此功能僅在安全上下文(HTTPS)中可用,且支援此功能的瀏覽器數量有限。

BluetoothRemoteGATTCharacteristic 介面是 Web Bluetooth API 的一部分,它代表一個 GATT 特徵(Characteristic)。GATT 特徵是提供裝置服務(peripheral's service)更多資訊的基本資料元素。

EventTarget BluetoothRemoteGATTCharacteristic

例項屬性

BluetoothRemoteGATTCharacteristic.service 只讀 實驗性

返回此特徵所屬的 BluetoothRemoteGATTService

BluetoothRemoteGATTCharacteristic.uuid 只讀 實驗性

返回一個包含該特徵 UUID 的字串,例如,心率測量(Heart Rate Measurement)特徵的 UUID 是 '00002a37-0000-1000-8000-00805f9b34fb'

BluetoothRemoteGATTCharacteristic.properties 只讀 實驗性

返回此特徵的屬性。

BluetoothRemoteGATTCharacteristic.value 只讀 實驗性

當前快取的特徵值。當特徵的值透過通知或指示讀取或更新時,此值會更新。

例項方法

BluetoothRemoteGATTCharacteristic.getDescriptor() 實驗性

返回一個 Promise,該 Promise 解析為給定描述符 UUID 的第一個 BluetoothRemoteGATTDescriptor

BluetoothRemoteGATTCharacteristic.getDescriptors() 實驗性

返回一個 Promise,該 Promise 解析為給定描述符 UUID 的所有 BluetoothRemoteGATTDescriptor 物件的 Array

BluetoothRemoteGATTCharacteristic.readValue() 實驗性

返回一個 Promise,如果 value 屬性可用且受支援,則該 Promise 解析為包含 value 屬性副本的 DataView。否則,它將丟擲錯誤。

BluetoothRemoteGATTCharacteristic.writeValue() 已棄用

value 屬性設定為給定 ArrayBuffer 中包含的位元組,以可選響應寫入特徵值,並返回生成的 Promise

BluetoothRemoteGATTCharacteristic.writeValueWithResponse() 實驗性

value 屬性設定為給定 ArrayBuffer 中包含的位元組,以必需響應寫入特徵值,並返回生成的 Promise

BluetoothRemoteGATTCharacteristic.writeValueWithoutResponse() 實驗性

value 屬性設定為給定 ArrayBuffer 中包含的位元組,無響應寫入特徵值,並返回生成的 Promise

BluetoothRemoteGATTCharacteristic.startNotifications() 實驗性

返回一個 Promise,當 navigator.bluetooth 被新增到活動通知上下文時,該 Promise 會解析。

BluetoothRemoteGATTCharacteristic.stopNotifications() 實驗性

返回一個 Promise,當 navigator.bluetooth 從活動通知上下文中移除時,該 Promise 會解析。

事件

characteristicvaluechanged 實驗性

BluetoothRemoteGATTCharacteristic 的值發生變化時,會在此物件上觸發。

規範

規範
Web 藍牙
# bluetoothgattcharacteristic-interface

瀏覽器相容性