2 // Copyright (C) 2015 Google, Inc.
4 // Licensed under the Apache License, Version 2.0 (the "License");
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at:
8 // http://www.apache.org/licenses/LICENSE-2.0
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
19 #include <base/macros.h>
20 #include <base/time/time.h>
24 // AdvertiseSettings provides a way to adjust advertising preferences for each
25 // Bluetooth LE advertisement instance. This is the native equivalent of the
26 // Android framework class defined in
27 // frameworks/base/core/java/android/bluetooth/le/AdvertiseSettings.java
28 class AdvertiseSettings {
30 // Advertising mode describes power consumption mode used for advertising.
32 // Perform Bluetooth LE advertising in low power mode. This is the default
33 // and preferred advertising mode as it consumes the least power.
34 MODE_LOW_POWER = 0x00,
36 // Perform Bluetooth LE advertising in balanced power mode. This is balanced
37 // between advertising frequency and power consumption.
40 // Perform Bluetooth LE advertising in low latency, high power mode. This
41 // has the highest power consumption and should not be used for continuous
42 // background advertising.
43 MODE_LOW_LATENCY = 0x02,
46 // Levels that can be set for advertising transmission power.
48 // Advertise using the lowest transmission (TX) power level. Low
49 // transmission power can be used to restrict the visibility range of
50 // advertising packets.
51 TX_POWER_LEVEL_ULTRA_LOW = 0x00,
53 // Advertise using low TX power level.
54 TX_POWER_LEVEL_LOW = 0x01,
56 // Advertise using medium TX power level.
57 TX_POWER_LEVEL_MEDIUM = 0x02,
59 // Advertise using high TX power level. This corresponds to largest
60 // visibility range of the advertising packet.
61 TX_POWER_LEVEL_HIGH = 0x03,
64 AdvertiseSettings(Mode mode,
65 base::TimeDelta timeout,
66 TxPowerLevel tx_power_level,
69 // The default constructor sets all fields to defaults:
70 // mode: MODE_LOW_POWER
71 // TX power level: TX_POWER_LEVEL_MEDIUM
74 ~AdvertiseSettings() = default;
76 // Returns the advertise mode.
77 Mode mode() const { return mode_; }
79 // Returns the advertising time limit in milliseconds.
80 const base::TimeDelta& timeout() const { return timeout_; }
82 // Returns the TX power level for advertising.
83 TxPowerLevel tx_power_level() const { return tx_power_level_; }
85 // Returns whether the advertisement will indicate connectable.
86 bool connectable() const { return connectable_; }
88 // Comparison operator.
89 bool operator==(const AdvertiseSettings& rhs) const;
93 base::TimeDelta timeout_;
94 TxPowerLevel tx_power_level_;
98 } // namespace bluetooth