Index: sources/cloudsync/CloudSyncController.h =================================================================== diff -u -re2dc7bd9995a3bb410aa472a1f95c1cc9ba3136d -r80250cfdbe58a3df17950d342212f155d52d3971 --- sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision e2dc7bd9995a3bb410aa472a1f95c1cc9ba3136d) +++ sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision 80250cfdbe58a3df17950d342212f155d52d3971) @@ -55,6 +55,7 @@ QString _date_out_File = ""; // The dated/actual filename : CloudSync puts its output to this file QString _date_inp_File = ""; // The dated/actual filename : UI Software puts the input data for the CloudSync in this file QDateTime _datetime ; + qint64 _secSinceEpoch ; QString _dateFormatted ; QString _timeFormatted ; @@ -65,8 +66,60 @@ const char _dateSeparator = '_'; // used in filename const char _separator = ','; - quint64 _seq = 0; + quint64 _seq = 0; + enum Errors_Enum { + eError_OK , + eError_Count , + eError_Timestamp , + eError_Sequence , + eError_MessageID , + eError_ParamCount , + eError_CRC , + eError_Parameter , + + eError_NoHistory , + + eError_LogFolder , + eError_LogFileInp , + }; + + typedef QHash MessageList; + MessageList _lastReceivedData ; // sent message history for later send upon request. + + enum Message_Enum { + eMessage_Timestamp , + eMessage_Sequence , + eMessage_MessageID , + eMessage_ParamCount , + eMessage_CRC , + eMessage_Count , + }; + + typedef QStringList Params; + struct Message { + qint64 timestamp = 0; + quint32 sequence = 0; + qint32 id = 0; + qint64 paramCount = 0; + quint8 crc = 0; + Params params { }; + }; + + enum MessageID_Enum { + eMessageID_DeviceInfo = 101, // CS asks for device info and UI sends back + eMessageID_WriteCredentials = 102, // CS asks to store credential and UI stores/confirms + eMessageID_ReadCredentials = 103, // CS asks for credentials and UI reads/sends + eMessageID_ResetFactory = 104, // CS asks for factory reset [no UI ack back yet] + + eMessageID_DeviceState = 201, // CS asks for device state and UI finds the history/sends + eMessageID_PatientID = 202, // [No CS req defined] UI sends the patient ID + eMessageID_TxReport = 203, // [No CS req defined] UI sends the Tx report + eMessageID_DeviceReport = 204, // [No CS req defined] UI sends the device report + + eMessageID_HeartBeat = 900, // CS sends the periodic Hb and UI can set the interval + }; + protected: void timerEvent(QTimerEvent *event) override; @@ -86,8 +139,14 @@ void initThread(QThread &vThread); void quitThread(); - void checkDate(); - void addCSBuffWatch(); - bool interpreter(const QString &vContent); // this function may later need to be a class. - bool sendUIBuff (const QString &vData); + void checkDate (); + bool addCSBuffWatch(); + bool sendUIResponse (const QString &vContent); + bool sendUIBuff (const QString &vData); + bool sendUIHistory (qint32 vAction); + bool interpret(const QString &vContent, Message &vMessage); + + QString toText (Errors_Enum vErrorID); + QString toInfo (Errors_Enum vErrorID, const QVariantList &vInfoItems); + void toLog (Errors_Enum vErrorID, const QVariantList &vInfoItems); };