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. |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
101 callback CharacteristicCallback = void(Characteristic result); | 101 callback CharacteristicCallback = void(Characteristic result); |
102 callback CharacteristicsCallback = void(Characteristic[] result); | 102 callback CharacteristicsCallback = void(Characteristic[] result); |
103 callback DescriptorCallback = void(Descriptor result); | 103 callback DescriptorCallback = void(Descriptor result); |
104 callback DescriptorsCallback = void(Descriptor[] result); | 104 callback DescriptorsCallback = void(Descriptor[] result); |
105 callback ResultCallback = void(); | 105 callback ResultCallback = void(); |
106 callback ServiceCallback = void(Service result); | 106 callback ServiceCallback = void(Service result); |
107 callback ServicesCallback = void(Service[] result); | 107 callback ServicesCallback = void(Service[] result); |
108 | 108 |
109 // These functions all report failures via chrome.runtime.lastError. | 109 // These functions all report failures via chrome.runtime.lastError. |
110 interface Functions { | 110 interface Functions { |
111 // Establishes a connection between the application and the device with the | |
112 // given address. A device may be already connected and its GATT services | |
113 // available without calling <code>connect</code>, however, an app that | |
114 // wants to access GATT services of a device should call this function to | |
115 // make sure that a connection to the device is maintained. If the device | |
116 // is not connected, all GATT services of the device will be discovered | |
117 // after a successful call to <code>connect</code>. | |
118 // |deviceAddress| : The Bluetooth address of the remote device to which a | |
119 // GATT connection should be opened. | |
120 // |callback| : Called when the connect request has completed. | |
121 static void connect(DOMString deviceAddress, ResultCallback callback); | |
122 | |
123 // Closes the app's connection to the device with the given address. Note | |
124 // that this will not always destroy the physical link itself, since there | |
125 // may be other apps with open connections. | |
126 static void disconnect(DOMString deviceAddress, ResultCallback callback); | |
keybuk
2014/06/19 17:23:49
Make the disconnect callback optional for consiste
armansito
2014/06/19 21:58:34
Done.
| |
127 | |
111 // Get the GATT service with the given instance ID. | 128 // Get the GATT service with the given instance ID. |
112 // |serviceId| : The instance ID of the requested GATT service. | 129 // |serviceId| : The instance ID of the requested GATT service. |
113 // |callback| : Called with the requested Service object. | 130 // |callback| : Called with the requested Service object. |
114 static void getService(DOMString serviceId, ServiceCallback callback); | 131 static void getService(DOMString serviceId, ServiceCallback callback); |
115 | 132 |
116 // Get all the GATT services that were discovered on the remote device with | 133 // Get all the GATT services that were discovered on the remote device with |
117 // the given device address. | 134 // the given device address. |
118 // |deviceAddress| : The Bluetooth Address of the remote device whose GATT | 135 // |deviceAddress| : The Bluetooth address of the remote device whose GATT |
119 // services should be returned. | 136 // services should be returned. |
120 // |callback| : Called with the list of requested Service objects. | 137 // |callback| : Called with the list of requested Service objects. |
121 static void getServices(DOMString deviceAddress, ServicesCallback callback); | 138 static void getServices(DOMString deviceAddress, ServicesCallback callback); |
122 | 139 |
123 // Get the GATT characteristic with the given instance ID that belongs to | 140 // Get the GATT characteristic with the given instance ID that belongs to |
124 // the given GATT service, if the characteristic exists. | 141 // the given GATT service, if the characteristic exists. |
125 // |characteristicId| : The instance ID of the requested GATT | 142 // |characteristicId| : The instance ID of the requested GATT |
126 // characteristic. | 143 // characteristic. |
127 // |callback| : Called with the requested Characteristic object. | 144 // |callback| : Called with the requested Characteristic object. |
128 static void getCharacteristic(DOMString characteristicId, | 145 static void getCharacteristic(DOMString characteristicId, |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
227 // |characteristic| : The GATT characteristic whose value has changed. | 244 // |characteristic| : The GATT characteristic whose value has changed. |
228 static void onCharacteristicValueChanged(Characteristic characteristic); | 245 static void onCharacteristicValueChanged(Characteristic characteristic); |
229 | 246 |
230 // Fired when the value of a remote GATT characteristic descriptor changes, | 247 // Fired when the value of a remote GATT characteristic descriptor changes, |
231 // usually as a result of a read or write request. | 248 // usually as a result of a read or write request. |
232 // |descriptor| : The GATT characteristic descriptor whose value has | 249 // |descriptor| : The GATT characteristic descriptor whose value has |
233 // changed. | 250 // changed. |
234 static void onDescriptorValueChanged(Descriptor descriptor); | 251 static void onDescriptorValueChanged(Descriptor descriptor); |
235 }; | 252 }; |
236 }; | 253 }; |
OLD | NEW |