Hell all!
This has been driving me nuts, and I can't figure out why.
I have the Microchip based (enc28j60) ethernet shield, that now fully works, I have a simple application that toggles an LED (a website) where when you press a button, it takes you to [website]/?cmd=1 (where the submit value is command 1). It all works well with 1 button (one form), however when I try to add another form, and connect to the arduino (at ip 192.168.0.15), it just hangs with "loading..."
Here is the code that works 100%
uint16_t print_webpage(uint8_t *buf)
{
uint16_t plen;
plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<title>Arduino Webserver with LED control</title><center><p><h1>LED Toggle Control </h1></p> "));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<hr>
<form METHOD=get action=\""));
plen=es.ES_fill_tcp_data(buf,plen,baseurl);
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("\">"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<h2> LED [PIN8] STATUS: </h2> "));
if (toggleLED==1) {
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<h1><font color=\"#00FF00\"> "));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<h2> ON! </h2> "));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("</font></h1>
") );
}
else {
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<h1><font color=\"#FF0000\"> "));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<h2> OFF! </h2> "));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("</font></h1>
") );
}
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<input type=hidden name=cmd value=1>"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<input type=submit value=\"TOGGLE LED!\"></form>"));
return(plen);
//return(plen);
}
But if I add another form to this, the whole thing stops working (can't connect to the arduino).
uint16_t print_webpage(uint8_t *buf)
{
uint16_t plen;
plen=es.ES_fill_tcp_data_p(buf,0,PSTR("HTTP/1.0 200 OK\r\nContent-Type: text/html\r\n\r\n"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<title>Arduino Webserver with LED control</title><center><p><h1>LED Toggle Control </h1></p> "));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<hr>
<form METHOD=get action=\""));
plen=es.ES_fill_tcp_data(buf,plen,baseurl);
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("\">"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<h2> LED [PIN8] STATUS: </h2> "));
if (toggleLED==1) {
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<h1><font color=\"#00FF00\"> "));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<h2> ON! </h2> "));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("</font></h1>
") );
}
else {
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<h1><font color=\"#FF0000\"> "));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<h2> OFF! </h2> "));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("</font></h1>
") );
}
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<input type=hidden name=cmd value=1>"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<input type=submit value=\"TOGGLE LED!\"></form>"));
//OTHER FUNCTION
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<hr>
<form METHOD=get action=\""));
plen=es.ES_fill_tcp_data(buf,plen,baseurl);
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("\">"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<input type=hidden name=cmd value=2>"));
plen=es.ES_fill_tcp_data_p(buf,plen,PSTR("<input type=submit value=\"TOGGLE AUX!\"></form>"));
return(plen);
//return(plen);
}
I have no idea what's going on, as it should be the browser that interprets HTML code.
Any help is greatly appreciated!
Thanks in advance!