esp8266 / espwebserver Goto Github PK
View Code? Open in Web Editor NEWHTTP server library for ESP8266/ESP32 Arduino cores (previously ESP8266WebServer)
HTTP server library for ESP8266/ESP32 Arduino cores (previously ESP8266WebServer)
Hi Guys i have developed a program for esp8266 to connect to any wifi station by providing SSID and password. I am using mDNS to find the device when its in AP Mode. but when in STA mode i cannot find it with the mDNS.
I am using websocket to communicate with the device , but here i need to know the IP address of the esp and then i can communicate with it.
What i want to achieve here is , I want to access the esp without knowing its IP address when it is connected to the network i am in. Also i cannot set a static ip address to the esp in my case.
What are the techniques to do so , please guide.
Any text input field containing '&' (encoded %26) is wrongly parsed as further arguments because parsing.cpp is performing urlDecode() on the entire buffer for "application/x-www-form-urlencoded" type header. Instead, url decoding should be executed on the parsed arguments themselves in _parseArguments().
(Indeed 2.4.0-rc.1 _parseArguments() is already performing urlDecode() on the arguments parsed)
ESP8266WebServer/src/Parsing.cpp
185: if (contentLength > 0) {
186: if (searchStr != "") searchStr += '&';
187: if(isEncoded){
188: //url encoded form
189: String decoded = urlDecode(plainBuf); <-- Cause of error
hence
plainBuf: arg0=arg0_value&arg1=arg1_value&arg2=inner_arg0%3Dinner_arg0_value%26inner_arg1%3Dinner_arg1_value%26inner_arg2%3Dinner_arg2_value
becomes
decoded : arg0=arg0_value&arg1=arg1_value&arg2=inner_arg0=inner_arg0_value&inner_arg1=inner_arg1_value&inner_arg2=inner_arg2_value
which then parsed in _parseArguments() as:
arg0 : arg0_value
arg1 : arg1_value
arg2 : inner_arg0=inner_arg0_value
inner_arg1 : inner_arg1_value
inner_arg2 : inner_arg2_value
though it should have been parsed to:
arg0 : arg0_value
arg1 : arg1_value
arg2 : inner_arg0=inner_arg0_value&inner_arg1=inner_arg1_value&inner_arg2=inner_arg2_value
I fixed the issue temporarily as following:
185: if (contentLength > 0) {
186: if (searchStr != "") searchStr += '&';
187: //if(isEncoded){
188: //url encoded form
189: // String decoded = urlDecode(plainBuf); --> plainBuf should not be decoded. Parameters should be decoded instead
190: // size_t decodedLen = decoded.length();
191: // memcpy(plainBuf, decoded.c_str(), decodedLen);
192: // plainBuf[decodedLen] = 0;
193: searchStr += plainBuf;
194: //}
though it may need a finer resolution by the original author(s)
Hardware: Sparkfun ESP8266 Thing Developer
Core Version: 2.4.0-rc.1
Module: Sparkfun ESP8266 Thing Developer
Flash Size: 512
CPU Frequency: 80Mhz
Flash Mode: qio
Flash Frequency: 40Mhz
Upload Using: SERIAL
Reset Method: nodemcu
I want to have WebServer for maybe 10 seconds or until I have clients sending requests and than I want DeepSleep for maybe 20 seconds. I have tried this but it's not working. I am sending only loop function.
void loop(void){ server.handleClient(); ESP.deepSleep(20e6); // 20e6 is 20 microseconds }
I am using this library to set-up a simple web-server with a static IP address. Everything works fine and the server is able to handle request from multiple devices.
After a random period of time (a couple of hours) the web-server becomes unresponsive. At the same time I am able to ping the ESP8266 and receive replies back, so the device is alive and well.
Is there anything I should be aware of based on how connections are handled ?
Is the server ok with handling mobile devices as clients ?
Not so much an issue as a question. Where is the 'FS.h' required in the FSBrowser example?
Thanks.
Hi,
This is not a issue, its a possible feature.
I try to use a enc28j60 module, but the ESPWebServer don't bind on that interface, is possible to change the bind IP from WI-FI to the one of the Ethernet module ?
Thank you.
fatal error: ESP8266WiFi.h: No such file or directory!
I have a ESP8266WebServer running on port 80 of my ESP8266 board. It does a fine job serving static HTML pages. However it gives me trouble to serve text files larger than few Kb hosted on the ESP8266 filesystem.
I can access just fine the small files, but the larger ones get truncated. I have tried to use wget, curl or aria2c with resume, but it seems not supported from this WebServer
-> [HttpResponse.cc:81] errorCode=8 Invalid range header. Request: 16384-359256/359257, Response: 0-359256/359257
or
curl: (33) HTTP server doesn't seem to support byte ranges. Cannot resume.
Is there any way I can run the webserver with resume enabled? or any tip to download these "large" files from the ESP8266?
client code:
WiFiClient client;
HTTPClient http1;
char url[500]={0};
char ipbuff[15]={0};
sprintf(url,"http://192.168.4.1/inline?deviceid=3F");
http1.setReuse(false);
http1.setTimeout(2000);
if (http1.begin(client,url))
{
int httpCode = http1.GET();
Serial.printf("HTTP CODE == %d \n\r",httpCode);
if (httpCode == HTTP_CODE_OK || httpCode == HTTP_CODE_MOVED_PERMANENTLY)
{
String payload = http1.getString();
Serial.println(payload);
}
else
{
Serial.println("HTTP ERROR CODE");
Serial.printf("[HTTP] GET... failed, error: %s\n", http1.errorToString(httpCode).c_str());
}
}
else
{
Serial.println("HTTP Cannot connect");
}
http1.end();
/////////////////////SERVER CODE/////////////////////////
IPAddress staticIP(192, 168, 4, 1); //ESP8266 static ip
IPAddress gateway(192, 168, 4, 180); //IP Address of your WiFi Router (Gateway)
IPAddress subnet(255, 255, 255, 0); //Subnet mask
IPAddress dns(8, 8, 8, 8); //DNS
ESP8266WebServer server(80);
void setup()
{
Serial.begin(19200);
Serial.println();
WiFi.mode(WIFI_STA);
WiFi.config(staticIP, subnet, gateway, dns);
WiFiMulti.addAP(ssid,password );
while ((WiFiMulti.run() != WL_CONNECTED))
{
Serial.print("*");
delay(500);
}
Serial.println();
if ((WiFiMulti.run() == WL_CONNECTED))
{
Serial.println("connected\n\r");
}
server.on("/inline",HTTP_GET,handleinlineresponse);
server.begin();
}
void loop()
{
server.handleClient()
}
void handleinlineresponse()
{
String powerstatus = server.arg("deviceid");
Serial.println(powerstatus);
server.send(200, "text/html",powerstatus);
return ;
}
i am bit new in Esp8266 trying to build interactive code that make the data updated webserver eventually
so i have a html error trying to solve it but it seem something i dont know if anyone have the reason
my code in lua
`
data = 10
print (data)
srv=net.createServer(net.TCP)
srv:listen(80,function(conn)
conn:on("receive",function(conn,payload)
local buf=""
local buf2=""
print(payload)
if data <1000 then data=data+1
elseif data>999 then data=0 end
tmr.delay(700000)
print (data)
buf = buf.."<!DOCTYPE HTML>\n\n"
buf = buf.."<html lang=\"en\" type=\"text/html\">\n"
buf = buf.."<head><meta charset=\"utf-8\" />\n"
buf = buf.."<title>Hello, World!</title></head>\n"
buf = buf.."<style>\n"
buf = buf.."html {\n"
buf = buf.."color: red;\n"
buf = buf.."background-color: #B39D99;\n"
buf = buf.."font-family :verdana,Arial ,Gemeva ,Arial Black;\n"
buf = buf.."}\n"
buf = buf.."</style>\n"
buf = buf.."<body onload='process()'>\n<h1>Hello, World!</h1>\n"
buf = buf.."<div id='div1'>"..data.."</div>\n"
buf = buf.."<script id=\"myxml\" type=\"text/XML\">\n"
-- buf=buf.." "
buf=buf..""
buf=buf..data
buf=buf.."\n\nโ"
buf = buf.."</script>\n"
buf = buf.."<script>\n"
buf=buf.."var xmlHttp=createXmlHttpObject();\n "
buf=buf.."function createXmlHttpObject(){;\n"
buf=buf.."if(window.XMLHttpRequest){\n"
buf=buf.."xmlHttp=new XMLHttpRequest();\n"
buf=buf.."}else{\n"
buf=buf.."xmlHttp=new ActiveXObject('Microsoft.XMLHTTP');\n"
buf=buf.."}\n"
buf=buf.."return xmlHttp; "
buf=buf.."\n"
buf=buf.."}\n"
buf=buf.."function response(){\n"
buf=buf.."xmlResponse=xmlHttp.responseXML;\n"
buf=buf.."xmldoc = xmlResponse.getElementByTagName('data').innerHTML;\n"
--buf=buf.." for (i = 0; i < x.length; i++) {\n"
--buf=buf.."if (areEqual = xmlDoc.getElementsByTagName(\'data\').toUpperCase() === nametxt.toUpperCase())\n" {
-- buf=buf.."document.getElementById(\"xml\").value = x[i];\n"
-- buf=buf.." }"
buf=buf.."message = xmldoc[0].firstChild.nodeValue;\n"
buf=buf.."document.getElementById('div1').innerHTML=message;}\n"
buf=buf.."function process(){\n"
buf=buf.."xmlHttp.open('PUT','XML',true);\n"
buf=buf.."xmlHttp.onreadystatechange=response;\n"
buf=buf.."xmlHttp.send(null);\n"
buf=buf.."setTimeout('process()',400);\n"
buf=buf.."}\n"
buf=buf.."</script>\n"
buf = buf.."</body>\n"
buf=buf.."</html>\n"
conn:send(buf);
conn:close();
collectgarbage();
end)
end)
`
and the error
(index):38 PUT http://192.168.1.8/XML net::ERR_CONNECTION_TIMED_OUT
process @ (index):38
(anonymous) @ VM10646:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10645:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10644:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10643:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10642:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10641:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10640:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10639:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10638:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10637:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10636:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10635:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10634:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10633:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10632:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10631:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10630:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10629:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10628:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10627:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10626:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10625:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10624:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10623:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10622:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10621:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10620:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10619:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10618:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10617:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10616:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10615:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10614:1
(index):32 Uncaught TypeError: Cannot read property 'getElementByTagName' of null
at XMLHttpRequest.response ((index):32)
response @ (index):32
XMLHttpRequest.send (async)
process @ (index):38
(anonymous) @ VM10646:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10645:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10644:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10643:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10642:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10641:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10640:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10639:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10638:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10637:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10636:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10635:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10634:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10633:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10632:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10631:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10630:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10629:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10628:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10627:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10626:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10625:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10624:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10623:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10622:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10621:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10620:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10619:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10618:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10617:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10616:1
setTimeout (async)
process @ (index):39
(anonymous) @ VM10615:1
(index):32 Uncaught TypeError: Cannot read property 'getElementByTagName' of null
at XMLHttpRequest.response ((index):32)
at process ((index):36)
at :1:1
Is there a way to use this without it requiring Internet access? Looking at the edit.html page it goes to a cloudflare site to get a JS file. This works when the machine accessing the ESP32 has Internet access and the ESP32 is on the same LAN as the PC. If the ESP32 is running as an AP though and the PC connects the page wont load completely because it doesn't have Internet.
Have spent few hours trying to close() the server to begin () it again with new handlers but nothing works. I am adding handlers with server.on() Here is part of my code:
ESP8266WebServer server(80);
void setup() {
server.on("/def", HTTP_GET, {
server.send ( 200, "text/plain", "DefStillHere");
});
server.on("/test", HTTP_GET, {
server.send ( 200, "text/plain", "StillAlive");
});
server.begin();
}
SetMode("CONFIG_MODE");
void SetMode(String MODE) {
//works?
delay(200);
if( MODE=="CONFIG_MODE"){
//set variables
StartAP();
SetEndpoints();
}
server.begin();
}
P.S. just want to remove the handlers, so I wont have to check if they should be available.
@bbx10 has created an ESPWebServer for ESP32. Will this work be incorporated into this repo, or ESP32 support live elsewhere? According to the roadmap, it seems that this should be the place.
hi ,using ESPWebServer file download speed(from wemose d1 to laptop) is max 140 kB/s(1.2 Mbps)- uploading bandwidth (from laptop to wemose) is max 62 Kbps.
how can increase file transfer speed?
Hi,
Please I need help in modifying the index.htm file to hide the System Volume Information folder that shows up in my SD card and also to hide the index.htm file.
I run the code on a tablet and the display screen is somewhat small and I face difficulties tapping on the folders to expand the tree items. Please how do I modify the code to increase the size of the folders and files and to expand the tree on startup. Or better still, display the files and folders like on a desktop computer.
Thanks for reading this and helping. Looking forward to hearing from you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.