Eric Jung / GMMP_mbed_Ethernet_Reinit

Dependents:   ThingPlug_Ethernet_Example

Fork of GMMP_mbed by Eric Jung

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers GMMP_Control.cpp Source File

GMMP_Control.cpp

00001 #include "GMMP_Control.h"
00002 
00003 int GMMP_Control_Req(Control_Req*  pControl_Req)
00004 {
00005     if(pControl_Req == NULL)
00006     {
00007         return SERVER_INFO_NOT_FOUND;
00008     }
00009 
00010     if(CheckSocket() != 0)
00011     {
00012         return SERVER_INFO_NOT_FOUND;
00013     }
00014 
00015     int nRet = ReadTCP( (char*)&pControl_Req->header  , sizeof(pControl_Req->header) );
00016     if(nRet == GMMP_SUCCESS)
00017     {
00018         return nRet;
00019     }
00020 
00021     ConvertShort cvtshort;
00022     cvtshort.sU8 = 0;
00023     memcpy(cvtshort.usShort, pControl_Req->header.usMessageLength, sizeof(pControl_Req->header.usMessageLength) );
00024 
00025     int nReadSize = ltobs(cvtshort.sU8) - sizeof(pControl_Req->header) ;
00026 
00027     return ReadTCP( (char*)&pControl_Req->body, nReadSize);
00028 }
00029 
00030 int GMMP_Control_Rsp(Control_Rsp*  pControl_Rsp)
00031 {
00032     if(pControl_Rsp == NULL)
00033     {
00034         return SERVER_INFO_NOT_FOUND;
00035     }
00036 
00037     if(CheckSocket() != 0)
00038     {
00039         return SERVER_INFO_NOT_FOUND;
00040     }
00041 
00042     return WriteTCP( (char*)pControl_Rsp, sizeof(Control_Rsp) );
00043 }
00044 
00045