|
|
Line 158: |
Line 158: |
| * [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#startNotifications.28.29|BluetoothGattCharacteristic.startNotifications()]] | | * [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#startNotifications.28.29|BluetoothGattCharacteristic.startNotifications()]] |
| * [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#stopNotifications.28.29|BluetoothGattCharacteristic.stopNotifications()]] | | * [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#stopNotifications.28.29|BluetoothGattCharacteristic.stopNotifications()]] |
| * [[B2G/Bluetooth/WebBluetooth-v2/BluetoothGattCharacteristic#findDescriptor.28DOMString uuid.29|BluetoothGattCharacteristic.findDescriptor(DOMString uuid)]]
| |
|
| |
|
| === readValue() === | | === readValue() === |
Line 195: |
Line 194: |
| ; Return | | ; Return |
| : A Promise to indicate whether the operation is resolved or rejected. The Promise is rejected if there is no Client Characteristic Configuration descriptor (CCCD) for this characteristic. | | : A Promise to indicate whether the operation is resolved or rejected. The Promise is rejected if there is no Client Characteristic Configuration descriptor (CCCD) for this characteristic. |
|
| |
| === findDescriptor(DOMString uuid) ===
| |
|
| |
| ; Description
| |
| : The method finds a descriptor of this characteristic from the descriptors property by the given UUID. When multiple descriptors with the same UUID exist, the first one is returned.
| |
|
| |
| ; Parameters
| |
| : ''uuid''
| |
| :: UUID DOMString of the descriptor to seek for.
| |
|
| |
| ; Return
| |
| : The first descriptor with the given uuid in descriptors property. A null pointer is returned if no descriptor is found by the given UUID.
| |
|
| |
| ; Sample
| |
| const HEART_RATE_SERVICE = "0000180d-0000-1000-8000-00805f9b34fb";
| |
| const HEART_RATE_MEASUREMENT = "00002a37-0000-1000-8000-00805f9b34fb";
| |
| const CLIENT_CHAR_CONFIG = "00002902-0000-1000-8000-00805f9b34fb";
| |
|
| |
| if (device.gatt) {
| |
| // get heart rate service
| |
| var heartRateService = device.gatt.findService(HEART_RATE_SERVICE));
| |
|
| |
| // get heart rate measurement characteristic from service
| |
| if (heartRateService) {
| |
| var heartRateMeasurement =
| |
| heartRateService.findCharacteristic(HEART_RATE_MEASUREMENT);
| |
|
| |
| // get Client Characteristic Configuration descriptor from characteristic
| |
| if (heartRateMeasurement) {
| |
| var cccd = heartRateMeasurement.findDescriptor(CLIENT_CHAR_CONFIG);
| |
| }
| |
| }
| |
| }
| |