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

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: 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 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.
81 static const int kUnknownPower = 127; 81 // We use 127 based on Bluetooth Spec Core Version 4.2 Vol 2, Part E 7.7.65.2
82 // LE Advertising Report Event.
83 enum : int8_t { kUnknownRSSI = 127 };
84 // The value returned if the TxPower cannot be read.
85 // We use -128 based on Core Specification Supplement (CSS) v6 Part A 1.5.2
86 // Format.
87 enum : int8_t { kUnknownTxPower = -128 };
88
82 // The value returned if the appearance is not present. 89 // The value returned if the appearance is not present.
83 static const uint16_t kAppearanceNotPresent = 0xffc0; 90 static const uint16_t kAppearanceNotPresent = 0xffc0;
84 91
85 struct DEVICE_BLUETOOTH_EXPORT ConnectionInfo { 92 struct DEVICE_BLUETOOTH_EXPORT ConnectionInfo {
86 int rssi; 93 int8_t rssi;
87 int transmit_power; 94 int8_t transmit_power;
88 int max_transmit_power; 95 int8_t max_transmit_power;
89 96
90 ConnectionInfo(); 97 ConnectionInfo();
91 ConnectionInfo(int rssi, int transmit_power, int max_transmit_power); 98 ConnectionInfo(int8_t rssi,
99 int8_t transmit_power,
100 int8_t max_transmit_power);
92 ~ConnectionInfo(); 101 ~ConnectionInfo();
93 }; 102 };
94 103
95 // Possible errors passed back to an error callback function in case of a 104 // Possible errors passed back to an error callback function in case of a
96 // failed call to Connect(). 105 // failed call to Connect().
97 enum ConnectErrorCode { 106 enum ConnectErrorCode {
98 ERROR_ATTRIBUTE_LENGTH_INVALID, 107 ERROR_ATTRIBUTE_LENGTH_INVALID,
99 ERROR_AUTH_CANCELED, 108 ERROR_AUTH_CANCELED,
100 ERROR_AUTH_FAILED, 109 ERROR_AUTH_FAILED,
101 ERROR_AUTH_REJECTED, 110 ERROR_AUTH_REJECTED,
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 bool IsTrustable() const; 286 bool IsTrustable() const;
278 287
279 // Returns the set of UUIDs that this device supports. For classic Bluetooth 288 // 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, 289 // 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 290 // 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./ 291 // services, for dual mode devices this may be collected from both./
283 virtual UUIDList GetUUIDs() const = 0; 292 virtual UUIDList GetUUIDs() const = 0;
284 293
285 // The received signal strength, in dBm. This field is avaliable and valid 294 // 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, 295 // only during discovery. If not during discovery, or RSSI wasn't reported,
287 // this method will return |kUnknownPower|. 296 // this method will return |kUnknownRSSI|.
288 virtual int16_t GetInquiryRSSI() const = 0; 297 virtual int8_t GetInquiryRSSI() const = 0;
289 298
290 // The transmitted power level. This field is avaliable only for LE devices 299 // 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 300 // 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 301 // discovery. If not during discovery, or TxPower wasn't reported, this
293 // method will return |kUnknownPower|. 302 // method will return |kUnknownTxPower|.
294 virtual int16_t GetInquiryTxPower() const = 0; 303 virtual int8_t GetInquiryTxPower() const = 0;
295 304
296 // The ErrorCallback is used for methods that can fail in which case it 305 // 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. 306 // is called, in the success case the callback is simply not called.
298 typedef base::Callback<void()> ErrorCallback; 307 typedef base::Callback<void()> ErrorCallback;
299 308
300 // The ConnectErrorCallback is used for methods that can fail with an error, 309 // The ConnectErrorCallback is used for methods that can fail with an error,
301 // passed back as an error code argument to this callback. 310 // passed back as an error code argument to this callback.
302 // In the success case this callback is not called. 311 // In the success case this callback is not called.
303 typedef base::Callback<void(enum ConnectErrorCode)> ConnectErrorCallback; 312 typedef base::Callback<void(enum ConnectErrorCode)> ConnectErrorCallback;
304 313
(...skipping 16 matching lines...) Expand all
321 // The RSSI indicates the power present in the received radio signal, measured 330 // 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 331 // in dBm, to a resolution of 1dBm. Larger (typically, less negative) values
323 // indicate a stronger signal. 332 // indicate a stronger signal.
324 // 333 //
325 // The transmit power indicates the strength of the signal broadcast from the 334 // The transmit power indicates the strength of the signal broadcast from the
326 // host's Bluetooth antenna when communicating with the device, measured in 335 // host's Bluetooth antenna when communicating with the device, measured in
327 // dBm, to a resolution of 1dBm. Larger (typically, less negative) values 336 // dBm, to a resolution of 1dBm. Larger (typically, less negative) values
328 // indicate a stronger signal. 337 // indicate a stronger signal.
329 // 338 //
330 // If the device isn't connected, then the ConnectionInfo struct passed into 339 // If the device isn't connected, then the ConnectionInfo struct passed into
331 // the callback will be populated with |kUnknownPower|. 340 // the callback will be populated with |kUnknownRSSI| and |kUnknownTxPower|.
332 virtual void GetConnectionInfo(const ConnectionInfoCallback& callback) = 0; 341 virtual void GetConnectionInfo(const ConnectionInfoCallback& callback) = 0;
333 342
334 // Initiates a connection to the device, pairing first if necessary. 343 // Initiates a connection to the device, pairing first if necessary.
335 // 344 //
336 // Method calls will be made on the supplied object |pairing_delegate| 345 // Method calls will be made on the supplied object |pairing_delegate|
337 // to indicate what display, and in response should make method calls 346 // to indicate what display, and in response should make method calls
338 // back to the device object. Not all devices require user responses 347 // back to the device object. Not all devices require user responses
339 // during pairing, so it is normal for |pairing_delegate| to receive no 348 // during pairing, so it is normal for |pairing_delegate| to receive no
340 // calls. To explicitly force a low-security connection without bonding, 349 // calls. To explicitly force a low-security connection without bonding,
341 // pass NULL, though this is ignored if the device is already paired. 350 // 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 561
553 private: 562 private:
554 // Returns a localized string containing the device's bluetooth address and 563 // Returns a localized string containing the device's bluetooth address and
555 // a device type for display when |name_| is empty. 564 // a device type for display when |name_| is empty.
556 base::string16 GetAddressWithLocalizedDeviceTypeName() const; 565 base::string16 GetAddressWithLocalizedDeviceTypeName() const;
557 }; 566 };
558 567
559 } // namespace device 568 } // namespace device
560 569
561 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_ 570 #endif // DEVICE_BLUETOOTH_BLUETOOTH_DEVICE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698