B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent: Difference between revisions
No edit summary |
(Replace device with deviceName) |
||
(2 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
== Overview == | == Overview == | ||
'''BluetoothPairingEvent''' is carried as the argument of pairing related event handlers, including [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingListener#ondisplaypasskeyreq|mReq.ondisplaypasskeyreq]], [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingListener#onenterpincodereq|adapter.pairingReqs.onenterpincodereq]], [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingListener#onpairingconfirmationreq|adapter.pairingReqs.onpairingconfirmationreq]], and [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingListener#onpairingconsentreq|adapter.pairingReqs.onpairingconsentreq]]. Applications can get the pairing | '''BluetoothPairingEvent''' is carried as the argument of pairing related event handlers, including [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingListener#ondisplaypasskeyreq|mReq.ondisplaypasskeyreq]], [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingListener#onenterpincodereq|adapter.pairingReqs.onenterpincodereq]], [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingListener#onpairingconfirmationreq|adapter.pairingReqs.onpairingconfirmationreq]], and [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingListener#onpairingconsentreq|adapter.pairingReqs.onpairingconsentreq]]. Applications can get the remote pairing device name and a [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent#BluetoothPairingHandle|BluetoothPairingHandle]] object. The '''BluetoothPairingHandle''' object contains required property and methods for respective pairing type, including the passkey to display on local UI ([[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingListener#ondisplaypasskeyreq|adapter.pairingReqs.ondisplaypasskeyreq]]) or to confirm ([[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingListener#onpairingconfirmationreq|adapter.pairingReqs.onpairingconfirmationreq]]), and methods to reply the pin code entered by user ([[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingListener#onenterpincodereq|adapter.pairingReqs.onenterpincodereq]]) and reply user confirmation on passkey ([[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingListener#onpairingconfirmationreq|adapter.pairingReqs.onpairingconfirmationreq]]). | ||
== Interfaces == | == Interfaces == | ||
Line 10: | Line 10: | ||
interface BluetoothPairingEvent : Event | interface BluetoothPairingEvent : Event | ||
{ | { | ||
readonly attribute | readonly attribute DOMString [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent#deviceName|deviceName]]; | ||
readonly attribute BluetoothPairingHandle [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent#handle|handle]]; | readonly attribute BluetoothPairingHandle [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent#handle|handle]]; | ||
}; | }; | ||
Line 21: | Line 21: | ||
Promise<void> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent#setPinCode.28DOMString_aPinCode.29|setPinCode(DOMString aPinCode)]]; | Promise<void> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent#setPinCode.28DOMString_aPinCode.29|setPinCode(DOMString aPinCode)]]; | ||
Promise<void> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent# | Promise<void> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent#accept.28.29|accept()]]; | ||
Promise<void> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent#reject.28.29|reject()]]; | |||
}; | }; | ||
Line 27: | Line 28: | ||
== Properties == | == Properties == | ||
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent# | * [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent#deviceName|BluetoothPairingEvent.deviceName]] | ||
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent#handle|BluetoothPairingEvent.handle]] | * [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent#handle|BluetoothPairingEvent.handle]] | ||
=== | === deviceName === | ||
; Description | ; Description | ||
: The remote pairing bluetooth device. | : The name of remote pairing bluetooth device. | ||
; Value type | ; Value type | ||
: | : DOMString | ||
=== handle === | === handle === | ||
Line 49: | Line 50: | ||
|- | |- | ||
! rowspan="2"| !! style="background:#efefef;" | Property | ! rowspan="2"| !! style="background:#efefef;" | Property | ||
!! colspan=" | !! colspan="3" style="background:#ffdead;" | Methods | ||
|- | |- | ||
! passkey !! setPinCode !! | ! passkey !! setPinCode !! accept !! reject | ||
|- | |- | ||
! ondisplaypasskeyreq | ! ondisplaypasskeyreq | ||
| V || || | | V || || || V | ||
|- | |- | ||
! onenterpincodereq | ! onenterpincodereq | ||
| || V || | | || V || || V | ||
|- | |- | ||
! onpairingconfirmationreq | ! onpairingconfirmationreq | ||
| V || || V | | V || || V || V | ||
|- | |- | ||
! onpairingconsentreq | ! onpairingconsentreq | ||
| || || | | || || V || V | ||
|} | |} | ||
Line 80: | Line 81: | ||
== Methods == | == Methods == | ||
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent#setPinCode.28DOMString_aPinCode.29|BluetoothPairingHandle.setPinCode(DOMString aPinCode)]] | * [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent#setPinCode.28DOMString_aPinCode.29|BluetoothPairingHandle.setPinCode(DOMString aPinCode)]] | ||
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent# | * [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent#accept.28.29|BluetoothPairingHandle.accept()]] | ||
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent#reject.28.29|BluetoothPairingHandle.reject()]] | |||
=== setPinCode(DOMString aPinCode) === | === setPinCode(DOMString aPinCode) === | ||
Line 93: | Line 95: | ||
: A Promise to indicate whether the operation is resolved or rejected. If setPinCode is invalid for current pairing request, the Promise would be rejected. | : A Promise to indicate whether the operation is resolved or rejected. If setPinCode is invalid for current pairing request, the Promise would be rejected. | ||
=== | === accept() === | ||
; Description | ; Description | ||
: The method replies user | : The method replies that user confirms to pair the local bluetooth adapter with the remote device. | ||
; | ; Return | ||
: | : A Promise to indicate whether the operation is resolved or rejected. If accept is invalid for current pairing request, the Promise would be rejected. | ||
: | |||
=== reject() === | |||
; Description | |||
: The method replies that user rejects to pair the local bluetooth adapter with the remote device. | |||
; Return | ; Return | ||
: A Promise to indicate whether the operation is resolved or | : A Promise to indicate whether the operation is resolved or rejected. |
Latest revision as of 08:05, 25 February 2015
Overview
BluetoothPairingEvent is carried as the argument of pairing related event handlers, including mReq.ondisplaypasskeyreq, adapter.pairingReqs.onenterpincodereq, adapter.pairingReqs.onpairingconfirmationreq, and adapter.pairingReqs.onpairingconsentreq. Applications can get the remote pairing device name and a BluetoothPairingHandle object. The BluetoothPairingHandle object contains required property and methods for respective pairing type, including the passkey to display on local UI (adapter.pairingReqs.ondisplaypasskeyreq) or to confirm (adapter.pairingReqs.onpairingconfirmationreq), and methods to reply the pin code entered by user (adapter.pairingReqs.onenterpincodereq) and reply user confirmation on passkey (adapter.pairingReqs.onpairingconfirmationreq).
Interfaces
BluetoothPairingEvent
[CheckPermissions="bluetooth"] interface BluetoothPairingEvent : Event { readonly attribute DOMString deviceName; readonly attribute BluetoothPairingHandle handle; };
BluetoothPairingHandle
[CheckPermissions="bluetooth"] interface BluetoothPairingHandle { readonly attribute unsigned DOMString? passkey; Promise<void> setPinCode(DOMString aPinCode); Promise<void> accept(); Promise<void> reject(); };
BluetoothPairingEvent
Properties
deviceName
- Description
- The name of remote pairing bluetooth device.
- Value type
- DOMString
handle
- Description
- The handle contains necessary property and methods for respective pairing type.
- Value type
- BluetoothPairingHandle
- Content table
- Pairing type v.s. BluetoothPairingHandle content
Property | Methods | |||
---|---|---|---|---|
passkey | setPinCode | accept | reject | |
ondisplaypasskeyreq | V | V | ||
onenterpincodereq | V | V | ||
onpairingconfirmationreq | V | V | V | |
onpairingconsentreq | V | V |
BluetoothPairingHandle
Properties
passkey
- Description
- The passkey generated during the pairing process when both devices support secure simple pairing (SSP). Passkey is a 6-digit string ranging from decimal 000000 to 999999 (e.g., 000123). The property is null for event handlers adapter.onenterpincodereq and adapter.onpairingconsentreq since these two pairing types require no passkey.
- Value type
- DOMString
Methods
- BluetoothPairingHandle.setPinCode(DOMString aPinCode)
- BluetoothPairingHandle.accept()
- BluetoothPairingHandle.reject()
setPinCode(DOMString aPinCode)
- Description
- The method replies PIN code to the remote device when the local bluetooth adapter is pairing with it.
- Parameter
- aPinCode
- A DOMString representing the PIN code set by user.
- Return
- A Promise to indicate whether the operation is resolved or rejected. If setPinCode is invalid for current pairing request, the Promise would be rejected.
accept()
- Description
- The method replies that user confirms to pair the local bluetooth adapter with the remote device.
- Return
- A Promise to indicate whether the operation is resolved or rejected. If accept is invalid for current pairing request, the Promise would be rejected.
reject()
- Description
- The method replies that user rejects to pair the local bluetooth adapter with the remote device.
- Return
- A Promise to indicate whether the operation is resolved or rejected.