B2G/Bluetooth/WebBluetooth-v2/BluetoothDevice
< B2G | Bluetooth | WebBluetooth-v2
Jump to navigation
Jump to search
Overview
The BluetoothDevice API provides information regarding a given Bluetooth device.
Interface
enum BluetoothDeviceAttribute {
"cod",
"name",
"paired",
"uuids"
}
interface BluetoothDevice: EventTarget
{
readonly attribute DOMString address;
readonly attribute BluetoothClassOfDevice cod;
readonly attribute DOMString name;
readonly attribute boolean paired;
readonly attribute any uuids; // array of type DOMString[]
attribute EventHandler onattributechanged;
DOMRequest fetchUuids();
};
Attributes
- BluetoothDevice.address
- BluetoothDevice.cod
- BluetoothDevice.name
- BluetoothDevice.paired
- BluetoothDevice.uuids
address
- Description
- Value
- Sample
cod
- Description
- Value
- Sample
name
- Description
- Value
- Sample
paired
- Description
- Value
- Sample
uuids
- Description
- Value
- Sample
Event Handlers
- BluetoothDevice.onattributechanged
onattributechanged
- Description
- A handler for adapteradded event; it is triggered when a Bluetooth adapter is plugged into the device. The event carries evt.adapter as the plugged BluetoothAdapter object.
- Sample
function bt_onAdapterAdded(evt) {
var adapter = evt.adapter;
// do your thing here!
}
var manager = navigator.mozBluetooth;
manager.onadapteradded = bt_onAdapterAdded;
Methods
fetchUuids()
- Description
- The fetchUuid method is used to retrieve all adapters of this device.
- Return
- An array of BluetoothAdapter objects.
- Sample
var manager = navigator.mozBluetooth; var adapter = manager.getAdapters();