aboutsummaryrefslogtreecommitdiff
path: root/files/th/web/api/bluetooth/index.html
blob: 74a1f52188dce980237d9187f346886cb7103014 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
---
title: Bluetooth
slug: Web/API/Bluetooth
tags:
  - API
  - Bluetooth
  - Experimental
  - Interface
  - NeedsTranslation
  - Reference
  - TopicStub
  - Web Bluetooth API
translation_of: Web/API/Bluetooth
---
<p>{{APIRef("Bluetooth API")}}{{securecontext_header}}{{SeeCompatTable}}</p>

<p>The <strong><code>Bluetooth</code></strong> interface of the <a href="/en-US/docs/Web/API/Web_Bluetooth_API">Web Bluetooth API</a> returns a {{jsxref("Promise")}} to a {{domxref("BluetoothDevice")}} object with the specified options.</p>

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

<pre class="syntaxbox">interface Bluetooth : EventTarget {
  [SecureContext] Promise&lt;boolean&gt; getAvailability();
  [SecureContext] attribute EventHandler onavailabilitychanged;
  [SecureContext, SameObject] readonly attribute BluetoothDevice? referringDevice;
  [SecureContext] Promise&lt;BluetoothDevice&gt; requestDevice(optional RequestDeviceOptions options);
};
Bluetooth implements BluetoothDeviceEventHandlers;
Bluetooth implements CharacteristicEventHandlers;
Bluetooth implements ServiceEventHandlers;</pre>

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

<p><em>Inherits properties from its parent {{domxref("EventTarget")}}.</em></p>

<dl>
 <dt>{{domxref("Bluetooth.referringDevice")}} {{readonlyinline}}</dt>
 <dd>Returns a reference to the device, if any, from which the user opened the current page. For example, an Eddystone beacon might advertise a URL, which the user agent allows the user to open. A BluetoothDevice representing the beacon would be available through <code>navigator.bluetooth.referringDevice</code>.</dd>
</dl>

<h3 id="Events">Events</h3>

<dl>
 <dt>{{domxref("Bluetooth.onavailabilitychanged")}}</dt>
 <dd>An event handler that runs when an event of type {{event("availabilitychanged")}} has fired.</dd>
</dl>

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

<dl>
 <dt>{{domxref("Bluetooth.getAvailability()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} that resolved to a {{jsxref("Boolean")}} indicating whether the user-agent has the ability to support Bluetooth. Some user-agents let the user configure an option that affects what is returned by this value. If this option is set, that is the value returned by this method.</dd>
 <dt>{{domxref("Bluetooth.requestDevice()")}}</dt>
 <dd>Returns a {{jsxref("Promise")}} to a {{domxref("BluetoothDevice")}} object with the specified options.</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', '#bluetooth', 'Bluetooth')}}</td>
   <td>{{Spec2('Web Bluetooth')}}</td>
   <td>Initial definition.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>



<p>{{Compat("api.Bluetooth")}}</p>