Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: chrome/common/extensions/api/bluetooth.idl

Issue 180163009: chrome.bluetooth API improvements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address code review feedback. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
11 // Common device types recognized by Chrome. 11 // Common device types recognized by Chrome.
12 enum DeviceType {computer, phone, modem, audio, carAudio, video, peripheral, 12 enum DeviceType {computer, phone, modem, audio, carAudio, video, peripheral,
13 joystick, gamepad, keyboard, mouse, tablet, 13 joystick, gamepad, keyboard, mouse, tablet,
14 keyboardMouseCombo}; 14 keyboardMouseCombo};
15 15
16 // Information about the state of the bluetooth adapater.
keybuk 2014/03/20 01:21:56 nit: Bluetooth everywhere
rpaquay 2014/03/20 18:21:11 Done.
16 dictionary AdapterState { 17 dictionary AdapterState {
17 // The address of the adapter, in the format 'XX:XX:XX:XX:XX:XX'. 18 // The address of the adapter, in the format 'XX:XX:XX:XX:XX:XX'.
18 DOMString address; 19 DOMString address;
19 20
20 // The human-readable name of the adapter. 21 // The human-readable name of the adapter.
21 DOMString name; 22 DOMString name;
22 23
23 // Indicates whether or not the adapter has power. 24 // Indicates whether or not the adapter has power.
24 boolean powered; 25 boolean powered;
25 26
26 // Indicates whether or not the adapter is available (i.e. enabled). 27 // Indicates whether or not the adapter is available (i.e. enabled).
27 boolean available; 28 boolean available;
28 29
29 // Indicates whether or not the adapter is currently discovering. 30 // Indicates whether or not the adapter is currently discovering.
30 boolean discovering; 31 boolean discovering;
31 }; 32 };
32 33
34 // Information about the state of a known bluetooth device.
33 dictionary Device { 35 dictionary Device {
34 // The address of the device, in the format 'XX:XX:XX:XX:XX:XX'. 36 // The address of the device, in the format 'XX:XX:XX:XX:XX:XX'.
35 DOMString address; 37 DOMString address;
36 38
37 // The human-readable name of the device. 39 // The human-readable name of the device.
38 DOMString? name; 40 DOMString? name;
39 41
40 // The class of the device, a bit-field defined by 42 // The class of the device, a bit-field defined by
41 // http://www.bluetooth.org/en-us/specification/assigned-numbers/baseband. 43 // http://www.bluetooth.org/en-us/specification/assigned-numbers/baseband.
42 long deviceClass; 44 long deviceClass;
(...skipping 10 matching lines...) Expand all
53 // field directly. 55 // field directly.
54 DeviceType? type; 56 DeviceType? type;
55 57
56 // Indicates whether or not the device is paired with the system. 58 // Indicates whether or not the device is paired with the system.
57 boolean? paired; 59 boolean? paired;
58 60
59 // Indicates whether the device is currently connected to the system. 61 // Indicates whether the device is currently connected to the system.
60 boolean? connected; 62 boolean? connected;
61 }; 63 };
62 64
65 // Information about a bluetooth profile.
63 dictionary Profile { 66 dictionary Profile {
64 // Unique profile identifier, e.g. 00001401-0000-1000-8000-00805F9B23FB 67 // Unique profile identifier, e.g. 00001401-0000-1000-8000-00805F9B23FB
65 DOMString uuid; 68 DOMString uuid;
66 69
67 // Human-readable name of the Profile, e.g. "Health Device" 70 // Human-readable name of the Profile, e.g. "Health Device"
68 DOMString? name; 71 DOMString? name;
69 72
70 // The RFCOMM channel id, used when the profile is to be exported to remote 73 // The RFCOMM channel id, used when the profile is to be exported to remote
71 // devices. 74 // devices.
72 long? channel; 75 long? channel;
73 76
74 // The LS2CAP PSM number, used when the profile is to be exported to remote 77 // The LS2CAP PSM number, used when the profile is to be exported to remote
75 // deviecs. 78 // devices.
76 long? psm; 79 long? psm;
77 80
78 // Specifies whether pairing (and encryption) is required to be able to 81 // Specifies whether pairing (and encryption) is required to be able to
79 // connect. 82 // connect.
80 boolean? requireAuthentication; 83 boolean? requireAuthentication;
81 84
82 // Specifies whether user authorization is required to be able to connect. 85 // Specifies whether user authorization is required to be able to connect.
83 boolean? requireAuthorization; 86 boolean? requireAuthorization;
84 87
85 // Specifies whether this profile will be automatically connected if any 88 // Specifies whether this profile will be automatically connected if any
86 // other profile of device also exporting this profile connects to the host. 89 // other profile of device also exporting this profile connects to the host.
87 boolean? autoConnect; 90 boolean? autoConnect;
88 91
89 // Specifies the implemented version of the profile. 92 // Specifies the implemented version of the profile.
90 long? version; 93 long? version;
91 94
92 // Specifies the profile-specific bit field of features the implementation 95 // Specifies the profile-specific bit field of features the implementation
93 // supports. 96 // supports.
94 long? features; 97 long? features;
95 }; 98 };
96 99
97 dictionary ServiceRecord { 100 // The socket properties specified in the $ref:update function. Each property
98 // The name of the service. 101 // is optional. If a property value is not specified, the existing value if
99 DOMString name; 102 // preserved when calling $ref:update.
103 dictionary SocketProperties {
104 // Flag indicating if the socket is left open when the event page of the
105 // application is unloaded (see <a
106 // href="http://developer.chrome.com/apps/app_lifecycle.html">Manage App
107 // Lifecycle</a>). The default value is "false." When the application is
108 // loaded, any sockets previously opened with persistent=true can be fetched
109 // with $ref:getSockets.
110 boolean? persistent;
100 111
101 // The UUID of the service. 112 // An application-defined string associated with the socket.
102 DOMString? uuid; 113 DOMString? name;
114
115 // The size of the buffer used to receive data. The default value is 4096.
116 long? bufferSize;
103 }; 117 };
104 118
105 dictionary Socket { 119 dictionary Socket {
120 // The socket identifier.
121 long id;
122
106 // The remote Bluetooth device associated with this socket. 123 // The remote Bluetooth device associated with this socket.
107 Device device; 124 Device device;
108 125
109 // The remote Bluetooth profile associated with this socket. 126 // The remote Bluetooth profile associated with this socket.
110 Profile profile; 127 Profile profile;
keybuk 2014/03/20 01:21:56 Replace with DOMString uuid;
rpaquay 2014/03/20 18:21:11 Done.
111 128
112 // An identifier for this socket that should be used with the 129 // Flag indicating whether the socket is left open when the application is
113 // read/write/disconnect methods. 130 // suspended (see <code>SocketProperties.persistent</code>).
114 long id; 131 boolean persistent;
132
133 // Application-defined string associated with the socket.
134 DOMString? name;
135
136 // The size of the buffer used to receive data. If no buffer size has been
137 // specified explictly, the value is not provided.
138 long? bufferSize;
139
140 // Flag indicating whether a connected socket blocks its peer from sending
141 // more data (see <code>setPaused</code>).
142 boolean paused;
115 }; 143 };
116 144
117 dictionary OutOfBandPairingData { 145 dictionary OutOfBandPairingData {
118 // Simple Pairing Hash C. 146 // Simple Pairing Hash C.
119 // Always 16 octets long. 147 // Always 16 octets long.
120 ArrayBuffer hash; 148 ArrayBuffer hash;
121 149
122 // Simple Pairing Randomizer R. 150 // Simple Pairing Randomizer R.
123 // Always 16 octets long. 151 // Always 16 octets long.
124 ArrayBuffer randomizer; 152 ArrayBuffer randomizer;
125 }; 153 };
126 154
127 callback AdapterStateCallback = void(AdapterState result); 155 callback AdapterStateCallback = void(AdapterState result);
128 callback AddressCallback = void (DOMString result); 156 callback AddressCallback = void (DOMString result);
129 callback BooleanCallback = void (boolean result); 157 callback BooleanCallback = void (boolean result);
130 callback DataCallback = void (optional ArrayBuffer result);
131 callback DevicesCallback = void (Device[] result); 158 callback DevicesCallback = void (Device[] result);
132 callback NameCallback = void (DOMString result);
133 callback OutOfBandPairingDataCallback = void (OutOfBandPairingData data); 159 callback OutOfBandPairingDataCallback = void (OutOfBandPairingData data);
134 callback ProfilesCallback = void(Profile[] result); 160 callback ProfilesCallback = void(Profile[] result);
135 callback ResultCallback = void (); 161 callback ResultCallback = void ();
136 callback ServicesCallback = void(ServiceRecord[] result);
137 callback SizeCallback = void (long result); 162 callback SizeCallback = void (long result);
138 callback SocketCallback = void (Socket result);
139 163
140 // Options for the getProfiles function. 164 // Options for the getProfiles function.
141 dictionary GetProfilesOptions { 165 dictionary GetProfilesOptions {
142 // The remote Bluetooth device to retrieve the exported profiles list from. 166 // The remote Bluetooth device to retrieve the exported profiles list from.
143 Device device; 167 Device device;
144 }; 168 };
145 169
146 // Options for the getServices function.
147 dictionary GetServicesOptions {
148 // The address of the device to inquire about. |deviceAddress| should be
149 // in the format 'XX:XX:XX:XX:XX:XX'.
150 DOMString deviceAddress;
151 };
152
153 // Options for the connect function. 170 // Options for the connect function.
154 dictionary ConnectOptions { 171 dictionary ConnectOptions {
155 // The connection is made to |device|. 172 // The connection is made to |device|.
156 Device device; 173 Device device;
157 174
158 // The connection is made to |profile|. 175 // The connection is made to |profile|.
159 Profile profile; 176 Profile profile;
160 }; 177 };
161 178
162 // Options for the disconnect function. 179 // Options for the disconnect function.
163 dictionary DisconnectOptions { 180 dictionary DisconnectOptions {
164 // The socket to disconnect. 181 // The socket identifier.
165 Socket socket; 182 long socketId;
166 }; 183 };
167 184
168 // Options for the read function. 185 // Options for the $ref:send function.
169 dictionary ReadOptions { 186 dictionary SendOptions {
170 // The socket to read from. 187 // The socket identifier.
171 Socket socket; 188 long socketId;
172 };
173 189
174 // Options for the write function. 190 // The data to send.
175 dictionary WriteOptions {
176 // The socket to write to.
177 Socket socket;
178
179 // The data to write.
180 ArrayBuffer data; 191 ArrayBuffer data;
181 }; 192 };
182 193
183 // Options for the setOutOfBandPairingData function. 194 // Options for the setOutOfBandPairingData function.
184 dictionary SetOutOfBandPairingDataOptions { 195 dictionary SetOutOfBandPairingDataOptions {
185 // The address of the remote device that the data should be associated 196 // The address of the remote device that the data should be associated
186 // with. |deviceAddress| should be in the format 'XX:XX:XX:XX:XX:XX'. 197 // with. |deviceAddress| should be in the format 'XX:XX:XX:XX:XX:XX'.
187 DOMString address; 198 DOMString address;
188 199
189 // The Out Of Band Pairing Data. If this is omitted, the data for the 200 // The Out Of Band Pairing Data. If this is omitted, the data for the
190 // device is cleared instead. 201 // device is cleared instead.
191 OutOfBandPairingData? data; 202 OutOfBandPairingData? data;
192 }; 203 };
193 204
205 // Callback from the <code>getSocket</code> method.
206 // |socket| : Object containing the socket information.
207 callback GetSocketCallback = void (Socket socket);
208
209 // Callback from the <code>getSockets</code> method.
210 // |sockets| : Array of object containing socket information.
211 callback GetSocketsCallback = void (Socket[] sockets);
212
213 // Data from an <code>onReceive</code> event.
214 dictionary ReceiveInfo {
215 // The socket identifier.
216 long socketId;
217
218 // The data received, with a maxium size of <code>bufferSize</code>.
219 ArrayBuffer data;
220 };
221
222 enum ReceiveError {
223 // The connection was disconnected.
224 disconnected,
225
226 // A system error occurred and the connection may be unrecoverable.
227 system_error
228 };
229
230 // Data from an <code>onReceiveError</code> event.
231 dictionary ReceiveErrorInfo {
232 // The socket identifier.
233 long socketId;
234
235 // The error message.
236 DOMString errorMessage;
237
238 // An error code indicating what went wrong.
239 ReceiveError error;
240 };
241
194 // These functions all report failures via chrome.runtime.lastError. 242 // These functions all report failures via chrome.runtime.lastError.
195 interface Functions { 243 interface Functions {
196 // Registers the JavaScript application as an implementation for the given
197 // Profile; if a channel or PSM is specified, the profile will be exported
198 // in the host's SDP and GATT tables and advertised to other devices.
199 static void addProfile(Profile profile, ResultCallback callback);
200
201 // Unregisters the JavaScript application as an implementation for the given
202 // Profile; only the uuid field of the Profile object is used.
203 static void removeProfile(Profile profile, ResultCallback callback);
204
205 // Get information about the Bluetooth adapter. 244 // Get information about the Bluetooth adapter.
206 // |callback| : Called with an AdapterState object describing the adapter 245 // |callback| : Called with an AdapterState object describing the adapter
207 // state. 246 // state.
208 static void getAdapterState(AdapterStateCallback callback); 247 static void getAdapterState(AdapterStateCallback callback);
209 248
210 // Get a list of Bluetooth devices known to the system, including paired 249 // Get a list of Bluetooth devices known to the system, including paired
211 // and recently discovered devices. 250 // and recently discovered devices.
212 // |callback| : Called when the search is completed. 251 // |callback| : Called when the search is completed.
213 static void getDevices(DevicesCallback callback); 252 static void getDevices(DevicesCallback callback);
214 253
254 // Registers the JavaScript application as an implementation for the given
255 // Profile; if a channel or PSM is specified, the profile will be exported
256 // in the host's SDP and GATT tables and advertised to other devices.
257 static void addProfile(Profile profile, ResultCallback callback);
258
259 // Unregisters the JavaScript application as an implementation for the given
260 // Profile; only the uuid field of the Profile object is used.
261 static void removeProfile(Profile profile, ResultCallback callback);
262
215 // Returns the set of exported profiles for the device specified in options. 263 // Returns the set of exported profiles for the device specified in options.
216 // This function will not initiate a connection to the remote device. 264 // This function will not initiate a connection to the remote device.
217 static void getProfiles(GetProfilesOptions options, 265 static void getProfiles(GetProfilesOptions options,
218 ProfilesCallback callback); 266 ProfilesCallback callback);
219 267
220 // Get a list of services provided by a device. 268 // Connects to a profile on a device.
221 static void getServices(GetServicesOptions options,
222 ServicesCallback callback);
223
224 // Connect to a service on a device.
225 // |options| : The options for the connection. 269 // |options| : The options for the connection.
226 // |callback| : Called to indicate success or failure. 270 // |callback| : Called to indicate success or failure.
227 static void connect(ConnectOptions options, 271 static void connect(ConnectOptions options,
228 ResultCallback callback); 272 ResultCallback callback);
229 273
230 // Close a Bluetooth connection. 274 // Closes a Bluetooth connection.
231 // |options| : The options for this function. 275 // |options| : The options for this function.
232 // |callback| : Called to indicate success or failure. 276 // |callback| : Called to indicate success or failure.
233 static void disconnect(DisconnectOptions options, 277 static void disconnect(DisconnectOptions options,
234 optional ResultCallback callback); 278 optional ResultCallback callback);
235 279
236 // Read data from a Bluetooth connection. The |callback| will be called 280 // Sends data to a Bluetooth connection.
237 // with the current data in the buffer even if it is empty. This function
238 // should be polled to read incoming data.
239 // |options| : The options for this function. 281 // |options| : The options for this function.
240 // |callback| : Called with the data read from the socket buffer. 282 // |callback| : Called with the number of bytes sent.
241 static void read(ReadOptions options, 283 static void send(SendOptions options,
keybuk 2014/03/20 01:21:56 Since send() is not write() we should make the cha
rpaquay 2014/03/20 18:21:11 Done.
242 DataCallback callback); 284 optional SizeCallback callback);
243 285
244 // Write data to a Bluetooth connection. 286 // Updates the socket properties.
245 // |options| : The options for this function. 287 // |socketId| : The socket identifier.
246 // |callback| : Called with the number of bytes written. 288 // |properties| : The properties to update.
247 static void write(WriteOptions options, 289 // |callback| : Called when the properties are updated.
248 optional SizeCallback callback); 290 static void updateSocket(long socketId,
291 SocketProperties properties,
292 optional ResultCallback callback);
293
294 // Enables or disables the application from receiving messages from its
295 // peer. The default value is "false". Pausing a socket is typically used by
296 // an application to throttle data sent by its peer. When a socket is
297 // paused, no $ref:onReceive event is raised. When a socket is connected and
298 // un-paused, $ref:onReceive events are raised again when messages are
299 // received.
300 static void setSocketPaused(long socketId,
301 boolean paused,
302 optional ResultCallback callback);
303
304 // Retrieves the state of the given socket.
305 // |socketId| : The socket identifier.
306 // |callback| : Called when the socket state is available.
307 static void getSocket(long socketId,
308 GetSocketCallback callback);
309
310 // Retrieves the list of currently opened sockets owned by the application.
311 // |callback| : Called when the list of sockets is available.
312 static void getSockets(GetSocketsCallback callback);
249 313
250 // Get the local Out of Band Pairing data. 314 // Get the local Out of Band Pairing data.
251 // |callback| : Called with the data. 315 // |callback| : Called with the data.
252 static void getLocalOutOfBandPairingData( 316 static void getLocalOutOfBandPairingData(
253 OutOfBandPairingDataCallback callback); 317 OutOfBandPairingDataCallback callback);
254 318
255 // Set the Out of Band Pairing data for a remote device. 319 // Set the Out of Band Pairing data for a remote device.
256 // Any previous Out Of Band Pairing Data for this device is overwritten. 320 // Any previous Out Of Band Pairing Data for this device is overwritten.
257 // |options| : The options for this function. 321 // |options| : The options for this function.
258 // |callback| : Called to indicate success or failure. 322 // |callback| : Called to indicate success or failure.
(...skipping 30 matching lines...) Expand all
289 static void onDeviceChanged(Device device); 353 static void onDeviceChanged(Device device);
290 354
291 // Fired when a Bluetooth device that was previously discovered has been 355 // Fired when a Bluetooth device that was previously discovered has been
292 // out of range for long enough to be considered unavailable again, and 356 // out of range for long enough to be considered unavailable again, and
293 // when a paired device is removed. 357 // when a paired device is removed.
294 static void onDeviceRemoved(Device device); 358 static void onDeviceRemoved(Device device);
295 359
296 // Fired when a connection has been made for a registered profile. 360 // Fired when a connection has been made for a registered profile.
297 // |socket| : The socket for the connection. 361 // |socket| : The socket for the connection.
298 static void onConnection(Socket socket); 362 static void onConnection(Socket socket);
363
364 // Event raised when data has been received for a given socket.
365 // |info| : The event data.
366 static void onReceive(ReceiveInfo info);
367
368 // Event raised when a network error occured while the runtime was waiting
369 // for data on the socket. Once this event is raised, the socket is set to
370 // <code>paused</code> and no more <code>onReceive</code> events are raised
371 // for this socket.
372 // |info| : The event data.
373 static void onReceiveError(ReceiveErrorInfo info);
299 }; 374 };
300 }; 375 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698