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

Side by Side 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: Moar fixes 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 unified diff | Download patch
OLDNEW
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> 8 #include <stddef.h>
9 #include <stdint.h> 9 #include <stdint.h>
10 10
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 DEVICE_VIDEO, 70 DEVICE_VIDEO,
71 DEVICE_PERIPHERAL, 71 DEVICE_PERIPHERAL,
72 DEVICE_JOYSTICK, 72 DEVICE_JOYSTICK,
73 DEVICE_GAMEPAD, 73 DEVICE_GAMEPAD,
74 DEVICE_KEYBOARD, 74 DEVICE_KEYBOARD,
75 DEVICE_MOUSE, 75 DEVICE_MOUSE,
76 DEVICE_TABLET, 76 DEVICE_TABLET,
77 DEVICE_KEYBOARD_MOUSE_COMBO 77 DEVICE_KEYBOARD_MOUSE_COMBO
78 }; 78 };
79 79
80 // The value returned if the RSSI or transmit power cannot be read. 80 // The value returned if the RSSI cannot be read.
scheib 2016/05/04 01:18:37 Helps to cite the location of the Bluetooth spec t
ortuno 2016/05/04 16:44:11 Done. Let me know if you prefer another format.
81 static const int kUnknownPower = 127; 81 static constexpr int8_t kUnknownRSSI = 127;
82 // The value returned if the TxPower cannot be read.
83 static constexpr int8_t kUnknownTxPower = -128;
84
82 // The value returned if the appearance is not present. 85 // The value returned if the appearance is not present.
83 static const uint16_t kAppearanceNotPresent = 0xffc0; 86 static const uint16_t kAppearanceNotPresent = 0xffc0;
84 87
85 struct DEVICE_BLUETOOTH_EXPORT ConnectionInfo { 88 struct DEVICE_BLUETOOTH_EXPORT ConnectionInfo {
86 int rssi; 89 int8_t rssi;
87 int transmit_power; 90 int8_t transmit_power;
88 int max_transmit_power; 91 int8_t max_transmit_power;
89 92
90 ConnectionInfo(); 93 ConnectionInfo();
91 ConnectionInfo(int rssi, int transmit_power, int max_transmit_power); 94 ConnectionInfo(int8_t rssi,
95 int8_t transmit_power,
96 int8_t max_transmit_power);
92 ~ConnectionInfo(); 97 ~ConnectionInfo();
93 }; 98 };
94 99
95 // Possible errors passed back to an error callback function in case of a 100 // Possible errors passed back to an error callback function in case of a
96 // failed call to Connect(). 101 // failed call to Connect().
97 enum ConnectErrorCode { 102 enum ConnectErrorCode {
98 ERROR_ATTRIBUTE_LENGTH_INVALID, 103 ERROR_ATTRIBUTE_LENGTH_INVALID,
99 ERROR_AUTH_CANCELED, 104 ERROR_AUTH_CANCELED,
100 ERROR_AUTH_FAILED, 105 ERROR_AUTH_FAILED,
101 ERROR_AUTH_REJECTED, 106 ERROR_AUTH_REJECTED,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 bool IsTrustable() const; 282 bool IsTrustable() const;
278 283
279 // Returns the set of UUIDs that this device supports. For classic Bluetooth 284 // Returns the set of UUIDs that this device supports. For classic Bluetooth
280 // devices this data is collected from both the EIR data and SDP tables, 285 // devices this data is collected from both the EIR data and SDP tables,
281 // for Low Energy devices this data is collected from AD and GATT primary 286 // for Low Energy devices this data is collected from AD and GATT primary
282 // services, for dual mode devices this may be collected from both./ 287 // services, for dual mode devices this may be collected from both./
283 virtual UUIDList GetUUIDs() const = 0; 288 virtual UUIDList GetUUIDs() const = 0;
284 289
285 // The received signal strength, in dBm. This field is avaliable and valid 290 // The received signal strength, in dBm. This field is avaliable and valid
286 // only during discovery. If not during discovery, or RSSI wasn't reported, 291 // only during discovery. If not during discovery, or RSSI wasn't reported,
287 // this method will return |kUnknownPower|. 292 // this method will return |kUnknownRSSI|.
288 virtual int16_t GetInquiryRSSI() const = 0; 293 virtual int8_t GetInquiryRSSI() const = 0;
289 294
290 // The transmitted power level. This field is avaliable only for LE devices 295 // The transmitted power level. This field is avaliable only for LE devices
291 // that include this field in AD. It is avaliable and valid only during 296 // that include this field in AD. It is avaliable and valid only during
292 // discovery. If not during discovery, or TxPower wasn't reported, this 297 // discovery. If not during discovery, or TxPower wasn't reported, this
293 // method will return |kUnknownPower|. 298 // method will return |kUnknownTxPower|.
294 virtual int16_t GetInquiryTxPower() const = 0; 299 virtual int8_t GetInquiryTxPower() const = 0;
295 300
296 // The ErrorCallback is used for methods that can fail in which case it 301 // The ErrorCallback is used for methods that can fail in which case it
297 // is called, in the success case the callback is simply not called. 302 // is called, in the success case the callback is simply not called.
298 typedef base::Callback<void()> ErrorCallback; 303 typedef base::Callback<void()> ErrorCallback;
299 304
300 // The ConnectErrorCallback is used for methods that can fail with an error, 305 // The ConnectErrorCallback is used for methods that can fail with an error,
301 // passed back as an error code argument to this callback. 306 // passed back as an error code argument to this callback.
302 // In the success case this callback is not called. 307 // In the success case this callback is not called.
303 typedef base::Callback<void(enum ConnectErrorCode)> ConnectErrorCallback; 308 typedef base::Callback<void(enum ConnectErrorCode)> ConnectErrorCallback;
304 309
(...skipping 16 matching lines...) Expand all
321 // The RSSI indicates the power present in the received radio signal, measured 326 // The RSSI indicates the power present in the received radio signal, measured
322 // in dBm, to a resolution of 1dBm. Larger (typically, less negative) values 327 // in dBm, to a resolution of 1dBm. Larger (typically, less negative) values
323 // indicate a stronger signal. 328 // indicate a stronger signal.
324 // 329 //
325 // The transmit power indicates the strength of the signal broadcast from the 330 // The transmit power indicates the strength of the signal broadcast from the
326 // host's Bluetooth antenna when communicating with the device, measured in 331 // host's Bluetooth antenna when communicating with the device, measured in
327 // dBm, to a resolution of 1dBm. Larger (typically, less negative) values 332 // dBm, to a resolution of 1dBm. Larger (typically, less negative) values
328 // indicate a stronger signal. 333 // indicate a stronger signal.
329 // 334 //
330 // If the device isn't connected, then the ConnectionInfo struct passed into 335 // If the device isn't connected, then the ConnectionInfo struct passed into
331 // the callback will be populated with |kUnknownPower|. 336 // the callback will be populated with |kUnknownRSSI| and |kUnknownTxPower|.
332 virtual void GetConnectionInfo(const ConnectionInfoCallback& callback) = 0; 337 virtual void GetConnectionInfo(const ConnectionInfoCallback& callback) = 0;
333 338
334 // Initiates a connection to the device, pairing first if necessary. 339 // Initiates a connection to the device, pairing first if necessary.
335 // 340 //
336 // Method calls will be made on the supplied object |pairing_delegate| 341 // Method calls will be made on the supplied object |pairing_delegate|
337 // to indicate what display, and in response should make method calls 342 // to indicate what display, and in response should make method calls
338 // back to the device object. Not all devices require user responses 343 // back to the device object. Not all devices require user responses
339 // during pairing, so it is normal for |pairing_delegate| to receive no 344 // during pairing, so it is normal for |pairing_delegate| to receive no
340 // calls. To explicitly force a low-security connection without bonding, 345 // calls. To explicitly force a low-security connection without bonding,
341 // pass NULL, though this is ignored if the device is already paired. 346 // pass NULL, though this is ignored if the device is already paired.
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 557
553 private: 558 private:
554 // Returns a localized string containing the device's bluetooth address and 559 // Returns a localized string containing the device's bluetooth address and
555 // a device type for display when |name_| is empty. 560 // a device type for display when |name_| is empty.
556 base::string16 GetAddressWithLocalizedDeviceTypeName() const; 561 base::string16 GetAddressWithLocalizedDeviceTypeName() const;
557 }; 562 };
558 563
559 } // namespace device 564 } // namespace device
560 565
561 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ 566 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698