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 // Allocation authorities for Vendor IDs. | 8 // Allocation authorities for Vendor IDs. |
9 enum VendorIdSource {bluetooth, usb}; | 9 enum VendorIdSource {bluetooth, usb}; |
10 | 10 |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 | 159 |
160 // The size of the buffer used to receive data. If no buffer size has been | 160 // The size of the buffer used to receive data. If no buffer size has been |
161 // specified explictly, the field is not provided. | 161 // specified explictly, the field is not provided. |
162 long? bufferSize; | 162 long? bufferSize; |
163 | 163 |
164 // Flag indicating whether a connected socket blocks its peer from sending | 164 // Flag indicating whether a connected socket blocks its peer from sending |
165 // more data (see <code>setPaused</code>). | 165 // more data (see <code>setPaused</code>). |
166 boolean paused; | 166 boolean paused; |
167 }; | 167 }; |
168 | 168 |
169 dictionary OutOfBandPairingData { | |
170 // Simple Pairing Hash C. | |
171 // Always 16 octets long. | |
172 ArrayBuffer hash; | |
173 | |
174 // Simple Pairing Randomizer R. | |
175 // Always 16 octets long. | |
176 ArrayBuffer randomizer; | |
177 }; | |
178 | |
179 callback AdapterStateCallback = void(AdapterState result); | 169 callback AdapterStateCallback = void(AdapterState result); |
180 callback AddressCallback = void(DOMString result); | 170 callback AddressCallback = void(DOMString result); |
181 callback BooleanCallback = void(boolean result); | 171 callback BooleanCallback = void(boolean result); |
182 callback DataCallback = void(optional ArrayBuffer result); | 172 callback DataCallback = void(optional ArrayBuffer result); |
183 callback DeviceCallback = void(Device result); | 173 callback DeviceCallback = void(Device result); |
184 callback DevicesCallback = void(Device[] result); | 174 callback DevicesCallback = void(Device[] result); |
185 callback NameCallback = void(DOMString result); | 175 callback NameCallback = void(DOMString result); |
186 callback OutOfBandPairingDataCallback = void(OutOfBandPairingData data); | |
187 callback ResultCallback = void(); | 176 callback ResultCallback = void(); |
188 callback SizeCallback = void(long result); | 177 callback SizeCallback = void(long result); |
189 callback SocketCallback = void(Socket result); | 178 callback SocketCallback = void(Socket result); |
190 | 179 |
191 // Options for the connect function. | 180 // Options for the connect function. |
192 dictionary ConnectOptions { | 181 dictionary ConnectOptions { |
193 // The connection is made to |device|. | 182 // The connection is made to |device|. |
194 Device device; | 183 Device device; |
195 | 184 |
196 // The connection is made to |profile|. | 185 // The connection is made to |profile|. |
197 Profile profile; | 186 Profile profile; |
198 }; | 187 }; |
199 | 188 |
200 // Options for the disconnect function. | 189 // Options for the disconnect function. |
201 dictionary DisconnectOptions { | 190 dictionary DisconnectOptions { |
202 // The socket identifier. | 191 // The socket identifier. |
203 long socketId; | 192 long socketId; |
204 }; | 193 }; |
205 | 194 |
206 // Options for the setOutOfBandPairingData function. | |
207 dictionary SetOutOfBandPairingDataOptions { | |
208 // The address of the remote device that the data should be associated | |
209 // with. |deviceAddress| should be in the format 'XX:XX:XX:XX:XX:XX'. | |
210 DOMString address; | |
211 | |
212 // The Out Of Band Pairing Data. If this is omitted, the data for the | |
213 // device is cleared instead. | |
214 OutOfBandPairingData? data; | |
215 }; | |
216 | |
217 // Callback from the <code>getSocket</code> method. | 195 // Callback from the <code>getSocket</code> method. |
218 // |socket| : Object containing the socket information. | 196 // |socket| : Object containing the socket information. |
219 callback GetSocketCallback = void (Socket socket); | 197 callback GetSocketCallback = void (Socket socket); |
220 | 198 |
221 // Callback from the <code>getSockets</code> method. | 199 // Callback from the <code>getSockets</code> method. |
222 // |sockets| : Array of object containing socket information. | 200 // |sockets| : Array of object containing socket information. |
223 callback GetSocketsCallback = void (Socket[] sockets); | 201 callback GetSocketsCallback = void (Socket[] sockets); |
224 | 202 |
225 // Data from an <code>onReceive</code> event. | 203 // Data from an <code>onReceive</code> event. |
226 dictionary ReceiveInfo { | 204 dictionary ReceiveInfo { |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 // Retrieves the state of the given socket. | 296 // Retrieves the state of the given socket. |
319 // |socketId| : The socket identifier. | 297 // |socketId| : The socket identifier. |
320 // |callback| : Called when the socket state is available. | 298 // |callback| : Called when the socket state is available. |
321 static void getSocket(long socketId, | 299 static void getSocket(long socketId, |
322 GetSocketCallback callback); | 300 GetSocketCallback callback); |
323 | 301 |
324 // Retrieves the list of currently opened sockets owned by the application. | 302 // Retrieves the list of currently opened sockets owned by the application. |
325 // |callback| : Called when the list of sockets is available. | 303 // |callback| : Called when the list of sockets is available. |
326 static void getSockets(GetSocketsCallback callback); | 304 static void getSockets(GetSocketsCallback callback); |
327 | 305 |
328 // Get the local Out of Band Pairing data. | |
329 // |callback| : Called with the data. | |
330 static void getLocalOutOfBandPairingData( | |
331 OutOfBandPairingDataCallback callback); | |
332 | |
333 // Set the Out of Band Pairing data for a remote device. | |
334 // Any previous Out Of Band Pairing Data for this device is overwritten. | |
335 // |options| : The options for this function. | |
336 // |callback| : Called to indicate success or failure. | |
337 static void setOutOfBandPairingData(SetOutOfBandPairingDataOptions options, | |
338 optional ResultCallback callback); | |
339 | |
340 // Start discovery. Newly discovered devices will be returned via the | 306 // Start discovery. Newly discovered devices will be returned via the |
341 // onDeviceAdded event. Previously discovered devices already known to | 307 // onDeviceAdded event. Previously discovered devices already known to |
342 // the adapter must be obtained using getDevices and will only be updated | 308 // the adapter must be obtained using getDevices and will only be updated |
343 // using the |onDeviceChanged| event if information about them changes. | 309 // using the |onDeviceChanged| event if information about them changes. |
344 // | 310 // |
345 // Discovery will fail to start if this application has already called | 311 // Discovery will fail to start if this application has already called |
346 // startDiscovery. Discovery can be resource intensive: stopDiscovery | 312 // startDiscovery. Discovery can be resource intensive: stopDiscovery |
347 // should be called as soon as possible. | 313 // should be called as soon as possible. |
348 // |callback| : Called to indicate success or failure. | 314 // |callback| : Called to indicate success or failure. |
349 static void startDiscovery( | 315 static void startDiscovery( |
(...skipping 30 matching lines...) Expand all Loading... |
380 static void onReceive(ReceiveInfo info); | 346 static void onReceive(ReceiveInfo info); |
381 | 347 |
382 // Event raised when a network error occured while the runtime was waiting | 348 // Event raised when a network error occured while the runtime was waiting |
383 // for data on the socket. Once this event is raised, the socket is set to | 349 // for data on the socket. Once this event is raised, the socket is set to |
384 // <code>paused</code> and no more <code>onReceive</code> events are raised | 350 // <code>paused</code> and no more <code>onReceive</code> events are raised |
385 // for this socket. | 351 // for this socket. |
386 // |info| : The event data. | 352 // |info| : The event data. |
387 static void onReceiveError(ReceiveErrorInfo info); | 353 static void onReceiveError(ReceiveErrorInfo info); |
388 }; | 354 }; |
389 }; | 355 }; |
OLD | NEW |