Hi!
I have an Arduino MEGA 1280 and an Ethernet Shield ENC28j60. I'm trying to make a WebServer with the example in Andy's Library http://blog.thiseldo.co.uk/?p=329. It is the only one that works with the Arduino MEGA 1280. All works well in the example, but not responses with my html code. If I reduce the code it works.
I've checked that if I increase the constant BUFFER SIZE it can works but now it doesn't work.
Can anyone helps me?
#define MYWWWPORT 80
#define BUFFER_SIZE 2000
static uint8_t buf[BUFFER_SIZE+1];
// The ethernet shield
EtherShield es=EtherShield();
uint16_t http200ok(void)
{
return(es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\nPragma: no-cache\r\n\r\n")));
}
// prepare the webpage by writing the data to the tcp send buffer
uint16_t print_webpage(uint8_t *buf)
{
uint16_t plen;
plen=http200ok();
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<html><title>Arduino servidor Domótico</title><body>"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<body bgcolor=\"#0099FF\" text=\"#FFFFFF\"><center><p><h1>SERVIDOR DOMOTICO ARDUINO</h1></p>"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<center><strong><h2>Estado Sensores</h2></strong></center>"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<table width=\"200\" border=\"1\" bordercolor=\"#FFFFFF\" cellspacing=\"0\" align=\"center\">"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<tr><td bgcolor=\"#FFFFFF\"><div align=\"center\" ><strong><font color=\"#000000\">Habitación 1</font></strong></div></td></tr>"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<tr><td><div align=\"center\">Luz X % </div></td></tr>"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<tr><td><div align=\"center\">Humedad X % </div></td></tr>"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<tr><td><div align=\"center\">Temperatura X ºC</div></td></tr></table>"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<center><strong><h2>Estado Actuadores</h2></strong></center>"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<table width=\"200\" border=\"1\" align=\"center\" cellspacing=\"0\" bordercolor=\"#FFFFFF\">"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<tr><td bgcolor=\"#FFFFFF\"><div align=\"center\"><strong><font color=\"#000000\">Habitación 1</font></strong></div></td></tr>"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<tr><td><div align=\"center\"><form method=\"get\">Luz<select name=\"LUZ\"><option value=\"1\">ON</option><option selected=\"selected\" value=\"0\">OFF</option></select>"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
Intensidad<input type=\"button\" onclick=\"masluz=1\" value=\"+\" /></input><input type=\"button\" onclick=\"menosluz=1\" value=\"-\" />"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
Temperatura<input name=\"TEMP\" type=\"text\" value=\"20\" size=\"4\" maxlength=\"2\"/>ºC
"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
Riego<select name=\"RIEGO\"><option value=\"1\">ON</option><option selected=\"selected\" value=\"0\">OFF</option></select>"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("
<input type=\"submit\" value=\"Enviar\"/></form></div></td></tr>"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("</table></body></html>"));
return(plen);
}
Thank you all. Sorry about my english.