Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1001647 of BluetoothRemoteGATTCharacteristic

  • Revision slug: Web/API/BluetoothRemoteGATTCharacteristic
  • Revision title: BluetoothGATTCharacteristic
  • Revision id: 1001647
  • Created:
  • Creator: jpmedley
  • Is current revision? No
  • Comment Web/API/BluetoothGattCharacteristic Web/API/BluetoothRemoteGATTCharacteristic

Revision Content

{{ apiref("Web Bluetooth API") }} {{Non-standard_header()}}

The BluetoothGattCharacteristic interface of the Web Bluetooth API represents a GATT Characteristic, which is a basic data element that provides further information about a peripheral’s service.

Interface

interface BluetoothGATTCharacteristic {
  readonly attribute BluetoothGATTService service;
  readonly attribute UUID uuid;
  readonly attribute BluetoothCharacteristicProperties properties;
  readonly attribute ArrayBuffer? value;
  Promise getDescriptor(BluetoothDescriptorUUID descriptor);
  Promise>
    getDescriptors(optional BluetoothDescriptorUUID descriptor);
  Promise readValue();
  Promise writeValue(BufferSource value);
  Promise startNotifications();
  Promise stopNotifications();
};
BluetoothGATTCharacteristic implements EventTarget;
BluetoothGATTCharacteristic implements CharacteristicEventHandlers;

Properties

{{domxref("BluetoothGATTCharacteristic.service")}} {{readonlyinline}}
Returns the {{domxref("BluetoothGATTService")}} this characteristic belongs to.
{{domxref("BluetoothGATTCharacteristic.uuid")}} {{readonlyinline}}
Returns a {{domxref("DOMString")}} containing the UUID of the characteristic, for example '00002a37-0000-1000-8000-00805f9b34fb' for the Heart Rate Measurement characteristic.
{{domxref("BluetoothGATTCharacteristic.properties")}} {{readonlyinline}}
Returns the properties of this characteristic.
{{domxref("BluetoothGATTCharacteristic.value")}} {{readonlyinline}}
The currently cached characteristic value. This value gets updated when the value of the characteristic is read or updated via a notification or indication.

Methods

{{domxref("BluetoothGATTCharacteristic.getDescriptor()")}} {{readonlyinline}}
Returns a {{jsxref("Promise")}} that resolves to the first {{domxref("BluetoothGATTDescriptor")}} for a given descriptor UUID.
{{domxref("BluetoothGATTCharacteristic.getDescriptors()")}} {{readonlyinline}}
Returns a {{jsxref("Promise")}} that resolves to an {{jsxref("Array")}} of all {{domxref("BluetoothGATTDescriptor")}} objects for a given descriptor UUID.
{{domxref("BluetoothGATTCharacteristic.readValue()")}} {{readonlyinline}}
Returns a {{jsxref("Promise")}} that resolves to an {{jsxref("ArrayBuffer")}} holding a duplicate of the value property if it is available and supported. Otherwise it throws an error.
{{domxref("BluetoothGATTCharacteristic.writeValue()")}} {{readonlyinline}}
Sets the value property to the bytes contained in an {{jsxref("ArrayBuffer")}} and returns a {{jsxref("Promise")}}.
{{domxref("BluetoothGATTCharacteristic.startNotifications()")}} {{readonlyinline}}
Returns a {{jsxref("Promise")}} when navigator.bluetooth is added to the active notification context.
{{domxref("BluetoothGATTCharacteristic.stopNotifications()")}} {{readonlyinline}}
Returns a {{jsxref("Promise")}} when navigator.bluetooth is removed from the active notification context.

Specifications

Specification Status Comment
{{SpecName('Web Bluetooth')}} {{Spec2('Web Bluetooth')}} Initial definition.

Browser Compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support {{CompatChrome (45.0)}} [1] {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Mobile Opera Mobile Safari Mobile Chrome for Android
Basic support {{CompatNo}} {{CompatNo}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatNo}}

[1] Behind a flag.  Chrome OS only.

Revision Source

<p>{{ apiref("Web Bluetooth API") }}&nbsp;{{Non-standard_header()}}</p>

<p>The <code>BluetoothGattCharacteristic</code>&nbsp;interface of the <a href="/en-US/docs/Web/API/Web_Bluetooth_API">Web Bluetooth API</a> represents a GATT&nbsp;Characteristic, which is a basic data element that provides further information about a peripheral’s service.</p>

<h2 id="Interface">Interface</h2>

<pre class="syntaxbox">
interface BluetoothGATTCharacteristic {
  readonly attribute BluetoothGATTService service;
  readonly attribute UUID uuid;
  readonly attribute BluetoothCharacteristicProperties properties;
  readonly attribute ArrayBuffer? value;
  Promise getDescriptor(BluetoothDescriptorUUID descriptor);
  Promise&gt;
    getDescriptors(optional BluetoothDescriptorUUID descriptor);
  Promise readValue();
  Promise writeValue(BufferSource value);
  Promise startNotifications();
  Promise stopNotifications();
};
BluetoothGATTCharacteristic implements EventTarget;
BluetoothGATTCharacteristic implements CharacteristicEventHandlers;</pre>

<h2 id="Properties">Properties</h2>

<dl>
 <dt>{{domxref("BluetoothGATTCharacteristic.service")}} {{readonlyinline}}</dt>
 <dd>Returns the {{domxref("BluetoothGATTService")}} this characteristic belongs to.</dd>
 <dt>{{domxref("BluetoothGATTCharacteristic.uuid")}} {{readonlyinline}}</dt>
 <dd>Returns a {{domxref("DOMString")}} containing&nbsp;the UUID of the characteristic, for example&nbsp;<code>'00002a37-0000-1000-8000-00805f9b34fb'</code>&nbsp;for the&nbsp;Heart Rate Measurement&nbsp;characteristic.</dd>
 <dt>{{domxref("BluetoothGATTCharacteristic.properties")}} {{readonlyinline}}</dt>
 <dd>Returns&nbsp;the properties of this characteristic.</dd>
 <dt>{{domxref("BluetoothGATTCharacteristic.value")}} {{readonlyinline}}</dt>
 <dd>The currently cached characteristic value. This value gets updated when the value of the characteristic is read or updated via a notification or indication.</dd>
</dl>

<h2 id="Methods">Methods</h2>

<dl>
 <dt>{{domxref("BluetoothGATTCharacteristic.getDescriptor()")}} {{readonlyinline}}</dt>
 <dd>Returns a {{jsxref("Promise")}} that resolves to the first&nbsp;{{domxref("BluetoothGATTDescriptor")}} for a given descriptor UUID.</dd>
 <dt>{{domxref("BluetoothGATTCharacteristic.getDescriptors()")}} {{readonlyinline}}</dt>
 <dd>Returns a {{jsxref("Promise")}} that resolves to an {{jsxref("Array")}}&nbsp;of all&nbsp;{{domxref("BluetoothGATTDescriptor")}} objects for a given descriptor UUID.</dd>
 <dt>{{domxref("BluetoothGATTCharacteristic.readValue()")}} {{readonlyinline}}</dt>
 <dd>Returns a {{jsxref("Promise")}} that resolves to an {{jsxref("ArrayBuffer")}} holding a duplicate of the&nbsp;<code>value</code> property if it is available and supported. Otherwise it throws an error.</dd>
 <dt>{{domxref("BluetoothGATTCharacteristic.writeValue()")}} {{readonlyinline}}</dt>
 <dd>Sets the value property to the bytes contained in an {{jsxref("ArrayBuffer")}} and returns a {{jsxref("Promise")}}.</dd>
 <dt>{{domxref("BluetoothGATTCharacteristic.startNotifications()")}} {{readonlyinline}}</dt>
 <dd>Returns a {{jsxref("Promise")}} when <code>navigator.bluetooth</code> is added to the active notification context.</dd>
 <dt>{{domxref("BluetoothGATTCharacteristic.stopNotifications()")}} {{readonlyinline}}</dt>
 <dd>Returns a {{jsxref("Promise")}} when <code>navigator.bluetooth</code> is removed from the active notification context.</dd>
</dl>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('Web Bluetooth')}}</td>
   <td>{{Spec2('Web Bluetooth')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_Compatibility">Browser Compatibility</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatChrome (45.0)}} [1]</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Android Webview</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>Firefox OS</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
   <th>Chrome for Android</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] Behind a flag.&nbsp;&nbsp;Chrome OS only.</p>
Revert to this revision