Don't show supervised user as "already on this device" while they're being imported.
[chromium-blink-merge.git] / extensions / common / api / bluetooth_low_energy.idl
blob63c45ed06ed4efb357a8a94cf242f72d9bb0de36
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 // The <code>chrome.bluetoothLowEnergy</code> API is used to communicate with
6 // Bluetooth Smart (Low Energy) devices using the
7 // <a href="https://developer.bluetooth.org/TechnologyOverview/Pages/GATT.aspx">
8 // Generic Attribute Profile (GATT)</a>.
9 namespace bluetoothLowEnergy {
10 // Values representing the possible properties of a characteristic.
11 enum CharacteristicProperty {broadcast, read, writeWithoutResponse, write,
12 notify, indicate, authenticatedSignedWrites,
13 extendedProperties, reliableWrite,
14 writableAuxiliaries};
16 // Type of advertisement. If 'broadcast' is chosen, the sent advertisement
17 // type will be ADV_NONCONN_IND. If set to 'peripheral', the advertisement
18 // type will be ADV_IND or ADV_SCAN_IND.
19 [nodoc] enum AdvertisementType {broadcast, peripheral};
21 // Represents a peripheral's Bluetooth GATT Service, a collection of
22 // characteristics and relationships to other services that encapsulate
23 // the behavior of part of a device.
24 dictionary Service {
25 // The UUID of the service, e.g. 0000180d-0000-1000-8000-00805f9b34fb.
26 DOMString uuid;
28 // Indicates whether the type of this service is primary or secondary.
29 boolean isPrimary;
31 // Indicates whether this service represents a local service hosted by the
32 // application and available to other peripherals, or a remote service
33 // hosted and received from a remote peripheral.
34 [nodoc] boolean isLocal;
36 // Returns the identifier assigned to this service. Use the instance ID to
37 // distinguish between services from a peripheral with the same UUID and
38 // to make function calls that take in a service identifier. Present, if
39 // this instance represents a remote service.
40 DOMString? instanceId;
42 // The device address of the remote peripheral that the GATT service belongs
43 // to. Present, if this instance represents a remote service.
44 DOMString? deviceAddress;
47 // Represents a GATT characteristic, which is a basic data element that
48 // provides further information about a peripheral's service.
49 dictionary Characteristic {
50 // The UUID of the characteristic, e.g.
51 // 00002a37-0000-1000-8000-00805f9b34fb.
52 DOMString uuid;
54 // Indicates whether this characteristic represents a local characteristic
55 // hosted by the application and available to other peripherals, or a remote
56 // characteristic hosted and received from a remote peripheral.
57 [nodoc] boolean isLocal;
59 // The GATT service this characteristic belongs to.
60 Service service;
62 // The properties of this characteristic.
63 CharacteristicProperty[] properties;
65 // Returns the identifier assigned to this characteristic. Use the instance
66 // ID to distinguish between characteristics from a peripheral with the same
67 // UUID and to make function calls that take in a characteristic identifier.
68 // Present, if this instance represents a remote characteristic.
69 DOMString? instanceId;
71 // The currently cached characteristic value. This value gets updated when
72 // the value of the characteristic is read or updated via a notification
73 // or indication.
74 ArrayBuffer? value;
77 // Represents a GATT characteristic descriptor, which provides further
78 // information about a characteristic's value.
79 dictionary Descriptor {
80 // The UUID of the characteristic descriptor, e.g.
81 // 00002902-0000-1000-8000-00805f9b34fb.
82 DOMString uuid;
84 // Indicates whether this descriptor represents a local descriptor
85 // hosted by the application and available to other peripherals, or a remote
86 // descriptor hosted and received from a remote peripheral.
87 [nodoc] boolean isLocal;
89 // The GATT characteristic this descriptor belongs to.
90 Characteristic characteristic;
92 // Returns the identifier assigned to this descriptor. Use the instance ID
93 // to distinguish between descriptors from a peripheral with the same UUID
94 // and to make function calls that take in a descriptor identifier. Present,
95 // if this instance represents a remote characteristic.
96 DOMString? instanceId;
98 // The currently cached descriptor value. This value gets updated when
99 // the value of the descriptor is read.
100 ArrayBuffer? value;
103 // The connection properties specified during a call to $(ref:connect).
104 dictionary ConnectProperties {
105 // Flag indicating whether a connection to the device is left open when the
106 // event page of the application is unloaded (see <a
107 // href="http://developer.chrome.com/apps/app_lifecycle.html">Manage App
108 // Lifecycle</a>). The default value is <code>false.</code>
109 boolean persistent;
112 // Optional characteristic notification session properties specified during a
113 // call to $(ref:startCharacteristicNotifications).
114 dictionary NotificationProperties {
115 // Flag indicating whether the app should receive notifications when the
116 // event page of the application is unloaded (see <a
117 // href="http://developer.chrome.com/apps/app_lifecycle.html">Manage App
118 // Lifecycle</a>). The default value is <code>false</code>.
119 boolean persistent;
122 // Represents an entry of the "Manufacturer Specific Data" field of Bluetooth
123 // LE advertisement data.
124 [nodoc] dictionary ManufacturerData {
125 long id;
126 long[] data;
129 // Represents an entry of the "Service Data" field of Bluetooth LE advertisement
130 // data.
131 [nodoc] dictionary ServiceData {
132 DOMString uuid;
133 long[] data;
136 // Represents a Bluetooth LE advertisement instance.
137 [nodoc] dictionary Advertisement {
138 // Type of advertisement.
139 AdvertisementType type;
141 // List of UUIDs to include in the "Service UUIDs" field of the Advertising
142 // Data. These UUIDs can be of the 16bit, 32bit or 128 formats.
143 DOMString[]? serviceUuids;
145 // List of manufacturer specific data to be included in "Manufacturer Specific
146 // Data" fields of the advertising data.
147 ManufacturerData[]? manufacturerData;
149 // List of UUIDs to include in the "Solicit UUIDs" field of the Advertising
150 // Data. These UUIDs can be of the 16bit, 32bit or 128 formats.
151 DOMString[]? solicitUuids;
153 // List of service data to be included in "Service Data" fields of the advertising
154 // data.
155 ServiceData[]? serviceData;
158 callback CharacteristicCallback = void(Characteristic result);
159 callback CharacteristicsCallback = void(Characteristic[] result);
160 callback DescriptorCallback = void(Descriptor result);
161 callback DescriptorsCallback = void(Descriptor[] result);
162 callback ResultCallback = void();
163 callback ServiceCallback = void(Service result);
164 callback ServicesCallback = void(Service[] result);
165 callback RegisterAdvertisementCallback = void (long advertisementId);
167 // These functions all report failures via chrome.runtime.lastError.
168 interface Functions {
169 // Establishes a connection between the application and the device with the
170 // given address. A device may be already connected and its GATT services
171 // available without calling <code>connect</code>, however, an app that
172 // wants to access GATT services of a device should call this function to
173 // make sure that a connection to the device is maintained. If the device
174 // is not connected, all GATT services of the device will be discovered
175 // after a successful call to <code>connect</code>.
176 // |deviceAddress| : The Bluetooth address of the remote device to which a
177 // GATT connection should be opened.
178 // |properties| : Connection properties (optional).
179 // |callback| : Called when the connect request has completed.
180 static void connect(DOMString deviceAddress,
181 optional ConnectProperties properties,
182 ResultCallback callback);
184 // Closes the app's connection to the device with the given address. Note
185 // that this will not always destroy the physical link itself, since there
186 // may be other apps with open connections.
187 // |deviceAddress| : The Bluetooth address of the remote device.
188 // |callback| : Called when the disconnect request has completed.
189 static void disconnect(DOMString deviceAddress,
190 optional ResultCallback callback);
192 // Get the GATT service with the given instance ID.
193 // |serviceId| : The instance ID of the requested GATT service.
194 // |callback| : Called with the requested Service object.
195 static void getService(DOMString serviceId, ServiceCallback callback);
197 // Get all the GATT services that were discovered on the remote device with
198 // the given device address.
199 // |deviceAddress| : The Bluetooth address of the remote device whose GATT
200 // services should be returned.
201 // |callback| : Called with the list of requested Service objects.
202 static void getServices(DOMString deviceAddress, ServicesCallback callback);
204 // Get the GATT characteristic with the given instance ID that belongs to
205 // the given GATT service, if the characteristic exists.
206 // |characteristicId| : The instance ID of the requested GATT
207 // characteristic.
208 // |callback| : Called with the requested Characteristic object.
209 static void getCharacteristic(DOMString characteristicId,
210 CharacteristicCallback callback);
212 // Get a list of all discovered GATT characteristics that belong to the
213 // given service.
214 // |serviceId| : The instance ID of the GATT service whose characteristics
215 // should be returned.
216 // |callback| : Called with the list of characteristics that belong to the
217 // given service.
218 static void getCharacteristics(DOMString serviceId,
219 CharacteristicsCallback callback);
221 // Get a list of GATT services that are included by the given service.
222 // |serviceId| : The instance ID of the GATT service whose included
223 // services should be returned.
224 // |callback| : Called with the list of GATT services included from the
225 // given service.
226 static void getIncludedServices(DOMString serviceId,
227 ServicesCallback callback);
229 // Get the GATT characteristic descriptor with the given instance ID.
230 // |descriptorId| : The instance ID of the requested GATT characteristic
231 // descriptor.
232 // |callback| : Called with the requested Descriptor object.
233 static void getDescriptor(DOMString descriptorId,
234 DescriptorCallback callback);
236 // Get a list of GATT characteristic descriptors that belong to the given
237 // characteristic.
238 // |characteristicId| : The instance ID of the GATT characteristic whose
239 // descriptors should be returned.
240 // |callback| : Called with the list of descriptors that belong to the given
241 // characteristic.
242 static void getDescriptors(DOMString characteristicId,
243 DescriptorsCallback callback);
245 // Retrieve the value of a specified characteristic from a remote
246 // peripheral.
247 // |characteristicId| : The instance ID of the GATT characteristic whose
248 // value should be read from the remote device.
249 // |callback| : Called with the Characteristic object whose value was
250 // requested. The <code>value</code> field of the returned Characteristic
251 // object contains the result of the read request.
252 static void readCharacteristicValue(DOMString characteristicId,
253 CharacteristicCallback callback);
255 // Write the value of a specified characteristic from a remote peripheral.
256 // |characteristicId| : The instance ID of the GATT characteristic whose
257 // value should be written to.
258 // |value| : The value that should be sent to the remote characteristic as
259 // part of the write request.
260 // |callback| : Called when the write request has completed.
261 static void writeCharacteristicValue(DOMString characteristicId,
262 ArrayBuffer value,
263 ResultCallback callback);
265 // Enable value notifications/indications from the specified characteristic.
266 // Once enabled, an application can listen to notifications using the
267 // $(ref:onCharacteristicValueChanged) event.
268 // |characteristicId| : The instance ID of the GATT characteristic that
269 // notifications should be enabled on.
270 // |properties| : Notification session properties (optional).
271 // |callback| : Called when the request has completed.
272 static void startCharacteristicNotifications(
273 DOMString characteristicId,
274 optional NotificationProperties properties,
275 ResultCallback callback);
277 // Disable value notifications/indications from the specified
278 // characteristic. After a successful call, the application will stop
279 // receiving notifications/indications from this characteristic.
280 // |characteristicId| : The instance ID of the GATT characteristic on which
281 // this app's notification session should be stopped.
282 // |callback| : Called when the request has completed (optional).
283 static void stopCharacteristicNotifications(
284 DOMString characteristicId,
285 optional ResultCallback callback);
287 // Retrieve the value of a specified characteristic descriptor from a remote
288 // peripheral.
289 // |descriptorId| : The instance ID of the GATT characteristic descriptor
290 // whose value should be read from the remote device.
291 // |callback| : Called with the Descriptor object whose value was requested.
292 // The <code>value</code> field of the returned Descriptor object contains
293 // the result of the read request.
294 static void readDescriptorValue(DOMString descriptorId,
295 DescriptorCallback callback);
297 // Write the value of a specified characteristic descriptor from a remote
298 // peripheral.
299 // |descriptorId| : The instance ID of the GATT characteristic descriptor
300 // whose value should be written to.
301 // |value| : The value that should be sent to the remote descriptor as part
302 // of the write request.
303 // |callback| : Called when the write request has completed.
304 static void writeDescriptorValue(DOMString descriptorId,
305 ArrayBuffer value,
306 ResultCallback callback);
308 // Create an advertisement and register it for advertising. To call this
309 // function, the app must have the bluetooth:low_energy and
310 // bluetooth:peripheral permissions set to true.
311 // See https://developer.chrome.com/apps/manifest/bluetooth
312 // Note: On some hardware central and peripheral modes at the same time is
313 // supported but on hardware that doesn't support this, making this call
314 // will switch the device to peripheral mode. In the case of hardware which
315 // does not support both central and peripheral mode, attempting to use the
316 // device in both modes will lead to undefined behavior or prevent other
317 // central-role applications from behaving correctly (including the
318 // discovery of Bluetooth Low Energy devices).
319 // |advertisement| : The advertisement to advertise.
320 // |callback| : Called once the registeration is done and we've started
321 // advertising. Returns the id of the created advertisement.
322 [nodoc] static void registerAdvertisement(
323 Advertisement advertisement, RegisterAdvertisementCallback callback);
325 // Unregisters an advertisement and stops its advertising.
326 // |advertisementId| : Id of the advertisement to unregister.
327 // |callback| : Called once the advertisement is unregistered and is no
328 // longer being advertised.
329 [nodoc] static void unregisterAdvertisement(long advertisementId,
330 ResultCallback callback);
333 interface Events {
334 // Fired whan a new GATT service has been discovered on a remote device.
335 // |service| : The GATT service that was added.
336 static void onServiceAdded(Service service);
338 // Fired when the state of a remote GATT service changes. This involves any
339 // characteristics and/or descriptors that get added or removed from the
340 // service, as well as "ServiceChanged" notifications from the remote
341 // device.
342 // |service| : The GATT service whose state has changed.
343 static void onServiceChanged(Service service);
345 // Fired when a GATT service that was previously discovered on a remote
346 // device has been removed.
347 // |service| : The GATT service that was removed.
348 static void onServiceRemoved(Service service);
350 // Fired when the value of a remote GATT characteristic changes, either as
351 // a result of a read request, or a value change notification/indication
352 // This event will only be sent if the app has enabled notifications by
353 // calling $(ref:startCharacteristicNotifications).
354 // |characteristic| : The GATT characteristic whose value has changed.
355 static void onCharacteristicValueChanged(Characteristic characteristic);
357 // Fired when the value of a remote GATT characteristic descriptor changes,
358 // usually as a result of a read request. This event exists
359 // mostly for convenience and will always be sent after a successful
360 // call to $(ref:readDescriptorValue).
361 // |descriptor| : The GATT characteristic descriptor whose value has
362 // changed.
363 static void onDescriptorValueChanged(Descriptor descriptor);