BluetoothRemoteGATTDescriptor - 表示 GATT 描述符,它提供了有关特性值的更多信息
非标准
该功能是非标准的。请尽量不要在生产环境中使用它:因为每个用户不一定会正常运行。它的实现可能存在很大的不兼容性,并且将来可能会改变行为。
BluetoothRemoteGATTDescriptor 是 Web Bluetooth API 的接口,表示 GATT 描述符,它提供了有关特性值的更多信息。
在规范的早期版本中,它被称为
BluetoothGATTDescriptor。
接口
interface BluetoothRemoteGATTDescriptor {
readonly attribute BluetoothGATTCharacteristic characteristic;
readonly attribute UUID uuid;
readonly attribute ArrayBuffer? value;
Promise<ArrayBuffer> readValue();
Promise<void> writeValue(BufferSource value);
};
属性
BluetoothRemoteGATTDescriptor.characteristic 只读
返回该描述符所属的 BluetoothRemoteGATTCharacteristic。
BluetoothRemoteGATTDescriptor.uuid 只读
返回特征描述符的 UUID,例如 “客户端特征配置” 描述符为 00002902-0000-1000-8000-00805f9b34fb。
BluetoothRemoteGATTDescriptor.value 只读
返回当前缓存的描述符值。当读取描述符的值时,该值会自动更新。
方法
BluetoothRemoteGATTDescriptor.readValue()
如果可用,并支持 value 属性,则返回一个 Promise,它解析为包含 value 属性副本的 ArrayBuffer。否则抛出一个错误。
BluetoothRemoteGATTDescriptor.writeValue()
将包含在 ArrayBuffer 中的字节写入到 value 属性中,并返回 Promise。
规范
| 规范 | 状态 | 备注 |
|---|---|---|
| Web Bluetooth BluetoothRemoteGATTDescriptor 的定义 |
草稿 | 初始定义。 |
桌面浏览器兼容性
| 特性 | Chrome | Edge | Firefox | Internet Explorer | Opera | Safari |
|---|---|---|---|---|---|---|
| 基础支持 | 57 | 未知 | 未知 | 未知 | 44 | 未知 |
characteristic |
57 | 未知 | 未知 | 未知 | 44 | 未知 |
uuid |
57 | 未知 | 未知 | 未知 | 44 | 未知 |
value |
57 | 未知 | 未知 | 未知 | 44 | 未知 |
readValue |
57 | 未知 | 未知 | 未知 | 44 | 未知 |
writeValue |
57 | 未知 | 未知 | 未知 | 44 | 未知 |
移动浏览器兼容性
| 特性 | Android | Chrome for Android | Edge mobile | Firefox for Android | IE mobile | Opera Android | iOS Safari |
|---|---|---|---|---|---|---|---|
| 基础支持 | 不支持 | 57 | 未知 | 未知 | 未知 | 44 | 未知 |
characteristic |
不支持 | 57 | 未知 | 未知 | 未知 | 44 | 未知 |
uuid |
不支持 | 57 | 未知 | 未知 | 未知 | 44 | 未知 |
value |
不支持 | 57 | 未知 | 未知 | 未知 | 44 | 未知 |
readValue |
不支持 | 57 | 未知 | 未知 | 未知 | 44 | 未知 |
writeValue |
不支持 | 57 | 未知 | 未知 | 未知 | 44 | 未知 |