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

Revision:
1:29d7f5c53126
Parent:
0:7e575e5f88ec
Child:
2:0c4e3edf2918
--- a/GMMP.cpp	Sun Aug 09 14:11:35 2015 +0000
+++ b/GMMP.cpp	Sun Aug 09 14:55:24 2015 +0000
@@ -23,16 +23,14 @@
 
 #include "config.h"
 
+#include "Client.h"
 
 /** moved to config.h
 //#define USE_SNIC_WIFI //Murata Type YD Wi-Fi
 //#define USE_WIZNET_W5500
  **/
 
-#if defined(TARGET_LPC1768)
-#include "EthernetInterface.h"
-EthernetInterface eth;
-#elif defined(TARGET_NUCLEO_F411RE) || defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F334R8) || defined(TARGET_NUCLEO_L152RE)
+#if defined(TARGET_NUCLEO_F411RE) || defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F334R8) || defined(TARGET_NUCLEO_L152RE)
 
 	#ifdef USE_SNIC_WIFI
 	#include "SNIC_WifiInterface.h"
@@ -56,7 +54,9 @@
 	#ifdef USE_WIZNET_W5500
 	#include "WIZnetInterface.h"
 	SPI spi(PA_7, PA_6, PA_5); // mosi, miso, sclk
+	char g_memory_guard_before[32];
     WIZnetInterface ethernet(&spi, PB_6, PA_9);//scs(PB_6), nRESET(PA_9); // reset pin is dummy, don't affect any pin of WIZ550io
+    char g_memory_guard_after[32];
 	#endif//USE_WIZNET_W5500
 #endif
 
@@ -64,9 +64,6 @@
 
 #include "GMMP.h"
 
-#include "Client.h"
-Client *g_pClient = NULL;
-
 byte g_serverIp[LEN_IP] ; ///< 서버 IP 정보를 저장한다.
 int  g_nServerPort = 0; ///<  서버 Port 정보를 저장한다.
 
@@ -78,6 +75,8 @@
 
 char g_szGWID[LEN_GW_ID]; ///< OMP에서 할당 받은 Gateway의 ID 문자열 저장 변수, 자동화를 위해 사용된다.
 
+Client *g_pClient = NULL;
+
 /**
  * @brief OMP서버로 부터 수신한 패킷을 제공할 콜백함수 포인트 구조체
  * @param pstGMMPHeader GMMP Header의 구조체 포인트
@@ -112,13 +111,6 @@
 
   infoln("Getting IP...");
 
-	#if defined(TARGET_LPC1768)
-    eth.init(); //Use DHCP
-    eth.connect();
-    wait(0.5);
-    printf("IP Address is %s\r\n", eth.getIPAddress());
-	#elif defined(TARGET_NUCLEO_F411RE) || defined(TARGET_NUCLEO_F401RE) || defined(TARGET_NUCLEO_F303RE) || defined(TARGET_NUCLEO_F334R8) || defined(TARGET_NUCLEO_L152RE)
-
 	#ifdef USE_SNIC_WIFI
 	wifi.init();
 
@@ -176,7 +168,6 @@
     }
 
 	#endif//USE_WIZNET_W5500
-	#endif
     
 	NTPClient ntp;
 	printf("Trying to update time...\r\n");