ThingPlug GMMP library for mbed

Dependents:   ThingPlug_WiFi_Example

Committer:
lesmin
Date:
Thu Jul 23 00:55:15 2015 +0000
Revision:
0:32c20cfb2b30
initial commit

Who changed what in which revision?

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