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_Notification.cpp Source File

GMMP_Notification.cpp

00001 /*
00002  * GMMP_Notification.c
00003  *
00004  *  Created on: 2013. 11. 18.
00005  *      Author: root
00006  */
00007 
00008 #include "GMMP_Notification.h"
00009 
00010 int GMMP_Notifi_Req(Notifi_Req*  pNotifi_Req, int nPacketSize)
00011 {
00012     if(pNotifi_Req == NULL)
00013     {
00014         return SERVER_INFO_NOT_FOUND;
00015     }
00016 
00017     if(CheckSocket() != 0)
00018     {
00019         return SERVER_INFO_NOT_FOUND;
00020     }
00021 
00022     return WriteTCP( (char*)pNotifi_Req, nPacketSize );
00023 }
00024 
00025 int GMMP_Notifi_Rsp(Notifi_Rsp*  pNotifi_Rsp)
00026 {
00027     if(pNotifi_Rsp == NULL)
00028     {
00029         return SERVER_INFO_NOT_FOUND;
00030     }
00031 
00032     if(CheckSocket() != 0)
00033     {
00034         return SERVER_INFO_NOT_FOUND;
00035     }
00036 
00037     int nRet = ReadTCP( (char*)&pNotifi_Rsp->header  , sizeof(pNotifi_Rsp->header) );
00038     if(nRet != GMMP_SUCCESS)
00039     {
00040         return nRet;
00041     }
00042 
00043     ConvertShort cvtshort;
00044     cvtshort.sU8 = 0;
00045     memcpy(cvtshort.usShort, pNotifi_Rsp->header.usMessageLength, sizeof(pNotifi_Rsp->header.usMessageLength) );
00046 
00047     int nReadSize = ltobs(cvtshort.sU8)- sizeof(pNotifi_Rsp->header);
00048 
00049     return ReadTCP( (char*)&pNotifi_Rsp->body, nReadSize);
00050 }
00051