Modified for W5500 Ethernet initialize Added the Ethernet interface re-initialize code Added the connection retry

Dependents:   ThingPlug_Ethernet_Example

Fork of GMMP_mbed by Eric Jung

Committer:
hkjung
Date:
Wed Aug 12 08:58:58 2015 +0000
Revision:
5:9bbb6933559b
Parent:
0:7e575e5f88ec
Ethernet interface reinitialize code added

Who changed what in which revision?

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