Library für ESP01 Webserver STM32F103RB Nucleo
Dependents: Nucleo_dht11_Webserver WebServerGSOEWorkshopSlider WebServerGSOEWorkshopDynamisch WebServerGSOEWorkshopStatisch ... more
Diff: ESP8266Webserver.cpp
- Revision:
- 38:848feec26df5
- Parent:
- 37:4680b876f77b
- Child:
- 40:6d79431a08aa
--- a/ESP8266Webserver.cpp Fri Aug 06 15:35:26 2021 +0000 +++ b/ESP8266Webserver.cpp Sat Aug 07 09:23:35 2021 +0000 @@ -18,7 +18,7 @@ dbg=pDebug; _serial = new BufferedSerial(tx,rx, ESP8266_DEFAULT_BAUD_RATE); - _parser = new ATCmdParser(_serial, "\r\n"); + _parser = new ATCmdParser(_serial, "\r\n",1000); _parser->debug_on(true); _parser->set_timeout(2000); @@ -216,10 +216,11 @@ { if (_parser->recv("+IPD,%d,%d:",&clientID[clientIdx],&value2)) { - if (dbg) printf("\r\nich Client ID=%d, Anzahl=%d",clientID[clientIdx],value2); + if (dbg) printf("\r\n >>> Client ID=%d, Anzahl=%d",clientID[clientIdx],value2); _parser->read(recbuf, value2); - if (dbg) printf("\r\nBuf=\n%s",recbuf); + + if (dbg) printf("\r\nBuf=\n%s\n\n",recbuf); if (beinhaltet(favicon)) { @@ -243,7 +244,7 @@ { printf("\r\n%s\r\n",hs[i]); } - if (dbg) printf("\r\nich Got\r\n"); + if (dbg) printf("\r\n>>> Got\r\n"); } } @@ -406,6 +407,8 @@ char *error; char* referer; char* favicon; + char* post; + post=strstr(recbuf,"POST"); favicon=strstr(recbuf,"favicon"); //if (favicon!=NULL) return NULL; error=strstr(recbuf,"ERROR"); @@ -414,23 +417,39 @@ referer=strstr(recbuf,"Referer"); int i=0; - - fundort=strstr(recbuf,suchstring); + fundort=strstr(recbuf,suchstring); + if (post==NULL) + { if (fundort!=NULL&&(fundort<referer||referer==NULL)) { - fundort=fundort+strlen(suchstring)+1; - while(i<20 && fundort[i]!=38 && fundort[i]>32 ) //space, & - { - hilf[i]=fundort[i]; - i++; + fundort=fundort+strlen(suchstring)+1; + while(i<20 && fundort[i]!=38 && fundort[i]>32 ) //space, & + { + hilf[i]=fundort[i]; + i++; + } + hilf[i]=0; + if (dbg) printf("\r\nsuchergebnis=%s\r\n",hilf); + return hilf; } - hilf[i]=0; - if (dbg) printf("\r\nsuchergebnis=%s\r\n",hilf); - return hilf; - } - else - return NULL; - + else return NULL; + } + else + { + if (fundort!=NULL) + { + fundort=fundort+strlen(suchstring)+1; + while(i<20 && fundort[i]!='&' && i<sizeof(fundort) ) + { + hilf[i]=fundort[i]; + i++; + } + hilf[i]=0; + if (dbg) printf("\r\nsuchergebnis=%s\r\n",hilf); + return hilf; + } + else return NULL; + } } void ESP8266Webserver::listAPs()