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.
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
,
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'.
21 // The human-readable name of the adapter.
24 // Indicates whether or not the adapter has power.
27 // Indicates whether or not the adapter is available (i.e. enabled).
30 // Indicates whether or not the adapter is currently discovering.
34 // Callback from the <code>getAdapterState</code> method.
35 // |adapterInfo| : Object containing the adapter information.
36 callback AdapterStateCallback
= void(AdapterState adapterInfo
);
38 // Information about the state of a known Bluetooth device.
40 // The address of the device, in the format 'XX:XX:XX:XX:XX:XX'.
43 // The human-readable name of the device.
46 // The class of the device, a bit-field defined by
47 // http://www.bluetooth.org/en-us/specification/assigned-numbers/baseband.
50 // The Device ID record of the device, where available.
51 VendorIdSource? vendorIdSource
;
56 // The type of the device, if recognized by Chrome. This is obtained from
57 // the |deviceClass| field and only represents a small fraction of the
58 // possible device types. When in doubt you should use the |deviceClass|
62 // Indicates whether or not the device is paired with the system.
65 // Indicates whether the device is currently connected to the system.
68 // UUIDs of protocols, profiles and services advertised by the device.
69 // For classic Bluetooth devices, this list is obtained from EIR data and
70 // SDP tables. For Low Energy devices, this list is obtained from AD and
71 // GATT primary services. For dual mode devices this may be obtained from
76 // Callback from the <code>getDevice</code> method.
77 // |deviceInfo| : Object containing the device information.
78 callback GetDeviceCallback
= void(Device deviceInfo
);
80 // Callback from the <code>getDevices</code> method.
81 // |deviceInfos| : Array of object containing device information.
82 callback GetDevicesCallback
= void(Device
[] deviceInfos
);
84 // Callback from the <code>startDiscovery</code> method.
85 callback StartDiscoveryCallback
= void();
87 // Callback from the <code>stopDiscovery</code> method.
88 callback StopDiscoveryCallback
= void();
90 // These functions all report failures via chrome.runtime.lastError.
92 // Get information about the Bluetooth adapter.
93 // |callback| : Called with an AdapterState object describing the adapter
95 static
void getAdapterState
(AdapterStateCallback
callback);
97 // Get information about a Bluetooth device known to the system.
98 // |deviceAddress| : Address of device to get.
99 // |callback| : Called with the Device object describing the device.
100 static
void getDevice
(DOMString deviceAddress
, GetDeviceCallback
callback);
102 // Get a list of Bluetooth devices known to the system, including paired
103 // and recently discovered devices.
104 // |callback| : Called when the search is completed.
105 static
void getDevices
(GetDevicesCallback
callback);
107 // Start discovery. Newly discovered devices will be returned via the
108 // onDeviceAdded event. Previously discovered devices already known to
109 // the adapter must be obtained using getDevices and will only be updated
110 // using the |onDeviceChanged| event if information about them changes.
112 // Discovery will fail to start if this application has already called
113 // startDiscovery. Discovery can be resource intensive: stopDiscovery
114 // should be called as soon as possible.
115 // |callback| : Called to indicate success or failure.
116 static
void startDiscovery
(optional StartDiscoveryCallback
callback);
119 // |callback| : Called to indicate success or failure.
120 static
void stopDiscovery
(optional StopDiscoveryCallback
callback);
124 // Fired when the state of the Bluetooth adapter changes.
125 // |state| : The new state of the adapter.
126 static
void onAdapterStateChanged
(AdapterState state
);
128 // Fired when information about a new Bluetooth device is available.
129 static
void onDeviceAdded
(Device device
);
131 // Fired when information about a known Bluetooth device has changed.
132 static
void onDeviceChanged
(Device device
);
134 // Fired when a Bluetooth device that was previously discovered has been
135 // out of range for long enough to be considered unavailable again, and
136 // when a paired device is removed.
137 static
void onDeviceRemoved
(Device device
);