Modified version of easy-connect for W5500 Ethernet components

Dependents:   http-webserver-example mbed-os-example-sockets

Fork of easy-connect by Sergei G

Files at this revision

API Documentation at this revision

Comitter:
Bongjun
Date:
Mon Aug 13 08:59:16 2018 +0000
Parent:
6:307d527714cf
Commit message:
moved to init mac and dhcp functions into W5500Interface

Changed in this revision

easy-connect.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 307d527714cf -r 15287721e11b easy-connect.cpp
--- a/easy-connect.cpp	Mon Aug 13 08:10:37 2018 +0000
+++ b/easy-connect.cpp	Mon Aug 13 08:59:16 2018 +0000
@@ -114,14 +114,6 @@
 #include "W5500Interface/W5500Interface.h"
 W5500Interface eth(W5500_SPI_MOSI,W5500_SPI_MISO,W5500_SPI_SCLK, W5500_SPI_CS, W5500_SPI_RST); // mosi, miso, sclk, cs, reset
 
-#include "W5500Interface/DHCPClient/DHCPClient.h"
-DHCPClient dhcp;
- 
-/*
-#include "W5500Interface/DNSClient/DNSClient.h"
-DNSClient  dns;
-#include "nsapi_dns.h"
-*/
 #else
 #error "No connectivity method chosen. Please add 'config.network-interfaces.value' to your mbed_app.json (see README.md for more information)."
 #endif // MBED_CONF_APP_NETWORK_INTERFACE
@@ -290,42 +282,9 @@
     if (log_messages) {
         printf("[EasyConnect] Using Ethernet W5500\n");
     }
-
     // wait during chip reset
     wait(1);
     
-    if (log_messages) {
-        printf("[EasyConnect] Init with MAC address\n");
-    }
-
-    uint8_t mac_addr[6] = {0x00, 0x08, 0xdc, 0x45, 0x56, 0x67};
-    eth.init(mac_addr);
-
-//  it might be better to move this DHCP code into W5500Interface
-    if (log_messages) {
-        printf("[EasyConnect] DHCP start\n");
-    }
-
-    int timeout_ms = 15*1000;
-    int err = dhcp.setup(&eth, mac_addr, timeout_ms);
-    if (err == (-1)) {
-        if (log_messages) {
-            printf("[EasyConnect] Timeout.\n");
-        }
-        return NULL;
-    }
-    if (log_messages) {
-        printf("[EasyConnect] DHCP completed\n");
-        printf("[EasyConnect] Connected, IP: %d.%d.%d.%d\r\n", dhcp.yiaddr[0], dhcp.yiaddr[1], dhcp.yiaddr[2], dhcp.yiaddr[3]);
-    }
-    char ip[24], gateway[24], netmask[24], dnsaddr[24];
-    sprintf(ip,      "%d.%d.%d.%d", dhcp.yiaddr[0],  dhcp.yiaddr[1],  dhcp.yiaddr[2],  dhcp.yiaddr[3]);
-    sprintf(gateway, "%d.%d.%d.%d", dhcp.gateway[0], dhcp.gateway[1], dhcp.gateway[2], dhcp.gateway[3]);
-    sprintf(netmask, "%d.%d.%d.%d", dhcp.netmask[0], dhcp.netmask[1], dhcp.netmask[2], dhcp.netmask[3]);
-    sprintf(dnsaddr, "%d.%d.%d.%d", dhcp.dnsaddr[0], dhcp.dnsaddr[1], dhcp.dnsaddr[2], dhcp.dnsaddr[3]);
-    eth.init(ip, netmask, gateway);
-    eth.setDnsServerIP(dnsaddr);
-    
     network_interface = ð
 #if MBED_CONF_EVENTS_SHARED_DISPATCH_FROM_APPLICATION
     eth.set_blocking(false);