/*! * \copyright * Copyright (c) 2019-2020 Diality Inc. - All Rights Reserved. * THIS CODE MAY NOT BE COPIED OR REPRODUCED IN ANY FORM, IN PART OR IN * WHOLE, WITHOUT THE EXPLICIT PERMISSION OF THE COPYRIGHT OWNER. * * \file BluetoothInterface.h * \author (last) Behrouz NematiPour * \author (original) Behrouz NematiPour * \date (last) 22-Aug-2021 * \date (original) 22-Aug-2021 */ #pragma once // Qt #include #include #include #include // Project #include "main.h" // Doxygen : do not remove #include "MBluetooth.h" // Define #define _BluetoothInterface Bluetooth::BluetoothInterface::I() // forward declarations class tst_initializations; // namespace namespace Bluetooth { using namespace Model; /*! * \brief The MessageAcknowModel class * \details The wrapper class of the AcknowModel which does the thread handling. */ class BluetoothInterface : public QObject { Q_OBJECT // Singleton SINGLETON(BluetoothInterface) // friends friend class ::tst_initializations; QThread *_thread = nullptr; bool _init = false; QBluetoothLocalDevice *_local ; QBluetoothDeviceDiscoveryAgent *_agent ; QLowEnergyController *_device ; // Factory pointer QBluetoothDeviceInfo _info ; MBluetooth _model ; MBluetooth::InterfaceStates _state ; bool _bpRead = false; const quint16 _interval = 1000 ; // the interface timer base interval in mSec protected: void timerEvent(QTimerEvent *event) override; public slots: bool init(); bool init(QThread &vThread); void doScan(); private slots: void quit(); void onDestroy(); // Local Device Slots void onLocalPairingFinish (const QBluetoothAddress &vAddress, QBluetoothLocalDevice::Pairing vPairing); void onLocalPairingDisplayConfirmation (const QBluetoothAddress &vAddress, const QString &vPin); void onLocalPairingDisplayPinCode (const QBluetoothAddress &vAddress, const QString &vPin); void onLocalDeviceConnect (const QBluetoothAddress &vAddress); void onLocalDeviceDisconnect (const QBluetoothAddress &vAddress); void onLocalError (QBluetoothLocalDevice::Error vError); // Discovery Agent Slots void onAgentDiscoverDevice(const QBluetoothDeviceInfo &vDevice); void onAgentDiscoverFinish(); void onAgentDiscoverCancel(); void onAgentDiscoverError (QBluetoothDeviceDiscoveryAgent::Error vError); private: void initConnections(); void initThread(QThread &vThread); void quitThread(); bool discoverStart (); bool discoverFinish (); void notifyStateChange(const MBluetooth &vData); signals: void didStateChange(const Model::MBluetooth &vData); SAFE_CALL(start) }; }