BluetoothCharacteristicProperties
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.
Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.
Giao diện BluetoothCharacteristicProperties của Web Bluetooth API cung cấp các thao tác hợp lệ trên BluetoothRemoteGATTCharacteristic đã cho.
Giao diện này được trả về khi gọi BluetoothRemoteGATTCharacteristic.properties.
Thuộc tính thực thể
authenticatedSignedWritesRead only Experimental-
Trả về một
booleancó giá trịtruenếu được phép ghi có chữ ký vào giá trị của đặc tính. broadcastRead only Experimental-
Trả về một
booleancó giá trịtruenếu được phép phát quảng bá giá trị của đặc tính bằng Server Characteristic Configuration Descriptor. indicateRead only Experimental-
Trả về một
booleancó giá trịtruenếu được phép gửi indication cho giá trị của đặc tính kèm xác nhận. notifyRead only Experimental-
Trả về một
booleancó giá trịtruenếu được phép gửi notification cho giá trị của đặc tính mà không cần xác nhận. readRead only Experimental-
Trả về một
booleancó giá trịtruenếu được phép đọc giá trị của đặc tính. reliableWriteRead only Experimental-
Trả về một
booleancó giá trịtruenếu được phép ghi đáng tin cậy vào đặc tính. writableAuxiliariesRead only Experimental-
Trả về một
booleancó giá trịtruenếu được phép ghi đáng tin cậy vào bộ mô tả của đặc tính. writeRead only Experimental-
Trả về một
booleancó giá trịtruenếu được phép ghi vào đặc tính có phản hồi. writeWithoutResponseRead only Experimental-
Trả về một
booleancó giá trịtruenếu được phép ghi vào đặc tính mà không có phản hồi.
Ví dụ
Ví dụ sau cho thấy cách xác định một đặc tính GATT có hỗ trợ thông báo thay đổi giá trị hay không.
let device = await navigator.bluetooth.requestDevice({
filters: [{ services: ["heart_rate"] }],
});
let gatt = await device.gatt.connect();
let service = await gatt.getPrimaryService("heart_rate");
let characteristic = await service.getCharacteristic("heart_rate_measurement");
if (characteristic.properties.notify) {
characteristic.addEventListener(
"characteristicvaluechanged",
async (event) => {
console.log(`Received heart rate measurement: ${event.target.value}`);
},
);
await characteristic.startNotifications();
}
Các đặc tả
| Specification |
|---|
| Web Bluetooth> # characteristicproperties-interface> |