42 #ifndef KALLISTO_CORE_IMPL_HPP_ 43 #define KALLISTO_CORE_IMPL_HPP_ 51 #include "../util/error/kallisto_error.hpp" 52 #include "../util/log/logger_configurator.hpp" 54 #include "../bluetooth/adapter/bluetooth_adapter_manager.hpp" 55 #include "../bluetooth/scanner/bluetooth_scanner.hpp" 56 #include "../bluetooth/bluetooth_adapter_event_listener.hpp" 57 #include "../bluetooth/bluetooth_scan_event_listener.hpp" 59 #include "../hardware/kallisto_factory.hpp" 60 #include "../hardware/kallisto_impl.hpp" 61 #include "../hardware/kallisto_helper.hpp" 62 #include "../hardware/kallisto_event_listener.hpp" 63 #include "../hardware/hal/sensors/sensor_factory.hpp" 64 #include "../hardware/hal/sensors/sensor.hpp" 65 #include "../hardware/hal/sensors/sensor_event_listener.hpp" 78 std::unique_ptr<bluetooth::BluetoothAdapterManager> m_adapter_manager =
nullptr;
82 std::unique_ptr<bluetooth::BluetoothScanner> m_scanner =
nullptr;
87 enum class AdapterEventType {
88 ADAPTER_ENABLED, ADAPTER_DISABLED, ADAPTER_IRRECUPERABLE
90 enum class ScanEventType {
91 DEVICE_FOUND, DEVICE_LOST, DEVICE_REPORT
93 enum class KallistoEventType {
94 LINK_LOSS, LINK_RECOVERED, LINK_REMOVED
96 std::mutex m_listener_list_mutex;
97 std::list<bluetooth::BluetoothAdapterEventListener*> m_adapter_listeners;
98 std::list<bluetooth::BluetoothScanEventListener*> m_scan_listeners;
101 enum class LinkLossScanStatus {
102 SCANNING, STOPPING, STOPPED
104 std::atomic<LinkLossScanStatus> m_link_loss_scan_status {LinkLossScanStatus::STOPPED};
111 std::mutex m_device_list_mutex;
112 std::list<std::unique_ptr<hardware::KallistoImpl> > m_device_list;
113 std::list<std::unique_ptr<hardware::KallistoImpl> > m_device_to_remove_list;
136 void stopScanningForLinkLoss();
141 void onLinkLossScanStop();
147 void onNormalScanStop(std::vector<kallisto::bluetooth::BluetoothDevice*> devices_found);
261 std::vector<hardware::KallistoImpl*>
getDevices();
374 void onScanStop(std::vector<kallisto::bluetooth::BluetoothDevice*> devices_found);
error::KallistoDetailedResult unregisterBluetoothAdapterEventListener(bluetooth::BluetoothAdapterEventListener &listener)
error::KallistoDetailedResult unregisterListener(hardware::KallistoEventListener &listener, hardware::Kallisto &kallisto)
Definition: sensor.hpp:53
void sendAdapterEvent(AdapterEventType type)
void sendScanEvent(ScanEventType type, hardware::Kallisto &device, const bluetooth::BluetoothAdapter::ScanListener::ScanRecord record)
error::KallistoDetailedResult stayConnected(hardware::Kallisto &kallisto, bool enable)
void sendKallistoEvent(KallistoEventType type)
error::KallistoDetailedResult registerSensorListener(hardware::SensorEventListener &listener, hardware::Sensor &sensor, std::map< std::string, const void *> parameters)
void onAdapterDisconnected(bluetooth::BluetoothAdapter &adapter)
Definition: bluetooth_adapter.hpp:52
Definition: bluetooth_adapter.hpp:67
Definition: kallisto_event_listener.hpp:56
KallistoCoreImpl(kallisto::bluetooth::BluetoothScannerConfiguration &scanner_configuration, kallisto::bluetooth::BluetoothScannerFilter &scanner_filter)
void onAdapterEnableFailed(bluetooth::BluetoothAdapter &adapter, bluetooth::BluetoothAdapter::Listener::Error error)
Class that encapsulates a result.
Definition: kallisto_error.hpp:81
Definition: bluetooth_adapter_event_listener.hpp:52
error::KallistoDetailedResult unregisterBluetoothScanEventListener(bluetooth::BluetoothScanEventListener &listener)
Error
Definition: bluetooth_adapter.hpp:75
Definition: bluetooth_device.hpp:58
error::KallistoDetailedResult registerBluetoothScanEventListener(bluetooth::BluetoothScanEventListener &listener)
void onAdapterEnabled(bluetooth::BluetoothAdapter &adapter)
void onLinkRecovered(std::chrono::nanoseconds timestamp, hardware::Kallisto &device)
error::KallistoDetailedResult registerListener(hardware::KallistoEventListener &listener, hardware::Kallisto &kallisto)
error::KallistoDetailedResult registerBluetoothAdapterEventListener(bluetooth::BluetoothAdapterEventListener &listener)
error::KallistoDetailedResult setScannerConfiguration(bluetooth::BluetoothScannerConfiguration &configuration)
Definition: bluetooth_scanner_filter.hpp:64
Definition: bluetooth_adapter.hpp:62
Definition: kallisto.hpp:52
Definition: bluetooth_scanner_configuration.hpp:92
void onScan(bluetooth::BluetoothDevice &device, const bluetooth::BluetoothAdapter::ScanListener::ScanRecord record)
Definition: executor.hpp:71
Definition: sensor_factory.hpp:60
Definition: bluetooth_adapter.hpp:111
const bluetooth::BluetoothScannerFilter * getScannerFilter()
Definition: kallisto_core.hpp:57
void onLinkLoss(std::chrono::nanoseconds timestamp, hardware::Kallisto &device)
const bluetooth::BluetoothScannerConfiguration * getScannerConfiguration()
Definition: kallisto_factory.hpp:56
std::vector< hardware::KallistoImpl * > getDevices()
void onAdapterDisabled(bluetooth::BluetoothAdapter &adapter)
void onLinkRemoved(std::chrono::nanoseconds, hardware::Kallisto &device)
error::KallistoDetailedResult setScannerFilter(bluetooth::BluetoothScannerFilter &filter)
error::KallistoDetailedResult unregisterSensorListener(hardware::SensorEventListener &listener, hardware::Sensor &sensor)
Definition: bluetooth_scan_event_listener.hpp:57
void onAdapterConnected(bluetooth::BluetoothAdapter &adapter)
Definition: bluetooth_adapter_manager.hpp:63
void onScanStop(std::vector< kallisto::bluetooth::BluetoothDevice *> devices_found)
Definition: sensor_event_listener.hpp:123
Definition: bluetooth_adapter.hpp:103
Definition: kallisto_core_impl.hpp:69