/********************************************************************** Arduino Ethernet Webserver nach: https://werner.rothschopf.net/202001_arduino_webserver_post.htm This version: - don't uses Arduino String class - read parameters POST - care about non defined pages - keeps the loop tidy - handle favicon.ico - don't use F-Makro in client.print **********************************************************************/ #define CS 53 // Pin 53 für CS Ethernet-Shield OKY3487 #include #include #include // https://github.com/jandrassy/StreamLibdownload byte mac[] { 0x52, 0x64, 0x75, 0x69, 0x6E, 0x6E }; // you can change the MAC and IP addresses to suit your network IPAddress ip( 192, 168, 1, 97 ); EthernetServer server(80); // Port 80 is HTTP port void printHardwareInfo() { if (Ethernet.hardwareStatus() == EthernetNoHardware) { Serial.println(F("Ethernet shield was not found")); } else if (Ethernet.hardwareStatus() == EthernetW5100) { Serial.println(F("W5100 detected")); } else { if (Ethernet.hardwareStatus() == EthernetW5200) { Serial.println(F("W5200 detected")); } else if (Ethernet.hardwareStatus() == EthernetW5500) { Serial.println(F("W5500 detected")); } if (Ethernet.linkStatus() == Unknown) { // cable connection Serial.println(F("Link status detection is only available with W5200 and W5500")); } else if (Ethernet.linkStatus() == LinkON) { Serial.println(F("Link status: On")); } else if (Ethernet.linkStatus() == LinkOFF) { Serial.println(F("Link status: Off")); } } } void setup() { Serial.begin(9600); Serial.println(F("\nsimple webserver")); delay(750); #ifdef CS Ethernet.init(CS); #endif Ethernet.begin(mac, ip); // Start the Ethernet shield: printHardwareInfo(); server.begin(); // Start the webserver: Serial.print(F("server available at http://")); Serial.println(Ethernet.localIP()); } void checkForClient() { EthernetClient client = server.available(); if (client) { Serial.println(F("\n[server] client connected")); uint8_t i = 0; // index / current read position const uint16_t buffersize = 100; // size of read buffer (reads a complete line) (if larger than 255, modify i also! const uint16_t smallbuffersize = 30; // a smaller buffer for results char lineBuffer[buffersize] {'\0'}; // buffer for incomming data char method[8]; // largest one 7+1. HTTP request methods in RFC7231 + RFC5789: GET HEAD POST PUT DELETE CONNECT OPTONS TRACE PATCH char uri[smallbuffersize]; // the requestet page, shorter than smallbuffersize - method char requestParameter[smallbuffersize]; // parameter appended to the URI after a ? char postParameter[smallbuffersize]; // parameter transmitted in the body / by POST enum class Status {REQUEST, CONTENT_LENGTH, EMPTY_LINE, BODY}; Status status = Status::REQUEST; while (client.connected()) { while (client.available()) { char c = client.read(); Serial.print(c); // Debug print received characters to Serial monitor if ( c == '\n' ) { if (status == Status::REQUEST) // read the first line { //Serial.print(F("lineBuffer="));Serial.println(lineBuffer); // now split the input char *ptr; ptr = strtok(lineBuffer, " "); // strtok will destroy the newRequest strlcpy(method, ptr, smallbuffersize); Serial.print(F("method=")); Serial.println(method); ptr = strtok(NULL, " "); strlcpy(uri, ptr, smallbuffersize); // enthält noch evtl. parameter if (strchr(uri, '?') != NULL) { ptr = strtok(uri, "?"); // split URI from parameters strcpy(uri, ptr); ptr = strtok(NULL, " "); strcpy(requestParameter, ptr); Serial.print(F("requestParameter=")); Serial.println(requestParameter); } Serial.print(F("uri=")); Serial.println(uri); status = Status::EMPTY_LINE; // jump to next status } else if (status == Status::CONTENT_LENGTH) // MISSING check for Content-Length { status = Status::EMPTY_LINE; } else if (status > Status::REQUEST && i < 2) // check if we have an empty line { status = Status::BODY; } else if (status == Status::BODY) { strlcpy(postParameter, lineBuffer, smallbuffersize); break; // we have received one line payload and break out } i = 0; strcpy(lineBuffer, ""); } else { if (i < buffersize) { lineBuffer[i] = c; i++; lineBuffer[i] = '\0'; } // MISSING wenn status 3 und content-length --> abbrechen. } } if (status == Status::BODY) // status 3 could end without linefeed, therefore we takeover here also { strlcpy(postParameter, lineBuffer, smallbuffersize); } Serial.print(F("\r\npostParameter=")); Serial.println(postParameter); // Simple evaluation of postParameter from body // Post data looks like pinD2=On // strncmp() vergleicht zwei Strings bis maximal zum angegebenen Zeichen // oder in einem der beiden Strings ein Nullbyte gefunden wurde. // Rückgabewert: 0 => Die verglichenen Strings sind bis zum angegebenen Zeichen identisch if (strncmp(postParameter, "dL", 2) == 0 ) { sendStatistics(client); } if (strncmp(postParameter, "rS", 2) == 0) { //resetFunc(); // Resetten } if (!strcmp(uri, "/") || !strcmp(uri, "/index.htm") ) // the homepage sendPage(client); else if (!strcmp(uri, "/favicon.ico")) // a favicon sendFavicon(client); //send204(client); // i you don't have a favicon, send a defined empty response else // if we don't know the page, send error 404 send404(client); } } } void sendPage(EthernetClient &client) { // Serial.println("[server] 200 response send"); const size_t MESSAGE_BUFFER_SIZE = 64; char buffer[MESSAGE_BUFFER_SIZE]; // a buffer needed for the StreamLib BufferedPrint message(client, buffer, sizeof(buffer)); message.println(F("HTTP/1.0 200 OK\r\n" // \r\n Header Fields are terminated by a carriage return (CR) and line feed (LF) character sequence. "Content-Type: text/html\r\n" // The Media type of the body of the request (used with POST and PUT requests). "\r\n" // a blank line to split HTTP header and HTTP body "\n" // the HTTP Page itself //"\n" "\n" "\n" "\n" "Webserver Heizzentrale\n" "\n" "\n")); //für ohne Seriffen message.print(F("

Webserver MONI-TOR

" "" "" //"" "" "" "" "" "" "" //"" "" "" "" "" "" //"" "

" "
xxxxxxxxxxxxxxxxxxxxxxxx
xxxxxxxxxxxxxxxxxx

" /////// Form für Download Statistics /////// "
" //"" // dass beide Elemente in einer ROW sind ^^^^^^^^^^^^^^^^^^^^ "
\n" /////// Ende Form für Download Statistics /////// /////// Form für Reset System /////// "
" "
\n" /////// Ende Form für Reset System /////// "







")); message.flush(); client.stop(); } void send404(EthernetClient &client) { // Serial.println("[server] response 404 file not found"); const size_t MESSAGE_BUFFER_SIZE = 64; char buffer[MESSAGE_BUFFER_SIZE]; // a buffer needed for the StreamLib BufferedPrint message(client, buffer, sizeof(buffer)); message.println(F("HTTP/1.0 404 Not Found\r\n" "Content-Type: text/plain\r\n" // we will send a simple plain text without html tags "\r\n" "404 File Fot Found\n")); message.flush(); client.stop(); } void send204(EthernetClient &client) { // Serial.println("[server] response 204 no content"); const size_t MESSAGE_BUFFER_SIZE = 64; char buffer[MESSAGE_BUFFER_SIZE]; // a buffer needed for the StreamLib BufferedPrint message(client, buffer, sizeof(buffer)); message.println(F("HTTP/1.0 204 no content\r\n")); // no content message.flush(); client.stop(); } void sendFavicon(EthernetClient &client) { const static byte tblFavicon[] PROGMEM = { 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x10, 0x10, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x68, 0x05, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01, 0x00, 0x83, 0x77, 0x09, 0x00, 0x49, 0x3F, 0x0D, 0x00, 0xD3, 0xBD, 0x09, 0x00, 0x25, 0x21, 0x09, 0x00, 0xF3, 0xDD, 0x0B, 0x00, 0x11, 0x11, 0x05, 0x00, 0xA1, 0x93, 0x0B, 0x00, 0x69, 0x5D, 0x09, 0x00, 0xFB, 0xE5, 0x07, 0x00, 0x09, 0x09, 0x03, 0x00, 0x07, 0x05, 0x01, 0x00, 0xB3, 0xA1, 0x0F, 0x00, 0x79, 0x6D, 0x0F, 0x00, 0x91, 0x85, 0x0F, 0x00, 0x35, 0x31, 0x09, 0x00, 0xFD, 0xE9, 0x03, 0x00, 0x05, 0x03, 0x03, 0x00, 0xD9, 0xC7, 0x0D, 0x00, 0xF5, 0xE1, 0x09, 0x00, 0x01, 0x03, 0x01, 0x00, 0x57, 0x51, 0x0D, 0x00, 0xA9, 0x9B, 0x0D, 0x00, 0xFF, 0xE7, 0x01, 0x00, 0x1F, 0x1B, 0x07, 0x00, 0x7F, 0x73, 0x0B, 0x00, 0x97, 0x8B, 0x0B, 0x00, 0x3D, 0x39, 0x09, 0x00, 0xD7, 0xC5, 0x09, 0x00, 0xA5, 0x97, 0x09, 0x00, 0xFB, 0xE7, 0x07, 0x00, 0xF9, 0xE1, 0x0B, 0x00, 0x5D, 0x55, 0x0D, 0x00, 0x03, 0x01, 0x01, 0x00, 0xF5, 0xDF, 0x09, 0x00, 0x17, 0x11, 0x07, 0x00, 0x73, 0x69, 0x0B, 0x00, 0x0F, 0x0D, 0x03, 0x00, 0xB9, 0xAB, 0x0D, 0x00, 0x7B, 0x71, 0x0D, 0x00, 0xE5, 0xCF, 0x09, 0x00, 0x03, 0x03, 0x01, 0x00, 0x99, 0x8D, 0x0B, 0x00, 0x41, 0x3B, 0x0B, 0x00, 0xFD, 0xE7, 0x03, 0x00, 0x8B, 0x7D, 0x0D, 0x00, 0x51, 0x4B, 0x0B, 0x00, 0xD3, 0xC1, 0x09, 0x00, 0x29, 0x25, 0x09, 0x00, 0xA5, 0x95, 0x09, 0x00, 0x6B, 0x61, 0x0D, 0x00, 0x09, 0x07, 0x03, 0x00, 0x7D, 0x6F, 0x0B, 0x00, 0x95, 0x89, 0x0D, 0x00, 0x39, 0x35, 0x09, 0x00, 0xDD, 0xC9, 0x09, 0x00, 0xF7, 0xE3, 0x09, 0x00, 0xAB, 0x9B, 0x0D, 0x00, 0xFF, 0xE7, 0x05, 0x00, 0x21, 0x1D, 0x07, 0x00, 0x81, 0x75, 0x0B, 0x00, 0x99, 0x8B, 0x0B, 0x00, 0x3F, 0x3B, 0x09, 0x00, 0x61, 0x57, 0x0D, 0x00, 0x1B, 0x17, 0x07, 0x00, 0x03, 0x03, 0x05, 0x00, 0xFD, 0xE7, 0x07, 0x00, 0x01, 0x01, 0x03, 0x00, 0x4B, 0x45, 0x0B, 0x00, 0xD3, 0xBF, 0x09, 0x00, 0x29, 0x23, 0x07, 0x00, 0xF5, 0xDD, 0x0B, 0x00, 0xA3, 0x95, 0x0B, 0x00, 0x0B, 0x09, 0x03, 0x00, 0x07, 0x05, 0x03, 0x00, 0xB7, 0xA7, 0x09, 0x00, 0x79, 0x6F, 0x0D, 0x00, 0x37, 0x33, 0x09, 0x00, 0xFF, 0xE9, 0x03, 0x00, 0xDB, 0xC7, 0x0F, 0x00, 0xF7, 0xE1, 0x09, 0x00, 0x5B, 0x51, 0x09, 0x00, 0xA9, 0x9B, 0x0F, 0x00, 0xFF, 0xE7, 0x03, 0x00, 0x21, 0x1B, 0x07, 0x00, 0x7F, 0x73, 0x0D, 0x00, 0x97, 0x8B, 0x0D, 0x00, 0xD7, 0xC5, 0x0B, 0x00, 0xA7, 0x97, 0x09, 0x00, 0xF9, 0xE3, 0x07, 0x00, 0x5F, 0x55, 0x0D, 0x00, 0x03, 0x01, 0x03, 0x00, 0xF5, 0xDF, 0x0B, 0x00, 0x19, 0x13, 0x05, 0x00, 0x0F, 0x0D, 0x05, 0x00, 0xBD, 0xAD, 0x0D, 0x00, 0x03, 0x03, 0x03, 0x00, 0xFD, 0xE7, 0x05, 0x00, 0x8D, 0x81, 0x0B, 0x00, 0x6D, 0x63, 0x09, 0x00, 0x97, 0x89, 0x0B, 0x00, 0x3F, 0x3B, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3A, 0x0F, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5B, 0x41, 0x28, 0x0B, 0x30, 0x4C, 0x5D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x27, 0x18, 0x43, 0x00, 0x45, 0x41, 0x0C, 0x10, 0x62, 0x14, 0x00, 0x00, 0x00, 0x00, 0x14, 0x39, 0x2C, 0x64, 0x43, 0x00, 0x03, 0x14, 0x08, 0x12, 0x44, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x12, 0x2E, 0x21, 0x00, 0x45, 0x00, 0x00, 0x4A, 0x5B, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x5B, 0x00, 0x00, 0x2F, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0x06, 0x21, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5B, 0x53, 0x3E, 0x0D, 0x31, 0x31, 0x31, 0x48, 0x20, 0x24, 0x1D, 0x1D, 0x58, 0x48, 0x5A, 0x21, 0x5D, 0x17, 0x34, 0x19, 0x2C, 0x53, 0x17, 0x17, 0x07, 0x3D, 0x2C, 0x17, 0x17, 0x17, 0x3C, 0x60, 0x51, 0x17, 0x5F, 0x1B, 0x1E, 0x2C, 0x17, 0x09, 0x4B, 0x3C, 0x2C, 0x17, 0x2C, 0x2C, 0x63, 0x43, 0x3D, 0x17, 0x22, 0x54, 0x0E, 0x64, 0x64, 0x3D, 0x0D, 0x2B, 0x35, 0x64, 0x3D, 0x64, 0x4D, 0x4A, 0x57, 0x17, 0x2C, 0x08, 0x00, 0x21, 0x21, 0x00, 0x15, 0x16, 0x23, 0x00, 0x21, 0x00, 0x43, 0x46, 0x09, 0x17, 0x17, 0x1C, 0x5E, 0x00, 0x00, 0x00, 0x16, 0x09, 0x36, 0x00, 0x00, 0x00, 0x14, 0x2D, 0x10, 0x17, 0x17, 0x2C, 0x26, 0x3E, 0x25, 0x0B, 0x18, 0x02, 0x33, 0x0B, 0x33, 0x54, 0x55, 0x50, 0x4E, 0x17, 0x17, 0x17, 0x2C, 0x09, 0x50, 0x05, 0x05, 0x05, 0x22, 0x22, 0x50, 0x09, 0x2C, 0x17, 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; const size_t MESSAGE_BUFFER_SIZE = 64; char buffer[MESSAGE_BUFFER_SIZE]; // a buffer needed for the StreamLib BufferedPrint message(client, buffer, sizeof(buffer)); message.print(F("HTTP/1.0 200 OK\r\n" "Content-Type: image/x-icon\r\n" "\r\n")); for (uint16_t i = 0; i < sizeof(tblFavicon); i++) { byte p = pgm_read_byte_near(tblFavicon + i); message.write(p); } message.flush(); client.stop(); } void sendStatistics(EthernetClient &client) { const size_t MESSAGE_BUFFER_SIZE = 64; char buffer[MESSAGE_BUFFER_SIZE]; // a buffer needed for the StreamLib BufferedPrint message(client, buffer, sizeof(buffer)); message.print(F("HTTP/1.0 200 OK\r\n" "Content-Type: application/octet-stream\r\n" "Content-Disposition: attachment; filename=statistics.bin\r\n" "Content-Length: 262144\r\n" "\r\n")); // Schicke 256kB Dummy-Daten for (int i = 0; i < 1024; i++) { for (byte j = 0; j < 256; j++) { message.write(j); } } message.flush(); client.stop(); } void loop() { checkForClient(); // listen for incoming clients // put your other main code here, to run repeatedly. avoid any delay() }