This API is available on Firefox OS for internal applications 仅。

BluetoothManager 接口在 Web Bluetooth API allows to access all Bluetooth adapters available on the device. Adapters are the connection interface to connect a Bluetooth device to that device.

Interface overview

[CheckPermissions="bluetooth"]
interface BluetoothManager: EventTarget
{
  readonly attribute BluetoothAdapter? defaultAdapter;
           attribute EventHandler onattributechanged;
           attribute EventHandler onadapteradded;
           attribute EventHandler onadapterremoved;
  sequence<BluetoothAdapter> getAdapters();
};
					

特性

BluetoothManager.enabled 只读
A boolean indicating whether the Bluetooth is on ( true ) or off ( false ).

事件处理程序

BluetoothManager.onadapteradded
处理程序为 adapteradded event; it is triggered when a Bluetooth adapter is enabled on the device.
BluetoothManager.onadapterremoved
处理程序为 adapterremoved event; it is triggered when a Bluetooth adapter is disabled on the device, or removed.
BluetoothManager.onattributechanged
处理程序为 attributechanged event; it is triggered when the BluetoothManager.defaultAdapter 特性改变。

注意: 由于 BluetoothManager interface inherits from the EventTarget interface, all these events can be listened by using the addEventListener 方法。

Obsolete event handlers

BluetoothManager.onenabled
处理程序为 被启用 event; it is triggered when the Bluetooth is turned on.
BluetoothManager.ondisabled
处理程序为 被禁用 event; it is triggered when the Bluetooth is turned off.

方法

BluetoothManager.getAdapters()
Returns a list of the current BluetoothAdapter s in use on the device.

过时方法

BluetoothManager.getDefaultAdapter()
Allows to retrieve the default adapter in use by the device. Returns a DOMRequest to handle the success or error of the operation. In case of success, the request's result BluetoothAdapter object. Superceded by the BluetoothManager.getAdapters() 方法。

规范

规范 状态 注释
Web Bluetooth
The definition of 'BluetoothManager' in that specification.
草案 Rough draft; not part of any official specification yet. It should be discussed as part of the W3C's System Applications Working Group .

浏览器兼容性

Firefox OS 2.1 adds bluetooth 'v2' support: getAdapters() , onattributechange , onadapterremoved .
Firefox OS 1.0.1 bluetooth initial support: getDefaultAdapter(), onenabled , ondisabled , onadapteradded .

另请参阅

Using the Web Bluetooth API

元数据

  • 最后修改: