Bonjours à tous, Je vient d'acquérir un module ENC28J60 sur ebay (à 3€, n'ayant pas le budget pour une shield officiel a 30 €)
J'ai télécharger la librairie nécessaire (http://www.geeetech.com/wiki/index.php/Arduino_ENC28J60_Ethernet_Module)
Je test le programme WebServerSimple, en ayant configurer l'ip comme : 192.168.0.3
Je l'envoie et je test, j'ai bien ma page qui s'affiche.
maintenant, j'ai sur mon pc portable à l'adresse 192.168.0.2 un serveur web (apache2 php5 mysql ...)
avec ma page dans le dossier /test/index.php
J'ouvre donc l'exemple WebClient, je configure les ip's, j'envoie, et la j'ai :
connecting...
connection failed
disconnecting.
#include <Ethernet.h>
byte mac[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55 };
byte ip[] = { 192, 168, 0, 3 };
Server server(80);
void setup() {
Ethernet.begin(mac, ip);
server.begin();
}
void loop() {
Client client = server.available();
if (client) {
boolean current_line_is_blank = true;
while (client.connected()) {
if (client.available()) {
char c = client.read();
if (c == '\n' && current_line_is_blank) {
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.print("Analog input 0 = <b>");
client.print(analogRead(0));
client.println("</b>
");
client.print("millis() = <b>");
client.println(millis());
client.println("</b>
");
break;
}
if (c == '\n') {
current_line_is_blank = true;
} else if (c != '\r') {
current_line_is_blank = false;
}
}
}
delay(1);
client.stop();
}
}
J'ai donc lancer wiresharks pour voir ce qui ce passe sur le réseau :
quand l'arduino est serveur Web, tout marche bien :
http://www.hostingpics.net/viewer.php?id=125396wiresharkarduinoServer1.png
quand l'arduino est client marche pas :
http://www.hostingpics.net/viewer.php?id=955310wiresharkarduinoClient.png
Je ne connais pas très bien le fonctionnement des trames réseau, et j'aimerais qu'on me disent pourquoi sa ne marche pas dans un sens alors que dans l'autre sa marche ...
Merci à vous.
Timiti29
PS: j'utilise un arduino mega 2560
