Index: sources/bluetooth/BluetoothInterface.h =================================================================== diff -u -r028cb1403e8fcb2d2e9ab2aa1562f660124015b1 -r93cb2e56782aa64aafb2b69ec526a5e49ffdf1c7 --- sources/bluetooth/BluetoothInterface.h (.../BluetoothInterface.h) (revision 028cb1403e8fcb2d2e9ab2aa1562f660124015b1) +++ sources/bluetooth/BluetoothInterface.h (.../BluetoothInterface.h) (revision 93cb2e56782aa64aafb2b69ec526a5e49ffdf1c7) @@ -58,17 +58,34 @@ QBluetoothDeviceDiscoveryAgent *_agent = nullptr ; QLowEnergyController *_device = nullptr ; + // QList _services ; + QLowEnergyService *_serviceDeviceInformation = nullptr ; QLowEnergyService *_serviceCurrentTime = nullptr ; QLowEnergyService *_serviceBloodPressure = nullptr ; QLowEnergyService *_serviceBattery = nullptr ; - QBluetoothDeviceInfo _info ; - MBluetooth _model ; - MBluetooth::InterfaceStates _state ; + QBluetoothDeviceInfo _temp ; - bool _bpRead = false ; + bool _connectionActive = false ; const quint16 _interval = 1000 ; // the interface timer base interval in mSec +public: + // 19 total bytes + struct MeasurementData { + uint8_t flags; // 1 byte + uint16_t systolic; // 2 bytes + uint16_t diastolic; // 2 bytes + uint16_t mean_arterial_pressure_value; // 2 bytes + uint16_t year; // 2 bytes + uint8_t month; // 1 byte + uint8_t day; // 1 byte + uint8_t hour; // 1 byte + uint8_t minute; // 1 byte + uint8_t second; // 1 byte + uint16_t pulse_rate; // 2 bytes + uint8_t user_id; // 1 byte + uint16_t measurement_status; // 2 bytes + }; protected: void timerEvent(QTimerEvent *event) override; @@ -81,9 +98,6 @@ void quit(); // 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 ); @@ -97,32 +111,49 @@ // Device Slots void onDeviceConnect ( ); void onDeviceDisconnect ( ); + void onDeviceDiscoverService (const QBluetoothUuid &vService); + void onDeviceDiscoverFinish ( ); void onDeviceError ( QLowEnergyController::Error vError ); - void onDeviceStateChanged ( QLowEnergyController::ControllerState vState ); - void onDeviceConnectionUpdated (const QLowEnergyConnectionParameters & vParameters ); + + void onServiceCharacteristicChanged (const QLowEnergyCharacteristic &vCharacteristic , const QByteArray &vValue ); + void onServiceCharacteristicRead (const QLowEnergyCharacteristic &vCharacteristic , const QByteArray &vValue ) { qDebug() << " ..... Service Charc R:" << vCharacteristic .name() << vValue; } + void onServiceCharacteristicWritten (const QLowEnergyCharacteristic &vCharacteristic , const QByteArray &vValue ) { qDebug() << " ..... Service Charc W:" << vCharacteristic .name() << vValue; } + void onServiceDescriptorRead (const QLowEnergyDescriptor &vDescriptor , const QByteArray &vValue ) { qDebug() << " ..... Service Descr R:" << vDescriptor .name() << vValue; } + void onServiceDescriptorWritten (const QLowEnergyDescriptor &vDescriptor , const QByteArray &vValue ) { qDebug() << " ..... Service Descr W:" << vDescriptor .name() << vValue; } + + void onServiceError ( QLowEnergyService::ServiceError vError ); + void onServiceStateChanged ( QLowEnergyService::ServiceState vState ); + private: - void initConnections(); + void initConnections (); + void initConnectionsDevice (); + void initConnectionsService (QLowEnergyService *vService); void initThread(QThread &vThread); void quitThread(); - bool discoverStart (); - bool discoverFinish (); + bool initDevice (); + bool makeDevice (); + void quitDevice (); - bool isLocalValid (); - bool isInfoValid (); - bool isDeviceValid (); - bool isDeviceSupported( const QString &vName ); + void initServices (const QBluetoothUuid &vService); + void makeServices (const QBluetoothUuid &vService); + void quitServices (); - bool initDevice (); - void resetDevice (); + bool isLocalValid (); + bool isInfoValid (); + bool isDeviceValid (); + // bool isServiceValid (QLowEnergyService *vService); + bool isDetailValid (const QLowEnergyCharacteristic &vDetail); + bool isDeviceSupported ( const QString &vName ); - bool connectToDevice(); - bool discoverServices(); + bool connectToDevice (); + void discoverServices (); + void discoverServicesDetails(); - void notifyStateChange(const BluetoothData &vData); + void parseMeasurement (const QByteArray &byteArray); signals: void didStateChange(const BluetoothData &vData);