Index: sources/cloudsync/CloudSyncController.h =================================================================== diff -u -r27cc308ff5113a9386899d3c8f8b29962a8498e1 -r39a9d9b3930ab483df75da6c2e7bf8838fa8ff5e --- sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision 27cc308ff5113a9386899d3c8f8b29962a8498e1) +++ sources/cloudsync/CloudSyncController.h (.../CloudSyncController.h) (revision 39a9d9b3930ab483df75da6c2e7bf8838fa8ff5e) @@ -69,8 +69,9 @@ quint64 _seq = 0; enum Errors_Enum { - eError_OK , - eError_Count , + eError_Unknown = 500, // Unknown error, initial error before error check + + eError_HeaderCount , eError_Timestamp , eError_Sequence , eError_CRC , @@ -82,6 +83,8 @@ eError_LogFolder , eError_LogFileInp , + + eError_OutFileEmpty , // Out file has changed from CS2UI but the content is empty. }; typedef QHash MessageList; @@ -98,26 +101,40 @@ typedef QStringList Params; struct Message { - qint64 timestamp = 0; + quint64 timestamp = 0; quint32 sequence = 0; quint8 crc = 0; qint32 id = 0; - qint64 paramCount = 0; + quint32 paramCount = 0; Params params { }; }; + enum Entity_Start_Index { + eUI = 1000, + eCS = 2000, + }; + 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] + // [ #1( ID ) <-> #2( ID ) ] Description ( #1 Requests and #2 responses ) + // Manufacturing + eMessageID_Error = 0, // [ CS(2000) <-> UI(1000) ] Error Report - 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_DeviceRegister = 1, // [ UI(1001) -> CS( ) ] Device Registration Request + eMessageID_DeviceInfo = 2, // [ CS(2002) <-> UI(1002) ] Device information Request + eMessageID_SaveCredentials = 3, // [ CS(2003) -> UI(1003) ] Save Credentials Request + eMessageID_SendCredentials = 4, // [ CS(2004) <-> UI(1004) ] Send Credentials Request + eMessageID_ResetFactory = 5, // [ CS(2005) <-> UI(1005) ] Reset Factory Request + // Deployment + eMessageID_DeviceState = 6, // [ CS(2006) <-> UI(1006) ] Device State Request - eMessageID_HeartBeat = 900, // CS sends the periodic Hb and UI can set the interval + eMessageID_TxReport = 7, // [ UI(1007) -> CS(2007) ] TxReport Notify + + // + // Subject to change so has been commented out for now + // + // eMessageID_PatientID = 202, // [No CS req defined] UI sends the patient ID + // 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: @@ -142,14 +159,20 @@ void initThread(QThread &vThread); void quitThread(); - void checkDate (); - bool addCSBuffWatch(); + quint8 generateCRC () { return 0; } // has not been implemented/decided yet + bool validateCRC () { return true; } // has not been implemented/decided yet + + void checkDate (); + bool addCSBuffWatch (); bool sendUIResponse (const QString &vContent); - bool sendUIBuff (const QString &vData); - bool sendUIHistory (qint32 vAction); + bool sendUIBuff (const QString &vData ); + bool sendUIHistory (const qint32 vAction, const QVariantList &vData = {}); 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); + + qint32 UI2CS (MessageID_Enum vID) { return vID + eUI; } + qint32 CS2UI (MessageID_Enum vID) { return vID - eCS; } };