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. | 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; |
11 | 11 |
12 // The human-readable name of the adapter. | 12 // The human-readable name of the adapter. |
13 DOMString name; | 13 DOMString name; |
14 | 14 |
15 // Indicates whether or not the adapter has power. | 15 // Indicates whether or not the adapter has power. |
16 boolean powered; | 16 boolean powered; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 // |callback| : Called to indicate success or failure. | 226 // |callback| : Called to indicate success or failure. |
227 static void connect(ConnectOptions options, | 227 static void connect(ConnectOptions options, |
228 ResultCallback callback); | 228 ResultCallback callback); |
229 | 229 |
230 // Close a Bluetooth connection. | 230 // Close a Bluetooth connection. |
231 // |options| : The options for this function. | 231 // |options| : The options for this function. |
232 // |callback| : Called to indicate success or failure. | 232 // |callback| : Called to indicate success or failure. |
233 static void disconnect(DisconnectOptions options, | 233 static void disconnect(DisconnectOptions options, |
234 optional ResultCallback callback); | 234 optional ResultCallback callback); |
235 | 235 |
236 // Read data from a Bluetooth connection. | 236 // Read data from a Bluetooth connection. The |callback| will be called |
| 237 // with the current data in the buffer even if it is empty. This function |
| 238 // should be polled to read incoming data. |
237 // |options| : The options for this function. | 239 // |options| : The options for this function. |
238 // |callback| : Called with the data when it is available. | 240 // |callback| : Called with the data read from the socket buffer. |
239 static void read(ReadOptions options, | 241 static void read(ReadOptions options, |
240 DataCallback callback); | 242 DataCallback callback); |
241 | 243 |
242 // Write data to a Bluetooth connection. | 244 // Write data to a Bluetooth connection. |
243 // |options| : The options for this function. | 245 // |options| : The options for this function. |
244 // |callback| : Called with the number of bytes written. | 246 // |callback| : Called with the number of bytes written. |
245 static void write(WriteOptions options, | 247 static void write(WriteOptions options, |
246 optional SizeCallback callback); | 248 optional SizeCallback callback); |
247 | 249 |
248 // Get the local Out of Band Pairing data. | 250 // Get the local Out of Band Pairing data. |
(...skipping 27 matching lines...) Expand all Loading... |
276 interface Events { | 278 interface Events { |
277 // Fired when the state of the Bluetooth adapter changes. | 279 // Fired when the state of the Bluetooth adapter changes. |
278 // |state| : The new state of the adapter. | 280 // |state| : The new state of the adapter. |
279 static void onAdapterStateChanged(AdapterState state); | 281 static void onAdapterStateChanged(AdapterState state); |
280 | 282 |
281 // Fired when a connection has been made for a registered profile. | 283 // Fired when a connection has been made for a registered profile. |
282 // |socket| : The socket for the connection. | 284 // |socket| : The socket for the connection. |
283 static void onConnection(Socket socket); | 285 static void onConnection(Socket socket); |
284 }; | 286 }; |
285 }; | 287 }; |
OLD | NEW |