Chromium Code Reviews| Index: device/bluetooth/bluetooth_device.h |
| diff --git a/device/bluetooth/bluetooth_device.h b/device/bluetooth/bluetooth_device.h |
| index 3c273ffcb775c01c8cb7a66118471e08c03b4778..d24f1123889f0c40cb73d377552eeac85a8e32de 100644 |
| --- a/device/bluetooth/bluetooth_device.h |
| +++ b/device/bluetooth/bluetooth_device.h |
| @@ -68,6 +68,22 @@ class BluetoothDevice { |
| // The value returned if the RSSI or transmit power cannot be read. |
| static const int kUnknownPower = 127; |
| + struct ConnectionInfo { |
| + int rssi; |
| + int transmit_power; |
| + int max_transmit_power; |
| + |
| + ConnectionInfo() |
| + : rssi(kUnknownPower), |
| + transmit_power(kUnknownPower), |
| + max_transmit_power(kUnknownPower) {} |
| + |
| + ConnectionInfo(int rssi, int transmit_power, int max_transmit_power) |
| + : rssi(rssi), |
| + transmit_power(transmit_power), |
| + max_transmit_power(max_transmit_power) {} |
|
armansito
2015/01/06 20:36:07
Even though this is a simple struct, I would move
Tim Song
2015/01/06 22:30:51
Done.
|
| + }; |
| + |
| // Possible errors passed back to an error callback function in case of a |
| // failed call to Connect(). |
| enum ConnectErrorCode { |
| @@ -203,28 +219,6 @@ class BluetoothDevice { |
| // DEVICE_PERIPHERAL. |
| DeviceType GetDeviceType() const; |
| - // Gets the "received signal strength indication" (RSSI) of the current |
| - // connection to the device. The RSSI indicates the power present in the |
| - // received radio signal, measured in dBm, to a resolution of 1dBm. Larger |
| - // (typically, less negative) values indicate a stronger signal. |
| - // If the device is not currently connected, then returns the RSSI read from |
| - // the last inquiry that returned the device, where available. In case of an |
| - // error, returns |kUnknownPower|. Otherwise, returns the connection's RSSI. |
| - virtual int GetRSSI() const = 0; |
| - |
| - // These two methods are used to read the current or maximum transmit power |
| - // ("Tx power") of the current connection to the device. The transmit power |
| - // indicates the strength of the signal broadcast from the host's Bluetooth |
| - // antenna when communicating with the device, measured in dBm, to a |
| - // resolution of 1dBm. Larger (typically, less negative) values |
| - // indicate a stronger signal. |
| - // It is only meaningful to call this method when there is a connection |
| - // established to the device. If there is no connection, or in case of an |
| - // error, returns |kUnknownPower|. Otherwise, returns the connection's |
| - // transmit power. |
| - virtual int GetCurrentHostTransmitPower() const = 0; |
| - virtual int GetMaximumHostTransmitPower() const = 0; |
| - |
| // Indicates whether the device is known to support pairing based on its |
| // device class and address. |
| bool IsPairable() const; |
| @@ -269,6 +263,8 @@ class BluetoothDevice { |
| // In the success case this callback is not called. |
| typedef base::Callback<void(enum ConnectErrorCode)> ConnectErrorCallback; |
| + typedef base::Callback<void(const ConnectionInfo&)> ConnectionInfoCallback; |
| + |
| // Indicates whether the device is currently pairing and expecting a |
| // PIN Code to be returned. |
| virtual bool ExpectingPinCode() const = 0; |
| @@ -281,6 +277,21 @@ class BluetoothDevice { |
| // confirmation of a displayed passkey. |
| virtual bool ExpectingConfirmation() const = 0; |
| + // Returns the RSSI and TX power of the active connection to the device: |
| + // |
| + // The RSSI indicates the power present in the received radio signal, measured |
| + // in dBm, to a resolution of 1dBm. Larger (typically, less negative) values |
| + // indicate a stronger signal. |
| + // |
| + // The transmit power indicates the strength of the signal broadcast from the |
| + // host's Bluetooth antenna when communicating with the device, measured in |
| + // dBm, to a resolution of 1dBm. Larger (typically, less negative) values |
| + // indicate a stronger signal. |
| + // |
| + // If the device isn't connected, then the ConnectionInfo struct passed into |
| + // the callback will filled by |kUnknownPower|. |
|
armansito
2015/01/06 20:36:07
nit: s/will filled by/will be populated with/
Tim Song
2015/01/06 22:30:51
Done.
|
| + virtual void GetConnectionInfo(const ConnectionInfoCallback& callback) = 0; |
|
armansito
2015/01/06 20:36:08
Maybe it's better to have an ErrorCallback instead
Tim Song
2015/01/06 22:30:51
The underlying dbus/mac apis might return invalid
armansito
2015/01/06 22:39:29
That's what I figured why you chose to do it this
|
| + |
| // Initiates a connection to the device, pairing first if necessary. |
| // |
| // Method calls will be made on the supplied object |pairing_delegate| |
| @@ -384,12 +395,6 @@ class BluetoothDevice { |
| const GattConnectionCallback& callback, |
| const ConnectErrorCallback& error_callback) = 0; |
| - // Starts monitoring the connection properties, RSSI and TX power. These |
| - // properties will be tracked, and updated when their values change. Exactly |
| - // one of |callback| or |error_callback| will be run. |
| - virtual void StartConnectionMonitor(const base::Closure& callback, |
| - const ErrorCallback& error_callback) = 0; |
| - |
| // Returns the list of discovered GATT services. |
| virtual std::vector<BluetoothGattService*> GetGattServices() const; |