this will be my first code post of the new year. hope it's a good one. I wrote this code to easily create a tcp server on either the wiznet or 28j60 chip based shields. this wasn't easy because there aren't any examples for a tcp server using 28j60, so it took a little time to figure it all out. below is an example of my code in use, and the first file I'm posting is just a bunch of functions. I plan to convert it to a library next.
http://growcontrol.com/_files/EthernetLayer.pde
// (enable only one)
#define UsingWizNet true // WIZ5100
//#define UsingEtherShield true // ENC28j60
// send outgoing ethernet data to serial also
#define ethPrintToSerial true
#if defined(UsingWizNet) || defined(UsingEtherShield)
static byte eth_mac[6] = {0x54,0x55,0x58,0x10,0x00,0x25};
static byte eth_ip[4] = {192,168,3,110};
static byte eth_gateway[4] = {192,168,3,1};
static byte eth_subnet[4] = {255,255,255,0};
static uint16_t eth_port = 80;
#endif
void setup(){
Serial.begin(115200);
EthernetLayer_Setup();
Serial.println("Ready");
}
void loop(){
EthernetLayer_Loop();
}
void eth_GotData(){
Serial.println("Got data:");
while( EthernetLayer_Available() ){
eth_Print( EthernetLayer_ReadNext() );
}
Serial.println();
Serial.println("Done");
EthernetLayer_SendData();
EthernetLayer_ClearBuffer();
}