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 /*
lesmin 0:7e575e5f88ec 2 * GMMP_ProfileInfo.c
lesmin 0:7e575e5f88ec 3 *
lesmin 0:7e575e5f88ec 4 * Created on: 2013. 11. 18.
lesmin 0:7e575e5f88ec 5 * Author: root
lesmin 0:7e575e5f88ec 6 */
lesmin 0:7e575e5f88ec 7
lesmin 0:7e575e5f88ec 8 #include "GMMP_ProfileInfo.h"
lesmin 0:7e575e5f88ec 9
lesmin 0:7e575e5f88ec 10 int GMMP_Profile_Req(Profile_Req* pstProfile_Req)
lesmin 0:7e575e5f88ec 11 {
lesmin 0:7e575e5f88ec 12 if(pstProfile_Req == NULL)
lesmin 0:7e575e5f88ec 13 {
lesmin 0:7e575e5f88ec 14 return SERVER_INFO_NOT_FOUND;
lesmin 0:7e575e5f88ec 15 }
lesmin 0:7e575e5f88ec 16
lesmin 0:7e575e5f88ec 17 if(CheckSocket() != 0)
lesmin 0:7e575e5f88ec 18 {
lesmin 0:7e575e5f88ec 19 return SERVER_INFO_NOT_FOUND;
lesmin 0:7e575e5f88ec 20 }
lesmin 0:7e575e5f88ec 21
lesmin 0:7e575e5f88ec 22 return WriteTCP( (char*)pstProfile_Req, sizeof(Profile_Req) );
lesmin 0:7e575e5f88ec 23 }
lesmin 0:7e575e5f88ec 24
lesmin 0:7e575e5f88ec 25 int GMMP_Profile_Rsp(Profile_Rsp* pstProfile_Rsp)
lesmin 0:7e575e5f88ec 26 {
lesmin 0:7e575e5f88ec 27 if(pstProfile_Rsp == NULL)
lesmin 0:7e575e5f88ec 28 {
lesmin 0:7e575e5f88ec 29 return SERVER_INFO_NOT_FOUND;
lesmin 0:7e575e5f88ec 30 }
lesmin 0:7e575e5f88ec 31
lesmin 0:7e575e5f88ec 32 if(CheckSocket() != 0)
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 int nRet = ReadTCP( (char*)&pstProfile_Rsp->header , sizeof(pstProfile_Rsp->header) );
lesmin 0:7e575e5f88ec 38 if(nRet != GMMP_SUCCESS)
lesmin 0:7e575e5f88ec 39 {
lesmin 0:7e575e5f88ec 40 return nRet;
lesmin 0:7e575e5f88ec 41 }
lesmin 0:7e575e5f88ec 42
lesmin 0:7e575e5f88ec 43 ConvertShort cvtshort;
lesmin 0:7e575e5f88ec 44 cvtshort.sU8 = 0;
lesmin 0:7e575e5f88ec 45 memcpy(cvtshort.usShort, pstProfile_Rsp->header.usMessageLength, sizeof(pstProfile_Rsp->header.usMessageLength) );
lesmin 0:7e575e5f88ec 46
lesmin 0:7e575e5f88ec 47 int nReadSize = ltobs(cvtshort.sU8)- sizeof(pstProfile_Rsp->header);
lesmin 0:7e575e5f88ec 48
lesmin 0:7e575e5f88ec 49 return ReadTCP( (char*)&pstProfile_Rsp->body, nReadSize);
lesmin 0:7e575e5f88ec 50 }