Changes

Jump to: navigation, search

B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt

1,195 bytes added, 06:25, 22 August 2014
connect()
=== connect() ===
 
; Description
: The method is used to re-connect to the remote GATT server after the connection has been dropped. If the remote GATT server is not in range, the re-connection will be triggered once the server is back in range.
 
; Parameter
: ''aAutoConnect''
:: Whether to directly connect to the remote device (false) or to automatically connect as soon as the remote device becomes available (true).
 
; Return
: A Promise to indicate whether the operation is resolved or rejected. If the Promise is resolved, it returns a [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#BluetoothGatt|BluetoothGatt]] object whose connectionState is connected. The promise is rejected if 1) the device is not of type le or dual, 2) creation of [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#BluetoothGatt#BluetoothGatt|BluetoothGatt]] object fails, or 2) connection to remote LE device fails.
 
; Sample
var autoConnect = false;
device.connectGatt(autoConnect).then { function onResolve(gatt) {
// gatt.connectionState is connected.
console.log("Resolved with gatt. Connection state:", gatt.connectionState);
}, function onReject(aReason) {
console.log("Rejected with this reason: " + aReason);
});
=== disconnect() ===
Confirm
891
edits

Navigation menu