|
|
@ -1,39 +1,33 @@
|
|
|
|
#include <SPI.h>
|
|
|
|
#include <SPI.h>
|
|
|
|
#include <Ethernet.h>
|
|
|
|
#include <Ethernet.h>
|
|
|
|
#include <SD.h>
|
|
|
|
#include <SD.h>
|
|
|
|
|
|
|
|
|
|
|
|
byte mac[] = { 0xFE, 0xFD, 0xBE, 0xEF, 0xFF, 0xFD };
|
|
|
|
byte mac[] = { 0xFE, 0xFD, 0xBE, 0xEF, 0xFF, 0xFD };
|
|
|
|
|
|
|
|
|
|
|
|
EthernetServer server(80); // create a server at port 80
|
|
|
|
EthernetServer server(80); // create a server at port 80
|
|
|
|
|
|
|
|
|
|
|
|
File webFile; // var webfile de type File
|
|
|
|
File webFile; // var webfile de type File
|
|
|
|
|
|
|
|
|
|
|
|
void setup()
|
|
|
|
void setup()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Serial.begin(9600); // for debugging
|
|
|
|
SerialUSB.begin(9600); // for debugging
|
|
|
|
|
|
|
|
|
|
|
|
Ethernet.begin(mac); // initialize Ethernet device
|
|
|
|
Ethernet.begin(mac); // initialize Ethernet device
|
|
|
|
server.begin(); // start to listen for clients
|
|
|
|
server.begin(); // start to listen for clients
|
|
|
|
SerialUSB.print("server is at "); // display on serial the IP you can find the webpage
|
|
|
|
SerialUSB.print("server is at "); // display on serial the IP you can find the webpage
|
|
|
|
SerialUSB.println(Ethernet.localIP());
|
|
|
|
SerialUSB.println(Ethernet.localIP());
|
|
|
|
|
|
|
|
SerialUSB.println("Initializing SD card...");
|
|
|
|
Serial.println("Initializing SD card...");
|
|
|
|
|
|
|
|
if (!SD.begin(4)) { // initialize SD card
|
|
|
|
if (!SD.begin(4)) { // initialize SD card
|
|
|
|
Serial.println("ERROR - SD card initialization failed!");
|
|
|
|
SerialUSB.println("ERROR - SD card initialization failed!");
|
|
|
|
return; // init failed
|
|
|
|
return; // init failed
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Serial.println("SUCCESS - SD card initialized.");
|
|
|
|
SerialUSB.println("SUCCESS - SD card initialized.");
|
|
|
|
if (!SD.exists("index.htm")) { // check for index.htm file
|
|
|
|
if (!SD.exists("index.htm")) { // check for index.htm file
|
|
|
|
Serial.println("ERROR - Can't find index.htm file!");
|
|
|
|
SerialUSB.println("ERROR - Can't find index.htm file!");
|
|
|
|
return; // can't find index file
|
|
|
|
return; // can't find index file
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Serial.println("SUCCESS - Found index.htm file.");
|
|
|
|
SerialUSB.println("SUCCESS - Found index.htm file.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void loop()
|
|
|
|
void loop()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
EthernetClient client = server.available(); // try to get client
|
|
|
|
EthernetClient client = server.available(); // try to get client
|
|
|
|
|
|
|
|
|
|
|
|
if (client) { // got client?
|
|
|
|
if (client) { // got client?
|
|
|
|
boolean currentLineIsBlank = true;
|
|
|
|
boolean currentLineIsBlank = true;
|
|
|
|
while (client.connected()) {
|
|
|
|
while (client.connected()) {
|
|
|
|