2 //#include <EtherCard.h>
3 //#include <enc28j60.h>
5 // This is a demo of the RBBB running as webserver with the Ether Card
6 // 2010-05-28 <jc@wippler.nl> http://opensource.org/licenses/mit-license.php
7 // https://hwstartup.wordpress.com/2013/03/25/how-to-connect-an-arduino-to-the-internet-for-10/
11 // ethernet interface mac address, must be unique on the LAN
12 static byte mymac[] = { 0x74,0x69,0x69,0x2D,0x30,0x31 };
13 static byte myip[] = { 192,168,0,100 };
15 byte Ethernet::buffer[500];
19 if (ether.begin(sizeof Ethernet::buffer, mymac) == 0)
20 Serial.println( "Failed to access Ethernet controller");
21 ether.staticSetup(myip);
24 static word homePage() {
25 long t = millis() / 1000;
27 byte m = (t / 60) % 60;
29 bfill = ether.tcpOffset();
32 "Content-Type: text/html\r\n"
33 "Pragma: no-cache\r\n"
35 "<meta http-equiv='refresh' content='1'/>"
36 "<title>RBBB server</title>"
37 "<h1>$D$D:$D$D:$D$D</h1>"),
38 h/10, h%10, m/10, m%10, s/10, s%10);
39 return bfill.position();
43 word len = ether.packetReceive();
44 word pos = ether.packetLoop(len);
46 if (pos) // check if valid tcp data is received
47 ether.httpServerReply(homePage()); // send web page data