W5500-Ethernet-Interface Makers / W5500Interface

Dependents:   EvrythngApi Websocket_Ethernet_HelloWorld_W5500 Websocket_Ethernet_W5500 CurrentWeatherData_W5500 ... more

Files at this revision

API Documentation at this revision

Comitter:
embeddist
Date:
Tue Apr 28 13:52:23 2015 +0000
Parent:
10:713b6d2aaefb
Commit message:
Remove the setting of tx/rx buffer in SWReset

Changed in this revision

EthernetInterface.cpp Show annotated file Show diff for this revision Revisions of this file
EthernetInterface.h Show annotated file Show diff for this revision Revisions of this file
--- a/EthernetInterface.cpp	Thu Oct 16 06:36:16 2014 +0000
+++ b/EthernetInterface.cpp	Tue Apr 28 13:52:23 2015 +0000
@@ -28,7 +28,8 @@
 
 #include "EthernetInterface.h"
 #include "DHCPClient.h"
-
+//static char ip_string[17];
+//static uint32_t ipaddr ;
 EthernetInterface::EthernetInterface(PinName mosi, PinName miso, PinName sclk, PinName cs, PinName reset) :
         WIZnet_Chip(mosi, miso, sclk, cs, reset)
 {
@@ -124,10 +125,22 @@
     return 0;
 }
 
+/*
+void EthernetInterface::getip(void)
+{
+    //ip = 0x12345678;
+    ipaddr = reg_rd<uint32_t>(SIPR);
+    //snprintf(ip_string, sizeof(ip_string), "%d.%d.%d.%d", (ipaddr>>24)&0xff, (ipaddr>>16)&0xff, (ipaddr>>8)&0xff, ipaddr&0xff);   
+}
+*/
 char* EthernetInterface::getIPAddress()
 {
+    //Suint32_t ip = inet_getip(SIPR);//reg_rd<uint32_t>(SIPR);
+    //static uint32_t ip = getip();
+    //uint32_t ip = getip();
+    
     uint32_t ip = reg_rd<uint32_t>(SIPR);
-    snprintf(ip_string, sizeof(ip_string), "%d.%d.%d.%d", (ip>>24)&0xff, (ip>>16)&0xff, (ip>>8)&0xff, ip&0xff);
+    snprintf(ip_string, sizeof(ip_string), "%d.%d.%d.%d", (ip>>24)&0xff, (ip>>16)&0xff, (ip>>8)&0xff, ip&0xff);   
     return ip_string;
 }
 
--- a/EthernetInterface.h	Thu Oct 16 06:36:16 2014 +0000
+++ b/EthernetInterface.h	Tue Apr 28 13:52:23 2015 +0000
@@ -6,6 +6,8 @@
  /** Interface using Wiznet W5500 chip to connect to an IP-based network
  *
  */
+ 
+
 class EthernetInterface: public WIZnet_Chip {
 public:
 
@@ -76,11 +78,12 @@
   int IPrenew(int timeout_ms = 15*1000);
     
 private:
-    char ip_string[20];
-    char mask_string[20];
-    char gw_string[20];
+    char ip_string[17];
+    char mask_string[17];
+    char gw_string[17];
     char mac_string[20];
     bool ip_set;
+    void getip(void);
 };
 
 #include "TCPSocketConnection.h"