Index: sources/bluetooth/BluetoothInterface.h =================================================================== diff -u -r2dd767833cf0cf706c457951c2d78e7e20aff768 -r028cb1403e8fcb2d2e9ab2aa1562f660124015b1 --- sources/bluetooth/BluetoothInterface.h (.../BluetoothInterface.h) (revision 2dd767833cf0cf706c457951c2d78e7e20aff768) +++ sources/bluetooth/BluetoothInterface.h (.../BluetoothInterface.h) (revision 028cb1403e8fcb2d2e9ab2aa1562f660124015b1) @@ -17,6 +17,7 @@ #include #include #include +#include // Project #include "main.h" // Doxygen : do not remove @@ -46,46 +47,59 @@ // friends friend class ::tst_initializations; + typedef QMap< QBluetoothUuid::ServiceClassUuid, QLowEnergyService *> ServiceMap; + 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 + QStringList _supportedDeviceKeywords { "BP7000", "BLEsmart", "BLESmart" }; // Regarding to Omron Documents. + QBluetoothLocalDevice *_local = nullptr ; + QBluetoothDeviceDiscoveryAgent *_agent = nullptr ; + QLowEnergyController *_device = nullptr ; + QLowEnergyService *_serviceDeviceInformation = nullptr ; + QLowEnergyService *_serviceCurrentTime = nullptr ; + QLowEnergyService *_serviceBloodPressure = nullptr ; + QLowEnergyService *_serviceBattery = nullptr ; + + 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); + 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); + void onAgentDiscoverDevice (const QBluetoothDeviceInfo & vDevice ); + void onAgentDiscoverFinish (); + void onAgentDiscoverCancel (); + void onAgentDiscoverError ( QBluetoothDeviceDiscoveryAgent::Error vError ); + // Device Slots + void onDeviceConnect ( ); + void onDeviceDisconnect ( ); + void onDeviceError ( QLowEnergyController::Error vError ); + void onDeviceStateChanged ( QLowEnergyController::ControllerState vState ); + void onDeviceConnectionUpdated (const QLowEnergyConnectionParameters & vParameters ); private: void initConnections(); @@ -95,11 +109,24 @@ bool discoverStart (); bool discoverFinish (); - void notifyStateChange(const MBluetooth &vData); + bool isLocalValid (); + bool isInfoValid (); + bool isDeviceValid (); + bool isDeviceSupported( const QString &vName ); + + bool initDevice (); + void resetDevice (); + + bool connectToDevice(); + bool discoverServices(); + + + void notifyStateChange(const BluetoothData &vData); + signals: - void didStateChange(const Model::MBluetooth &vData); + void didStateChange(const BluetoothData &vData); - SAFE_CALL(start) + SAFE_CALL(start ) + SAFE_CALL(doScan) }; } -