| OLD | NEW |
| (Empty) | |
| 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. |
| 4 |
| 5 // Bluetooth API. |
| 6 |
| 7 namespace bluetooth { |
| 8 dictionary AdapterState { |
| 9 // The address of the adapter, in the format 'XX:XX:XX:XX:XX:XX'. |
| 10 DOMString address; |
| 11 |
| 12 // The human-readable name of the adapter. |
| 13 DOMString name; |
| 14 |
| 15 // Indicates whether or not the adapter has power. |
| 16 boolean powered; |
| 17 |
| 18 // Indicates whether or not the adapter is available (i.e. enabled). |
| 19 boolean available; |
| 20 |
| 21 // Indicates whether or not the adapter is currently discovering. |
| 22 boolean discovering; |
| 23 }; |
| 24 |
| 25 dictionary Device { |
| 26 // The address of the device, in the format 'XX:XX:XX:XX:XX:XX'. |
| 27 DOMString address; |
| 28 |
| 29 // The human-readable name of the device. |
| 30 DOMString name; |
| 31 |
| 32 // Indicates whether or not the device is paired with the system. |
| 33 boolean paired; |
| 34 |
| 35 // Indicates whether or not the device is bonded with the system. A device |
| 36 // is bonded if it is paired and high-security link keys have been |
| 37 // exchanged so that connections may be encrypted. |
| 38 boolean bonded; |
| 39 |
| 40 // Indicates whether the device is currently connected to the system. |
| 41 boolean connected; |
| 42 }; |
| 43 |
| 44 dictionary ServiceRecord { |
| 45 // The name of the service. |
| 46 DOMString name; |
| 47 |
| 48 // The UUID of the service. |
| 49 DOMString? uuid; |
| 50 }; |
| 51 |
| 52 dictionary Socket { |
| 53 // The remote Bluetooth device associated with this socket. |
| 54 Device device; |
| 55 |
| 56 // The remote Bluetooth service associated with this socket. |
| 57 DOMString serviceUuid; |
| 58 |
| 59 // An identifier for this socket that should be used with the |
| 60 // read/write/disconnect methods. |
| 61 long id; |
| 62 }; |
| 63 |
| 64 dictionary OutOfBandPairingData { |
| 65 // Simple Pairing Hash C. |
| 66 // Always 16 octets long. |
| 67 ArrayBuffer hash; |
| 68 |
| 69 // Simple Pairing Randomizer R. |
| 70 // Always 16 octets long. |
| 71 ArrayBuffer randomizer; |
| 72 }; |
| 73 |
| 74 callback AdapterStateCallback = void(AdapterState result); |
| 75 callback AddressCallback = void (DOMString result); |
| 76 callback BooleanCallback = void (boolean result); |
| 77 callback DataCallback = void (optional ArrayBuffer result); |
| 78 callback DeviceCallback = void (Device device); |
| 79 callback DevicesCallback = void (Device[] result); |
| 80 callback NameCallback = void (DOMString result); |
| 81 callback OutOfBandPairingDataCallback = void (OutOfBandPairingData data); |
| 82 callback ResultCallback = void (); |
| 83 callback ServicesCallback = void(ServiceRecord[] result); |
| 84 callback SizeCallback = void (long result); |
| 85 callback SocketCallback = void (Socket result); |
| 86 |
| 87 // Options for the getDevices function. If neither |uuid| or |name| are |
| 88 // provided, all devices known to the system are returned. |
| 89 dictionary GetDevicesOptions { |
| 90 // Only devices providing a service with a UUID that matches |uuid| will be |
| 91 // returned. |
| 92 DOMString? uuid; |
| 93 |
| 94 // Only devices providing a service with a name that matches |name| will be |
| 95 // returned. |
| 96 DOMString? name; |
| 97 |
| 98 // Called for each matching device. Note that a service discovery request |
| 99 // must be made to each non-matching device before it can be definitively |
| 100 // excluded. This can take some time. |
| 101 DeviceCallback deviceCallback; |
| 102 }; |
| 103 |
| 104 // Options for the getServices function. |
| 105 dictionary GetServicesOptions { |
| 106 // The address of the device to inquire about. |deviceAddress| should be |
| 107 // in the format 'XX:XX:XX:XX:XX:XX'. |
| 108 DOMString deviceAddress; |
| 109 }; |
| 110 |
| 111 // Options for the connect function. |
| 112 dictionary ConnectOptions { |
| 113 // The connection is made to the device at |deviceAddress|. |
| 114 // |deviceAddress| should be in the format 'XX:XX:XX:XX:XX:XX'. |
| 115 DOMString deviceAddress; |
| 116 |
| 117 // The connection is made to the service with UUID |serviceUuid|. |
| 118 DOMString serviceUuid; |
| 119 }; |
| 120 |
| 121 // Options for the disconnect function. |
| 122 dictionary DisconnectOptions { |
| 123 // The socket to disconnect. |
| 124 long socketId; |
| 125 }; |
| 126 |
| 127 // Options for the read function. |
| 128 dictionary ReadOptions { |
| 129 // The socket to read from. |
| 130 long socketId; |
| 131 }; |
| 132 |
| 133 // Options for the write function. |
| 134 dictionary WriteOptions { |
| 135 // The socket to write to. |
| 136 long socketId; |
| 137 |
| 138 // The data to write. |
| 139 ArrayBuffer data; |
| 140 }; |
| 141 |
| 142 // Options for the setOutOfBandPairingData function. |
| 143 dictionary SetOutOfBandPairingDataOptions { |
| 144 // The address of the remote device that the data should be associated |
| 145 // with. |deviceAddress| should be in the format 'XX:XX:XX:XX:XX:XX'. |
| 146 DOMString address; |
| 147 |
| 148 // The Out Of Band Pairing Data. If this is omitted, the data for the |
| 149 // device is cleared instead. |
| 150 OutOfBandPairingData? data; |
| 151 }; |
| 152 |
| 153 // Options for the startDiscovery function. |
| 154 dictionary StartDiscoveryOptions { |
| 155 // Called for each device that is discovered. |
| 156 DeviceCallback deviceCallback; |
| 157 }; |
| 158 |
| 159 // These functions all report failures via chrome.runtime.lastError. |
| 160 interface Functions { |
| 161 // Get information about the Bluetooth adapter. |
| 162 // |callback| : Called with an AdapterState object describing the adapter |
| 163 // state. |
| 164 static void getAdapterState(AdapterStateCallback callback); |
| 165 |
| 166 // Get a bluetooth devices known to the system. Known devices are either |
| 167 // currently bonded, or have been bonded in the past. |
| 168 // |options| : Controls which devices are returned and provides |
| 169 // |deviceCallback|, which is called for each matching device. |
| 170 // |callback| : Called when the search is completed. |
| 171 // |options.deviceCallback| will not be called after |
| 172 // |callback| has been called. |
| 173 static void getDevices(GetDevicesOptions options, |
| 174 ResultCallback callback); |
| 175 |
| 176 // Get a list of services provided by a device. |
| 177 static void getServices(GetServicesOptions options, |
| 178 ServicesCallback callback); |
| 179 |
| 180 // Connect to a service on a device. |
| 181 // |options| : The options for the connection. |
| 182 // |callback| : Called when the connection is established with a Socket |
| 183 // that can be used to communicate with |device|. |
| 184 static void connect(ConnectOptions options, |
| 185 SocketCallback callback); |
| 186 |
| 187 // Close a Bluetooth connection. |
| 188 // |options| : The options for this function. |
| 189 // |callback| : Called to indicate success or failure. |
| 190 static void disconnect(DisconnectOptions options, |
| 191 optional ResultCallback callback); |
| 192 |
| 193 // Read data from a Bluetooth connection. |
| 194 // |options| : The options for this function. |
| 195 // |callback| : Called with the data when it is available. |
| 196 static void read(ReadOptions options, |
| 197 DataCallback callback); |
| 198 |
| 199 // Write data to a Bluetooth connection. |
| 200 // |options| : The options for this function. |
| 201 // |callback| : Called with the number of bytes written. |
| 202 static void write(WriteOptions options, |
| 203 optional SizeCallback callback); |
| 204 |
| 205 // Get the local Out of Band Pairing data. |
| 206 // |callback| : Called with the data. |
| 207 static void getLocalOutOfBandPairingData( |
| 208 OutOfBandPairingDataCallback callback); |
| 209 |
| 210 // Set the Out of Band Pairing data for a remote device. |
| 211 // Any previous Out Of Band Pairing Data for this device is overwritten. |
| 212 // |options| : The options for this function. |
| 213 // |callback| : Called to indicate success or failure. |
| 214 static void setOutOfBandPairingData(SetOutOfBandPairingDataOptions options, |
| 215 optional ResultCallback callback); |
| 216 |
| 217 // Start discovery. Discovered devices will be returned via the |
| 218 // |onDeviceDiscovered| callback. Discovery will fail to start if it is |
| 219 // already in progress. Discovery can be resource intensive: stopDiscovery |
| 220 // should be called as soon as possible. |
| 221 // |options| : The options for this function. |
| 222 // |callback| : Called to indicate success or failure. |
| 223 static void startDiscovery( |
| 224 StartDiscoveryOptions options, |
| 225 optional ResultCallback callback); |
| 226 |
| 227 // Stop discovery. |
| 228 // |callback| : Called to indicate success or failure. |
| 229 static void stopDiscovery( |
| 230 optional ResultCallback callback); |
| 231 }; |
| 232 |
| 233 interface Events { |
| 234 // Fired when the state of the Bluetooth adapter changes. |
| 235 // |state| : The new state of the adapter. |
| 236 static void onAdapterStateChanged(AdapterState state); |
| 237 }; |
| 238 }; |
| OLD | NEW |