Como eu disse no post inicial, os códigos que testei e não funcionaram são os codigos exemplo da biblioteca EtherCard e os codigos do site http://www.lucadentella.it/en/category/enc28j60-arduino/ .
Não achei necessário postá-los aqui denovo mas se acham necessário, aqui vai:
IP fixo:
#include <EtherCard.h>
static byte mymac[] = {0xDD,0xDD,0xDD,0x00,0x00,0x01};
static byte myip[] = {192,168,1,10};
byte Ethernet::buffer[700];
void setup () {
Serial.begin(57600);
Serial.println("PING Demo");
if (ether.begin(sizeof Ethernet::buffer, mymac, 10) == 0)
Serial.println( "Failed to access Ethernet controller");
if (!ether.staticSetup(myip))
Serial.println("Failed to set IP address");
}
void loop() {
ether.packetLoop(ether.packetReceive());
}
DHCP:
#include <EtherCard.h>
static byte mymac[] = {0xDD,0xDD,0xDD,0x00,0x00,0x01};
byte Ethernet::buffer[700];
void setup () {
Serial.begin(57600);
Serial.println("DHCP Demo");
if (!ether.begin(sizeof Ethernet::buffer, mymac, 10))
Serial.println( "Failed to access Ethernet controller");
else
Serial.println("Ethernet controller initialized");
if (!ether.dhcpSetup())
Serial.println("Failed to get configuration from DHCP");
else
Serial.println("DHCP configuration done");
ether.printIp("IP Address:\t", ether.myip);
ether.printIp("Netmask:\t", ether.mymask);
ether.printIp("Gateway:\t", ether.gwip);
}
void loop() {
ether.packetLoop(ether.packetReceive());
}
Web Server:
#include <EtherCard.h>
static byte mymac[] = {0xDD,0xDD,0xDD,0x00,0x00,0x01};
byte Ethernet::buffer[700];
void setup () {
Serial.begin(57600);
Serial.println("BasicServer Demo");
if (!ether.begin(sizeof Ethernet::buffer, mymac, 10))
Serial.println( "Failed to access Ethernet controller");
else
Serial.println("Ethernet controller initialized");
if (!ether.dhcpSetup())
Serial.println("Failed to get configuration from DHCP");
else
Serial.println("DHCP configuration done");
ether.printIp("IP Address:\t", ether.myip);
ether.printIp("Netmask:\t", ether.mymask);
ether.printIp("Gateway:\t", ether.gwip);
Serial.println();
}
void loop() {
word len = ether.packetReceive();
word pos = ether.packetLoop(len);
if(pos) {
Serial.println("---------------------------------------- NEW PACKET ----------------------------------------");
Serial.println((char *)Ethernet::buffer + pos);
Serial.println("--------------------------------------------------------------------------------------------");
Serial.println();
BufferFiller bfill = ether.tcpOffset();
bfill.emit_p(PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nPragma: no-cache\r\n\r\n"
"<html><body><h1>BasicServer Demo</h1></body></html>"));
ether.httpServerReply(bfill.position());
}
}