42 #ifndef KALLISTO_IMPL_HPP 43 #define KALLISTO_IMPL_HPP 52 #include "../util/error/kallisto_error.hpp" 61 #include "../bluetooth/adapter/bluetooth_adapter.hpp" 62 #include "../bluetooth/device/bluetooth_device.hpp" 63 #include "../bluetooth/device/bluetooth_dispatcher.hpp" 71 class KallistoImpl :
public Kallisto,
public bluetooth::BluetoothDispatcher {
74 static const std::string DIS_SERVICE_UUID;
76 static const std::string SW_VERSION_UUID;
78 static const std::string FW_VERSION_UUID;
80 static const std::string HW_VERSION_UUID;
82 static const std::string MANUFACTURER_UUID;
85 std::atomic_bool m_valid {
false};
87 bluetooth::BluetoothDevice* m_bluetooth_device;
89 std::atomic_bool m_discovered {
false};
91 std::atomic_bool m_stay_connected {
false};
95 std::atomic_bool m_link_loss {
false};
97 std::atomic_bool m_link_removed {
false};
99 std::thread m_link_loss_worker;
101 std::mutex m_link_loss_worker_mutex;
103 std::condition_variable m_link_loss_cv;
106 std::map<std::string, std::vector<uint8_t>> m_service_data;
108 std::map<uint16_t, std::vector<uint8_t>> m_manufacturer_data;
110 std::list<KallistoEventListener*> m_listeners;
112 std::unique_ptr<TimeSynchronizer> m_synchronizer =
nullptr;
115 SensorFactory& m_sensor_factory;
117 std::vector<std::unique_ptr<SensorImpl> > m_sensors;
119 util::Executor& m_event_dispatcher;
126 KallistoImpl(KallistoImpl
const&) =
delete;
127 KallistoImpl(KallistoImpl&&) =
delete;
128 void operator=(KallistoImpl
const&) =
delete;
129 void operator=(KallistoImpl &&) =
delete;
135 void closeInternal();
141 error::KallistoDetailedResult connect();
152 error::KallistoDetailedResult discover();
158 error::KallistoDetailedResult disconnect();
163 void onDisconnection();
175 bool getBeingUsedInternal();
190 util::Executor& event_dispatcher, SensorFactory& sensor_factory);
230 error::KallistoDetailedResult
registerListener(KallistoEventListener& listener);
269 error::KallistoDetailedResult
registerSensorListener(Sensor& sensor, std::map<std::string, const void*> parameters, SensorEventListener& listener);
290 error::KallistoDetailedResult
getRssi(
int& buffer);
293 error::KallistoDetailedResult
readCharacteristic(std::string service_uuid, std::string characteristic_uuid, std::vector<unsigned char>& buffer);
294 error::KallistoDetailedResult
writeCharacteristic(std::string service_uuid, std::string characteristic_uuid, std::vector<unsigned char>& buffer);
295 error::KallistoDetailedResult enableNotification(std::string service_uuid, std::string characteristic_uuid, BluetoothDispatcher::NotificationListener& listener);
296 error::KallistoDetailedResult disableNotification(std::string service_uuid, std::string characteristic_uuid, BluetoothDispatcher::NotificationListener& listener);
302 #endif // KALLISTO_IMPL_HPP error::KallistoDetailedResult onBluetoothDeviceRecovered(kallisto::bluetooth::BluetoothDevice &bluetooth_device)
std::vector< std::string > getServices()
error::KallistoDetailedResult unregisterListener(KallistoEventListener &listener)
std::vector< Sensor * > getSensors()
std::vector< std::string > getCharacteristics(std::string service_uuid)
Definition: bluetooth_adapter.hpp:52
Definition: bluetooth_device.hpp:58
error::KallistoDetailedResult getRssi(int &buffer)
error::KallistoDetailedResult readCharacteristic(std::string service_uuid, std::string characteristic_uuid, std::vector< unsigned char > &buffer)
Sensor * getSensor(unsigned int handle)
error::KallistoDetailedResult stayConnected(bool enable)
error::KallistoDetailedResult writeCharacteristic(std::string service_uuid, std::string characteristic_uuid, std::vector< unsigned char > &buffer)
error::KallistoDetailedResult registerSensorListener(Sensor &sensor, std::map< std::string, const void *> parameters, SensorEventListener &listener)
error::KallistoDetailedResult unregisterSensorListener(Sensor &sensor, SensorEventListener &listener)
error::KallistoDetailedResult registerListener(KallistoEventListener &listener)