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 <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 DEVICE_VIDEO, | 59 DEVICE_VIDEO, |
60 DEVICE_PERIPHERAL, | 60 DEVICE_PERIPHERAL, |
61 DEVICE_JOYSTICK, | 61 DEVICE_JOYSTICK, |
62 DEVICE_GAMEPAD, | 62 DEVICE_GAMEPAD, |
63 DEVICE_KEYBOARD, | 63 DEVICE_KEYBOARD, |
64 DEVICE_MOUSE, | 64 DEVICE_MOUSE, |
65 DEVICE_TABLET, | 65 DEVICE_TABLET, |
66 DEVICE_KEYBOARD_MOUSE_COMBO | 66 DEVICE_KEYBOARD_MOUSE_COMBO |
67 }; | 67 }; |
68 | 68 |
| 69 // The value returned if the RSSI or transmit power cannot be read. |
| 70 static const int kUnknownPower = 127; |
| 71 |
69 // Possible errors passed back to an error callback function in case of a | 72 // Possible errors passed back to an error callback function in case of a |
70 // failed call to Connect(). | 73 // failed call to Connect(). |
71 enum ConnectErrorCode { | 74 enum ConnectErrorCode { |
72 ERROR_UNKNOWN, | 75 ERROR_UNKNOWN, |
73 ERROR_INPROGRESS, | 76 ERROR_INPROGRESS, |
74 ERROR_FAILED, | 77 ERROR_FAILED, |
75 ERROR_AUTH_FAILED, | 78 ERROR_AUTH_FAILED, |
76 ERROR_AUTH_CANCELED, | 79 ERROR_AUTH_CANCELED, |
77 ERROR_AUTH_REJECTED, | 80 ERROR_AUTH_REJECTED, |
78 ERROR_AUTH_TIMEOUT, | 81 ERROR_AUTH_TIMEOUT, |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 // be a synthesized string containing the address and localized type name | 223 // be a synthesized string containing the address and localized type name |
221 // if the device has no obtained name. | 224 // if the device has no obtained name. |
222 virtual base::string16 GetName() const; | 225 virtual base::string16 GetName() const; |
223 | 226 |
224 // Returns the type of the device, limited to those we support or are | 227 // Returns the type of the device, limited to those we support or are |
225 // aware of, by decoding the bluetooth class information. The returned | 228 // aware of, by decoding the bluetooth class information. The returned |
226 // values are unique, and do not overlap, so DEVICE_KEYBOARD is not also | 229 // values are unique, and do not overlap, so DEVICE_KEYBOARD is not also |
227 // DEVICE_PERIPHERAL. | 230 // DEVICE_PERIPHERAL. |
228 DeviceType GetDeviceType() const; | 231 DeviceType GetDeviceType() const; |
229 | 232 |
| 233 // Gets the "received signal strength indication" (RSSI) of the current |
| 234 // connection to the device. The RSSI indicates the power present in the |
| 235 // received radio signal, measured in dBm, to a resolution of 1dBm. Larger |
| 236 // (typically, less negative) values indicate a stronger signal. |
| 237 // It is only meaningful to call this method when there is a connection |
| 238 // established to the device. If there is no connection, or in case of an |
| 239 // error, returns |kUnknownPower|. Otherwise, returns the connection's RSSI. |
| 240 virtual int GetRSSI() const = 0; |
| 241 |
| 242 // These two methods are used to read the current or maximum transmit power |
| 243 // ("Tx power") of the current connection to the device. The transmit power |
| 244 // indicates the strength of the signal broadcast from the host's Bluetooth |
| 245 // antenna when communicating with the device, measured in dBm, to a |
| 246 // resolution of 1dBm. Larger (typically, less negative) values |
| 247 // indicate a stronger signal. |
| 248 // It is only meaningful to call this method when there is a connection |
| 249 // established to the device. If there is no connection, or in case of an |
| 250 // error, returns |kUnknownPower|. Otherwise, returns the connection's |
| 251 // transmit power. |
| 252 virtual int GetCurrentHostTransmitPower() const = 0; |
| 253 virtual int GetMaximumHostTransmitPower() const = 0; |
| 254 |
230 // Indicates whether the device is known to support pairing based on its | 255 // Indicates whether the device is known to support pairing based on its |
231 // device class and address. | 256 // device class and address. |
232 bool IsPairable() const; | 257 bool IsPairable() const; |
233 | 258 |
234 // Indicates whether the device is paired with the adapter. | 259 // Indicates whether the device is paired with the adapter. |
235 virtual bool IsPaired() const = 0; | 260 virtual bool IsPaired() const = 0; |
236 | 261 |
237 // Indicates whether the device is currently connected to the adapter. | 262 // Indicates whether the device is currently connected to the adapter. |
238 // Note that if IsConnected() is true, does not imply that the device is | 263 // Note that if IsConnected() is true, does not imply that the device is |
239 // connected to any application or service. If the device is not paired, it | 264 // connected to any application or service. If the device is not paired, it |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
388 | 413 |
389 private: | 414 private: |
390 // Returns a localized string containing the device's bluetooth address and | 415 // Returns a localized string containing the device's bluetooth address and |
391 // a device type for display when |name_| is empty. | 416 // a device type for display when |name_| is empty. |
392 base::string16 GetAddressWithLocalizedDeviceTypeName() const; | 417 base::string16 GetAddressWithLocalizedDeviceTypeName() const; |
393 }; | 418 }; |
394 | 419 |
395 } // namespace device | 420 } // namespace device |
396 | 421 |
397 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ | 422 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ |
OLD | NEW |