Hi all
I see a strange behavior when i use the arduino as a webserver.
I have code that generates a form with some option bullets and a submit button.
While the page loads with two bullets, it will not load with four bullets.
I m using a module with the enc28j60 ethernet controller ant the UIP lib for it.
I m not that expierienced in coding and I m out of clue's.
See below the code:
#include <WString.h>
#include <UIPEthernet.h>
#include <avr/wdt.h>
#define MaxHeaderLength 32 //maximum length of http header required
int gr = 17;
int rd = 16;
int dummy_inA = 18;
int dummy_inB = 19;
int ping = 2;
int CharPos[] = {0,0,0,0};
int Relais[] = {0,0,0,0};
String HttpHeader = String(MaxHeaderLength);
EthernetServer server = EthernetServer(1000);
void setup(){
wdt_disable();
wdt_enable(WDTO_1S);
pinMode(dummy_inA, INPUT);
pinMode(dummy_inB, INPUT);
pinMode(gr, OUTPUT);
pinMode(rd, OUTPUT);
digitalWrite(gr, HIGH);
digitalWrite(rd, LOW);
uint8_t mac[6] = {0x00,0x01,0x02,0x03,0x04,0x05};
IPAddress myIP(192,168,1,15);
Ethernet.begin(mac,myIP);
server.begin();
}
void loop(){
// Create a client connection
EthernetClient client = server.available();
if (client) {
while (client.connected()) {
if (client.available()) {
char c = client.read();
//store characters to string
HttpHeader = HttpHeader + c;
//if HTTP request has ended
if (c == '\n') {
// start of web page
delay(ping); client.println("<!DOCTYPE html>");
delay(ping); client.println("<html>");
delay(ping); client.println("<body>");
delay(ping); client.println("Light control system
");
delay(ping); client.println("<form method='get'>");
delay(ping); client.println("1 : ");
delay(ping); client.println("<input type='radio' name=v value='1'> AAN");
delay(ping); client.println("<input type='radio' name=v value='0'> UIT
");
delay(ping); client.println("2 : ");
delay(ping); client.println("<input type='radio' name=w value='1'> AAN");
delay(ping); client.println("<input type='radio' name=w value='0'> UIT
");
//delay(ping); client.println("3 : ");
//delay(ping); client.println("<input type='radio' name=x value='1'> AAN");
//delay(ping); client.println("<input type='radio' name=x value='0'> UIT
");
//delay(ping); client.println("4 : ");
//delay(ping); client.println("<input type='radio' name=y value='1'> AAN");
//delay(ping); client.println("<input type='radio' name=y value='0'> UIT
");
delay(ping); client.println("<input type='submit' value='submit'></form>");
delay(ping); client.println("</body>");
delay(ping); client.println("</html>");
//stopping client
delay(4);
client.stop();
delay(4);
}
}
}
}
CharPos[0] = HttpHeader.indexOf('v');
CharPos[1] = HttpHeader.indexOf('w');
CharPos[2] = HttpHeader.indexOf('x');
CharPos[3] = HttpHeader.indexOf('y');
//clearing string for next read
HttpHeader="";
// reset the watchdog
wdt_reset();
}