Cast: Stop logging kVideoFrameSentToEncoder and rename a couple events.
[chromium-blink-merge.git] / chrome / common / extensions / api / bluetooth.idl
blobcebbf804cbb4af7363dff4c415d806c9e06d9de0
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
3 // found in the LICENSE file.
5 // Use the <code>chrome.bluetooth</code> API to connect to a Bluetooth
6 // device. All functions report failures via chrome.runtime.lastError.
7 namespace bluetooth {
8 // Allocation authorities for Vendor IDs.
9 enum VendorIdSource {bluetooth, usb};
11 // Common device types recognized by Chrome.
12 enum DeviceType {computer, phone, modem, audio, carAudio, video, peripheral,
13 joystick, gamepad, keyboard, mouse, tablet,
14 keyboardMouseCombo};
16 // Information about the state of the Bluetooth adapter.
17 dictionary AdapterState {
18 // The address of the adapter, in the format 'XX:XX:XX:XX:XX:XX'.
19 DOMString address;
21 // The human-readable name of the adapter.
22 DOMString name;
24 // Indicates whether or not the adapter has power.
25 boolean powered;
27 // Indicates whether or not the adapter is available (i.e. enabled).
28 boolean available;
30 // Indicates whether or not the adapter is currently discovering.
31 boolean discovering;
34 // Information about the state of a known Bluetooth device.
35 dictionary Device {
36 // The address of the device, in the format 'XX:XX:XX:XX:XX:XX'.
37 DOMString address;
39 // The human-readable name of the device.
40 DOMString? name;
42 // The class of the device, a bit-field defined by
43 // http://www.bluetooth.org/en-us/specification/assigned-numbers/baseband.
44 long? deviceClass;
46 // The Device ID record of the device, where available.
47 VendorIdSource? vendorIdSource;
48 long? vendorId;
49 long? productId;
50 long? deviceId;
52 // The type of the device, if recognized by Chrome. This is obtained from
53 // the |deviceClass| field and only represents a small fraction of the
54 // possible device types. When in doubt you should use the |deviceClass|
55 // field directly.
56 DeviceType? type;
58 // Indicates whether or not the device is paired with the system.
59 boolean? paired;
61 // Indicates whether the device is currently connected to the system.
62 boolean? connected;
64 // Indicates the RSSI ("received signal strength indication") of the
65 // connection to the device, measured in dBm, to a resolution of 1dBm.
66 // If the device is currently connected, then measures the RSSI of the
67 // connection signal. Otherwise, measures the RSSI of the last inquiry sent
68 // to the device, where available. Absent if unavailable.
69 long? rssi;
71 // Indicates the host's current transmit power ("Tx power") for the
72 // connection to the device, measured in dBm, to a resolution of 1dBm.
73 // This value is only available if the device is currently connected.
74 long? currentHostTransmitPower;
76 // Indicates the host's maximum transmit power ("Tx power") for the
77 // connection to the device, measured in dBm, to a resolution of 1dBm.
78 // This value is only available if the device is currently connected.
79 long? maximumHostTransmitPower;
81 // UUIDs of protocols, profiles and services advertised by the device.
82 // For classic Bluetooth devices, this list is obtained from EIR data and
83 // SDP tables. For Low Energy devices, this list is obtained from AD and
84 // GATT primary services. For dual mode devices this may be obtained from
85 // both.
86 DOMString[]? uuids;
89 // Information about a Bluetooth profile.
90 dictionary Profile {
91 // Unique profile identifier, e.g. 00001401-0000-1000-8000-00805F9B23FB
92 DOMString uuid;
94 // Human-readable name of the Profile, e.g. "Health Device"
95 DOMString? name;
97 // The RFCOMM channel id, used when the profile is to be exported to remote
98 // devices.
99 long? channel;
101 // The LS2CAP PSM number, used when the profile is to be exported to remote
102 // devices.
103 long? psm;
105 // Specifies whether pairing (and encryption) is required to be able to
106 // connect.
107 boolean? requireAuthentication;
109 // Specifies whether user authorization is required to be able to connect.
110 boolean? requireAuthorization;
112 // Specifies whether this profile will be automatically connected if any
113 // other profile of device also exporting this profile connects to the host.
114 boolean? autoConnect;
116 // Specifies the implemented version of the profile.
117 long? version;
119 // Specifies the profile-specific bit field of features the implementation
120 // supports.
121 long? features;
124 // The socket properties specified in the $ref:update function. Each property
125 // is optional. If a property value is not specified, the existing value if
126 // preserved when calling $ref:update.
127 dictionary SocketProperties {
128 // Flag indicating whether the socket is left open when the event page of
129 // the application is unloaded (see <a
130 // href="http://developer.chrome.com/apps/app_lifecycle.html">Manage App
131 // Lifecycle</a>). The default value is <code>false.</code> When the
132 // application is loaded, any sockets previously opened with persistent=true
133 // can be fetched with $ref:getSockets.
134 boolean? persistent;
136 // An application-defined string associated with the socket.
137 DOMString? name;
139 // The size of the buffer used to receive data. The default value is 4096.
140 long? bufferSize;
143 dictionary Socket {
144 // The socket identifier.
145 long id;
147 // The remote Bluetooth device associated with this socket.
148 Device device;
150 // The remote Bluetooth uuid associated with this socket.
151 DOMString uuid;
153 // Flag indicating whether the socket is left open when the application is
154 // suspended (see <code>SocketProperties.persistent</code>).
155 boolean persistent;
157 // Application-defined string associated with the socket.
158 DOMString? name;
160 // The size of the buffer used to receive data. If no buffer size has been
161 // specified explictly, the field is not provided.
162 long? bufferSize;
164 // Flag indicating whether a connected socket blocks its peer from sending
165 // more data (see <code>setPaused</code>).
166 boolean paused;
169 dictionary OutOfBandPairingData {
170 // Simple Pairing Hash C.
171 // Always 16 octets long.
172 ArrayBuffer hash;
174 // Simple Pairing Randomizer R.
175 // Always 16 octets long.
176 ArrayBuffer randomizer;
179 callback AdapterStateCallback = void(AdapterState result);
180 callback AddressCallback = void(DOMString result);
181 callback BooleanCallback = void(boolean result);
182 callback DataCallback = void(optional ArrayBuffer result);
183 callback DeviceCallback = void(Device result);
184 callback DevicesCallback = void(Device[] result);
185 callback NameCallback = void(DOMString result);
186 callback OutOfBandPairingDataCallback = void(OutOfBandPairingData data);
187 callback ResultCallback = void();
188 callback SizeCallback = void(long result);
189 callback SocketCallback = void(Socket result);
191 // Options for the connect function.
192 dictionary ConnectOptions {
193 // The connection is made to |device|.
194 Device device;
196 // The connection is made to |profile|.
197 Profile profile;
200 // Options for the disconnect function.
201 dictionary DisconnectOptions {
202 // The socket identifier.
203 long socketId;
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;
212 // The Out Of Band Pairing Data. If this is omitted, the data for the
213 // device is cleared instead.
214 OutOfBandPairingData? data;
217 // Callback from the <code>getSocket</code> method.
218 // |socket| : Object containing the socket information.
219 callback GetSocketCallback = void (Socket socket);
221 // Callback from the <code>getSockets</code> method.
222 // |sockets| : Array of object containing socket information.
223 callback GetSocketsCallback = void (Socket[] sockets);
225 // Data from an <code>onReceive</code> event.
226 dictionary ReceiveInfo {
227 // The socket identifier.
228 long socketId;
230 // The data received, with a maximum size of <code>bufferSize</code>.
231 ArrayBuffer data;
234 enum ReceiveError {
235 // The connection was disconnected.
236 disconnected,
238 // A system error occurred and the connection may be unrecoverable.
239 system_error
242 // Data from an <code>onReceiveError</code> event.
243 dictionary ReceiveErrorInfo {
244 // The socket identifier.
245 long socketId;
247 // The error message.
248 DOMString errorMessage;
250 // An error code indicating what went wrong.
251 ReceiveError error;
254 // These functions all report failures via chrome.runtime.lastError.
255 interface Functions {
256 // Get information about the Bluetooth adapter.
257 // |callback| : Called with an AdapterState object describing the adapter
258 // state.
259 static void getAdapterState(AdapterStateCallback callback);
261 // Get a list of Bluetooth devices known to the system, including paired
262 // and recently discovered devices.
263 // |callback| : Called when the search is completed.
264 static void getDevices(DevicesCallback callback);
266 // Get information about a Bluetooth device known to the system.
267 // |deviceAddress| : Address of device to get.
268 // |callback| : Called with the Device object describing the device.
269 static void getDevice(DOMString deviceAddress, DeviceCallback callback);
271 // Registers the JavaScript application as an implementation for the given
272 // Profile; if a channel or PSM is specified, the profile will be exported
273 // in the host's SDP and GATT tables and advertised to other devices.
274 static void addProfile(Profile profile, ResultCallback callback);
276 // Unregisters the JavaScript application as an implementation for the given
277 // Profile; only the uuid field of the Profile object is used.
278 static void removeProfile(Profile profile, ResultCallback callback);
280 // Connect to a service on a device.
281 // |options| : The options for the connection.
282 // |callback| : Called to indicate success or failure.
283 static void connect(ConnectOptions options,
284 ResultCallback callback);
286 // Closes a Bluetooth connection.
287 // |options| : The options for this function.
288 // |callback| : Called to indicate success or failure.
289 static void disconnect(DisconnectOptions options,
290 optional ResultCallback callback);
292 // Sends data to a Bluetooth connection.
293 // |socketId| : The socket identifier.
294 // |data| : The data to send.
295 // |callback| : Called with the number of bytes sent.
296 static void send(long socketId,
297 ArrayBuffer data,
298 optional SizeCallback callback);
300 // Updates the socket properties.
301 // |socketId| : The socket identifier.
302 // |properties| : The properties to update.
303 // |callback| : Called when the properties are updated.
304 static void updateSocket(long socketId,
305 SocketProperties properties,
306 optional ResultCallback callback);
308 // Enables or disables the application from receiving messages from its
309 // peer. The default value is <code>false</code>. Pausing a socket is
310 // typically used by an application to throttle data sent by its peer. When
311 // a socket is paused, no $ref:onReceive event is raised. When a socket is
312 // connected and un-paused, $ref:onReceive events are raised again when
313 // messages are received.
314 static void setSocketPaused(long socketId,
315 boolean paused,
316 optional ResultCallback callback);
318 // Retrieves the state of the given socket.
319 // |socketId| : The socket identifier.
320 // |callback| : Called when the socket state is available.
321 static void getSocket(long socketId,
322 GetSocketCallback callback);
324 // Retrieves the list of currently opened sockets owned by the application.
325 // |callback| : Called when the list of sockets is available.
326 static void getSockets(GetSocketsCallback callback);
328 // Get the local Out of Band Pairing data.
329 // |callback| : Called with the data.
330 static void getLocalOutOfBandPairingData(
331 OutOfBandPairingDataCallback callback);
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);
340 // Start discovery. Newly discovered devices will be returned via the
341 // onDeviceAdded event. Previously discovered devices already known to
342 // the adapter must be obtained using getDevices and will only be updated
343 // using the |onDeviceChanged| event if information about them changes.
345 // Discovery will fail to start if this application has already called
346 // startDiscovery. Discovery can be resource intensive: stopDiscovery
347 // should be called as soon as possible.
348 // |callback| : Called to indicate success or failure.
349 static void startDiscovery(
350 optional ResultCallback callback);
352 // Stop discovery.
353 // |callback| : Called to indicate success or failure.
354 static void stopDiscovery(
355 optional ResultCallback callback);
358 interface Events {
359 // Fired when the state of the Bluetooth adapter changes.
360 // |state| : The new state of the adapter.
361 static void onAdapterStateChanged(AdapterState state);
363 // Fired when information about a new Bluetooth device is available.
364 static void onDeviceAdded(Device device);
366 // Fired when information about a known Bluetooth device has changed.
367 static void onDeviceChanged(Device device);
369 // Fired when a Bluetooth device that was previously discovered has been
370 // out of range for long enough to be considered unavailable again, and
371 // when a paired device is removed.
372 static void onDeviceRemoved(Device device);
374 // Fired when a connection has been made for a registered profile.
375 // |socket| : The socket for the connection.
376 static void onConnection(Socket socket);
378 // Event raised when data has been received for a given socket.
379 // |info| : The event data.
380 static void onReceive(ReceiveInfo info);
382 // 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
384 // <code>paused</code> and no more <code>onReceive</code> events are raised
385 // for this socket.
386 // |info| : The event data.
387 static void onReceiveError(ReceiveErrorInfo info);