#ifndef VBLUETOOTH_H #define VBLUETOOTH_H // Qt #include #include #include // Project #include "VBluetoothDeviceInfo.h" #include "GuiController.h" using namespace Gui; using namespace Storage; // forward declarations class tst_views; namespace View { class VBluetooth : public QObject { Q_OBJECT public: explicit VBluetooth(QObject *parent = nullptr); protected: Q_PROPERTY(QVariant devices READ doGetDevices NOTIFY didDevicesChanged) Q_PROPERTY(QVariant pairedDevices READ doGetPairedDevices NOTIFY didPairedDevicesChanged) Q_PROPERTY(QVariant status READ getStatus NOTIFY didStatusChanged) public slots: void doScanForDevices(); QVariant doGetDevices(); QVariant doGetPairedDevices(); void doSelectDevice(const QString &addr); void doSaveMyDevices(const QString &path = Bluetooth_Saved_Devices_Path_JSON); signals: void didDevicesChanged(); void didSelectDevice(const QString &addr); void didScanFinished(); void didStatusChanged(); void didRequestScanForDevices(); void didPairedDevicesChanged(); void didRequestConcurrentSave(QString, QString, bool); private: QList bleDevices; QList pairedDevices; QString status; QString getStatus() { return status; } QString controllerErrorToString(QLowEnergyController::Error error); bool isDeviceAlreadyPaired(const QBluetoothDeviceInfo &deviceInfo); void removeFromDevices(const VBluetoothDeviceInfo *info); void setDeviceConnected(const QBluetoothDeviceInfo &deviceInfo, const bool &connected); private slots: void onScanForDevicesError(QBluetoothDeviceDiscoveryAgent::Error error); void onScanForDevicesFinished(); void onDeviceDiscovered(const QBluetoothDeviceInfo &device); void onConnectingToDevice(); void onUpdateStatus(const QString &message); void onControllerError(QLowEnergyController::Error error); void onConnectedToDevice(const QBluetoothDeviceInfo &deviceInfo); void onDisconnectedFromDevice(const QBluetoothDeviceInfo &deviceInfo); void onLoadMyDevices(const QString &path = Bluetooth_Saved_Devices_Path_JSON); }; } #endif // VBLUETOOTH_H