From 1609fbc61484c22eca9681ed392988d359c9da02 Mon Sep 17 00:00:00 2001 From: Eddy Date: Tue, 25 Aug 2015 21:47:31 +0200 Subject: [PATCH] Ethernet use DNS in examples Set the DNS-Server as third parameter of Ethernet.begin if at least gateway is specified. Reference is Updated before. In BarometricPressureWebServer gateway and subnet wasn't used. Signed-off-by: Eddy --- .../examples/AdvancedChatServer/AdvancedChatServer.ino | 3 ++- .../BarometricPressureWebServer.ino | 2 -- libraries/Ethernet/examples/ChatServer/ChatServer.ino | 3 ++- libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino | 3 ++- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/libraries/Ethernet/examples/AdvancedChatServer/AdvancedChatServer.ino b/libraries/Ethernet/examples/AdvancedChatServer/AdvancedChatServer.ino index 1c7ec4cabd8..958d46b4a3d 100644 --- a/libraries/Ethernet/examples/AdvancedChatServer/AdvancedChatServer.ino +++ b/libraries/Ethernet/examples/AdvancedChatServer/AdvancedChatServer.ino @@ -30,6 +30,7 @@ byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; IPAddress ip(192, 168, 1, 177); +IPAddress myDns(192, 168, 1, 1); IPAddress gateway(192, 168, 1, 1); IPAddress subnet(255, 255, 0, 0); @@ -41,7 +42,7 @@ EthernetClient clients[4]; void setup() { // initialize the ethernet device - Ethernet.begin(mac, ip, gateway, subnet); + Ethernet.begin(mac, ip, myDns, gateway, subnet); // start listening for clients server.begin(); // Open serial communications and wait for port to open: diff --git a/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino b/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino index f7439a039c3..c0a3298a9f2 100644 --- a/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino +++ b/libraries/Ethernet/examples/BarometricPressureWebServer/BarometricPressureWebServer.ino @@ -33,8 +33,6 @@ byte mac[] = { }; // assign an IP address for the controller: IPAddress ip(192, 168, 1, 20); -IPAddress gateway(192, 168, 1, 1); -IPAddress subnet(255, 255, 255, 0); // Initialize the Ethernet server library diff --git a/libraries/Ethernet/examples/ChatServer/ChatServer.ino b/libraries/Ethernet/examples/ChatServer/ChatServer.ino index 927a60e1be2..74fb50a6983 100644 --- a/libraries/Ethernet/examples/ChatServer/ChatServer.ino +++ b/libraries/Ethernet/examples/ChatServer/ChatServer.ino @@ -27,6 +27,7 @@ byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED }; IPAddress ip(192, 168, 1, 177); +IPAddress myDns(192,168,1, 1); IPAddress gateway(192, 168, 1, 1); IPAddress subnet(255, 255, 0, 0); @@ -37,7 +38,7 @@ boolean alreadyConnected = false; // whether or not the client was connected pre void setup() { // initialize the ethernet device - Ethernet.begin(mac, ip, gateway, subnet); + Ethernet.begin(mac, ip, myDns, gateway, subnet); // start listening for clients server.begin(); // Open serial communications and wait for port to open: diff --git a/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino b/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino index 73cde4bbbbe..b8bae48312c 100644 --- a/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino +++ b/libraries/Ethernet/examples/DhcpChatServer/DhcpChatServer.ino @@ -28,6 +28,7 @@ byte mac[] = { 0x00, 0xAA, 0xBB, 0xCC, 0xDE, 0x02 }; IPAddress ip(192, 168, 1, 177); +IPAddress myDns(192,168,1, 1); IPAddress gateway(192, 168, 1, 1); IPAddress subnet(255, 255, 0, 0); @@ -49,7 +50,7 @@ void setup() { if (Ethernet.begin(mac) == 0) { Serial.println("Failed to configure Ethernet using DHCP"); // initialize the ethernet device not using DHCP: - Ethernet.begin(mac, ip, gateway, subnet); + Ethernet.begin(mac, ip, myDns, gateway, subnet); } // print your local IP address: Serial.print("My IP address: ");