
Zitat von
Ceos
ich korrigiere meine Aussage, erst flush(), dann RX leer machen, dann delay(1000), dann stop()
danke, nur verstehe ich jetzt noch nicht was genau wohin soll,
kannst du da mal bitte direkt in meinem Code korrigieren und in code tags posten?
edit: was bedeutet z.B. auch "RX leer machen"?
Code:
//stopping client
client.flush();
delay(1000); // debug
client.stop();
das macht bis jetzt noch keinen Unterschied (bricht ebenfalls wieder nach ca. 1 sec. ab, ohne delay(1000) auch wieder sofort)...
Code:
bool authorized=false;
void handleNotAuthorized() {
String readString = "";
char strinput[MAXLEN], strupwd[TOKLEN], struname[TOKLEN] ;
WiFiClient client = wifiserver.available();
//---------------------------------------
// debug
// authorized=true;
strcpy(strinput, "");
strcpy(strupwd, "");
strcpy(struname, "");
while ( client.connected() ) {
if (authorized) return;
if ( client.available() ) {
char c = client.read();
//read char by request
readString = "";
while ( (readString.length() < TOKLEN) && (c != '\n') ) {
readString += c;
c = client.read();
}
readString.toCharArray(strinput, MAXLEN);
// cstringarg(strinput, "uname", struname); // uname
// cstringarg(strinput, "upwd", strupwd); // upwd
if(strstr(website_upwd,strupwd)!=NULL & strstr(website_uname,struname)!=NULL)
{
authorized = true;
readString = "";
return;
// return; // <<< selbes Ergebnis, egal ob kommentiert oder auskommentiert
}
//if HTTP request has ended
if (c == '\n') {
//now output html data header
String script = "";
script += ("HTTP/1.1 200 OK \n");
script += ("Content-Type: text/html \n");
script += ("\n"); // do not forget this one //????
script += ("<!DOCTYPE html> \n");
script += ("<html> \n");
script += ("<head> \n");
// utf-8 für "°" Zeichen
script += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"> \n" ;
script += "<title>" ;
script += "</title> \n" ;
script += "</head> \n" ;
script += "<body> \n" ;
script += ("<h2><p style=\"color:rgb(255,0,191);\"> log in to proceed: </p> </h2> \n");
script += ("<FORM ACTION='/' method=GET > \n");
script += ("<h2>user name: <INPUT TYPE=text NAME='uname' VALUE='' MAXLENGTH='50'> </h2> \n");
script += ("<h2>password : <INPUT TYPE=PASSWORD NAME='upwd' VALUE='' MAXLENGTH='50'> </h2> \n");
script += ("<h2><INPUT TYPE=SUBMIT></h2> \n");
script += ("</FORM> \n");
script += ("<BR> \n");
script += ("</body> \n");
script += ("</html> \n");
client.print(script);
//stopping client
client.flush();
delay(1000); // debug
client.stop();
//clearing string for next read
//readString = "";
}
}
delay(1);
}
}
Lesezeichen