提交 193d27c8 编写于 作者: 丁劲犇's avatar 丁劲犇 😸

Delete some fields in message defs, make master branch a "example" branch for...

Delete some fields in message defs, make master branch a "example" branch for study , also as a template for other new branches.
上级 0d22bb0c
......@@ -172,22 +172,14 @@ void MainDialog::on_pushButton_regisit_clicked()
(ptr))+sizeof(SMARTLINK_MSG)-1
);
pMsg->Mark = 0x55AA;
pMsg->version = 1;
pMsg->SerialNum = 0;
pMsg->Priority = 1;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(0xffffffff) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(0x00000001) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
pApp->header.AskID = 0x01;
pApp->header.MsgType = 0x1000;
pApp->header.MsgFmtVersion = 0x01;
for (int i=0;i<=nMaxLen;i++)
pApp->MsgUnion.msg_HostRegistReq.HostSerialNum[i] =
i<nMaxLen?pSrc[i]:0;
......@@ -219,21 +211,13 @@ void MainDialog::on_pushButton_Login_clicked()
(ptr))+sizeof(SMARTLINK_MSG)-1
);
pMsg->Mark = 0x55AA;
pMsg->version = 1;
pMsg->SerialNum = 0;
pMsg->Priority = 1;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(0xffffffff) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(0x00000001) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
pApp->header.AskID = 0x01;
pApp->header.MsgType = 0x1001;
pApp->header.MsgFmtVersion = 0x01;
for (int i=0;i<=nMaxLen;i++)
pApp->MsgUnion.msg_HostLogonReq.HostSerialNum[i] =
......@@ -269,21 +253,14 @@ void MainDialog::on_pushButton_clientLogin_clicked()
(ptr))+sizeof(SMARTLINK_MSG)-1
);
pMsg->Mark = 0x55AA;
pMsg->version = 1;
pMsg->SerialNum = 0;
pMsg->Priority = 1;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(0xffffffff) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(0x00000001) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
pApp->header.AskID = 0x01;
pApp->header.MsgType = 0x3000;
pApp->header.MsgFmtVersion = 0x01;
......@@ -323,21 +300,12 @@ void MainDialog::on_pushButton_CrTime_clicked()
(ptr))+sizeof(SMARTLINK_MSG)-1
);
pMsg->Mark = 0x55AA;
pMsg->version = 1;
pMsg->SerialNum = 0;
pMsg->Priority = 1;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(ui->lineEdit_boxid->text().toUInt()) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(0x00000001) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
pApp->header.AskID = 0x01;
pApp->header.MsgType = 0x1002;
pApp->header.MsgFmtVersion = 0x01;
//3/10 possibility to send a data block to server
client->SendData(array);
......@@ -371,21 +339,14 @@ void MainDialog::on_pushButton_box_upload_uid_clicked()
(ptr))+sizeof(SMARTLINK_MSG)-1
);
pMsg->Mark = 0x55AA;
pMsg->version = 1;
pMsg->SerialNum = 0;
pMsg->Priority = 1;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(ui->lineEdit_boxid->text().toUInt()) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(0x00000001) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
pApp->header.AskID = 0x01;
pApp->header.MsgType = 0x1003;
pApp->header.MsgFmtVersion = 0x01;
pApp->MsgUnion.msg_UploadUserListReq.UserNum = (quint16)(vecInt.size() & 0x00ffff);
for (int i=0;i< vecInt.size();i++)
......@@ -417,21 +378,13 @@ void MainDialog::on_pushButton_box_download_uid_clicked()
(ptr))+sizeof(SMARTLINK_MSG)-1
);
pMsg->Mark = 0x55AA;
pMsg->version = 1;
pMsg->SerialNum = 0;
pMsg->Priority = 1;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(ui->lineEdit_boxid->text().toUInt()) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(0x00000001) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
pApp->header.AskID = 0x01;
pApp->header.MsgType = 0x1004;
pApp->header.MsgFmtVersion = 0x01;
//3/10 possibility to send a data block to server
client->SendData(array);
......@@ -458,21 +411,14 @@ void MainDialog::on_pushButton_client_downHost_clicked()
(ptr))+sizeof(SMARTLINK_MSG)-1
);
pMsg->Mark = 0x55AA;
pMsg->version = 1;
pMsg->SerialNum = 0;
pMsg->Priority = 1;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(ui->lineEdit_userid->text().toUInt()) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(0x00000001) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
pApp->header.AskID = 0x01;
pApp->header.MsgType = 0x3002;
pApp->header.MsgFmtVersion = 0x01;
//3/10 possibility to send a data block to server
client->SendData(array);
}
......@@ -499,21 +445,14 @@ void MainDialog::on_pushButton_clientLogout_clicked()
(ptr))+sizeof(SMARTLINK_MSG)-1
);
pMsg->Mark = 0x55AA;
pMsg->version = 1;
pMsg->SerialNum = 0;
pMsg->Priority = 1;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(ui->lineEdit_userid->text().toUInt()) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(0x00000001) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
pApp->header.AskID = 0x01;
pApp->header.MsgType = 0x3001;
pApp->header.MsgFmtVersion = 0x01;
pApp->MsgUnion.msg_ClientLogoutReq.UserName[0] = 0;
......@@ -808,11 +747,6 @@ void MainDialog::on_pushButton_sendToClient_clicked()
SMARTLINK_MSG * pMsg = (SMARTLINK_MSG *)ptr;
pMsg->Mark = 0x55AA;
pMsg->version = 1;
pMsg->SerialNum = 0;
pMsg->Priority = 1;
pMsg->Reserved1 = 0;
if (m_bBox==true)
pMsg->source_id = (quint32)((quint64)(ui->lineEdit_boxid->text().toUInt()) & 0xffffffff );
else
......@@ -820,7 +754,6 @@ void MainDialog::on_pushButton_sendToClient_clicked()
pMsg->destin_id = (quint32)((quint64)(ui->lineEdit_client_uuid->text().toUInt()) & 0xffffffff );;
pMsg->data_length = arrMsg.size();
pMsg->Reserved2 = 0;
array.append(arrMsg);
......
......@@ -129,16 +129,11 @@ void QTcpClientTest::timerEvent(QTimerEvent * evt)
char * ptr = array.data();
SMARTLINK_MSG * pMsg = (SMARTLINK_MSG *)ptr;
pMsg->Mark = 0x55AA;
pMsg->version = 1;
pMsg->SerialNum = 0;
pMsg->Priority = 1;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(sock) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(sockDestin) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
for (int i=0;i<nMsgLen;i++)
pMsg->data[i] = '0' + i%10;
//3/10 possibility to send a data block to server
......
......@@ -35,22 +35,13 @@ namespace SmartLink{
(ptr))+sizeof(SMARTLINK_MSG)-1
);
pMsg->Mark = 0x55AA;
pMsg->version = m_currentHeader.version;
pMsg->SerialNum = m_currentHeader.SerialNum;
pMsg->Priority = m_currentHeader.Priority;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(m_currentHeader.destin_id) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(m_currentHeader.source_id) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
pApp->header.AskID = m_current_app_header.header.AskID;
pApp->header.MsgType = 0x1800;
pApp->header.MsgFmtVersion = m_current_app_header.header.MsgFmtVersion;
stMsg_HostRegistRsp & reply = pApp->MsgUnion.msg_HostRegistRsp;
//Check the database, find current equipment info
......@@ -159,21 +150,13 @@ namespace SmartLink{
(ptr))+sizeof(SMARTLINK_MSG)-1
);
pMsg->Mark = 0x55AA;
pMsg->version = m_currentHeader.version;
pMsg->SerialNum = m_currentHeader.SerialNum;
pMsg->Priority = m_currentHeader.Priority;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(m_currentHeader.destin_id) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(m_currentHeader.source_id) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
pApp->header.AskID = m_current_app_header.header.AskID;
pApp->header.MsgType = 0x1801;
pApp->header.MsgFmtVersion = m_current_app_header.header.MsgFmtVersion;
stMsg_HostLogonRsp & reply = pApp->MsgUnion.msg_HostLogonRsp;
......@@ -281,21 +264,13 @@ namespace SmartLink{
(ptr))+sizeof(SMARTLINK_MSG)-1
);
pMsg->Mark = 0x55AA;
pMsg->version = m_currentHeader.version;
pMsg->SerialNum = m_currentHeader.SerialNum;
pMsg->Priority = m_currentHeader.Priority;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(m_currentHeader.destin_id) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(m_currentHeader.source_id) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
pApp->header.AskID = m_current_app_header.header.AskID;
pApp->header.MsgType = 0x3800;
pApp->header.MsgFmtVersion = m_current_app_header.header.MsgFmtVersion;
stMsg_ClientLoginRsp & reply = pApp->MsgUnion.msg_ClientLoginRsp;
......@@ -380,21 +355,13 @@ namespace SmartLink{
(ptr))+sizeof(SMARTLINK_MSG)-1
);
pMsg->Mark = 0x55AA;
pMsg->version = m_currentHeader.version;
pMsg->SerialNum = m_currentHeader.SerialNum;
pMsg->Priority = m_currentHeader.Priority;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(m_currentHeader.destin_id) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(m_currentHeader.source_id) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
pApp->header.AskID = m_current_app_header.header.AskID;
pApp->header.MsgType = 0x1802;
pApp->header.MsgFmtVersion = m_current_app_header.header.MsgFmtVersion;
stMsg_HostTimeCorrectRsp & reply = pApp->MsgUnion.msg_HostTimeCorrectRsp;
......@@ -444,21 +411,13 @@ namespace SmartLink{
(ptr))+sizeof(SMARTLINK_MSG)-1
);
pMsg->Mark = 0x55AA;
pMsg->version = m_currentHeader.version;
pMsg->SerialNum = m_currentHeader.SerialNum;
pMsg->Priority = m_currentHeader.Priority;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(m_currentHeader.destin_id) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(m_currentHeader.source_id) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
pApp->header.AskID = m_current_app_header.header.AskID;
pApp->header.MsgType = 0x1803;
pApp->header.MsgFmtVersion = m_current_app_header.header.MsgFmtVersion;
stMsg_UploadUserListRsp & reply = pApp->MsgUnion.msg_UploadUserListRsp;
......@@ -515,21 +474,13 @@ namespace SmartLink{
(ptr))+sizeof(SMARTLINK_MSG)-1
);
pMsg->Mark = 0x55AA;
pMsg->version = m_currentHeader.version;
pMsg->SerialNum = m_currentHeader.SerialNum;
pMsg->Priority = m_currentHeader.Priority;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(m_currentHeader.destin_id) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(m_currentHeader.source_id) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
pApp->header.AskID = m_current_app_header.header.AskID;
pApp->header.MsgType = 0x1804;
pApp->header.MsgFmtVersion = m_current_app_header.header.MsgFmtVersion;
stMsg_DownloadUserListRsp & reply = pApp->MsgUnion.msg_DownloadUserListRsp;
......@@ -570,21 +521,14 @@ namespace SmartLink{
(ptr))+sizeof(SMARTLINK_MSG)-1
);
pMsg->Mark = 0x55AA;
pMsg->version = m_currentHeader.version;
pMsg->SerialNum = m_currentHeader.SerialNum;
pMsg->Priority = m_currentHeader.Priority;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(m_currentHeader.destin_id) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(m_currentHeader.source_id) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
pApp->header.AskID = m_current_app_header.header.AskID;
pApp->header.MsgType = 0x3801;
pApp->header.MsgFmtVersion = m_current_app_header.header.MsgFmtVersion;
stMsg_ClientLogoutRsp & reply = pApp->MsgUnion.msg_ClientLogoutRsp;
......@@ -619,21 +563,13 @@ namespace SmartLink{
(ptr))+sizeof(SMARTLINK_MSG)-1
);
pMsg->Mark = 0x55AA;
pMsg->version = m_currentHeader.version;
pMsg->SerialNum = m_currentHeader.SerialNum;
pMsg->Priority = m_currentHeader.Priority;
pMsg->Reserved1 = 0;
pMsg->source_id = (quint32)((quint64)(m_currentHeader.destin_id) & 0xffffffff );
pMsg->destin_id = (quint32)((quint64)(m_currentHeader.source_id) & 0xffffffff );;
pMsg->data_length = nMsgLen;
pMsg->Reserved2 = 0;
pApp->header.AskID = m_current_app_header.header.AskID;
pApp->header.MsgType = 0x3802;
pApp->header.MsgFmtVersion = m_current_app_header.header.MsgFmtVersion;
stMsg_GetHostListRsp & reply = pApp->MsgUnion.msg_GetHostListRsp;
......
......@@ -250,13 +250,6 @@ namespace SmartLink{
((unsigned char *)this->m_currentBlock.constData()) + sizeof(SMARTLINK_MSG) - 1,
sizeof (SMARTLINK_MSG_APP::tag_app_layer_header)
);
if (m_current_app_header.header.MsgFmtVersion!=0x01)
{
emit evt_Message(this,tr("Application Layer Version too new."));
emit evt_close_client(this->sock());
return false;
}
//do
//qDebug()<<m_current_app_header.header.MsgType<<"\n";
switch (m_current_app_header.header.MsgType)
{
......@@ -335,12 +328,6 @@ namespace SmartLink{
((unsigned char *)this->m_currentBlock.constData()) + sizeof(SMARTLINK_MSG) - 1,
sizeof (SMARTLINK_MSG_APP::tag_app_layer_header)
);
if (m_current_app_header.header.MsgFmtVersion!=0x01)
{
emit evt_Message(this,tr("Application Layer Version too new."));
emit evt_close_client(this->sock());
return false;
}
//do
switch (m_current_app_header.header.MsgType)
{
......
......@@ -7,16 +7,15 @@ namespace SmartLink{
#if defined(__GNUC__)
#include <stdint.h>
/**
* @brief this structure provides a basic trans blocks.
*
*/
typedef struct tag_smartlink_message{
__UINT16_TYPE__ Mark; //Always be "0xAA55"
__UINT16_TYPE__ version; //Structure Version
__UINT8_TYPE__ Priority;
__UINT8_TYPE__ Reserved1;
__UINT16_TYPE__ SerialNum;
__UINT32_TYPE__ source_id ; //0xffffffff means from server
__UINT32_TYPE__ destin_id ; //0xffffffff means to server
__UINT16_TYPE__ data_length; //Data at least have 2 byte, for heart-beating counter.
__UINT16_TYPE__ Reserved2;
__UINT8_TYPE__ data[1];
} SMARTLINK_MSG;
typedef struct tag_smartlink_heartBeating
......@@ -29,14 +28,9 @@ namespace SmartLink{
#if defined(_MSC_VER)
typedef struct tag_smartlink_message{
unsigned __int16 Mark; //Always be 0xAA55
unsigned __int16 version; //Structure Version
unsigned __int8 Priority;
unsigned __int8 Reserved1;
unsigned __int16 SerialNum;
unsigned __int32 source_id ; //0xffffffff means from server
unsigned __int32 destin_id ; //0xffffffff means to server
unsigned __int16 data_length; //Data at least have 2 byte, for heart-beating counter.
unsigned __int16 Reserved2;
unsigned __int8 data[1];
} SMARTLINK_MSG;
typedef struct tag_smartlink_heartBeating
......
......@@ -33,7 +33,6 @@ namespace SmartLink{
//SMARTLINK_MSG_APP::MsgType = 0x1801
typedef struct tag_stMsg_HostLogonRsp{
__UINT8_TYPE__ DoneCode;
//char TextInfo[64];
} stMsg_HostLogonRsp;
//User Login request
......@@ -41,7 +40,6 @@ namespace SmartLink{
typedef struct tag_stMsg_ClientLoginReq{
__UINT16_TYPE__ ClientVersion;
char UserNameAndPasswd[1];
//char Password[32];
}stMsg_ClientLoginReq;
//User Log response
......@@ -49,7 +47,6 @@ namespace SmartLink{
typedef struct tag_stMsg_ClientLoginRsp{
__UINT8_TYPE__ DoneCode;
__UINT32_TYPE__ UserID;
//char TextInfo[64];
} stMsg_ClientLoginRsp;
//User Log response
......@@ -61,7 +58,6 @@ namespace SmartLink{
//Time Correct
typedef struct tag_stMsg_HostTimeCorrectRsp{
__UINT8_TYPE__ DoneCode;
//char TextInfo[64];
struct tag_stDateTime{
__UINT16_TYPE__ Year;
__UINT8_TYPE__ Month;
......@@ -82,7 +78,6 @@ namespace SmartLink{
//SMARTLINK_MSG_APP::MsgType = 0x1803
typedef struct tag_stMsg_UploadUserListRsp{
__UINT8_TYPE__ DoneCode;
//char TextInfo[64];
} stMsg_UploadUserListRsp;
//SMARTLINK_MSG_APP::MsgType = 0x1004
......@@ -93,7 +88,6 @@ namespace SmartLink{
//SMARTLINK_MSG_APP::MsgType = 0x1804
typedef struct tag_stMsg_DownloadUserListRsp{
__UINT8_TYPE__ DoneCode;
//char TextInfo[64];
__UINT16_TYPE__ UserNum;
__UINT32_TYPE__ pUserIDList[1];
} stMsg_DownloadUserListRsp;
......@@ -107,7 +101,6 @@ namespace SmartLink{
//0x3801
typedef struct tag_stMsg_ClientLogoutRsp{
__UINT8_TYPE__ DoneCode;
//char TextInfo[64];
}stMsg_ClientLogoutRsp;
//SMARTLINK_MSG_APP::MsgType = 0x3002
......@@ -122,8 +115,6 @@ namespace SmartLink{
typedef struct tag_smartlink_app_layer{
struct tag_app_layer_header{
__UINT16_TYPE__ MsgFmtVersion;
__UINT8_TYPE__ AskID;
__UINT16_TYPE__ MsgType;
} header;
union union_MsgUnion
......@@ -162,7 +153,6 @@ namespace SmartLink{
//SMARTLINK_MSG_APP::MsgType = 0x1800
typedef struct tag_stMsg_HostRegistRsp{
unsigned __int8 DoneCode;
//char TextInfo[64];
unsigned __int32 ID;
}stMsg_HostRegistRsp;
......@@ -177,7 +167,6 @@ namespace SmartLink{
//SMARTLINK_MSG_APP::MsgType = 0x1801
typedef struct tag_stMsg_HostLogonRsp{
unsigned __int8 DoneCode;
//char TextInfo[64];
} stMsg_HostLogonRsp;
//User Login request
......@@ -185,7 +174,6 @@ namespace SmartLink{
typedef struct tag_stMsg_ClientLoginReq{
unsigned __int16 ClientVersion;
char UserNameAndPasswd[1];//max 65
//char Password[1];//max 32
}stMsg_ClientLoginReq;
//User Log response
......@@ -193,7 +181,6 @@ namespace SmartLink{
typedef struct tag_stMsg_ClientLoginRsp{
unsigned __int8 DoneCode;
unsigned __int32 UserID;
//char TextInfo[64];
} stMsg_ClientLoginRsp;
......@@ -239,7 +226,6 @@ namespace SmartLink{
//SMARTLINK_MSG_APP::MsgType = 0x1804
typedef struct tag_stMsg_DownloadUserListRsp{
unsigned __int8 DoneCode;
//char TextInfo[64];
unsigned __int16 UserNum;
unsigned __int32 pUserIDList[1];
} stMsg_DownloadUserListRsp;
......@@ -252,7 +238,6 @@ namespace SmartLink{
//0x3801
typedef struct tag_stMsg_ClientLogoutRsp{
unsigned __int8 DoneCode;
//char TextInfo[64];
}stMsg_ClientLogoutRsp;
//SMARTLINK_MSG_APP::MsgType = 0x3002
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册