OLD | NEW |
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 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 5 #ifndef DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 6 #define DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
7 | 7 |
| 8 #include <stddef.h> |
| 9 #include <stdint.h> |
| 10 |
8 #include <set> | 11 #include <set> |
9 #include <string> | 12 #include <string> |
10 #include <vector> | 13 #include <vector> |
11 | 14 |
12 #include "base/callback.h" | 15 #include "base/callback.h" |
13 #include "base/containers/scoped_ptr_hash_map.h" | 16 #include "base/containers/scoped_ptr_hash_map.h" |
14 #include "base/gtest_prod_util.h" | 17 #include "base/gtest_prod_util.h" |
15 #include "base/memory/ref_counted.h" | 18 #include "base/memory/ref_counted.h" |
16 #include "base/strings/string16.h" | 19 #include "base/strings/string16.h" |
17 #include "device/bluetooth/bluetooth_export.h" | 20 #include "device/bluetooth/bluetooth_export.h" |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 const std::string& pincode) = 0; | 141 const std::string& pincode) = 0; |
139 | 142 |
140 // This method will be called when the Bluetooth daemon requires that the | 143 // This method will be called when the Bluetooth daemon requires that the |
141 // user enter the Passkey |passkey| into the device |device| so that it | 144 // user enter the Passkey |passkey| into the device |device| so that it |
142 // may be authenticated. | 145 // may be authenticated. |
143 // | 146 // |
144 // This is used for Bluetooth 2.1 and later devices that support input | 147 // This is used for Bluetooth 2.1 and later devices that support input |
145 // but not display, such as keyboards. The Passkey is a numeric in the | 148 // but not display, such as keyboards. The Passkey is a numeric in the |
146 // range 0-999999 and should be always presented zero-padded to six | 149 // range 0-999999 and should be always presented zero-padded to six |
147 // digits. | 150 // digits. |
148 virtual void DisplayPasskey(BluetoothDevice* device, | 151 virtual void DisplayPasskey(BluetoothDevice* device, uint32_t passkey) = 0; |
149 uint32 passkey) = 0; | |
150 | 152 |
151 // This method will be called when the Bluetooth daemon gets a notification | 153 // This method will be called when the Bluetooth daemon gets a notification |
152 // of a key entered on the device |device| while pairing with the device | 154 // of a key entered on the device |device| while pairing with the device |
153 // using a PIN code or a Passkey. | 155 // using a PIN code or a Passkey. |
154 // | 156 // |
155 // This method will be called only after DisplayPinCode() or | 157 // This method will be called only after DisplayPinCode() or |
156 // DisplayPasskey() method is called, but is not warranted to be called | 158 // DisplayPasskey() method is called, but is not warranted to be called |
157 // on every pairing process that requires a PIN code or a Passkey because | 159 // on every pairing process that requires a PIN code or a Passkey because |
158 // some device may not support this feature. | 160 // some device may not support this feature. |
159 // | 161 // |
160 // The |entered| value describes the number of keys entered so far, | 162 // The |entered| value describes the number of keys entered so far, |
161 // including the last [enter] key. A first call to KeysEntered() with | 163 // including the last [enter] key. A first call to KeysEntered() with |
162 // |entered| as 0 will be sent when the device supports this feature. | 164 // |entered| as 0 will be sent when the device supports this feature. |
163 virtual void KeysEntered(BluetoothDevice* device, | 165 virtual void KeysEntered(BluetoothDevice* device, uint32_t entered) = 0; |
164 uint32 entered) = 0; | |
165 | 166 |
166 // This method will be called when the Bluetooth daemon requires that the | 167 // This method will be called when the Bluetooth daemon requires that the |
167 // user confirm that the Passkey |passkey| is displayed on the screen | 168 // user confirm that the Passkey |passkey| is displayed on the screen |
168 // of the device |device| so that it may be authenticated. The delegate | 169 // of the device |device| so that it may be authenticated. The delegate |
169 // should display to the user and ask for confirmation, then call | 170 // should display to the user and ask for confirmation, then call |
170 // ConfirmPairing() on the device to confirm, RejectPairing() on the device | 171 // ConfirmPairing() on the device to confirm, RejectPairing() on the device |
171 // to reject or CancelPairing() on the device to cancel authentication | 172 // to reject or CancelPairing() on the device to cancel authentication |
172 // for any other reason. | 173 // for any other reason. |
173 // | 174 // |
174 // This is used for Bluetooth 2.1 and later devices that support display, | 175 // This is used for Bluetooth 2.1 and later devices that support display, |
175 // such as other computers or phones. The Passkey is a numeric in the | 176 // such as other computers or phones. The Passkey is a numeric in the |
176 // range 0-999999 and should be always present zero-padded to six | 177 // range 0-999999 and should be always present zero-padded to six |
177 // digits. | 178 // digits. |
178 virtual void ConfirmPasskey(BluetoothDevice* device, | 179 virtual void ConfirmPasskey(BluetoothDevice* device, uint32_t passkey) = 0; |
179 uint32 passkey) = 0; | |
180 | 180 |
181 // This method will be called when the Bluetooth daemon requires that a | 181 // This method will be called when the Bluetooth daemon requires that a |
182 // pairing request, usually only incoming, using the just-works model is | 182 // pairing request, usually only incoming, using the just-works model is |
183 // authorized. The delegate should decide whether the user should confirm | 183 // authorized. The delegate should decide whether the user should confirm |
184 // or not, then call ConfirmPairing() on the device to confirm the pairing | 184 // or not, then call ConfirmPairing() on the device to confirm the pairing |
185 // (whether by user action or by default), RejectPairing() on the device to | 185 // (whether by user action or by default), RejectPairing() on the device to |
186 // reject or CancelPairing() on the device to cancel authorization for | 186 // reject or CancelPairing() on the device to cancel authorization for |
187 // any other reason. | 187 // any other reason. |
188 virtual void AuthorizePairing(BluetoothDevice* device) = 0; | 188 virtual void AuthorizePairing(BluetoothDevice* device) = 0; |
189 }; | 189 }; |
190 | 190 |
191 virtual ~BluetoothDevice(); | 191 virtual ~BluetoothDevice(); |
192 | 192 |
193 // Returns the Bluetooth class of the device, used by GetDeviceType() | 193 // Returns the Bluetooth class of the device, used by GetDeviceType() |
194 // and metrics logging, | 194 // and metrics logging, |
195 virtual uint32 GetBluetoothClass() const = 0; | 195 virtual uint32_t GetBluetoothClass() const = 0; |
196 | 196 |
197 // Returns the identifier of the bluetooth device. | 197 // Returns the identifier of the bluetooth device. |
198 virtual std::string GetIdentifier() const; | 198 virtual std::string GetIdentifier() const; |
199 | 199 |
200 // Returns the Bluetooth of address the device. This should be used as | 200 // Returns the Bluetooth of address the device. This should be used as |
201 // a unique key to identify the device and copied where needed. | 201 // a unique key to identify the device and copied where needed. |
202 virtual std::string GetAddress() const = 0; | 202 virtual std::string GetAddress() const = 0; |
203 | 203 |
204 // Returns the allocation source of the identifier returned by GetVendorID(), | 204 // Returns the allocation source of the identifier returned by GetVendorID(), |
205 // where available, or VENDOR_ID_UNKNOWN where not. | 205 // where available, or VENDOR_ID_UNKNOWN where not. |
206 virtual VendorIDSource GetVendorIDSource() const = 0; | 206 virtual VendorIDSource GetVendorIDSource() const = 0; |
207 | 207 |
208 // Returns the Vendor ID of the device, where available. | 208 // Returns the Vendor ID of the device, where available. |
209 virtual uint16 GetVendorID() const = 0; | 209 virtual uint16_t GetVendorID() const = 0; |
210 | 210 |
211 // Returns the Product ID of the device, where available. | 211 // Returns the Product ID of the device, where available. |
212 virtual uint16 GetProductID() const = 0; | 212 virtual uint16_t GetProductID() const = 0; |
213 | 213 |
214 // Returns the Device ID of the device, typically the release or version | 214 // Returns the Device ID of the device, typically the release or version |
215 // number in BCD format, where available. | 215 // number in BCD format, where available. |
216 virtual uint16 GetDeviceID() const = 0; | 216 virtual uint16_t GetDeviceID() const = 0; |
217 | 217 |
218 // Returns the name of the device suitable for displaying, this may | 218 // Returns the name of the device suitable for displaying, this may |
219 // be a synthesized string containing the address and localized type name | 219 // be a synthesized string containing the address and localized type name |
220 // if the device has no obtained name. | 220 // if the device has no obtained name. |
221 virtual base::string16 GetName() const; | 221 virtual base::string16 GetName() const; |
222 | 222 |
223 // Returns the type of the device, limited to those we support or are | 223 // Returns the type of the device, limited to those we support or are |
224 // aware of, by decoding the bluetooth class information. The returned | 224 // aware of, by decoding the bluetooth class information. The returned |
225 // values are unique, and do not overlap, so DEVICE_KEYBOARD is not also | 225 // values are unique, and do not overlap, so DEVICE_KEYBOARD is not also |
226 // DEVICE_PERIPHERAL. | 226 // DEVICE_PERIPHERAL. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
259 | 259 |
260 // Returns the set of UUIDs that this device supports. For classic Bluetooth | 260 // Returns the set of UUIDs that this device supports. For classic Bluetooth |
261 // devices this data is collected from both the EIR data and SDP tables, | 261 // devices this data is collected from both the EIR data and SDP tables, |
262 // for Low Energy devices this data is collected from AD and GATT primary | 262 // for Low Energy devices this data is collected from AD and GATT primary |
263 // services, for dual mode devices this may be collected from both./ | 263 // services, for dual mode devices this may be collected from both./ |
264 virtual UUIDList GetUUIDs() const = 0; | 264 virtual UUIDList GetUUIDs() const = 0; |
265 | 265 |
266 // The received signal strength, in dBm. This field is avaliable and valid | 266 // The received signal strength, in dBm. This field is avaliable and valid |
267 // only during discovery. If not during discovery, or RSSI wasn't reported, | 267 // only during discovery. If not during discovery, or RSSI wasn't reported, |
268 // this method will return |kUnknownPower|. | 268 // this method will return |kUnknownPower|. |
269 virtual int16 GetInquiryRSSI() const = 0; | 269 virtual int16_t GetInquiryRSSI() const = 0; |
270 | 270 |
271 // The transmitted power level. This field is avaliable only for LE devices | 271 // The transmitted power level. This field is avaliable only for LE devices |
272 // that include this field in AD. It is avaliable and valid only during | 272 // that include this field in AD. It is avaliable and valid only during |
273 // discovery. If not during discovery, or TxPower wasn't reported, this | 273 // discovery. If not during discovery, or TxPower wasn't reported, this |
274 // method will return |kUnknownPower|. | 274 // method will return |kUnknownPower|. |
275 virtual int16 GetInquiryTxPower() const = 0; | 275 virtual int16_t GetInquiryTxPower() const = 0; |
276 | 276 |
277 // The ErrorCallback is used for methods that can fail in which case it | 277 // The ErrorCallback is used for methods that can fail in which case it |
278 // is called, in the success case the callback is simply not called. | 278 // is called, in the success case the callback is simply not called. |
279 typedef base::Callback<void()> ErrorCallback; | 279 typedef base::Callback<void()> ErrorCallback; |
280 | 280 |
281 // The ConnectErrorCallback is used for methods that can fail with an error, | 281 // The ConnectErrorCallback is used for methods that can fail with an error, |
282 // passed back as an error code argument to this callback. | 282 // passed back as an error code argument to this callback. |
283 // In the success case this callback is not called. | 283 // In the success case this callback is not called. |
284 typedef base::Callback<void(enum ConnectErrorCode)> ConnectErrorCallback; | 284 typedef base::Callback<void(enum ConnectErrorCode)> ConnectErrorCallback; |
285 | 285 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 // | 343 // |
344 // PIN Codes are generally required for Bluetooth 2.0 and earlier devices | 344 // PIN Codes are generally required for Bluetooth 2.0 and earlier devices |
345 // for which there is no automatic pairing or special handling. | 345 // for which there is no automatic pairing or special handling. |
346 virtual void SetPinCode(const std::string& pincode) = 0; | 346 virtual void SetPinCode(const std::string& pincode) = 0; |
347 | 347 |
348 // Sends the Passkey |passkey| to the remote device during pairing. | 348 // Sends the Passkey |passkey| to the remote device during pairing. |
349 // | 349 // |
350 // Passkeys are generally required for Bluetooth 2.1 and later devices | 350 // Passkeys are generally required for Bluetooth 2.1 and later devices |
351 // which cannot provide input or display on their own, and don't accept | 351 // which cannot provide input or display on their own, and don't accept |
352 // passkey-less pairing, and are a numeric in the range 0-999999. | 352 // passkey-less pairing, and are a numeric in the range 0-999999. |
353 virtual void SetPasskey(uint32 passkey) = 0; | 353 virtual void SetPasskey(uint32_t passkey) = 0; |
354 | 354 |
355 // Confirms to the remote device during pairing that a passkey provided by | 355 // Confirms to the remote device during pairing that a passkey provided by |
356 // the ConfirmPasskey() delegate call is displayed on both devices. | 356 // the ConfirmPasskey() delegate call is displayed on both devices. |
357 virtual void ConfirmPairing() = 0; | 357 virtual void ConfirmPairing() = 0; |
358 | 358 |
359 // Rejects a pairing or connection request from a remote device. | 359 // Rejects a pairing or connection request from a remote device. |
360 virtual void RejectPairing() = 0; | 360 virtual void RejectPairing() = 0; |
361 | 361 |
362 // Cancels a pairing or connection attempt to a remote device, releasing | 362 // Cancels a pairing or connection attempt to a remote device, releasing |
363 // the pairing delegate. | 363 // the pairing delegate. |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 | 519 |
520 private: | 520 private: |
521 // Returns a localized string containing the device's bluetooth address and | 521 // Returns a localized string containing the device's bluetooth address and |
522 // a device type for display when |name_| is empty. | 522 // a device type for display when |name_| is empty. |
523 base::string16 GetAddressWithLocalizedDeviceTypeName() const; | 523 base::string16 GetAddressWithLocalizedDeviceTypeName() const; |
524 }; | 524 }; |
525 | 525 |
526 } // namespace device | 526 } // namespace device |
527 | 527 |
528 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 528 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
OLD | NEW |