OLD | NEW |
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 |
| 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}; |
| 20 |
16 // Represents a peripheral's Bluetooth GATT Service, a collection of | 21 // Represents a peripheral's Bluetooth GATT Service, a collection of |
17 // characteristics and relationships to other services that encapsulate | 22 // characteristics and relationships to other services that encapsulate |
18 // the behavior of part of a device. | 23 // the behavior of part of a device. |
19 dictionary Service { | 24 dictionary Service { |
20 // The UUID of the service, e.g. 0000180d-0000-1000-8000-00805f9b34fb. | 25 // The UUID of the service, e.g. 0000180d-0000-1000-8000-00805f9b34fb. |
21 DOMString uuid; | 26 DOMString uuid; |
22 | 27 |
23 // Indicates whether the type of this service is primary or secondary. | 28 // Indicates whether the type of this service is primary or secondary. |
24 boolean isPrimary; | 29 boolean isPrimary; |
25 | 30 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 // Optional characteristic notification session properties specified during a | 112 // Optional characteristic notification session properties specified during a |
108 // call to $(ref:startCharacteristicNotifications). | 113 // call to $(ref:startCharacteristicNotifications). |
109 dictionary NotificationProperties { | 114 dictionary NotificationProperties { |
110 // Flag indicating whether the app should receive notifications when the | 115 // Flag indicating whether the app should receive notifications when the |
111 // event page of the application is unloaded (see <a | 116 // event page of the application is unloaded (see <a |
112 // href="http://developer.chrome.com/apps/app_lifecycle.html">Manage App | 117 // href="http://developer.chrome.com/apps/app_lifecycle.html">Manage App |
113 // Lifecycle</a>). The default value is <code>false</code>. | 118 // Lifecycle</a>). The default value is <code>false</code>. |
114 boolean persistent; | 119 boolean persistent; |
115 }; | 120 }; |
116 | 121 |
| 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; |
| 127 }; |
| 128 |
| 129 // Represents an entry of the "Service Data" field of Bluetooth LE advertiseme
nt |
| 130 // data. |
| 131 [nodoc] dictionary ServiceData { |
| 132 DOMString uuid; |
| 133 long[] data; |
| 134 }; |
| 135 |
| 136 // Represents a Bluetooth LE advertisement instance. |
| 137 [nodoc] dictionary Advertisement { |
| 138 // Type of advertisement. |
| 139 AdvertisementType type; |
| 140 |
| 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; |
| 144 |
| 145 // List of manufacturer specific data to be included in "Manufacturer Specif
ic |
| 146 // Data" fields of the advertising data. |
| 147 ManufacturerData[]? manufacturerData; |
| 148 |
| 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; |
| 152 |
| 153 // List of service data to be included in "Service Data" fields of the adver
tising |
| 154 // data. |
| 155 ServiceData[]? serviceData; |
| 156 }; |
| 157 |
117 callback CharacteristicCallback = void(Characteristic result); | 158 callback CharacteristicCallback = void(Characteristic result); |
118 callback CharacteristicsCallback = void(Characteristic[] result); | 159 callback CharacteristicsCallback = void(Characteristic[] result); |
119 callback DescriptorCallback = void(Descriptor result); | 160 callback DescriptorCallback = void(Descriptor result); |
120 callback DescriptorsCallback = void(Descriptor[] result); | 161 callback DescriptorsCallback = void(Descriptor[] result); |
121 callback ResultCallback = void(); | 162 callback ResultCallback = void(); |
122 callback ServiceCallback = void(Service result); | 163 callback ServiceCallback = void(Service result); |
123 callback ServicesCallback = void(Service[] result); | 164 callback ServicesCallback = void(Service[] result); |
| 165 callback RegisterAdvertisementCallback = void (long advertisementId); |
124 | 166 |
125 // These functions all report failures via chrome.runtime.lastError. | 167 // These functions all report failures via chrome.runtime.lastError. |
126 interface Functions { | 168 interface Functions { |
127 // Establishes a connection between the application and the device with the | 169 // Establishes a connection between the application and the device with the |
128 // given address. A device may be already connected and its GATT services | 170 // given address. A device may be already connected and its GATT services |
129 // available without calling <code>connect</code>, however, an app that | 171 // available without calling <code>connect</code>, however, an app that |
130 // wants to access GATT services of a device should call this function to | 172 // wants to access GATT services of a device should call this function to |
131 // make sure that a connection to the device is maintained. If the device | 173 // make sure that a connection to the device is maintained. If the device |
132 // is not connected, all GATT services of the device will be discovered | 174 // is not connected, all GATT services of the device will be discovered |
133 // after a successful call to <code>connect</code>. | 175 // after a successful call to <code>connect</code>. |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
255 // Write the value of a specified characteristic descriptor from a remote | 297 // Write the value of a specified characteristic descriptor from a remote |
256 // peripheral. | 298 // peripheral. |
257 // |descriptorId| : The instance ID of the GATT characteristic descriptor | 299 // |descriptorId| : The instance ID of the GATT characteristic descriptor |
258 // whose value should be written to. | 300 // whose value should be written to. |
259 // |value| : The value that should be sent to the remote descriptor as part | 301 // |value| : The value that should be sent to the remote descriptor as part |
260 // of the write request. | 302 // of the write request. |
261 // |callback| : Called when the write request has completed. | 303 // |callback| : Called when the write request has completed. |
262 static void writeDescriptorValue(DOMString descriptorId, | 304 static void writeDescriptorValue(DOMString descriptorId, |
263 ArrayBuffer value, | 305 ArrayBuffer value, |
264 ResultCallback callback); | 306 ResultCallback callback); |
| 307 |
| 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); |
| 324 |
| 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); |
265 }; | 331 }; |
266 | 332 |
267 interface Events { | 333 interface Events { |
268 // Fired whan a new GATT service has been discovered on a remote device. | 334 // Fired whan a new GATT service has been discovered on a remote device. |
269 // |service| : The GATT service that was added. | 335 // |service| : The GATT service that was added. |
270 static void onServiceAdded(Service service); | 336 static void onServiceAdded(Service service); |
271 | 337 |
272 // Fired when the state of a remote GATT service changes. This involves any | 338 // Fired when the state of a remote GATT service changes. This involves any |
273 // characteristics and/or descriptors that get added or removed from the | 339 // characteristics and/or descriptors that get added or removed from the |
274 // service, as well as "ServiceChanged" notifications from the remote | 340 // service, as well as "ServiceChanged" notifications from the remote |
(...skipping 15 matching lines...) Expand all Loading... |
290 | 356 |
291 // Fired when the value of a remote GATT characteristic descriptor changes, | 357 // Fired when the value of a remote GATT characteristic descriptor changes, |
292 // usually as a result of a read request. This event exists | 358 // usually as a result of a read request. This event exists |
293 // mostly for convenience and will always be sent after a successful | 359 // mostly for convenience and will always be sent after a successful |
294 // call to $(ref:readDescriptorValue). | 360 // call to $(ref:readDescriptorValue). |
295 // |descriptor| : The GATT characteristic descriptor whose value has | 361 // |descriptor| : The GATT characteristic descriptor whose value has |
296 // changed. | 362 // changed. |
297 static void onDescriptorValueChanged(Descriptor descriptor); | 363 static void onDescriptorValueChanged(Descriptor descriptor); |
298 }; | 364 }; |
299 }; | 365 }; |
OLD | NEW |