Go Down

Topic: library to support both ethernet shield types (Read 724 times) previous topic - next topic


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.


Code: [Select]

// (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;

void setup(){

void loop(){

void eth_GotData(){
   Serial.println("Got data:");
   while( EthernetLayer_Available() ){
     eth_Print( EthernetLayer_ReadNext() );


here's my first library. I wanted to finish it before posting it, but this isn't functional. I've been stuck on a bug for the last few days, and I still don't know what line it's on or the nature of the problem. it would be 10 minutes from finished if I could get it to compile and work. when I do hack it into compiling, the defines don't carry over into the library and the right code isn't included. a lot of other odd symptoms like this.

I hate to say it, but at least for now, I give up on this part of my project. the previous code I posted works, and I can drop it into my project to get the same intended result.

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131