Das Problem hat sich gelöst...
Ich habe lediglich jegliche HTML-Formatierung von Text (und überflüssige Zeilen) aus dem HTML-Output entfernt; und siehe da: es geht!
Hier:
/*
Original Version by Poldi
modified by Katsu
the functions readString.append() and readString.contains() where replaced
*/
#include <RCSwitch.h>
#include <SPI.h> // insert by Katsu
// #include <WString.h> removed by Katsu
#include <Ethernet.h>
byte mac[] = { 0x54, 0x55, 0x58, 0x10, 0x00, 0x24 }; // entspricht einer MAC von 84.85.88.16.0.36
byte ip[] = { 192, 168, 0, 5 }; // IP-Adresse
byte gateway[] = { 192, 168, 0, 1 }; // Gateway
byte subnet[] = { 255, 255, 255, 0 };
EthernetServer server(80);
String readString = String(100); // string for fetching data from address
boolean RC1 = false; // Status flag
boolean RC2 = false;
RCSwitch rcControl = RCSwitch();
void setup(){
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
// Transmitter is connected to Arduino Pin #10
rcControl.enableTransmit(2);
Serial.begin(9600); }
void loop(){
// Create a client connection
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
//read char by char HTTP request
if (readString.length() < 100) {
//store characters to string
// readString.append(c); removed by Katsu
readString = readString + c; // insert by Katsu
// very simple but it works...
}
Serial.print(c); //output chars to serial port
if (c == '\n') { //if HTTP request has ended
// readString.contains() replaced with readString.indexOf(val) > -1 by Katsu
// indexOf locates a character or String within another String.
// Returns the index of val within the String, or -1 if not found.
if(readString.indexOf("rc1=on") > -1) {
rcControl.switchOn('a', 1, 1);
Serial.println("Steckdose 1 eingeschaltet!");
RC1 = true;
}
if(readString.indexOf("rc1=off") > -1){
rcControl.switchOff('a', 1, 1);
Serial.println("Steckdose 1 ausgeschaltet!");
RC1 = false;
}
if(readString.indexOf("all=off") > -1){
rcControl.switchOff('a', 1, 1);
Serial.println("Alles ausgeschaltet");
RC1 = false;
}
//--------------------------HTML------------------------
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();
client.print("<html><head>");
client.print("<title>Arduino Webserver Poldi</title>");
client.println("</head>");
client.print("<body>");
//---Ausgänge schalten---
client.println("Steckdose 1
");
client.println("<form method=get><input type=submit name=rc1 value='on'></form>");
client.println("<form method=get><input type=submit name=rc1 value='off'></form>");
if (RC1)
client.println("Status: ON");
else
client.println("Status: OFF");
client.println("
");
client.println("Steckdose 2
");
client.println("<form method=get><input type=submit name=rc2 value='on'></form>");
client.println("<form method=get><input type=submit name=rc2 value='off'></form>");
if (RC1)
client.println("Status: ON");
else
client.println("Status: OFF");
client.println("
");
client.println("<form method=get><input type=submit name=all value='off'></form>");
client.println("</body></html>");
//---Ausgänge schalten---
//clearing string for next read
readString="";
//stopping client
client.stop();
}}}}}