B2G/Bluetooth/WebBluetooth-v2/BluetoothPairingEvent
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 pairing BluetoothDevice object 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 BluetoothDevice device; 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
device
- Description
- The remote pairing bluetooth device.
- Value type
- BluetoothDevice
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.