120
edits
No edit summary |
(remove auto connect) |
||
| Line 16: | Line 16: | ||
attribute EventHandler [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#onconnectionstatechanged|onconnectionstatechanged]]; | attribute EventHandler [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#onconnectionstatechanged|onconnectionstatechanged]]; | ||
[NewObject, Throws] Promise<void> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#connect. | [NewObject, Throws] Promise<void> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#connect.28.29|connect()]]; | ||
[NewObject, Throws] Promise<void> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#disconnect.28.29|disconnect()]]; | [NewObject, Throws] Promise<void> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#disconnect.28.29|disconnect()]]; | ||
[NewObject, Throws] Promise<short> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#readRemoteRssi.28.29|readRemoteRssi()]]; | [NewObject, Throws] Promise<short> [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#readRemoteRssi.28.29|readRemoteRssi()]]; | ||
| Line 91: | Line 91: | ||
== Methods == | == Methods == | ||
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#connect. | * [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#connect.28.29|BluetoothGatt.connect()]] | ||
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#disconnect.28.29|BluetoothGatt.disconnect()]] | * [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#disconnect.28.29|BluetoothGatt.disconnect()]] | ||
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#readRemoteRssi.28.29|BluetoothGatt.readRemoteRssi()]] | * [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#readRemoteRssi.28.29|BluetoothGatt.readRemoteRssi()]] | ||
| Line 98: | Line 98: | ||
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#abortReliableWrite.28.29|BluetoothGatt.abortReliableWrite()]] | * [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#abortReliableWrite.28.29|BluetoothGatt.abortReliableWrite()]] | ||
=== connect( | === connect() === | ||
; Description | ; Description | ||
: The method is used connect to the remote LE device. | : The method is used connect to the remote LE device. | ||
: This is an asynchronous method and its result is returned via a Promise. Once the method is called, property [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#connectionState|connectionState]] becomes <tt>connecting</tt> and a corresponding [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#onconnectionstatechanged|onconnectionstatechanged]] would be triggered. If the connect operation succeeds, another [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#onconnectionstatechanged|onconnectionstatechanged]] would be triggered before the Promise is resolved to indicate property [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#connectionState|connectionState]] becomes <tt>connected</tt>. | : This is an asynchronous method and its result is returned via a Promise. Once the method is called, property [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#connectionState|connectionState]] becomes <tt>connecting</tt> and a corresponding [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#onconnectionstatechanged|onconnectionstatechanged]] would be triggered. If the connect operation succeeds, another [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#onconnectionstatechanged|onconnectionstatechanged]] would be triggered before the Promise is resolved to indicate property [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#connectionState|connectionState]] becomes <tt>connected</tt>. | ||
; Return | ; Return | ||
| Line 120: | Line 116: | ||
}); | }); | ||
} | } | ||
; Note | |||
: Auto connection establishment procedure defined in bluetooth specification(3.C.9.3.5) is not support yet. | |||
: Please see [https://bugzilla.mozilla.org/show_bug.cgi?id=1126123 Bug 1126123] for details. | |||
=== disconnect() === | === disconnect() === | ||
; Description | ; Description | ||
: The method disconnects an established | : The method disconnects an established connection. | ||
: This is an asynchronous method and its result is returned via a Promise. Once the method is called, property [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#connectionState|connectionState]] becomes <tt>disconnecting</tt> and a corresponding [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#onconnectionstatechanged|onconnectionstatechanged]] would be triggered. If the connect operation succeeds, another [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#onconnectionstatechanged|onconnectionstatechanged]] would be triggered before the Promise is resolved to indicate property [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#connectionState|connectionState]] becomes <tt>disconnected</tt>. | : This is an asynchronous method and its result is returned via a Promise. Once the method is called, property [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#connectionState|connectionState]] becomes <tt>disconnecting</tt> and a corresponding [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#onconnectionstatechanged|onconnectionstatechanged]] would be triggered. If the connect operation succeeds, another [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#onconnectionstatechanged|onconnectionstatechanged]] would be triggered before the Promise is resolved to indicate property [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#connectionState|connectionState]] becomes <tt>disconnected</tt>. | ||
; Return | ; Return | ||
: A Promise to indicate whether the operation is resolved or rejected. If the property [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#connectionState|connectionState]] is not <tt>connected | : A Promise to indicate whether the operation is resolved or rejected. If the property [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#connectionState|connectionState]] is not <tt>connected</tt> when the method is called, the Promise would be rejected. | ||
; Sample | ; Sample | ||
edits