Hi !
This hardware configuration is working as web server perfectly.
I am trying to use ENC28j60 Ethernet controller as web client.
I have got the folowing error:
I try to run a code web client but I can not get the ip of server.
What can be the problem ? Does anyone has this problem ? It is the dns server ? It can not translate the name ot ip. Here is the code.
// This demo does web requests to a fixed IP address, using a fixed gateway.
// 2010-11-27 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
#include <EtherCard.h>
#define REQUEST_RATE 5000 // milliseconds
// ethernet interface mac address
static byte mymac = { 0x74,0x69,0x69,0x2D,0x30,0x33 };
static byte myip = { 192,168,0,190 };
static byte gwip = { 192,168,0,1 };
static byte hisip = { 216,58,209,206 };//
const char website PROGMEM = “www.google.com”;
byte Ethernet::buffer[300];
static long timer;
void setup () {
Serial.begin(57600);
Serial.println(“\n[getStaticIP]”);
if (ether.begin(sizeof Ethernet::buffer, mymac, 10) == 0)
Serial.println( “Failed to access Ethernet controller”);
ether.staticSetup(myip, gwip);
if(ether.dnsLookup (website, false)){
Serial.println( “dnsLookup ok”);
}else{
Serial.println( “dnsLookup faild”);
}
while (ether.clientWaitingGw())
ether.packetLoop(ether.packetReceive());
Serial.println(“Gateway found”);
ether.printIp("My IP: ", ether.myip);
ether.printIp("Netmask: ", ether.netmask);
ether.printIp("GW IP: ", ether.gwip);
ether.printIp("DNS IP: ", ether.dnsip);
ether.printIp("SRV: ", ether.hisip);
timer = - REQUEST_RATE; // start timing out right away
}
void loop () {
ether.packetLoop(ether.packetReceive());
if (millis() > timer + REQUEST_RATE) {
timer = millis();
Serial.println(“\n>>> REQ”);
//ether.browseUrl(PSTR(“/”), “bar”, website, my_result_cb);
ether.browseUrl(PSTR(“/index.html”), “”, website, my_result_cb);
}
}
// called when the client request is complete
static void my_result_cb (byte status, word off, word len) {
Serial.print("<<< reply ");
Serial.print(millis() - timer);
Serial.println(" ms");
Serial.println((const char*) Ethernet::buffer + off);
}
The serial log is :
→ dnsLookup
DNS Lookup failed
My IP: 192.168.0.190
Netmask: 0.0.0.0
GW IP: 192.168.0.1
DNS IP: 8.8.8.8
SRV: 0.0.0.0