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 // Bluetooth API. | 5 // Bluetooth API. |
6 // TODO(bryeung): mark this API as ChromeOS only (see crbug.com/119398). | 6 // TODO(bryeung): mark this API as ChromeOS only (see crbug.com/119398). |
7 | 7 |
8 [nodoc] namespace experimental.bluetooth { | 8 [nodoc] namespace experimental.bluetooth { |
9 dictionary Device { | 9 dictionary Device { |
10 DOMString address; | 10 DOMString address; |
11 DOMString name; | 11 DOMString name; |
12 }; | 12 }; |
13 | 13 |
14 dictionary Socket { | 14 dictionary Socket { |
15 long id; | 15 long id; |
16 }; | 16 }; |
17 | 17 |
18 // TODO(bryeung): This is a temporary hack until Blobs are supported | |
19 dictionary Blob { | |
20 DOMString data; | |
21 }; | |
22 | |
23 dictionary OutOfBandPairingData { | 18 dictionary OutOfBandPairingData { |
24 // Simple Pairing Hash C | 19 // Simple Pairing Hash C |
25 // Always 16 octets long. | 20 // Always 16 octets long. |
26 // TODO(bryeung): this should really be an octet[] | 21 ArrayBuffer hash; |
27 DOMString hash; | |
28 | 22 |
29 // Simple Pairing Randomizer R | 23 // Simple Pairing Randomizer R |
30 // Always 16 octets long. | 24 // Always 16 octets long. |
31 // TODO(bryeung): this should really be an octet[] | 25 ArrayBuffer randomizer; |
32 DOMString randomizer; | |
33 }; | 26 }; |
34 | 27 |
35 // Reports failures via chrome.extension.lastError. | 28 // Reports failures via chrome.extension.lastError. |
36 callback ResultCallback = void (); | 29 callback ResultCallback = void (); |
37 callback BooleanCallback = void (boolean result); | 30 callback BooleanCallback = void (boolean result); |
38 callback AddressCallback = void (DOMString result); | 31 callback AddressCallback = void (DOMString result); |
39 callback DevicesCallback = void (Device[] result); | 32 callback DevicesCallback = void (Device[] result); |
40 callback SocketCallback = void (Socket result); | 33 callback SocketCallback = void (Socket result); |
41 callback DataCallback = void (Blob result); | 34 callback DataCallback = void (ArrayBuffer result); |
42 callback OutOfBandPairingDataCallback = void (OutOfBandPairingData data); | 35 callback OutOfBandPairingDataCallback = void (OutOfBandPairingData data); |
43 | 36 |
44 interface Functions { | 37 interface Functions { |
45 // Checks if the system has bluetooth support. | 38 // Checks if the system has bluetooth support. |
46 // |callback| : Called with the boolean result. | 39 // |callback| : Called with the boolean result. |
47 static void isAvailable(BooleanCallback callback); | 40 static void isAvailable(BooleanCallback callback); |
48 | 41 |
49 // Checks if the system's bluetooth module has power. | 42 // Checks if the system's bluetooth module has power. |
50 // |callback| : Called with the boolean result. | 43 // |callback| : Called with the boolean result. |
51 static void isPowered(BooleanCallback callback); | 44 static void isPowered(BooleanCallback callback); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 // Read data from a bluetooth connection. | 77 // Read data from a bluetooth connection. |
85 // |socket| : The socket to read from. | 78 // |socket| : The socket to read from. |
86 // |callback| : Called with the data when it is available. | 79 // |callback| : Called with the data when it is available. |
87 static void read(Socket socket, DataCallback callback); | 80 static void read(Socket socket, DataCallback callback); |
88 | 81 |
89 // Write data to a bluetooth connection. | 82 // Write data to a bluetooth connection. |
90 // |socket| : The socket to write to. | 83 // |socket| : The socket to write to. |
91 // |data| : The data to write. | 84 // |data| : The data to write. |
92 // |callback| : Called to indicate success or failure. | 85 // |callback| : Called to indicate success or failure. |
93 static void write( | 86 static void write( |
94 Socket socket, Blob data, optional ResultCallback callback); | 87 Socket socket, ArrayBuffer data, optional ResultCallback callback); |
95 | 88 |
96 // Get the local Out of Band Pairing data. | 89 // Get the local Out of Band Pairing data. |
97 // |callback| : Called with the data. | 90 // |callback| : Called with the data. |
98 static void getOutOfBandPairingData(OutOfBandPairingDataCallback callback); | 91 static void getOutOfBandPairingData(OutOfBandPairingDataCallback callback); |
99 | 92 |
100 // Set the Out of Band Pairing data for the bluetooth device at |address|. | 93 // Set the Out of Band Pairing data for the bluetooth device at |address|. |
101 // |address| : The bluetooth address of the device sending the data. | 94 // |address| : The bluetooth address of the device sending the data. |
102 // |data| : The data. | 95 // |data| : The data. |
103 // |callback| : Called to indicate success or failure. | 96 // |callback| : Called to indicate success or failure. |
104 static void setOutOfBandPairingData( | 97 static void setOutOfBandPairingData( |
105 DOMString address, | 98 DOMString address, |
106 OutOfBandPairingData data, | 99 OutOfBandPairingData data, |
107 optional ResultCallback callback); | 100 optional ResultCallback callback); |
108 }; | 101 }; |
109 | 102 |
110 interface Events { | 103 interface Events { |
111 // Fired when the availability of bluetooth on the system changes. | 104 // Fired when the availability of bluetooth on the system changes. |
112 // |available| : True if bluetooth is available, false otherwise. | 105 // |available| : True if bluetooth is available, false otherwise. |
113 static void onAvailabilityChanged(boolean available); | 106 static void onAvailabilityChanged(boolean available); |
114 | 107 |
115 // Fired when the power state of bluetooth on the system changes. | 108 // Fired when the power state of bluetooth on the system changes. |
116 // |powered| : True if bluetooth is powered, false otherwise. | 109 // |powered| : True if bluetooth is powered, false otherwise. |
117 static void onPowerChanged(boolean has_power); | 110 static void onPowerChanged(boolean has_power); |
118 }; | 111 }; |
119 }; | 112 }; |
OLD | NEW |