Kallisto Linux API
Library for interacting with Kallisto devices
bluetooth_scanner_configuration.hpp
Go to the documentation of this file.
1 
42 #ifndef BLUETOOTH_SCANNER_CONFIGURATION_HPP_
43 #define BLUETOOTH_SCANNER_CONFIGURATION_HPP_
44 
45 #include <string>
46 #include <memory>
47 #include <chrono>
48 
49 namespace kallisto {
50 namespace bluetooth {
51 
55 #define MAX_DURATION std::chrono::seconds(60)
56 
60 #define MAX_CYCLE_DURATION std::chrono::seconds(3600)
61 
62 //Helper variables for scan duration
66 #define SHORT_SCAN std::chrono::seconds(5)
67 
70 #define MEDIUM_SCAN std::chrono::seconds(10)
71 
74 #define LONG_SCAN std::chrono::seconds(20)
75 
76 //Helper variables for scanner configuration
80 #define RESPONSIVE_SCANNER std::chrono::seconds(5)
81 
84 #define BALANCED_SCANNER std::chrono::seconds(15)
85 
88 #define LOW_POWER_SCANNER std::chrono::seconds(60)
89 
93 class BluetoothScannerConfiguration {
94 public:
95  class Builder;
96  friend class Builder;
97 
104  enum class ScanConfiguration {
109  ONE_SHOT,
113  CYCLIC,
118  CONTINUOUS,
122  STOPPED
123  };
124 
125 private:
127  ScanConfiguration m_scan_configuration; //Configuration
128 
130  std::chrono::seconds m_duration; //Scan duration, in seconds
131 
133  std::chrono::seconds m_cycle_duration; //Time variable for cyclic scanner, in seconds. Will only be used in CYCLIC configuration
134 
136  bool m_legacy_discovery; //If we should fallback to legacy discovery if device is not using Scan Response advertising
137 
141  BluetoothScannerConfiguration(ScanConfiguration scan_configuration, std::chrono::seconds scan_duration, std::chrono::seconds cycle_duration, bool legacy_discovery);
142 
143 public:
148 
152  BluetoothScannerConfiguration(const BluetoothScannerConfiguration& configuration);
153 
157  BluetoothScannerConfiguration& operator=(const BluetoothScannerConfiguration& configuration);
158 
162  BluetoothScannerConfiguration(BluetoothScannerConfiguration&& configuration);
163 
167  BluetoothScannerConfiguration& operator=(BluetoothScannerConfiguration&& configuration);
168 
175 
181  std::chrono::seconds getDuration() const;
182 
191  std::chrono::seconds getCycleDuration() const;
192 
201  bool getLegacyDiscovery() const;
203  class Builder {
204  private:
206  ScanConfiguration m_scan_configuration = ScanConfiguration::CYCLIC;
207 
209  bool m_configuration_explicit = false; //Signals if the dev forced the scan type
210 
212  std::chrono::seconds m_duration = std::chrono::seconds(0); //Scan duration
213 
215  std::chrono::seconds m_cycle_duration = std::chrono::seconds(0); //Time variable for cyclic scanner. Will only be used in CYCLIC configuration
216 
218  bool m_legacy_discovery = false; //If we should fallback to legacy discovery if device is not using Scan Response advertising
219 
223  Builder(Builder const&) = delete;
224  Builder(Builder&&) = delete;
225  void operator=(Builder const&) = delete;
226  void operator=(Builder &&) = delete;
227 
228  public:
232  Builder();
233 
237  ~Builder();
238 
246  Builder& continuous();
247 
255  Builder& stop();
256 
269  Builder& withDuration(std::chrono::seconds duration);
270 
278  Builder& withShortDuration();
279 
287  Builder& withMediumDuration();
288 
296  Builder& withLongDuration();
297 
313  Builder& withCycle(std::chrono::seconds cycle_time);
314 
322  Builder& withResponsiveCycle();
323 
331  Builder& withBalancedCycle();
332 
340  Builder& withLowPowerCycle();
341 
352  Builder& withLegacyDiscoveryFallback();
353 
360 
373  BluetoothScannerConfiguration buildDefault();
374  };
375 };
376 
377 } /* namespace bluetooth */
378 } /* namespace kallisto */
379 
380 #endif /* BLUETOOTH_SCANNER_CONFIGURATION_HPP_ */
Definition: bluetooth_adapter.hpp:52
Definition: bluetooth_scanner_configuration.hpp:202
Definition: bluetooth_scanner_configuration.hpp:92
ScanConfiguration
Definition: bluetooth_scanner_configuration.hpp:103
BluetoothScannerConfiguration & operator=(const BluetoothScannerConfiguration &configuration)