Serving a more complex webpage

Hi there,

Im working on a remote control for my television over ethernet using the ethernet shield. Its working if I reduce the used html code to a minimum but if I try to serve the full webpage with the Arduino the output is getting very strange and the order is not right anymore.
This is my code:

#include <SPI.h>

#include <Ethernet.h>
#include <IRremote.h>

byte mac[] = { 0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED };
byte ip[] = { 192, 168, 178, 253 };
byte gateway[] = { 192, 168, 178, 1 };
byte subnet[] = { 255, 255, 255, 0 };

String inString = String(35);

Server server(80);

IRsend irsend;

void setup()
{
Serial.begin(9600);
Ethernet.begin(mac, ip,gateway,subnet); 
server.begin();
Serial.println("Serial READY");
Serial.println("Ethernet READY");
Serial.println("Server READY");
}

void loop()
{

Client client = server.available();


if (client) {

// an http request ends with a blank line
boolean current_line_is_blank = true;
while (client.connected()) {

if (client.available()) {

char c = client.read();
// if we've gotten to the end of the line (received a newline
// character) and the line is blank, the http request has ended,
// so we can send a reply
if (inString.length() < 35) {
inString.concat(c);

} 
if (c == '\n' && current_line_is_blank) {

if(inString.indexOf("power") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0xa90, 12); // Sony TV power code
      delay(100);
   }
}
if(inString.indexOf("mute") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0x290, 12); // Sony TV power code
      delay(100);
   }
}
if(inString.indexOf("prou") >= 0){
    for (int i = 0; i < 3; i++) {
      irsend.sendSony(0x090, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("prod") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0x890, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("volu") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0x490, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("vold") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0xC90, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("num") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0x890, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("num1") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0x010, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("num2") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0x816, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("num3") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0x410, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("num4") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0xc10, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("num5") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0x210, 12); // Sony TV power code
      delay(100);
    }
}if(inString.indexOf("num6") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0xa10, 12); // Sony TV power code
      delay(100);
    }
}if(inString.indexOf("num7") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0x610, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("num8") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0xe10, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("num9") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0x110, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("nummore") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0xb90, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("picture") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0x5d0, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("video") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0xa50, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("tv") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0x1d0, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("txt") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0xfd0, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("green") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0xb38, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("red") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0x338, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("blue") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0xf38, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("yellow") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0x738, 12); // Sony TV power code
      delay(100);
    }
}
if(inString.indexOf("menu") >= 0){
  for (int i = 0; i < 3; i++) {
      irsend.sendSony(0x070, 12); // Sony TV power code
      delay(100);
    }
}
// send a standard http response header
client.println("HTTP/1.1 200 OK");
client.println("Content-Type: text/html");
client.println();

client.println("<html><head><meta name='viewport' content='user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0'/>");
client.println("<meta name='apple-mobile-web-app-capable' content='yes' />");
client.println("<meta name='apple-mobile-web-app-status-bar-style' content='black' />");
client.println("<style type='text/css'>.button {padding:5px;margin:5px;font-size:14px;	color: #000000;	}</style>");
client.println("</head><body bgcolor='#333333'><center>");
client.println("<form method=GET><table border=0 width=100%><tr><td align=center>");

client.println("<input type=submit name=power value='Power' class='button'></td>");
client.println("<td align=center>&nbsp;</td><td align=center><input type=submit name=mute value='Mute' class='button'></td></tr>");

client.println("<tr><td align=center><input type=submit name=num1 value='1' class='button'>");
client.println("</td><td align=center><input type=submit name=num2 value='2' class='button'>");
client.println("</td><td align=center><input type=submit name=num3 value='3' class='button'></td></tr>");
client.println("<tr><td align=center><input type=submit name=num4 value='4' class='button'>");
client.println("</td><td align=center><input type=submit name=num5 value='5' class='button'></td>");
client.println("<td align=center><input type=submit name=num6 value='6' class='button'></td></tr>");
client.println("<tr><td align=center><input type=submit name=num7 value='7' class='button'></td>");
client.println("<td align=center><input type=submit name=num8 value='8' class='button'></td>");
client.println("<td align=center><input type=submit name=num9 value='9' class='button'></td></tr>");
client.println("<tr><td align=center><input type=submit name=picture value='Bild' class='button'></td>");
client.println("<td align=center><input type=submit name=num value='0' class='button'></td>");
client.println("<td align=center><input type=submit name=nummore value='_/__' class='button'></td></tr>");
client.println("<tr><td align=center><input type=submit name=tv value='TV' class='button'></td>");
client.println("<td align=center><input type=submit name=txt value='Text' class='button'></td>");
client.println("<td align=center><input type=submit name=video value='Video' class='button'></td></tr>");

client.println("<tr><td align=center><input type=submit name=volu value='V+' class='button'></td>");
client.println("<td>&nbsp;</td><td align=center><input type=submit name=prou value='P+' class='button'></td></tr>");
client.println("<tr><td align=center><input type=submit name=vold value='V-' class='button'></td>");
client.println("<td>&nbsp;</td><td align=center><input type=submit name=prod value='P-' class='button'></td></tr>");

client.println("<tr><td align=center>&nbsp;</td>");
client.println("<td align=center><input type=submit name=green value='/\' class='button'></td>");
client.println("<td align=center>&nbsp;</td></tr>");
client.println("<tr><td align=center><input type=submit name=red value='<' class='button'></td>");
client.println("<td align=center><input type=submit name=menu value='Men&uuml;' class='button'></td>");
client.println("<td align=center><input type=submit name=yellow value='>' class='button'></td></tr>");
client.println("<tr><td align=center>&nbsp;</td><td align=center>");
client.println("<input type=submit name=blue value='!' class='button'></td>");
client.println("<td align=center>&nbsp;</td></tr>");

client.println("</table></body></html>");

delay(100);

client.stop();
}
}

}
}
}

Im running 0022 on an the latest Arduino Uno with with the Ethernet Shield with SD Port.

I'd say you're running out of RAM, do a search for PROGMEM and place all those constant strings in flash memory.


Rob