OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "config.h" | |
6 #include "modules/bluetooth/BluetoothAdvertisingData.h" | |
7 | |
8 namespace blink { | |
9 | |
10 namespace { | |
11 const int kUnknownPower = INT8_MAX; | |
12 const int kNegativeUnknownPower = INT8_MIN; | |
scheib
2015/10/29 17:37:26
kNegativeUnknownPower seems to be a valid minimum
ortuno
2015/10/29 20:21:42
Done.
| |
13 } // namespace | |
14 | |
15 BluetoothAdvertisingData* BluetoothAdvertisingData::create(int txPower, int rssi ) | |
16 { | |
17 return new BluetoothAdvertisingData(txPower, rssi); | |
18 } | |
19 | |
20 int8_t BluetoothAdvertisingData::txPower(bool& isNull) | |
21 { | |
22 if (m_txPower == kUnknownPower) { | |
23 isNull = true; | |
24 } | |
25 return m_txPower; | |
26 } | |
27 | |
28 int8_t BluetoothAdvertisingData::rssi(bool& isNull) | |
29 { | |
30 if (m_rssi == kUnknownPower) { | |
31 isNull = true; | |
32 } | |
33 return m_rssi; | |
34 } | |
35 | |
36 static int8_t GetValidatedPower(int power) | |
37 { | |
38 return (power > kUnknownPower || power < kNegativeUnknownPower) ? kUnknownPo wer : power; | |
39 } | |
40 | |
41 BluetoothAdvertisingData::BluetoothAdvertisingData(int txPower, int rssi) | |
42 : m_txPower(GetValidatedPower(txPower)) | |
43 , m_rssi(GetValidatedPower(rssi)) | |
44 { | |
45 } | |
46 | |
47 } // namespace blink | |
OLD | NEW |