Modified for W5500 Ethernet initialize
Fork of GMMP_mbed by
Diff: Network/Network.cpp
- Revision:
- 3:6b4536e1962f
- Parent:
- 0:7e575e5f88ec
--- a/Network/Network.cpp Sun Aug 09 15:02:18 2015 +0000 +++ b/Network/Network.cpp Wed Aug 12 02:13:34 2015 +0000 @@ -29,8 +29,8 @@ } int Connect() -{ - int ret = GMMP_SUCCESS; +{ + int ret = GMMP_SUCCESS; //delay(2000); infoln("Connecting..."); @@ -45,12 +45,30 @@ } // if (client.connect((char *)szServerIp, g_nServerPort)) { - if (g_pClient->connect((char *)szServerIp, g_nServerPort)) { - infoln("Connected!!"); - } else { - infoln("connection failed!"); - ret = SERVER_CONNECT_ERROR; - } + /* + if (g_pClient->connect((char *)szServerIp, g_nServerPort)) { + infoln("Connected!!"); + } else { + infoln("connection failed!"); + ret = SERVER_CONNECT_ERROR; + } + */ + int retry = 30; + do + { + if(retry <= 0) { + ret = SERVER_CONNECT_ERROR; + break; + } + + infoln("Trying to connect to Server..."); + if (g_pClient->connect((char *)szServerIp, g_nServerPort)) { + infoln("Connected!"); + break; + } + + infoln("Connection failed!"); + } while(retry--); return ret; } @@ -66,7 +84,7 @@ return LIB_PARAM_ERROR; } // client.write(pBuf, nLen); - g_pClient->write(pBuf, nLen); + g_pClient->write(pBuf, nLen); return GMMP_SUCCESS; }