B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt: Difference between revisions

Line 110: Line 110:
* [[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()]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#findService.28DOMString_serviceUuid.29|BluetoothGatt.findService(DOMString serviceUuid)]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#beginReliableWrite.28.29|BluetoothGatt.beginReliableWrite()]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#beginReliableWrite.28.29|BluetoothGatt.beginReliableWrite()]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#executeReliableWrite.28.29|BluetoothGatt.executeReliableWrite()]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#executeReliableWrite.28.29|BluetoothGatt.executeReliableWrite()]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#abortReliableWrite.28.29|BluetoothGatt.abortReliableWrite()]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#abortReliableWrite.28.29|BluetoothGatt.abortReliableWrite()]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#findService.28DOMString_serviceUuid.29|BluetoothGatt.findService(DOMString serviceUuid)]]


=== connect() ===
=== connect() ===
Line 177: Line 177:
     console.log("Rejected with this reason: ", aReason);
     console.log("Rejected with this reason: ", aReason);
   };
   };
}
=== findService(DOMString serviceUuid) ===
; Description
: The method is a helper to find the [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#BluetoothGattService|BluetoothGattService]] object of given service UUID from the offered GATT services list (i.e., property [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#services|services]]). If multiple [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#BluetoothGattService|BluetoothGattService]] objects of given service UUID exist, the first [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#BluetoothGattService|BluetoothGattService]] object of the service is returned.
; Return
: A [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#BluetoothGattService|BluetoothGattService]] object of given service UUID.
; Sample
var gatt = device.gatt;
if (gatt) {
  heartRateService = gatt.findService(0x180D);
  }
  }


Line 203: Line 217:
; Return
; Return
: A Promise to indicate whether the operation is resolved or rejected.
: A Promise to indicate whether the operation is resolved or rejected.
=== findService(DOMString serviceUuid) ===
; Description
: The method is a helper to find the [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#BluetoothGattService|BluetoothGattService]] object of given service UUID from the offered GATT services list (i.e., property [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGatt#services|services]]). If multiple [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#BluetoothGattService|BluetoothGattService]] objects of given service UUID exist, the first [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#BluetoothGattService|BluetoothGattService]] object of the service is returned.
; Return
: A [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattService#BluetoothGattService|BluetoothGattService]] object of given service UUID.
; Sample
var gatt = device.gatt;
if (gatt) {
  heartRateService = gatt.findService(0x180D);
}


== See Also ==
== See Also ==
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothDevice|BluetoothDevice]]
* [[B2G/Bluetooth/WebBluetooth-v2/BluetoothDevice|BluetoothDevice]]
Confirmed users
891

edits