Modified for W5500 Ethernet initialize

Fork of GMMP_mbed by SKTelecom_ThingPlug

Committer:
hkjung
Date:
Wed Aug 12 02:13:34 2015 +0000
Revision:
3:6b4536e1962f
Parent:
0:7e575e5f88ec
Modified for W5500 Ethernet initialize

Who changed what in which revision?

UserRevisionLine numberNew contents of line
lesmin 0:7e575e5f88ec 1 #include "GMMP_Control.h"
lesmin 0:7e575e5f88ec 2
lesmin 0:7e575e5f88ec 3 int GMMP_Control_Req(Control_Req* pControl_Req)
lesmin 0:7e575e5f88ec 4 {
lesmin 0:7e575e5f88ec 5 if(pControl_Req == NULL)
lesmin 0:7e575e5f88ec 6 {
lesmin 0:7e575e5f88ec 7 return SERVER_INFO_NOT_FOUND;
lesmin 0:7e575e5f88ec 8 }
lesmin 0:7e575e5f88ec 9
lesmin 0:7e575e5f88ec 10 if(CheckSocket() != 0)
lesmin 0:7e575e5f88ec 11 {
lesmin 0:7e575e5f88ec 12 return SERVER_INFO_NOT_FOUND;
lesmin 0:7e575e5f88ec 13 }
lesmin 0:7e575e5f88ec 14
lesmin 0:7e575e5f88ec 15 int nRet = ReadTCP( (char*)&pControl_Req->header , sizeof(pControl_Req->header) );
lesmin 0:7e575e5f88ec 16 if(nRet == GMMP_SUCCESS)
lesmin 0:7e575e5f88ec 17 {
lesmin 0:7e575e5f88ec 18 return nRet;
lesmin 0:7e575e5f88ec 19 }
lesmin 0:7e575e5f88ec 20
lesmin 0:7e575e5f88ec 21 ConvertShort cvtshort;
lesmin 0:7e575e5f88ec 22 cvtshort.sU8 = 0;
lesmin 0:7e575e5f88ec 23 memcpy(cvtshort.usShort, pControl_Req->header.usMessageLength, sizeof(pControl_Req->header.usMessageLength) );
lesmin 0:7e575e5f88ec 24
lesmin 0:7e575e5f88ec 25 int nReadSize = ltobs(cvtshort.sU8) - sizeof(pControl_Req->header) ;
lesmin 0:7e575e5f88ec 26
lesmin 0:7e575e5f88ec 27 return ReadTCP( (char*)&pControl_Req->body, nReadSize);
lesmin 0:7e575e5f88ec 28 }
lesmin 0:7e575e5f88ec 29
lesmin 0:7e575e5f88ec 30 int GMMP_Control_Rsp(Control_Rsp* pControl_Rsp)
lesmin 0:7e575e5f88ec 31 {
lesmin 0:7e575e5f88ec 32 if(pControl_Rsp == NULL)
lesmin 0:7e575e5f88ec 33 {
lesmin 0:7e575e5f88ec 34 return SERVER_INFO_NOT_FOUND;
lesmin 0:7e575e5f88ec 35 }
lesmin 0:7e575e5f88ec 36
lesmin 0:7e575e5f88ec 37 if(CheckSocket() != 0)
lesmin 0:7e575e5f88ec 38 {
lesmin 0:7e575e5f88ec 39 return SERVER_INFO_NOT_FOUND;
lesmin 0:7e575e5f88ec 40 }
lesmin 0:7e575e5f88ec 41
lesmin 0:7e575e5f88ec 42 return WriteTCP( (char*)pControl_Rsp, sizeof(Control_Rsp) );
lesmin 0:7e575e5f88ec 43 }
lesmin 0:7e575e5f88ec 44
lesmin 0:7e575e5f88ec 45