大网数据广告活动
Web 标准与前端开发

BluetoothCharacteristicProperties

· 52CE 我爱测

The **`BluetoothCharacteristicProperties`** interface of the Web Bluetooth API provides the operations that are valid on the given BluetoothRemoteGATTCharacteristic.

Bluetooth API

The BluetoothCharacteristicProperties interface of the Web Bluetooth API provides the operations that are valid on the given BluetoothRemoteGATTCharacteristic.

This interface is returned by calling BluetoothRemoteGATTCharacteristic.properties.

Instance properties

  • BluetoothCharacteristicProperties.authenticatedSignedWrites
    • : Returns a boolean that is true if signed writing to the characteristic value is permitted.
  • BluetoothCharacteristicProperties.broadcast
    • : Returns a boolean that is true if the broadcast of the characteristic value is permitted using the Server Characteristic Configuration Descriptor.
  • BluetoothCharacteristicProperties.indicate
    • : Returns a boolean that is true if indications of the characteristic value with acknowledgement is permitted.
  • BluetoothCharacteristicProperties.notify
    • : Returns a boolean that is true if notifications of the characteristic value without acknowledgement is permitted.
  • BluetoothCharacteristicProperties.read
    • : Returns a boolean that is true if the reading of the characteristic value is permitted.
  • BluetoothCharacteristicProperties.reliableWrite
    • : Returns a boolean that is true if reliable writes to the characteristic is permitted.
  • BluetoothCharacteristicProperties.writableAuxiliaries
    • : Returns a boolean that is true if reliable writes to the characteristic descriptor is permitted.
  • BluetoothCharacteristicProperties.write
    • : Returns a boolean that is true if the writing to the characteristic with response is permitted.
  • BluetoothCharacteristicProperties.writeWithoutResponse
    • : Returns a boolean that is true if the writing to the characteristic without response is permitted.

Examples

The following example shows how tell if a GATT characteristic supports value change notifications.

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();
}

Specifications

Browser compatibility

来源:MDN Web Docs / Mozilla 贡献者 · 作者与贡献记录 · CC BY-SA 2.5。离线整理了版式、链接和媒体显示。

资料来源与适用范围

资料来源
MDN Web Docs / Mozilla 贡献者
适用范围
请按文中版本与环境说明核对
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 2.5

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。