Changes

Jump to: navigation, search

B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt

850 bytes added, 08:00, 28 January 2015
add discoverServices
* [[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#discoverServices.28.29|BluetoothGatt.discoverServices()]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#readRemoteRssi.28.29|BluetoothGatt.readRemoteRssi()]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#beginReliableWrite.28.29|BluetoothGatt.beginReliableWrite()]]
}, function onReject(aReason) {
console.log("Rejected with this reason: ", aReason, ". ConnectionState becomes:", gatt.connectionState);
};
}
 
=== discoverServices() ===
 
; Description
: The method discover services, characteristics, and descriptors offered by the remote GATT server.
 
; 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</tt> when the method is called, the Promise would be rejected.
 
; Sample
var gatt = device.gatt;
if (gatt && gatt.connectionState === "connected") {
gatt.discoverServices().then ( function onResolve() {
console.log("Services, characteristics, and descriptors are successfully discovered.");
}, function onReject(aReason) {
console.log("Rejected with this reason: ", aReason);
};
}
120
edits

Navigation menu