42 #ifndef BLUETOOTH_SCANNER_HPP_ 43 #define BLUETOOTH_SCANNER_HPP_ 48 #include "../../util/error/kallisto_error.hpp" 49 #include "../../util/executor/executor.hpp" 50 #include "../adapter/bluetooth_adapter.hpp" 60 class BluetoothScanner : BluetoothAdapter::ScanListener {
63 BluetoothAdapter& m_adapter;
65 BluetoothScannerConfiguration m_scan_configuration = BluetoothScannerConfiguration::Builder().buildDefault();
67 BluetoothScannerFilter m_scan_filter = BluetoothScannerFilter::Builder().buildDefault();
69 BluetoothAdapter::ScanListener* m_listener =
nullptr;
71 std::atomic_bool m_running{
false};
73 util::Executor m_event_dispatcher{
"BluetoothScanner", 1};
75 std::thread m_scanner_thread;
77 std::mutex m_scanner_mtx;
79 std::condition_variable m_scanner_cv;
84 void scannerRunnable();
94 void onScanStartFailed();
100 void onScanStop(std::vector<BluetoothDevice*> devices_found);
107 void onScan(BluetoothDevice& device,
const ScanRecord record);
112 BluetoothScanner(BluetoothScanner
const&) =
delete;
113 BluetoothScanner(BluetoothScanner&&) =
delete;
114 void operator=(BluetoothScanner
const&) =
delete;
115 void operator=(BluetoothScanner &&) =
delete;
121 BluetoothScanner(BluetoothAdapter& adapter);
136 error::KallistoDetailedResult
start(BluetoothScannerConfiguration& configuration, BluetoothScannerFilter& filter, BluetoothAdapter::ScanListener& listener);
143 error::KallistoDetailedResult
stop();
150 return m_scan_configuration;
157 const BluetoothScannerFilter&
getFilter(){
158 return m_scan_filter;
166 error::KallistoDetailedResult
setConfiguration(BluetoothScannerConfiguration& configuration);
173 error::KallistoDetailedResult
setFilter(BluetoothScannerFilter& filter);
error::KallistoDetailedResult start(BluetoothScannerConfiguration &configuration, BluetoothScannerFilter &filter, BluetoothAdapter::ScanListener &listener)
error::KallistoDetailedResult setFilter(BluetoothScannerFilter &filter)
Definition: bluetooth_adapter.hpp:52
error::KallistoDetailedResult stop()
const BluetoothScannerFilter & getFilter()
Definition: bluetooth_scanner.hpp:156
error::KallistoDetailedResult setConfiguration(BluetoothScannerConfiguration &configuration)
const BluetoothScannerConfiguration & getConfiguration()
Definition: bluetooth_scanner.hpp:148