Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(353)

Side by Side Diff: chrome/common/extensions/api/bluetooth_low_energy.idl

Issue 1915243003: API Bindings for GATT server functionality. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@adapter_and_tests
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // The <code>chrome.bluetoothLowEnergy</code> API is used to communicate with 5 // The <code>chrome.bluetoothLowEnergy</code> API is used to communicate with
6 // Bluetooth Smart (Low Energy) devices using the 6 // Bluetooth Smart (Low Energy) devices using the
7 // <a href="https://developer.bluetooth.org/TechnologyOverview/Pages/GATT.aspx"> 7 // <a href="https://developer.bluetooth.org/TechnologyOverview/Pages/GATT.aspx">
8 // Generic Attribute Profile (GATT)</a>. 8 // Generic Attribute Profile (GATT)</a>.
9 namespace bluetoothLowEnergy { 9 namespace bluetoothLowEnergy {
10 // Values representing the possible properties of a characteristic. 10 // Values representing the possible properties of a characteristic.
11 enum CharacteristicProperty {broadcast, read, writeWithoutResponse, write, 11 enum CharacteristicProperty {broadcast, read, writeWithoutResponse, write,
12 notify, indicate, authenticatedSignedWrites, 12 notify, indicate, authenticatedSignedWrites,
13 extendedProperties, reliableWrite, 13 extendedProperties, reliableWrite,
14 writableAuxiliaries}; 14 writableAuxiliaries};
15 15
16 // Type of advertisement. If 'broadcast' is chosen, the sent advertisement 16 // Type of advertisement. If 'broadcast' is chosen, the sent advertisement
17 // type will be ADV_NONCONN_IND and the device will broadcast with a random 17 // type will be ADV_NONCONN_IND and the device will broadcast with a random
18 // MAC Address. If set to 'peripheral', the advertisement type will be 18 // MAC Address. If set to 'peripheral', the advertisement type will be
19 // ADV_IND or ADV_SCAN_IND and the device will broadcast with real Bluetooth 19 // ADV_IND or ADV_SCAN_IND and the device will broadcast with real Bluetooth
20 // Adapter's MAC Address. 20 // Adapter's MAC Address.
21 enum AdvertisementType {broadcast, peripheral}; 21 enum AdvertisementType {broadcast, peripheral};
22 22
23 // Result of a register or unregister service call.
24 enum ServiceResult {
25 // The service operation was successful.
26 success,
27 // The service that is being registered is already regsitered.
28 alreadyRegistered,
29 // The service that is being unregistered is not regsitered.
30 notRegistered
31 };
32
33 // Represents a bluetooth central device that is connected to the local GATT
34 // server.
35 dictionary Device {
36 // The address of the device, in the format 'XX:XX:XX:XX:XX:XX'.
37 DOMString address;
38
39 // The human-readable name of the device.
40 DOMString? name;
41
42 // The class of the device, a bit-field defined by
43 // http://www.bluetooth.org/en-us/specification/assigned-numbers/baseband.
44 long? deviceClass;
45 };
46
23 // Represents a peripheral's Bluetooth GATT Service, a collection of 47 // Represents a peripheral's Bluetooth GATT Service, a collection of
24 // characteristics and relationships to other services that encapsulate 48 // characteristics and relationships to other services that encapsulate
25 // the behavior of part of a device. 49 // the behavior of part of a device.
26 dictionary Service { 50 dictionary Service {
27 // The UUID of the service, e.g. 0000180d-0000-1000-8000-00805f9b34fb. 51 // The UUID of the service, e.g. 0000180d-0000-1000-8000-00805f9b34fb.
28 DOMString uuid; 52 DOMString uuid;
29 53
30 // Indicates whether the type of this service is primary or secondary. 54 // Indicates whether the type of this service is primary or secondary.
31 boolean isPrimary; 55 boolean isPrimary;
32 56
33 // Indicates whether this service represents a local service hosted by the
34 // application and available to other peripherals, or a remote service
35 // hosted and received from a remote peripheral.
36 [nodoc] boolean isLocal;
37
38 // Returns the identifier assigned to this service. Use the instance ID to 57 // Returns the identifier assigned to this service. Use the instance ID to
39 // distinguish between services from a peripheral with the same UUID and 58 // distinguish between services from a peripheral with the same UUID and
40 // to make function calls that take in a service identifier. Present, if 59 // to make function calls that take in a service identifier. Present, if
41 // this instance represents a remote service. 60 // this instance represents a remote service.
42 DOMString? instanceId; 61 DOMString? instanceId;
43 62
44 // The device address of the remote peripheral that the GATT service belongs 63 // The device address of the remote peripheral that the GATT service belongs
45 // to. Present, if this instance represents a remote service. 64 // to. Present, if this instance represents a remote service.
46 DOMString? deviceAddress; 65 DOMString? deviceAddress;
47 }; 66 };
48 67
49 // Represents a GATT characteristic, which is a basic data element that 68 // Represents a GATT characteristic, which is a basic data element that
50 // provides further information about a peripheral's service. 69 // provides further information about a peripheral's service.
51 dictionary Characteristic { 70 dictionary Characteristic {
52 // The UUID of the characteristic, e.g. 71 // The UUID of the characteristic, e.g.
53 // 00002a37-0000-1000-8000-00805f9b34fb. 72 // 00002a37-0000-1000-8000-00805f9b34fb.
54 DOMString uuid; 73 DOMString uuid;
55 74
56 // Indicates whether this characteristic represents a local characteristic
57 // hosted by the application and available to other peripherals, or a remote
58 // characteristic hosted and received from a remote peripheral.
59 [nodoc] boolean isLocal;
60
61 // The GATT service this characteristic belongs to. 75 // The GATT service this characteristic belongs to.
62 Service service; 76 Service? service;
63 77
64 // The properties of this characteristic. 78 // The properties of this characteristic.
65 CharacteristicProperty[] properties; 79 CharacteristicProperty[] properties;
66 80
67 // Returns the identifier assigned to this characteristic. Use the instance 81 // Returns the identifier assigned to this characteristic. Use the instance
68 // ID to distinguish between characteristics from a peripheral with the same 82 // ID to distinguish between characteristics from a peripheral with the same
69 // UUID and to make function calls that take in a characteristic identifier. 83 // UUID and to make function calls that take in a characteristic identifier.
70 // Present, if this instance represents a remote characteristic. 84 // Present, if this instance represents a remote characteristic.
71 DOMString? instanceId; 85 DOMString? instanceId;
72 86
73 // The currently cached characteristic value. This value gets updated when 87 // The currently cached characteristic value. This value gets updated when
74 // the value of the characteristic is read or updated via a notification 88 // the value of the characteristic is read or updated via a notification
75 // or indication. 89 // or indication.
76 ArrayBuffer? value; 90 ArrayBuffer? value;
77 }; 91 };
78 92
79 // Represents a GATT characteristic descriptor, which provides further 93 // Represents a GATT characteristic descriptor, which provides further
80 // information about a characteristic's value. 94 // information about a characteristic's value.
81 dictionary Descriptor { 95 dictionary Descriptor {
82 // The UUID of the characteristic descriptor, e.g. 96 // The UUID of the characteristic descriptor, e.g.
83 // 00002902-0000-1000-8000-00805f9b34fb. 97 // 00002902-0000-1000-8000-00805f9b34fb.
84 DOMString uuid; 98 DOMString uuid;
85 99
86 // Indicates whether this descriptor represents a local descriptor
87 // hosted by the application and available to other peripherals, or a remote
88 // descriptor hosted and received from a remote peripheral.
89 [nodoc] boolean isLocal;
90
91 // The GATT characteristic this descriptor belongs to. 100 // The GATT characteristic this descriptor belongs to.
92 Characteristic characteristic; 101 Characteristic? characteristic;
93 102
94 // Returns the identifier assigned to this descriptor. Use the instance ID 103 // Returns the identifier assigned to this descriptor. Use the instance ID
95 // to distinguish between descriptors from a peripheral with the same UUID 104 // to distinguish between descriptors from a peripheral with the same UUID
96 // and to make function calls that take in a descriptor identifier. Present, 105 // and to make function calls that take in a descriptor identifier. Present,
97 // if this instance represents a remote characteristic. 106 // if this instance represents a remote characteristic.
98 DOMString? instanceId; 107 DOMString? instanceId;
99 108
100 // The currently cached descriptor value. This value gets updated when 109 // The currently cached descriptor value. This value gets updated when
101 // the value of the descriptor is read. 110 // the value of the descriptor is read.
102 ArrayBuffer? value; 111 ArrayBuffer? value;
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 // List of UUIDs to include in the "Solicit UUIDs" field of the Advertising 160 // List of UUIDs to include in the "Solicit UUIDs" field of the Advertising
152 // Data. These UUIDs can be of the 16bit, 32bit or 128 formats. 161 // Data. These UUIDs can be of the 16bit, 32bit or 128 formats.
153 DOMString[]? solicitUuids; 162 DOMString[]? solicitUuids;
154 163
155 // List of service data to be included in "Service Data" fields of the adver tising 164 // List of service data to be included in "Service Data" fields of the adver tising
156 // data. 165 // data.
157 ServiceData[]? serviceData; 166 ServiceData[]? serviceData;
158 }; 167 };
159 168
160 callback CharacteristicCallback = void(Characteristic result); 169 callback CharacteristicCallback = void(Characteristic result);
170 callback CreateCharacteristicCallback = void(DOMString characteristicId);
161 callback CharacteristicsCallback = void(Characteristic[] result); 171 callback CharacteristicsCallback = void(Characteristic[] result);
162 callback DescriptorCallback = void(Descriptor result); 172 callback DescriptorCallback = void(Descriptor result);
173 callback CreateDescriptorCallback = void(DOMString descriptorId);
163 callback DescriptorsCallback = void(Descriptor[] result); 174 callback DescriptorsCallback = void(Descriptor[] result);
164 callback ResultCallback = void(); 175 callback ResultCallback = void();
165 callback ServiceCallback = void(Service result); 176 callback ServiceCallback = void(Service result);
177 callback CreateServiceCallback = void(DOMString serviceId);
166 callback ServicesCallback = void(Service[] result); 178 callback ServicesCallback = void(Service[] result);
179 callback ServiceResultCallback = void(ServiceResult result);
167 callback RegisterAdvertisementCallback = void (long advertisementId); 180 callback RegisterAdvertisementCallback = void (long advertisementId);
181 callback ValueCallback = void(ArrayBuffer value);
168 182
169 // These functions all report failures via chrome.runtime.lastError. 183 // These functions all report failures via chrome.runtime.lastError.
170 interface Functions { 184 interface Functions {
171 // Establishes a connection between the application and the device with the 185 // Establishes a connection between the application and the device with the
172 // given address. A device may be already connected and its GATT services 186 // given address. A device may be already connected and its GATT services
173 // available without calling <code>connect</code>, however, an app that 187 // available without calling <code>connect</code>, however, an app that
174 // wants to access GATT services of a device should call this function to 188 // wants to access GATT services of a device should call this function to
175 // make sure that a connection to the device is maintained. If the device 189 // make sure that a connection to the device is maintained. If the device
176 // is not connected, all GATT services of the device will be discovered 190 // is not connected, all GATT services of the device will be discovered
177 // after a successful call to <code>connect</code>. 191 // after a successful call to <code>connect</code>.
(...skipping 11 matching lines...) Expand all
189 // |deviceAddress| : The Bluetooth address of the remote device. 203 // |deviceAddress| : The Bluetooth address of the remote device.
190 // |callback| : Called when the disconnect request has completed. 204 // |callback| : Called when the disconnect request has completed.
191 static void disconnect(DOMString deviceAddress, 205 static void disconnect(DOMString deviceAddress,
192 optional ResultCallback callback); 206 optional ResultCallback callback);
193 207
194 // Get the GATT service with the given instance ID. 208 // Get the GATT service with the given instance ID.
195 // |serviceId| : The instance ID of the requested GATT service. 209 // |serviceId| : The instance ID of the requested GATT service.
196 // |callback| : Called with the requested Service object. 210 // |callback| : Called with the requested Service object.
197 static void getService(DOMString serviceId, ServiceCallback callback); 211 static void getService(DOMString serviceId, ServiceCallback callback);
198 212
213 // Create a locally hosted GATT service. This service can be registered
214 // to be available on a local GATT server.
215 // |service| : The service to create.
216 // |callback| : Called with the created services's unique ID.
217 static void createService(Service service, CreateServiceCallback callback);
218
199 // Get all the GATT services that were discovered on the remote device with 219 // Get all the GATT services that were discovered on the remote device with
200 // the given device address. 220 // the given device address.
201 // |deviceAddress| : The Bluetooth address of the remote device whose GATT 221 // |deviceAddress| : The Bluetooth address of the remote device whose GATT
202 // services should be returned. 222 // services should be returned.
203 // |callback| : Called with the list of requested Service objects. 223 // |callback| : Called with the list of requested Service objects.
204 static void getServices(DOMString deviceAddress, ServicesCallback callback); 224 static void getServices(DOMString deviceAddress, ServicesCallback callback);
205 225
206 // Get the GATT characteristic with the given instance ID that belongs to 226 // Get the GATT characteristic with the given instance ID that belongs to
207 // the given GATT service, if the characteristic exists. 227 // the given GATT service, if the characteristic exists.
208 // |characteristicId| : The instance ID of the requested GATT 228 // |characteristicId| : The instance ID of the requested GATT
209 // characteristic. 229 // characteristic.
210 // |callback| : Called with the requested Characteristic object. 230 // |callback| : Called with the requested Characteristic object.
211 static void getCharacteristic(DOMString characteristicId, 231 static void getCharacteristic(DOMString characteristicId,
212 CharacteristicCallback callback); 232 CharacteristicCallback callback);
213 233
234 // Create a locally hosted GATT characteristic. This characteristic must
235 // be hosted under a valid service. If the service ID is not valid, the
236 // lastError will be set.
237 // |characteristic| : The characteristic to create.
238 // |serviceId| : ID of the service to create this characteristic for.
239 // |callback| : Called with the created characteristic's unique ID.
240 static void createCharacteristic(Characteristic characteristic,
241 DOMString serviceId,
242 CreateCharacteristicCallback callback);
243
214 // Get a list of all discovered GATT characteristics that belong to the 244 // Get a list of all discovered GATT characteristics that belong to the
215 // given service. 245 // given service.
216 // |serviceId| : The instance ID of the GATT service whose characteristics 246 // |serviceId| : The instance ID of the GATT service whose characteristics
217 // should be returned. 247 // should be returned.
218 // |callback| : Called with the list of characteristics that belong to the 248 // |callback| : Called with the list of characteristics that belong to the
219 // given service. 249 // given service.
220 static void getCharacteristics(DOMString serviceId, 250 static void getCharacteristics(DOMString serviceId,
221 CharacteristicsCallback callback); 251 CharacteristicsCallback callback);
222 252
223 // Get a list of GATT services that are included by the given service. 253 // Get a list of GATT services that are included by the given service.
224 // |serviceId| : The instance ID of the GATT service whose included 254 // |serviceId| : The instance ID of the GATT service whose included
225 // services should be returned. 255 // services should be returned.
226 // |callback| : Called with the list of GATT services included from the 256 // |callback| : Called with the list of GATT services included from the
227 // given service. 257 // given service.
228 static void getIncludedServices(DOMString serviceId, 258 static void getIncludedServices(DOMString serviceId,
229 ServicesCallback callback); 259 ServicesCallback callback);
230 260
231 // Get the GATT characteristic descriptor with the given instance ID. 261 // Get the GATT characteristic descriptor with the given instance ID.
232 // |descriptorId| : The instance ID of the requested GATT characteristic 262 // |descriptorId| : The instance ID of the requested GATT characteristic
233 // descriptor. 263 // descriptor.
234 // |callback| : Called with the requested Descriptor object. 264 // |callback| : Called with the requested Descriptor object.
235 static void getDescriptor(DOMString descriptorId, 265 static void getDescriptor(DOMString descriptorId,
236 DescriptorCallback callback); 266 DescriptorCallback callback);
237 267
268 // Create a locally hosted GATT descriptor. This descriptor must
269 // be hosted under a valid characteristic. If the characteristic ID is not
270 // valid, the lastError will be set.
271 // |descriptor| : The descriptor to create.
272 // |characteristicId| : ID of the characteristic to create this descriptor
273 // for.
274 // |callback| : Called with the created descriptor's unique ID.
275 static void createDescriptor(Descriptor descriptor,
276 DOMString characteristicId,
277 CreateDescriptorCallback callback);
278
238 // Get a list of GATT characteristic descriptors that belong to the given 279 // Get a list of GATT characteristic descriptors that belong to the given
239 // characteristic. 280 // characteristic.
240 // |characteristicId| : The instance ID of the GATT characteristic whose 281 // |characteristicId| : The instance ID of the GATT characteristic whose
241 // descriptors should be returned. 282 // descriptors should be returned.
242 // |callback| : Called with the list of descriptors that belong to the given 283 // |callback| : Called with the list of descriptors that belong to the given
243 // characteristic. 284 // characteristic.
244 static void getDescriptors(DOMString characteristicId, 285 static void getDescriptors(DOMString characteristicId,
245 DescriptorsCallback callback); 286 DescriptorsCallback callback);
246 287
247 // Retrieve the value of a specified characteristic from a remote 288 // Retrieve the value of a specified characteristic from a remote
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 // peripheral. 341 // peripheral.
301 // |descriptorId| : The instance ID of the GATT characteristic descriptor 342 // |descriptorId| : The instance ID of the GATT characteristic descriptor
302 // whose value should be written to. 343 // whose value should be written to.
303 // |value| : The value that should be sent to the remote descriptor as part 344 // |value| : The value that should be sent to the remote descriptor as part
304 // of the write request. 345 // of the write request.
305 // |callback| : Called when the write request has completed. 346 // |callback| : Called when the write request has completed.
306 static void writeDescriptorValue(DOMString descriptorId, 347 static void writeDescriptorValue(DOMString descriptorId,
307 ArrayBuffer value, 348 ArrayBuffer value,
308 ResultCallback callback); 349 ResultCallback callback);
309 350
351 // Register the given service with the local GATT server. If the service
352 // ID is invalid, the lastError will be set.
353 // |serviceId| : Unique ID of a created service.
354 // |callback| : Callback with the result of the register operation.
355 static void registerService(DOMString serviceId,
356 ServiceResultCallback callback);
357
358 // Unregister the given service with the local GATT server. If the service
359 // ID is invalid, the lastError will be set.
360 // |serviceId| : Unique ID of a current registered service.
361 // |callback| : Callback with the result of the register operation.
362 static void unregisterService(DOMString serviceId,
363 ServiceResultCallback callback);
364
310 // Create an advertisement and register it for advertising. To call this 365 // Create an advertisement and register it for advertising. To call this
311 // function, the app must have the bluetooth:low_energy and 366 // function, the app must have the bluetooth:low_energy and
312 // bluetooth:peripheral permissions set to true. Additionally this API 367 // bluetooth:peripheral permissions set to true. Additionally this API
313 // is only available to auto launched apps in Kiosk Mode of by setting 368 // is only available to auto launched apps in Kiosk Mode of by setting
314 // the 'enable-ble-advertising-in-apps' flag. 369 // the 'enable-ble-advertising-in-apps' flag.
315 // See https://developer.chrome.com/apps/manifest/bluetooth 370 // See https://developer.chrome.com/apps/manifest/bluetooth
316 // Note: On some hardware, central and peripheral modes at the same time is 371 // Note: On some hardware, central and peripheral modes at the same time is
317 // supported but on hardware that doesn't support this, making this call 372 // supported but on hardware that doesn't support this, making this call
318 // will switch the device to peripheral mode. In the case of hardware which 373 // will switch the device to peripheral mode. In the case of hardware which
319 // does not support both central and peripheral mode, attempting to use the 374 // does not support both central and peripheral mode, attempting to use the
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
360 // |characteristic| : The GATT characteristic whose value has changed. 415 // |characteristic| : The GATT characteristic whose value has changed.
361 static void onCharacteristicValueChanged(Characteristic characteristic); 416 static void onCharacteristicValueChanged(Characteristic characteristic);
362 417
363 // Fired when the value of a remote GATT characteristic descriptor changes, 418 // Fired when the value of a remote GATT characteristic descriptor changes,
364 // usually as a result of a read request. This event exists 419 // usually as a result of a read request. This event exists
365 // mostly for convenience and will always be sent after a successful 420 // mostly for convenience and will always be sent after a successful
366 // call to $(ref:readDescriptorValue). 421 // call to $(ref:readDescriptorValue).
367 // |descriptor| : The GATT characteristic descriptor whose value has 422 // |descriptor| : The GATT characteristic descriptor whose value has
368 // changed. 423 // changed.
369 static void onDescriptorValueChanged(Descriptor descriptor); 424 static void onDescriptorValueChanged(Descriptor descriptor);
425
426 // Fired when a connected central device requests to read the value of a
427 // characteristic registered on the local GATT server.
428 // Calling both the valueCallback and errorCallback will have undefined
429 // results. Calling neither will cause a timeout and the device may
430 // disconnect.
431 // |device| : The bluetooth device that is requesting this read.
432 // |characteristic| : The GATT characteristic whose value is requested.
433 // |valueCallback| : Callback to call with the value.
434 // |errorCallback| : Callback to call if the read failed.
435 static void onCharacteristicReadRequest(
436 Device device, Characteristic characteristic,
437 ValueCallback valueCallback, ResultCallback errorCallback);
438
439 // Fired when a connected central device requests to write the value of a
440 // characteristic registered on the local GATT server.
441 // Calling both the successCallback and errorCallback will have undefined
442 // results. Calling neither will cause a timeout and the device may
443 // disconnect.
444 // |device| : The bluetooth device that is requesting this write.
445 // |characteristic| : The GATT characteristic whose value is being written.
446 // |successCallback| : Callback to call if the write was successful.
447 // |errorCallback| : Callback to call if the write failed.
448 static void onCharacteristicWriteRequest(
449 Device device, Characteristic characteristic, ArrayBuffer value,
450 ResultCallback successCallback, ResultCallback errorCallback);
451
452 // Fired when a connected central device requests to read the value of a
453 // descriptor registered on the local GATT server.
454 // Calling both the valueCallback and errorCallback will have undefined
455 // results. Calling neither will cause a timeout and the device may
456 // disconnect.
457 // |device| : The bluetooth device that is requesting this read.
458 // |descriptor| : The GATT descriptor whose value is requested.
459 // |valueCallback| : Callback to call with the value.
460 // |errorCallback| : Callback to call if the read failed.
461 static void onDescriptorReadRequest(
462 Device device, Descriptor descriptor, ValueCallback valueCallback,
463 ResultCallback errorCallback);
464
465 // Fired when a connected central device requests to write the value of a
466 // descriptor registered on the local GATT server.
467 // Calling both the successCallback and errorCallback will have undefined
468 // results. Calling neither will cause a timeout and the device may
469 // disconnect.
470 // |device| : The bluetooth device that is requesting this write.
471 // |descriptor| : The GATT descriptor whose value is being written.
472 // |successCallback| : Callback to call if the write was successful.
473 // |errorCallback| : Callback to call if the write failed.
474 static void onDescriptorWriteRequest(
475 Device device, Descriptor descriptor, ArrayBuffer value,
476 ResultCallback successCallback, ResultCallback errorCallback);
477
370 }; 478 };
371 }; 479 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698