Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(135)

Unified Diff: device/bluetooth/bluetooth_device.h

Issue 1941923002: bluetooth: Return int8_t and use -128 for unknown tx power. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Use enum and change to EXPECT_EQ Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: device/bluetooth/bluetooth_device.h
diff --git a/device/bluetooth/bluetooth_device.h b/device/bluetooth/bluetooth_device.h
index 2d7f4b96d6991375155559beb44fb2ee72ea7b53..768543abe3c9644e9fbd2161a741207b7062e890 100644
--- a/device/bluetooth/bluetooth_device.h
+++ b/device/bluetooth/bluetooth_device.h
@@ -77,18 +77,27 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDevice {
DEVICE_KEYBOARD_MOUSE_COMBO
};
- // The value returned if the RSSI or transmit power cannot be read.
- static const int kUnknownPower = 127;
+ // The value returned if the RSSI cannot be read.
+ // We use 127 based on Bluetooth Spec Core Version 4.2 Vol 2, Part E 7.7.65.2
+ // LE Advertising Report Event.
+ enum : int8_t { kUnknownRSSI = 127 };
+ // The value returned if the TxPower cannot be read.
+ // We use -128 based on Core Specification Supplement (CSS) v6 Part A 1.5.2
+ // Format.
+ enum : int8_t { kUnknownTxPower = -128 };
+
// The value returned if the appearance is not present.
static const uint16_t kAppearanceNotPresent = 0xffc0;
struct DEVICE_BLUETOOTH_EXPORT ConnectionInfo {
- int rssi;
- int transmit_power;
- int max_transmit_power;
+ int8_t rssi;
+ int8_t transmit_power;
+ int8_t max_transmit_power;
ConnectionInfo();
- ConnectionInfo(int rssi, int transmit_power, int max_transmit_power);
+ ConnectionInfo(int8_t rssi,
+ int8_t transmit_power,
+ int8_t max_transmit_power);
~ConnectionInfo();
};
@@ -284,14 +293,14 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDevice {
// The received signal strength, in dBm. This field is avaliable and valid
// only during discovery. If not during discovery, or RSSI wasn't reported,
- // this method will return |kUnknownPower|.
- virtual int16_t GetInquiryRSSI() const = 0;
+ // this method will return |kUnknownRSSI|.
+ virtual int8_t GetInquiryRSSI() const = 0;
// The transmitted power level. This field is avaliable only for LE devices
// that include this field in AD. It is avaliable and valid only during
// discovery. If not during discovery, or TxPower wasn't reported, this
- // method will return |kUnknownPower|.
- virtual int16_t GetInquiryTxPower() const = 0;
+ // method will return |kUnknownTxPower|.
+ virtual int8_t GetInquiryTxPower() const = 0;
// The ErrorCallback is used for methods that can fail in which case it
// is called, in the success case the callback is simply not called.
@@ -328,7 +337,7 @@ class DEVICE_BLUETOOTH_EXPORT BluetoothDevice {
// indicate a stronger signal.
//
// If the device isn't connected, then the ConnectionInfo struct passed into
- // the callback will be populated with |kUnknownPower|.
+ // the callback will be populated with |kUnknownRSSI| and |kUnknownTxPower|.
virtual void GetConnectionInfo(const ConnectionInfoCallback& callback) = 0;
// Initiates a connection to the device, pairing first if necessary.

Powered by Google App Engine
This is Rietveld 408576698