#ifndef BLUETOOTH_H #define BLUETOOTH_H #include #include // For now #include #include #define D BOOST_LOG_TRIVIAL(debug) #define I BOOST_LOG_TRIVIAL(info) #define W BOOST_LOG_TRIVIAL(warning) namespace trygvis { using namespace std; class BluetoothAdapter; class BluetoothDevice; class BluetoothException : public runtime_error { public: BluetoothException(const BluetoothAdapter *adapter, string const &what) : adapter(adapter), device(nullptr), runtime_error(what) { } BluetoothException(const BluetoothAdapter *adapter, const BluetoothDevice *device, string const &what) : adapter(adapter), device(device), runtime_error(what) { } const BluetoothAdapter *adapter; const BluetoothDevice *device; }; class Mac { public: Mac(uint8_t _0, uint8_t _1, uint8_t _2, uint8_t _3, uint8_t _4, uint8_t _5) { bytes[0] = _0; bytes[1] = _1; bytes[2] = _2; bytes[3] = _3; bytes[4] = _4; bytes[5] = _5; }; string str() const; bool operator==(Mac& other) const; void copy(uint8_t &_0, uint8_t &_1, uint8_t &_2, uint8_t &_3, uint8_t &_4, uint8_t &_5) const; static Mac *parseMac(string s); private: uint8_t bytes[6]; }; class BluetoothDevice { public: virtual Mac const &mac() = 0; virtual void connect() = 0; virtual void disconnect() = 0; virtual BluetoothAdapter& adapter() = 0; }; class BluetoothAdapter { public: BluetoothAdapter() {}; virtual ~BluetoothAdapter(); virtual void stopScan() = 0; virtual void runScan(void (callback)(BluetoothDevice &device)) = 0; }; // BluetoothAdapter &getDevice(int hciDevice); BluetoothAdapter *getDevice(int hciDevice); } #endif