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

Side by Side Diff: content/common/bluetooth/bluetooth_device.cc

Issue 1427653003: bluetooth: Implement TxPower and RSSI of BluetoothAdvertisementData (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@my-origin
Patch Set: Change PowerValueAdapter to int8_t Created 5 years, 1 month 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "content/common/bluetooth/bluetooth_device.h" 5 #include "content/common/bluetooth/bluetooth_device.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 8
9 namespace content { 9 namespace content {
10 10
11 BluetoothDevice::BluetoothDevice() 11 BluetoothDevice::BluetoothDevice()
12 : id(""), 12 : id(""),
13 name(base::string16()), 13 name(base::string16()),
14 tx_power(device::BluetoothDevice::kUnknownPower),
15 rssi(device::BluetoothDevice::kUnknownPower),
14 device_class(0), 16 device_class(0),
15 vendor_id_source( 17 vendor_id_source(
16 device::BluetoothDevice::VendorIDSource::VENDOR_ID_UNKNOWN), 18 device::BluetoothDevice::VendorIDSource::VENDOR_ID_UNKNOWN),
17 vendor_id(0), 19 vendor_id(0),
18 product_id(0), 20 product_id(0),
19 product_version(0), 21 product_version(0),
20 paired(false), 22 paired(false),
21 uuids() {} 23 uuids() {}
22 24
23 BluetoothDevice::BluetoothDevice( 25 BluetoothDevice::BluetoothDevice(
24 const std::string& id, 26 const std::string& id,
25 const base::string16& name, 27 const base::string16& name,
28 int8_t tx_power,
29 int8_t rssi,
26 uint32 device_class, 30 uint32 device_class,
27 device::BluetoothDevice::VendorIDSource vendor_id_source, 31 device::BluetoothDevice::VendorIDSource vendor_id_source,
28 uint16 vendor_id, 32 uint16 vendor_id,
29 uint16 product_id, 33 uint16 product_id,
30 uint16 product_version, 34 uint16 product_version,
31 bool paired, 35 bool paired,
32 const std::vector<std::string>& uuids) 36 const std::vector<std::string>& uuids)
33 : id(id), 37 : id(id),
34 name(name), 38 name(name),
39 tx_power(tx_power),
40 rssi(rssi),
35 device_class(device_class), 41 device_class(device_class),
36 vendor_id_source(vendor_id_source), 42 vendor_id_source(vendor_id_source),
37 vendor_id(vendor_id), 43 vendor_id(vendor_id),
38 product_id(product_id), 44 product_id(product_id),
39 product_version(product_version), 45 product_version(product_version),
40 paired(paired), 46 paired(paired),
41 uuids(uuids) {} 47 uuids(uuids) {}
42 48
43 BluetoothDevice::~BluetoothDevice() { 49 BluetoothDevice::~BluetoothDevice() {
44 } 50 }
45 51
46 // static 52 // static
47 std::vector<std::string> BluetoothDevice::UUIDsFromBluetoothUUIDs( 53 std::vector<std::string> BluetoothDevice::UUIDsFromBluetoothUUIDs(
48 const device::BluetoothDevice::UUIDList& uuid_list) { 54 const device::BluetoothDevice::UUIDList& uuid_list) {
49 std::vector<std::string> uuids; 55 std::vector<std::string> uuids;
50 uuids.reserve(uuid_list.size()); 56 uuids.reserve(uuid_list.size());
51 for (const auto& it : uuid_list) 57 for (const auto& it : uuid_list)
52 uuids.push_back(it.canonical_value()); 58 uuids.push_back(it.canonical_value());
53 return uuids; 59 return uuids;
54 } 60 }
55 61
62 // static
63 int8_t BluetoothDevice::ValidatePower(int16_t power) {
64 return ((power < -127) || (power > 127)) ? BluetoothDevice::kUnknownPower
65 : power;
66 }
67
56 } // namespace content 68 } // namespace content
OLDNEW
« no previous file with comments | « content/common/bluetooth/bluetooth_device.h ('k') | content/common/bluetooth/bluetooth_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698