这是 实验性技术
检查 浏览器兼容性表格 要小心谨慎在生产中使用这之前。

The BluetoothDevice interface of the Web Bluetooth API represents a Bluetooth device inside a particular script execution environment.

  <div id="interfaceDiagram" style="display: inline-block; position: relative; width: 100%; padding-bottom: 11.666666666666666%; vertical-align: middle; overflow: hidden;"><svg style="display: inline-block; position: absolute; top: 0; left: 0;" viewbox="-50 0 600 70" preserveAspectRatio="xMinYMin meet"><a xlink:href="../API/EventTarget.html" target="_top"><rect x="1" y="1" width="110" height="50" fill="#fff" stroke="#D4DDE4" stroke-width="2px" /><text  x="56" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">EventTarget</text></a><polyline points="111,25  121,20  121,30  111,25" stroke="#D4DDE4" fill="none"/><line x1="121" y1="25" x2="151" y2="25" stroke="#D4DDE4"/><a xlink:href="../API/BluetoothDevice" target="_top"><rect x="151" y="1" width="150" height="50" fill="#F4F7F8" stroke="#D4DDE4" stroke-width="2px" /><text  x="226" y="30" font-size="12px" font-family="Consolas,Monaco,Andale Mono,monospace" fill="#4D4E53" text-anchor="middle" alignment-baseline="middle">BluetoothDevice</text></a></svg></div>
					
  a:hover text { fill: #0095DD; pointer-events: all;}
					

接口

interface BluetoothDevice {
  readonly attribute DOMString id;
  readonly attribute DOMString? name;
  readonly attribute BluetoothRemoteGATTServer? gatt;
  readonly attribute FrozenArray uuids;
  Promise watchAdvertisements();
  void unwatchAdvertisements();
  readonly attribute boolean watchingAdvertisements;
};
BluetoothDevice implements EventTarget;
BluetoothDevice implements BluetoothDeviceEventHandlers;
BluetoothDevice implements CharacteristicEventHandlers;
BluetoothDevice implements ServiceEventHandlers;
					

特性

BluetoothDevice.id 只读
DOMString that uniquely identifies a device.
BluetoothDevice.name 只读
DOMString that provices a human-readable name for the device.
BluetoothDevice.gatt 只读
A reference to the device's BluetoothRemoteGATTServer .
BluetoothDevice.uuids 只读

Lists the UUID's of GATT services provided by the device, that the current origin is allowed to access.

BluetoothDevice.watchingAdvertisements 只读
If advertisments were activated using BluetoothDevice.watchAdvertisements() .

Non-standard Chrome OS properties

非标
此特征是非标准的,且不在标准轨道中。不要在面向 Web 的生产站点中使用它:它不适用于每个用户。实现之间可能存在大的不兼容性,且行为将来可能改变。

These properties were only implemented on Google’s Chrome OS 45 and removed from Chrome 52.

BluetoothDevice.adData 只读
实例化的 BluetoothAdvertisingData containing the most recent advertising data received for the device.
BluetoothDevice.deviceClass 只读

A number representing the Bluetooth devices "Class of Device".

BluetoothDevice.vendorIDSource 只读
The Vendor ID Source field in the pnp_id characteristic in the device_information service.
BluetoothDevice.vendorID 只读
The 16-bit Vendor ID field in the pnp_id characteristic in the device_information service.
BluetoothDevice.productID 只读
The 16-bit Product ID field in the pnp_id characteristic in the device_information service.
BluetoothDevice.productVersion 只读
The 16-bit Product Version field in the pnp_id characteristic in the device_information service.
BluetoothDevice.paired 只读
布尔 value indicating whether the device is paired with the system.
BluetoothDevice.gattServer 只读

A reference to the device's GATT server or null if the device is disconnected.

方法

BluetoothDevice.watchAdvertisments()
Promise that resolves to undefined or is rejected with an error if advetisments can’t shown for any reason.
BluetoothDevice.unwatchAdvertisments()

Stops watching for advertisments.

BluetoothDevice.connectGATT()
Promise that resolves to an instance of BluetoothGATTRemoteServer .

规范

规范 状态 注释
Web Bluetooth
The definition of 'BluetoothDevice' in that specification.
草案 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
BluetoothDevice Chrome 74 Edge ≤79 Firefox 不支持 No IE 不支持 No Opera Yes Safari 不支持 No WebView Android 不支持 No Chrome Android 74 Firefox Android 不支持 No Opera Android Yes Safari iOS 不支持 No Samsung Internet Android 11.0
adData 弃用 非标 Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera ? Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android ? Safari iOS 不支持 No Samsung Internet Android 不支持 No
connectGATT 弃用 非标 Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera ? Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android ? Safari iOS 不支持 No Samsung Internet Android 不支持 No
deviceClass 弃用 非标 Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera ? Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android ? Safari iOS 不支持 No Samsung Internet Android 不支持 No
gatt Chrome 74 Edge ≤79 Firefox 不支持 No IE 不支持 No Opera Yes Safari 不支持 No WebView Android 不支持 No Chrome Android 74 Firefox Android 不支持 No Opera Android Yes Safari iOS 不支持 No Samsung Internet Android 11.0
gattServer 弃用 非标 Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera ? Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android ? Safari iOS 不支持 No Samsung Internet Android 不支持 No
id Chrome 74 Edge ≤79 Firefox 不支持 No IE 不支持 No Opera Yes Safari 不支持 No WebView Android 不支持 No Chrome Android 74 Firefox Android 不支持 No Opera Android Yes Safari iOS 不支持 No Samsung Internet Android 11.0
名称 Chrome 74 Edge ≤79 Firefox 不支持 No IE 不支持 No Opera Yes Safari 不支持 No WebView Android 不支持 No Chrome Android 74 Firefox Android 不支持 No Opera Android Yes Safari iOS 不支持 No Samsung Internet Android 11.0
paired 弃用 非标 Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera ? Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android ? Safari iOS 不支持 No Samsung Internet Android 不支持 No
productID 弃用 非标 Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera ? Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android ? Safari iOS 不支持 No Samsung Internet Android 不支持 No
productVersion 弃用 非标 Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera ? Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android ? Safari iOS 不支持 No Samsung Internet Android 不支持 No
unwatchAdvertisements Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera ? Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android ? Safari iOS 不支持 No Samsung Internet Android 不支持 No
uuids 弃用 非标 Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera ? Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android ? Safari iOS 不支持 No Samsung Internet Android 不支持 No
vendorID 弃用 非标 Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera ? Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android ? Safari iOS 不支持 No Samsung Internet Android 不支持 No
vendorIDSource 弃用 非标 Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera ? Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android ? Safari iOS 不支持 No Samsung Internet Android 不支持 No
watchAdvertisements Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera ? Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android ? Safari iOS 不支持 No Samsung Internet Android 不支持 No
watchingAdvertisements Chrome 不支持 No Edge 不支持 No Firefox 不支持 No IE 不支持 No Opera ? Safari 不支持 No WebView Android 不支持 No Chrome Android 不支持 No Firefox Android 不支持 No Opera Android ? Safari iOS 不支持 No Samsung Internet Android 不支持 No

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

实验。期望将来行为有所改变。

实验。期望将来行为有所改变。

非标。预期跨浏览器支持较差。

弃用。不要用于新网站。

弃用。不要用于新网站。

元数据

  • 最后修改: