42 #ifndef BLUETOOTH_ADAPTER_HPP_ 43 #define BLUETOOTH_ADAPTER_HPP_ 50 #include "../../util/error/kallisto_error.hpp" 51 #include "../device/bluetooth_device.hpp" 56 class BluetoothAdapterNative;
63 class BluetoothAdapter {
106 virtual ~ScanListener(){}
117 const std::chrono::nanoseconds timestamp;
122 const std::map<std::string, std::vector<uint8_t>> service_data;
127 const std::map<uint16_t, std::vector<uint8_t>> manufacturer_data;
138 ScanRecord() : timestamp(std::chrono::nanoseconds(0)), rssi(0) {}
144 ScanRecord(std::chrono::nanoseconds _timestamp, std::map<std::string, std::vector<uint8_t>> _service_data, std::map<uint16_t, std::vector<uint8_t>> _manufacturer_data,
int _rssi):
145 timestamp(_timestamp), service_data(_service_data), manufacturer_data(_manufacturer_data), rssi(_rssi){}
151 virtual void onScanStart() = 0;
156 virtual void onScanStartFailed() = 0;
162 virtual void onScanStop(std::vector<BluetoothDevice*> devices_found) = 0;
169 virtual void onScan(BluetoothDevice& device,
const ScanRecord record) = 0;
174 std::unique_ptr<BluetoothAdapterNative> m_native_implementation;
210 std::string
getId()
const {
219 error::KallistoDetailedResult
enable();
225 error::KallistoDetailedResult
disable();
237 const std::vector<BluetoothDevice*>
getDevices();
243 BluetoothDevice*
getDevice(std::string address);
250 error::KallistoDetailedResult
registerListener(BluetoothAdapter::Listener& listener);
267 error::KallistoDetailedResult
startScan(BluetoothAdapter::ScanListener& listener);
273 error::KallistoDetailedResult
stopScan();
276 return (this->
getId() == other.getId());
280 return !(*
this == other);
BluetoothDevice * getDevice(std::string address)
Definition: bluetooth_adapter.hpp:52
virtual void onAdapterEnabled(BluetoothAdapter &adapter)=0
Error
Definition: bluetooth_adapter.hpp:75
const std::vector< BluetoothDevice * > getDevices()
error::KallistoDetailedResult registerListener(BluetoothAdapter::Listener &listener)
void unregisterListener()
error::KallistoDetailedResult startScan(BluetoothAdapter::ScanListener &listener)
error::KallistoDetailedResult stopScan()
BluetoothAdapter(std::string id)
virtual void onAdapterEnableFailed(BluetoothAdapter &adapter, BluetoothAdapter::Listener::Error error)=0
error::KallistoDetailedResult disable()
virtual void onAdapterDisabled(BluetoothAdapter &adapter)=0
error::KallistoDetailedResult enable()
std::string getId() const
Definition: bluetooth_adapter.hpp:209