I'm trying my new Ethernet shield, but I can't connect at all.
I'm using the Webserver example of the Arduino 0013 environment, and when I try to connect from a local machine, I see in wireshark that the arp broadcast ("who has this IP") is not answered. This is confirmed by:
$ ip neigh
192.168.0.77 dev eth1 FAILED
[... other machines ...]
Of course, under these conditions the browser doesn't get any answer when trying to connect to http://192.168.0.77/. The yellow lamp on the Ethernet shield blinks three times (for the three arp requests), but that's all. Trying the first time after resetting or trying several times makes no difference.
What's going on? Is there a bug in the ethernet library? Or am I missing something?
This is my code, straight from the example of the 0013 environment:
#include <Ethernet.h>
// Ethernet MAC-Address and IP parameters
byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = {192, 168, 0, 77};
byte gateway[] = {192, 168, 0, 1};
byte netmask[] = {255, 255, 255, 0};
// Webserver on port 80
Server server = Server(80);
void setup() {
//Set up Ethernet
Ethernet.begin(mac, ip); //, gateway, netmask);
// start listening for clients
server.begin();
}
void loop() {
Client client = server.available();
if (client) {
// an http request ends with a blank line
boolean current_line_is_blank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
// if we've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so we can send a reply
if (c == '\n' && current_line_is_blank) {
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
// output the value of each analog input pin
for (int i = 0; i < 6; i++) {
client.print("analog input ");
client.print(i);
client.print(" is ");
client.print(analogRead(i));
client.println("
");
}
break;
}
if (c == '\n') {
// we're starting a new line
current_line_is_blank = true;
} else if (c != '\r') {
// we've gotten a character on the current line
current_line_is_blank = false;
}
}
}
// give the web browser time to receive the data
delay(1);
client.stop();
}
}