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

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

Issue 284183012: Bluetooth: remove Profile API (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
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
(...skipping 13 matching lines...) Expand all
24 // Indicates whether or not the adapter has power. 24 // Indicates whether or not the adapter has power.
25 boolean powered; 25 boolean powered;
26 26
27 // Indicates whether or not the adapter is available (i.e. enabled). 27 // Indicates whether or not the adapter is available (i.e. enabled).
28 boolean available; 28 boolean available;
29 29
30 // Indicates whether or not the adapter is currently discovering. 30 // Indicates whether or not the adapter is currently discovering.
31 boolean discovering; 31 boolean discovering;
32 }; 32 };
33 33
34 // Callback from the <code>getAdapterState</code> method.
35 // |adapterInfo| : Object containing the adapter information.
36 callback AdapterStateCallback = void(AdapterState adapterInfo);
37
34 // Information about the state of a known Bluetooth device. 38 // Information about the state of a known Bluetooth device.
35 dictionary Device { 39 dictionary Device {
36 // The address of the device, in the format 'XX:XX:XX:XX:XX:XX'. 40 // The address of the device, in the format 'XX:XX:XX:XX:XX:XX'.
37 DOMString address; 41 DOMString address;
38 42
39 // The human-readable name of the device. 43 // The human-readable name of the device.
40 DOMString? name; 44 DOMString? name;
41 45
42 // The class of the device, a bit-field defined by 46 // The class of the device, a bit-field defined by
43 // http://www.bluetooth.org/en-us/specification/assigned-numbers/baseband. 47 // http://www.bluetooth.org/en-us/specification/assigned-numbers/baseband.
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 long? maximumHostTransmitPower; 83 long? maximumHostTransmitPower;
80 84
81 // UUIDs of protocols, profiles and services advertised by the device. 85 // UUIDs of protocols, profiles and services advertised by the device.
82 // For classic Bluetooth devices, this list is obtained from EIR data and 86 // 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 87 // 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 88 // GATT primary services. For dual mode devices this may be obtained from
85 // both. 89 // both.
86 DOMString[]? uuids; 90 DOMString[]? uuids;
87 }; 91 };
88 92
89 // Information about a Bluetooth profile. 93 // Callback from the <code>getDevice</code> method.
90 dictionary Profile { 94 // |deviceInfo| : Object containing the device information.
91 // Unique profile identifier, e.g. 00001401-0000-1000-8000-00805F9B23FB 95 callback GetDeviceCallback = void(Device deviceInfo);
92 DOMString uuid;
93 96
94 // Human-readable name of the Profile, e.g. "Health Device" 97 // Callback from the <code>getDevices</code> method.
95 DOMString? name; 98 // |deviceInfos| : Array of object containing device information.
99 callback GetDevicesCallback = void(Device[] deviceInfos);
96 100
97 // The RFCOMM channel id, used when the profile is to be exported to remote 101 // Callback from the <code>startDiscovery</code> method.
98 // devices. 102 callback StartDiscoveryCallback = void();
99 long? channel;
100 103
101 // The LS2CAP PSM number, used when the profile is to be exported to remote 104 // Callback from the <code>stopDiscovery</code> method.
102 // devices. 105 callback StopDiscoveryCallback = void();
103 long? psm;
104
105 // Specifies whether pairing (and encryption) is required to be able to
106 // connect.
107 boolean? requireAuthentication;
108
109 // Specifies whether user authorization is required to be able to connect.
110 boolean? requireAuthorization;
111
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;
115
116 // Specifies the implemented version of the profile.
117 long? version;
118
119 // Specifies the profile-specific bit field of features the implementation
120 // supports.
121 long? features;
122 };
123
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;
135
136 // An application-defined string associated with the socket.
137 DOMString? name;
138
139 // The size of the buffer used to receive data. The default value is 4096.
140 long? bufferSize;
141 };
142
143 dictionary Socket {
144 // The socket identifier.
145 long id;
146
147 // The remote Bluetooth device associated with this socket.
148 Device device;
149
150 // The remote Bluetooth uuid associated with this socket.
151 DOMString uuid;
152
153 // Flag indicating whether the socket is left open when the application is
154 // suspended (see <code>SocketProperties.persistent</code>).
155 boolean persistent;
156
157 // Application-defined string associated with the socket.
158 DOMString? name;
159
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;
163
164 // Flag indicating whether a connected socket blocks its peer from sending
165 // more data (see <code>setPaused</code>).
166 boolean paused;
167 };
168
169 callback AdapterStateCallback = void(AdapterState result);
170 callback AddressCallback = void(DOMString result);
171 callback BooleanCallback = void(boolean result);
172 callback DataCallback = void(optional ArrayBuffer result);
173 callback DeviceCallback = void(Device result);
174 callback DevicesCallback = void(Device[] result);
175 callback NameCallback = void(DOMString result);
176 callback ResultCallback = void();
177 callback SizeCallback = void(long result);
178 callback SocketCallback = void(Socket result);
179
180 // Options for the connect function.
181 dictionary ConnectOptions {
182 // The connection is made to |device|.
183 Device device;
184
185 // The connection is made to |profile|.
186 Profile profile;
187 };
188
189 // Options for the disconnect function.
190 dictionary DisconnectOptions {
191 // The socket identifier.
192 long socketId;
193 };
194
195 // Callback from the <code>getSocket</code> method.
196 // |socket| : Object containing the socket information.
197 callback GetSocketCallback = void (Socket socket);
198
199 // Callback from the <code>getSockets</code> method.
200 // |sockets| : Array of object containing socket information.
201 callback GetSocketsCallback = void (Socket[] sockets);
202
203 // Data from an <code>onReceive</code> event.
204 dictionary ReceiveInfo {
205 // The socket identifier.
206 long socketId;
207
208 // The data received, with a maximum size of <code>bufferSize</code>.
209 ArrayBuffer data;
210 };
211
212 enum ReceiveError {
213 // The connection was disconnected.
214 disconnected,
215
216 // A system error occurred and the connection may be unrecoverable.
217 system_error
218 };
219
220 // Data from an <code>onReceiveError</code> event.
221 dictionary ReceiveErrorInfo {
222 // The socket identifier.
223 long socketId;
224
225 // The error message.
226 DOMString errorMessage;
227
228 // An error code indicating what went wrong.
229 ReceiveError error;
230 };
231 106
232 // These functions all report failures via chrome.runtime.lastError. 107 // These functions all report failures via chrome.runtime.lastError.
233 interface Functions { 108 interface Functions {
234 // Get information about the Bluetooth adapter. 109 // Get information about the Bluetooth adapter.
235 // |callback| : Called with an AdapterState object describing the adapter 110 // |callback| : Called with an AdapterState object describing the adapter
236 // state. 111 // state.
237 static void getAdapterState(AdapterStateCallback callback); 112 static void getAdapterState(AdapterStateCallback callback);
238 113
114 // Get information about a Bluetooth device known to the system.
115 // |deviceAddress| : Address of device to get.
116 // |callback| : Called with the Device object describing the device.
117 static void getDevice(DOMString deviceAddress, GetDeviceCallback callback);
118
239 // Get a list of Bluetooth devices known to the system, including paired 119 // Get a list of Bluetooth devices known to the system, including paired
240 // and recently discovered devices. 120 // and recently discovered devices.
241 // |callback| : Called when the search is completed. 121 // |callback| : Called when the search is completed.
242 static void getDevices(DevicesCallback callback); 122 static void getDevices(GetDevicesCallback callback);
243
244 // Get information about a Bluetooth device known to the system.
245 // |deviceAddress| : Address of device to get.
246 // |callback| : Called with the Device object describing the device.
247 static void getDevice(DOMString deviceAddress, DeviceCallback callback);
248
249 // Registers the JavaScript application as an implementation for the given
250 // Profile; if a channel or PSM is specified, the profile will be exported
251 // in the host's SDP and GATT tables and advertised to other devices.
252 static void addProfile(Profile profile, ResultCallback callback);
253
254 // Unregisters the JavaScript application as an implementation for the given
255 // Profile; only the uuid field of the Profile object is used.
256 static void removeProfile(Profile profile, ResultCallback callback);
257
258 // Connect to a service on a device.
259 // |options| : The options for the connection.
260 // |callback| : Called to indicate success or failure.
261 static void connect(ConnectOptions options,
262 ResultCallback callback);
263
264 // Closes a Bluetooth connection.
265 // |options| : The options for this function.
266 // |callback| : Called to indicate success or failure.
267 static void disconnect(DisconnectOptions options,
268 optional ResultCallback callback);
269
270 // Sends data to a Bluetooth connection.
271 // |socketId| : The socket identifier.
272 // |data| : The data to send.
273 // |callback| : Called with the number of bytes sent.
274 static void send(long socketId,
275 ArrayBuffer data,
276 optional SizeCallback callback);
277
278 // Updates the socket properties.
279 // |socketId| : The socket identifier.
280 // |properties| : The properties to update.
281 // |callback| : Called when the properties are updated.
282 static void updateSocket(long socketId,
283 SocketProperties properties,
284 optional ResultCallback callback);
285
286 // Enables or disables the application from receiving messages from its
287 // peer. The default value is <code>false</code>. Pausing a socket is
288 // typically used by an application to throttle data sent by its peer. When
289 // a socket is paused, no $ref:onReceive event is raised. When a socket is
290 // connected and un-paused, $ref:onReceive events are raised again when
291 // messages are received.
292 static void setSocketPaused(long socketId,
293 boolean paused,
294 optional ResultCallback callback);
295
296 // Retrieves the state of the given socket.
297 // |socketId| : The socket identifier.
298 // |callback| : Called when the socket state is available.
299 static void getSocket(long socketId,
300 GetSocketCallback callback);
301
302 // Retrieves the list of currently opened sockets owned by the application.
303 // |callback| : Called when the list of sockets is available.
304 static void getSockets(GetSocketsCallback callback);
305 123
306 // Start discovery. Newly discovered devices will be returned via the 124 // Start discovery. Newly discovered devices will be returned via the
307 // onDeviceAdded event. Previously discovered devices already known to 125 // onDeviceAdded event. Previously discovered devices already known to
308 // the adapter must be obtained using getDevices and will only be updated 126 // the adapter must be obtained using getDevices and will only be updated
309 // using the |onDeviceChanged| event if information about them changes. 127 // using the |onDeviceChanged| event if information about them changes.
310 // 128 //
311 // Discovery will fail to start if this application has already called 129 // Discovery will fail to start if this application has already called
312 // startDiscovery. Discovery can be resource intensive: stopDiscovery 130 // startDiscovery. Discovery can be resource intensive: stopDiscovery
313 // should be called as soon as possible. 131 // should be called as soon as possible.
314 // |callback| : Called to indicate success or failure. 132 // |callback| : Called to indicate success or failure.
315 static void startDiscovery( 133 static void startDiscovery(optional StartDiscoveryCallback callback);
316 optional ResultCallback callback);
317 134
318 // Stop discovery. 135 // Stop discovery.
319 // |callback| : Called to indicate success or failure. 136 // |callback| : Called to indicate success or failure.
320 static void stopDiscovery( 137 static void stopDiscovery(optional StopDiscoveryCallback callback);
321 optional ResultCallback callback);
322 }; 138 };
323 139
324 interface Events { 140 interface Events {
325 // Fired when the state of the Bluetooth adapter changes. 141 // Fired when the state of the Bluetooth adapter changes.
326 // |state| : The new state of the adapter. 142 // |state| : The new state of the adapter.
327 static void onAdapterStateChanged(AdapterState state); 143 static void onAdapterStateChanged(AdapterState state);
328 144
329 // Fired when information about a new Bluetooth device is available. 145 // Fired when information about a new Bluetooth device is available.
330 static void onDeviceAdded(Device device); 146 static void onDeviceAdded(Device device);
331 147
332 // Fired when information about a known Bluetooth device has changed. 148 // Fired when information about a known Bluetooth device has changed.
333 static void onDeviceChanged(Device device); 149 static void onDeviceChanged(Device device);
334 150
335 // Fired when a Bluetooth device that was previously discovered has been 151 // Fired when a Bluetooth device that was previously discovered has been
336 // out of range for long enough to be considered unavailable again, and 152 // out of range for long enough to be considered unavailable again, and
337 // when a paired device is removed. 153 // when a paired device is removed.
338 static void onDeviceRemoved(Device device); 154 static void onDeviceRemoved(Device device);
339
340 // Fired when a connection has been made for a registered profile.
341 // |socket| : The socket for the connection.
342 static void onConnection(Socket socket);
343
344 // Event raised when data has been received for a given socket.
345 // |info| : The event data.
346 static void onReceive(ReceiveInfo info);
347
348 // Event raised when a network error occured while the runtime was waiting
349 // for data on the socket. Once this event is raised, the socket is set to
350 // <code>paused</code> and no more <code>onReceive</code> events are raised
351 // for this socket.
352 // |info| : The event data.
353 static void onReceiveError(ReceiveErrorInfo info);
354 }; 155 };
355 }; 156 };
OLDNEW
« no previous file with comments | « chrome/chrome_tests_unit.gypi ('k') | chrome/test/data/extensions/api_test/bluetooth/on_connection/manifest.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698