OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Use the <code>chrome.bluetooth</code> API to connect to a Bluetooth | 5 // Use the <code>chrome.bluetooth</code> API to connect to a Bluetooth |
6 // device. All functions report failures via chrome.runtime.lastError. | 6 // device. All functions report failures via chrome.runtime.lastError. |
7 namespace bluetooth { | 7 namespace bluetooth { |
8 dictionary AdapterState { | 8 dictionary AdapterState { |
9 // The address of the adapter, in the format 'XX:XX:XX:XX:XX:XX'. | 9 // The address of the adapter, in the format 'XX:XX:XX:XX:XX:XX'. |
10 DOMString address; | 10 DOMString address; |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
97 | 97 |
98 // Simple Pairing Randomizer R. | 98 // Simple Pairing Randomizer R. |
99 // Always 16 octets long. | 99 // Always 16 octets long. |
100 ArrayBuffer randomizer; | 100 ArrayBuffer randomizer; |
101 }; | 101 }; |
102 | 102 |
103 callback AdapterStateCallback = void(AdapterState result); | 103 callback AdapterStateCallback = void(AdapterState result); |
104 callback AddressCallback = void (DOMString result); | 104 callback AddressCallback = void (DOMString result); |
105 callback BooleanCallback = void (boolean result); | 105 callback BooleanCallback = void (boolean result); |
106 callback DataCallback = void (optional ArrayBuffer result); | 106 callback DataCallback = void (optional ArrayBuffer result); |
107 callback DeviceCallback = void (Device device); | |
108 callback DevicesCallback = void (Device[] result); | 107 callback DevicesCallback = void (Device[] result); |
109 callback NameCallback = void (DOMString result); | 108 callback NameCallback = void (DOMString result); |
110 callback OutOfBandPairingDataCallback = void (OutOfBandPairingData data); | 109 callback OutOfBandPairingDataCallback = void (OutOfBandPairingData data); |
111 callback ProfilesCallback = void(Profile[] result); | 110 callback ProfilesCallback = void(Profile[] result); |
112 callback ResultCallback = void (); | 111 callback ResultCallback = void (); |
113 callback ServicesCallback = void(ServiceRecord[] result); | 112 callback ServicesCallback = void(ServiceRecord[] result); |
114 callback SizeCallback = void (long result); | 113 callback SizeCallback = void (long result); |
115 callback SocketCallback = void (Socket result); | 114 callback SocketCallback = void (Socket result); |
116 | 115 |
117 // Options for the getDevices function. If |profile| is not provided, all | |
118 // devices known to the system are returned. | |
119 dictionary GetDevicesOptions { | |
120 // Only devices providing |profile| will be returned. | |
121 Profile? profile; | |
122 | |
123 // Called for each matching device. Note that a service discovery request | |
124 // must be made to each non-matching device before it can be definitively | |
125 // excluded. This can take some time. | |
126 DeviceCallback deviceCallback; | |
127 }; | |
128 | |
129 // Options for the getProfiles function. | 116 // Options for the getProfiles function. |
130 dictionary GetProfilesOptions { | 117 dictionary GetProfilesOptions { |
131 // The remote Bluetooth device to retrieve the exported profiles list from. | 118 // The remote Bluetooth device to retrieve the exported profiles list from. |
132 Device device; | 119 Device device; |
133 }; | 120 }; |
134 | 121 |
135 // Options for the getServices function. | 122 // Options for the getServices function. |
136 dictionary GetServicesOptions { | 123 dictionary GetServicesOptions { |
137 // The address of the device to inquire about. |deviceAddress| should be | 124 // The address of the device to inquire about. |deviceAddress| should be |
138 // in the format 'XX:XX:XX:XX:XX:XX'. | 125 // in the format 'XX:XX:XX:XX:XX:XX'. |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 dictionary SetOutOfBandPairingDataOptions { | 160 dictionary SetOutOfBandPairingDataOptions { |
174 // The address of the remote device that the data should be associated | 161 // The address of the remote device that the data should be associated |
175 // with. |deviceAddress| should be in the format 'XX:XX:XX:XX:XX:XX'. | 162 // with. |deviceAddress| should be in the format 'XX:XX:XX:XX:XX:XX'. |
176 DOMString address; | 163 DOMString address; |
177 | 164 |
178 // The Out Of Band Pairing Data. If this is omitted, the data for the | 165 // The Out Of Band Pairing Data. If this is omitted, the data for the |
179 // device is cleared instead. | 166 // device is cleared instead. |
180 OutOfBandPairingData? data; | 167 OutOfBandPairingData? data; |
181 }; | 168 }; |
182 | 169 |
183 // Options for the startDiscovery function. | |
184 dictionary StartDiscoveryOptions { | |
185 // Called for each device that is discovered. | |
186 DeviceCallback deviceCallback; | |
187 }; | |
188 | |
189 // These functions all report failures via chrome.runtime.lastError. | 170 // These functions all report failures via chrome.runtime.lastError. |
190 interface Functions { | 171 interface Functions { |
191 // Registers the JavaScript application as an implementation for the given | 172 // Registers the JavaScript application as an implementation for the given |
192 // Profile; if a channel or PSM is specified, the profile will be exported | 173 // Profile; if a channel or PSM is specified, the profile will be exported |
193 // in the host's SDP and GATT tables and advertised to other devices. | 174 // in the host's SDP and GATT tables and advertised to other devices. |
194 static void addProfile(Profile profile, ResultCallback callback); | 175 static void addProfile(Profile profile, ResultCallback callback); |
195 | 176 |
196 // Unregisters the JavaScript application as an implementation for the given | 177 // Unregisters the JavaScript application as an implementation for the given |
197 // Profile; only the uuid field of the Profile object is used. | 178 // Profile; only the uuid field of the Profile object is used. |
198 static void removeProfile(Profile profile, ResultCallback callback); | 179 static void removeProfile(Profile profile, ResultCallback callback); |
199 | 180 |
200 // Get information about the Bluetooth adapter. | 181 // Get information about the Bluetooth adapter. |
201 // |callback| : Called with an AdapterState object describing the adapter | 182 // |callback| : Called with an AdapterState object describing the adapter |
202 // state. | 183 // state. |
203 static void getAdapterState(AdapterStateCallback callback); | 184 static void getAdapterState(AdapterStateCallback callback); |
204 | 185 |
205 // Get a bluetooth devices known to the system. Known devices are either | 186 // Get a list of Bluetooth devices known to the system, including paired |
206 // currently paired, or have been paired in the past. | 187 // and recently discovered devices. |
207 // |options| : Controls which devices are returned and provides | |
208 // |deviceCallback|, which is called for each matching device. | |
209 // |callback| : Called when the search is completed. | 188 // |callback| : Called when the search is completed. |
210 // |options.deviceCallback| will not be called after | 189 static void getDevices(DevicesCallback callback); |
211 // |callback| has been called. | |
212 static void getDevices(GetDevicesOptions options, | |
213 ResultCallback callback); | |
214 | 190 |
215 // Returns the set of exported profiles for the device specified in options. | 191 // Returns the set of exported profiles for the device specified in options. |
216 // This function will not initiate a connection to the remote device. | 192 // This function will not initiate a connection to the remote device. |
217 static void getProfiles(GetProfilesOptions options, | 193 static void getProfiles(GetProfilesOptions options, |
218 ProfilesCallback callback); | 194 ProfilesCallback callback); |
219 | 195 |
220 // Get a list of services provided by a device. | 196 // Get a list of services provided by a device. |
221 static void getServices(GetServicesOptions options, | 197 static void getServices(GetServicesOptions options, |
222 ServicesCallback callback); | 198 ServicesCallback callback); |
223 | 199 |
(...skipping 28 matching lines...) Expand all Loading... |
252 static void getLocalOutOfBandPairingData( | 228 static void getLocalOutOfBandPairingData( |
253 OutOfBandPairingDataCallback callback); | 229 OutOfBandPairingDataCallback callback); |
254 | 230 |
255 // Set the Out of Band Pairing data for a remote device. | 231 // Set the Out of Band Pairing data for a remote device. |
256 // Any previous Out Of Band Pairing Data for this device is overwritten. | 232 // Any previous Out Of Band Pairing Data for this device is overwritten. |
257 // |options| : The options for this function. | 233 // |options| : The options for this function. |
258 // |callback| : Called to indicate success or failure. | 234 // |callback| : Called to indicate success or failure. |
259 static void setOutOfBandPairingData(SetOutOfBandPairingDataOptions options, | 235 static void setOutOfBandPairingData(SetOutOfBandPairingDataOptions options, |
260 optional ResultCallback callback); | 236 optional ResultCallback callback); |
261 | 237 |
262 // Start discovery. Discovered devices will be returned via the | 238 // Start discovery. Newly discovered devices will be returned via the |
263 // |onDeviceDiscovered| callback. Discovery will fail to start if it is | 239 // onDeviceAdded event. Previously discovered devices already known to |
264 // already in progress. Discovery can be resource intensive: stopDiscovery | 240 // the adapter must be obtained using getDevices and will only be updated |
| 241 // using the |onDeviceChanged| event if information about them changes. |
| 242 // |
| 243 // Discovery will fail to start if this application has already called |
| 244 // startDiscovery. Discovery can be resource intensive: stopDiscovery |
265 // should be called as soon as possible. | 245 // should be called as soon as possible. |
266 // |options| : The options for this function. | |
267 // |callback| : Called to indicate success or failure. | 246 // |callback| : Called to indicate success or failure. |
268 static void startDiscovery( | 247 static void startDiscovery( |
269 StartDiscoveryOptions options, | |
270 optional ResultCallback callback); | 248 optional ResultCallback callback); |
271 | 249 |
272 // Stop discovery. | 250 // Stop discovery. |
273 // |callback| : Called to indicate success or failure. | 251 // |callback| : Called to indicate success or failure. |
274 static void stopDiscovery( | 252 static void stopDiscovery( |
275 optional ResultCallback callback); | 253 optional ResultCallback callback); |
276 }; | 254 }; |
277 | 255 |
278 interface Events { | 256 interface Events { |
279 // Fired when the state of the Bluetooth adapter changes. | 257 // Fired when the state of the Bluetooth adapter changes. |
280 // |state| : The new state of the adapter. | 258 // |state| : The new state of the adapter. |
281 static void onAdapterStateChanged(AdapterState state); | 259 static void onAdapterStateChanged(AdapterState state); |
282 | 260 |
| 261 // Fired when information about a new Bluetooth device is available. |
| 262 static void onDeviceAdded(Device device); |
| 263 |
| 264 // Fired when information about a known Bluetooth device has changed. |
| 265 static void onDeviceChanged(Device device); |
| 266 |
| 267 // Fired when a Bluetooth device that was previously discovered has been |
| 268 // out of range for long enough to be considered unavailable again, and |
| 269 // when a paired device is removed. |
| 270 static void onDeviceRemoved(Device device); |
| 271 |
283 // Fired when a connection has been made for a registered profile. | 272 // Fired when a connection has been made for a registered profile. |
284 // |socket| : The socket for the connection. | 273 // |socket| : The socket for the connection. |
285 static void onConnection(Socket socket); | 274 static void onConnection(Socket socket); |
286 }; | 275 }; |
287 }; | 276 }; |
OLD | NEW |