Changes

Jump to: navigation, search

B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt

1,295 bytes added, 07:18, 22 August 2014
disconnect()
=== disconnect() ===
 
; Description
: The method disconnects an established connection.
 
; Return
: A Promise to indicate whether the operation is resolved or rejected. 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>. If the property [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#connectionState|connectionState]] is not <tt>connected</tt>, the Promise would be rejected.
 
; Sample
var gatt = device.gatt;
if (gatt && gatt.connectionState === "connected") {
gatt.disconnect().then { function onResolve() {
console.log("Disconnection succeeds. ConnectionState becomes:", gatt.connectionState);
}, function onReject(aReason) {
console.log("Rejected with this reason: ", aReason, ". ConnectionState becomes:", gatt.connectionState);
};
}
=== readRemoteRssi() ===
Confirm
891
edits

Navigation menu