B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent

From MozillaWiki
< B2G‎ | Bluetooth‎ | WebBluetooth-v2
Revision as of 07:12, 7 April 2014 by Btian (talk | contribs)
Jump to navigation Jump to search

Overview

BluetoothPairingEvent is carried as the argument of pairing related event handlers, including adapter.ondisplaypasskeyreq, adapter.onenterpasskeyreq, adapter.onpairingconfirmationreq, and adapter.onpairingconsentreq. Applications can get the pairing BluetoothDevice object, and a BluetoothPairingHandle object. The BluetoothPairingHandle object may carry the passkey to display on local UI (adapter.ondisplaypasskeyreq) or to confirm (adapter.onpairingconfirmationreq), and methods to reply the passkey entered by user (adapter.onenterpasskeyreq) or reply user confirmation on passkey (adapter.onpairingconfirmationreq).

Interface

BluetoothPairingEvent

interface BluetoothPairingEvent : Event
{
  readonly attribute BluetoothDevice device;
  readonly attribute BluetoothPairingHandle handle;
};

BluetoothPairingHandle

interface BluetoothPairingHandle
{
  readonly attribute unsigned long?  passkey;

  DOMRequest setPasskey(DOMString aPasskey);
  DOMRequest setPairingConfirmation(boolean aConfirm);
};

BluetoothPairingEvent

Properties

device

Description
The remote pairing bluetooth device.
Value type
BluetoothDevice

handle

Description
The handle contains necessary property and methods for pairing
Value type
BluetoothDevice

BluetoothPairingHandle

Properties

passkey

Description
The passkey generated during the pairing process when both devices support secure simple pairing (SSP). The valid values of passkey are decimal 000000 - 999999.
Value type
unsigned long
Default value
0

Methods

setPasskey(DOMString aPasskey)

Description
The method replies passkey or PIN code to the remote device when the local bluetooth adapter is pairing with it.
Parameter
aPasskey
A DOMString representing the passkey or PIN code set by user.
Return
A DOMRequest object to handle the success or error of the operation. In case of success, it means that the setPasskey operation has completed.

setPairingConfirmation(boolean aConfirm)

Description
The method replies user's pairing confirmation when the local bluetooth adapter is pairing with the remote device.
Parameter
aConfirm
A boolean indicating whether user confirms pairing with the remote device (true) or not (false).
Return
A DOMRequest object to handle the success or error of the operation. In case of success, it means that the setPairingConfirmation operation has completed.