B2G/Bluetooth/WebBluetooth-v2/BluetoothDevice: Difference between revisions
< B2G | Bluetooth | WebBluetooth-v2
Jump to navigation
Jump to search
(Created page with "== Overview == The BluetoothDevice API provides information regarding a given Bluetooth device. === Interface === enum BluetoothDeviceAttribute { "cod", "name", "pa...") |
|||
| Line 33: | Line 33: | ||
; Description | ; Description | ||
: The <tt>address</tt> attribute provides the address of the device on the Bluetooth micro-network. This attribute must be non-empty value. Both empty and null string are regarded invalid. | |||
; Value | ; Value | ||
: Return a string. The default value is empty string "". | |||
; Sample | ; Sample | ||
var address = ''instanceOfBluetoothDevice''.address; | |||
; // TODO | |||
* The attribute cannot be empty but the default value is empty string? | |||
=== cod === | === cod === | ||
Revision as of 06:31, 26 February 2014
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
- The address attribute provides the address of the device on the Bluetooth micro-network. This attribute must be non-empty value. Both empty and null string are regarded invalid.
- Value
- Return a string. The default value is empty string "".
- Sample
var address = instanceOfBluetoothDevice.address;
- // TODO
- The attribute cannot be empty but the default value is empty string?
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();