File: bluetooth.webidl

package info (click to toggle)
chromium 145.0.7632.159-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,976,224 kB
  • sloc: cpp: 36,198,469; ansic: 7,634,080; javascript: 3,564,060; python: 1,649,622; xml: 838,470; asm: 717,087; pascal: 185,708; sh: 88,786; perl: 88,718; objc: 79,984; sql: 59,811; cs: 42,452; fortran: 24,101; makefile: 21,144; tcl: 15,277; php: 14,022; yacc: 9,066; ruby: 7,553; awk: 3,720; lisp: 3,233; lex: 1,328; ada: 727; jsp: 228; sed: 36
file content (220 lines) | stat: -rw-r--r-- 7,694 bytes parent folder | download | duplicates (12)
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
// Copyright 2025 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Allocation authorities for Vendor IDs.
enum VendorIdSource {
  "bluetooth",
  "usb"
};

// Common device types recognized by Chrome.
enum DeviceType {
  "computer",
  "phone",
  "modem",
  "audio",
  "carAudio",
  "video",
  "peripheral",
  "joystick",
  "gamepad",
  "keyboard",
  "mouse",
  "tablet",
  "keyboardMouseCombo"
};

// Types for filtering bluetooth devices.
enum FilterType {
  "all",
  "known"
};

// Transport type of the bluetooth device.
enum Transport {
  "invalid",
  "classic",
  "le",
  "dual"
};

// Information about the state of the Bluetooth adapter.
dictionary AdapterState {
  // The address of the adapter, in the format 'XX:XX:XX:XX:XX:XX'.
  required DOMString address;

  // The human-readable name of the adapter.
  required DOMString name;

  // Indicates whether or not the adapter has power.
  required boolean powered;

  // Indicates whether or not the adapter is available (i.e. enabled).
  required boolean available;

  // Indicates whether or not the adapter is currently discovering.
  required boolean discovering;
};

// Information about the state of a known Bluetooth device. Note: this
// dictionary is also used in bluetooth_private.idl
dictionary Device {
  // The address of the device, in the format 'XX:XX:XX:XX:XX:XX'.
  required DOMString address;

  // The human-readable name of the device.
  DOMString name;

  // The class of the device, a bit-field defined by
  // http://www.bluetooth.org/en-us/specification/assigned-numbers/baseband.
  long deviceClass;

  // The Device ID record of the device, where available.
  VendorIdSource vendorIdSource;
  long vendorId;
  long productId;
  long deviceId;

  // The type of the device, if recognized by Chrome. This is obtained from
  // the |deviceClass| field and only represents a small fraction of the
  // possible device types. When in doubt you should use the |deviceClass|
  // field directly.
  DeviceType type;

  // Indicates whether or not the device is paired with the system.
  boolean paired;

  // Indicates whether the device is currently connected to the system.
  boolean connected;

  // Indicates whether the device is currently connecting to the system.
  boolean connecting;

  // Indicates whether the device is connectable.
  boolean connectable;

  // UUIDs of protocols, profiles and services advertised by the device.
  // For classic Bluetooth devices, this list is obtained from EIR data and
  // SDP tables. For Low Energy devices, this list is obtained from AD and
  // GATT primary services. For dual mode devices this may be obtained from
  // both.
  sequence<DOMString> uuids;

  // The received signal strength, in dBm. This field is avaliable and valid
  // only during discovery. Outside of discovery it's value is not specified.
  long inquiryRssi;

  // The transmitted power level. This field is avaliable only for LE devices
  // that include this field in AD. It is avaliable and valid only during
  // discovery.
  long inquiryTxPower;

  // The transport type of the bluetooth device.
  Transport transport;

  // The remaining battery of the device.
  long batteryPercentage;
};

dictionary BluetoothFilter {
  // Type of filter to apply to the device list. Default is all.
  FilterType filterType;

  // Maximum number of bluetooth devices to return. Default is 0 (no limit)
  // if unspecified.
  long limit;
};

// |state|: The new state of the adapter.
callback OnAdapterStateChangedListener = undefined(AdapterState state);

interface OnAdapterStateChangedEvent : ExtensionEvent {
  static undefined addListener(OnAdapterStateChangedListener listener);
  static undefined removeListener(OnAdapterStateChangedListener listener);
  static boolean hasListener(OnAdapterStateChangedListener listener);
};

callback OnDeviceAddedListener = undefined(Device device);

interface OnDeviceAddedEvent : ExtensionEvent {
  static undefined addListener(OnDeviceAddedListener listener);
  static undefined removeListener(OnDeviceAddedListener listener);
  static boolean hasListener(OnDeviceAddedListener listener);
};

callback OnDeviceChangedListener = undefined(Device device);

interface OnDeviceChangedEvent : ExtensionEvent {
  static undefined addListener(OnDeviceChangedListener listener);
  static undefined removeListener(OnDeviceChangedListener listener);
  static boolean hasListener(OnDeviceChangedListener listener);
};

callback OnDeviceRemovedListener = undefined(Device device);

interface OnDeviceRemovedEvent : ExtensionEvent {
  static undefined addListener(OnDeviceRemovedListener listener);
  static undefined removeListener(OnDeviceRemovedListener listener);
  static boolean hasListener(OnDeviceRemovedListener listener);
};

// Use the <code>chrome.bluetooth</code> API to connect to a Bluetooth
// device. All functions report failures via chrome.runtime.lastError.
interface Bluetooth {
  // Get information about the Bluetooth adapter.
  // |Returns|: Called with an AdapterState object describing the adapter
  // state.
  // |PromiseValue|: adapterInfo: Object containing the adapter information.
  [requiredCallback] static Promise<AdapterState> getAdapterState();

  // Get information about a Bluetooth device known to the system.
  // |deviceAddress|: Address of device to get.
  // |Returns|: Called with the Device object describing the device.
  // |PromiseValue|: deviceInfo: Object containing the device information.
  [requiredCallback] static Promise<Device> getDevice(DOMString deviceAddress);

  // Get a list of Bluetooth devices known to the system, including paired
  // and recently discovered devices.
  // |filter|: Some criteria to filter the list of returned bluetooth devices.
  // If the filter is not set or set to <code>{}</code>, returned device list
  // will contain all bluetooth devices. Right now this is only supported in
  // ChromeOS, for other platforms, a full list is returned.
  // |Returns|: Called when the search is completed.
  // |PromiseValue|: deviceInfos: Array of object containing device information.
  [requiredCallback] static Promise<sequence<Device>> getDevices(
      optional BluetoothFilter filter);

  // Start discovery. Newly discovered devices will be returned via the
  // onDeviceAdded event. Previously discovered devices already known to
  // the adapter must be obtained using getDevices and will only be updated
  // using the |onDeviceChanged| event if information about them changes.
  //
  // Discovery will fail to start if this application has already called
  // startDiscovery.  Discovery can be resource intensive: stopDiscovery
  // should be called as soon as possible.
  // |Returns|: Called to indicate success or failure.
  static Promise<undefined> startDiscovery();

  // Stop discovery.
  // |Returns|: Called to indicate success or failure.
  static Promise<undefined> stopDiscovery();

  // Fired when the state of the Bluetooth adapter changes.
  static attribute OnAdapterStateChangedEvent onAdapterStateChanged;

  // Fired when information about a new Bluetooth device is available.
  static attribute OnDeviceAddedEvent onDeviceAdded;

  // Fired when information about a known Bluetooth device has changed.
  static attribute OnDeviceChangedEvent onDeviceChanged;

  // Fired when a Bluetooth device that was previously discovered has been
  // out of range for long enough to be considered unavailable again, and
  // when a paired device is removed.
  static attribute OnDeviceRemovedEvent onDeviceRemoved;
};

partial interface Browser {
  static attribute Bluetooth bluetooth;
};