fix whatever went wrong the previous time
This commit is contained in:
parent
3bc54a8071
commit
c05f719f32
|
@ -7,7 +7,6 @@ script:
|
||||||
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16
|
- /sbin/start-stop-daemon --start --quiet --pidfile /tmp/custom_xvfb_1.pid --make-pidfile --background --exec /usr/bin/Xvfb -- :1 -ac -screen 0 1280x1024x16
|
||||||
- sleep 3
|
- sleep 3
|
||||||
- export DISPLAY=:1.0
|
- export DISPLAY=:1.0
|
||||||
|
|
||||||
- wget http://downloads.arduino.cc/arduino-1.6.5-linux64.tar.xz
|
- wget http://downloads.arduino.cc/arduino-1.6.5-linux64.tar.xz
|
||||||
- tar xf arduino-1.6.5-linux64.tar.xz
|
- tar xf arduino-1.6.5-linux64.tar.xz
|
||||||
- mv arduino-1.6.5 $HOME/arduino_ide
|
- mv arduino-1.6.5 $HOME/arduino_ide
|
||||||
|
@ -28,7 +27,7 @@ script:
|
||||||
- cd espressif
|
- cd espressif
|
||||||
- git clone https://github.com/me-no-dev/ESP31B.git ESP31B
|
- git clone https://github.com/me-no-dev/ESP31B.git ESP31B
|
||||||
- cd ESP31B/tools
|
- cd ESP31B/tools
|
||||||
- wget http://static.ficeto.com/xtensa-esp108-elf-linux64.tar.gz
|
- wget https://github.com/me-no-dev/ESP31B/releases/download/0.0.1/xtensa-esp108-elf-linux64.tar.gz
|
||||||
- tar zxvf xtensa-esp108-elf-linux64.tar.gz
|
- tar zxvf xtensa-esp108-elf-linux64.tar.gz
|
||||||
- chmod +x xtensa-esp108-elf/bin/*
|
- chmod +x xtensa-esp108-elf/bin/*
|
||||||
- chmod +x xtensa-esp108-elf/xtensa-esp108-elf/bin/*
|
- chmod +x xtensa-esp108-elf/xtensa-esp108-elf/bin/*
|
||||||
|
|
28
README.md
28
README.md
|
@ -235,8 +235,9 @@ request->send("text/plain", 128, [](uint8_t *buffer, size_t maxLen) -> size_t {
|
||||||
### Respond with content using a callback and extra headers
|
### Respond with content using a callback and extra headers
|
||||||
```cpp
|
```cpp
|
||||||
//send 128 bytes as plain text
|
//send 128 bytes as plain text
|
||||||
AsyncWebServerResponse *response = request->beginResponse("text/plain", 128, [](uint8_t *buffer, size_t maxLen) -> size_t {
|
AsyncWebServerResponse *response = request->beginResponse("text/plain", 128, [](uint8_t *buffer, size_t maxLen, size_t index) -> size_t {
|
||||||
//Write up to "maxLen" bytes into "buffer" and return the amount written.
|
//Write up to "maxLen" bytes into "buffer" and return the amount written.
|
||||||
|
//index equals the amount of bytes that have been already sent
|
||||||
//You will not be asked for more bytes once the content length has been reached.
|
//You will not be asked for more bytes once the content length has been reached.
|
||||||
//Keep in mind that you can not delay or yield waiting for more data!
|
//Keep in mind that you can not delay or yield waiting for more data!
|
||||||
//Send what you currently have and you will be asked for more again
|
//Send what you currently have and you will be asked for more again
|
||||||
|
@ -249,8 +250,9 @@ request->send(response);
|
||||||
### Chunked Response
|
### Chunked Response
|
||||||
Used when content length is unknown. Works best if the client supports HTTP/1.1
|
Used when content length is unknown. Works best if the client supports HTTP/1.1
|
||||||
```cpp
|
```cpp
|
||||||
AsyncWebServerResponse *response = request->beginChunkedResponse("text/plain", [](uint8_t *buffer, size_t maxLen) -> size_t {
|
AsyncWebServerResponse *response = request->beginChunkedResponse("text/plain", [](uint8_t *buffer, size_t maxLen, size_t index) -> size_t {
|
||||||
//Write up to "maxLen" bytes into "buffer" and return the amount written.
|
//Write up to "maxLen" bytes into "buffer" and return the amount written.
|
||||||
|
//index equals the amount of bytes that have been already sent
|
||||||
//You will be asked for more data until 0 is returned
|
//You will be asked for more data until 0 is returned
|
||||||
//Keep in mind that you can not delay or yield waiting for more data!
|
//Keep in mind that you can not delay or yield waiting for more data!
|
||||||
return mySource.read(buffer, maxLen);
|
return mySource.read(buffer, maxLen);
|
||||||
|
@ -309,6 +311,28 @@ response->print("</body></html>");
|
||||||
request->send(response);
|
request->send(response);
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Send a large webpage from PROGMEM using callback response
|
||||||
|
Example provided by [@nouser2013](https://github.com/nouser2013)
|
||||||
|
```cpp
|
||||||
|
const char indexhtml[] PROGMEM = "..."; // large char array, tested with 5k
|
||||||
|
AsyncWebServerResponse *response = request->beginResponse(
|
||||||
|
String("text/html"),
|
||||||
|
strlen_P(indexhtml),
|
||||||
|
[](uint8_t *buffer, size_t maxLen, size_t alreadySent) -> size_t {
|
||||||
|
if (strlen_P(indexhtml+alreadySent)>maxLen) {
|
||||||
|
// We have more to read than fits in maxLen Buffer
|
||||||
|
memcpy_P((char*)buffer, indexhtml+alreadySent, maxLen);
|
||||||
|
return maxLen;
|
||||||
|
}
|
||||||
|
// Ok, last chunk
|
||||||
|
memcpy_P((char*)buffer, indexhtml+sentCounter, strlen_P(indexhtml+sentCounter));
|
||||||
|
return strlen_P(indexhtml+sentCounter); // Return from here to end of indexhtml
|
||||||
|
}
|
||||||
|
);
|
||||||
|
response->addHeader("Server", "MyServerString");
|
||||||
|
request->send(response);
|
||||||
|
```
|
||||||
|
|
||||||
### ArduinoJson Basic Response
|
### ArduinoJson Basic Response
|
||||||
This way of sending Json is great for when the result is below 4KB
|
This way of sending Json is great for when the result is below 4KB
|
||||||
```cpp
|
```cpp
|
||||||
|
|
|
@ -1,3 +1,23 @@
|
||||||
|
/*
|
||||||
|
Asynchronous WebServer library for Espressif MCUs
|
||||||
|
|
||||||
|
Copyright (c) 2016 Hristo Gochkov. All rights reserved.
|
||||||
|
This file is part of the esp8266 core for Arduino environment.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
#ifndef _ESPAsyncWebServer_H_
|
#ifndef _ESPAsyncWebServer_H_
|
||||||
#define _ESPAsyncWebServer_H_
|
#define _ESPAsyncWebServer_H_
|
||||||
|
|
||||||
|
@ -76,7 +96,7 @@ class AsyncWebHeader {
|
||||||
* REQUEST :: Each incoming Client is wrapped inside a Request and both live together until disconnect
|
* REQUEST :: Each incoming Client is wrapped inside a Request and both live together until disconnect
|
||||||
* */
|
* */
|
||||||
|
|
||||||
typedef std::function<size_t(uint8_t*, size_t)> AwsResponseFiller;
|
typedef std::function<size_t(uint8_t*, size_t, size_t)> AwsResponseFiller;
|
||||||
|
|
||||||
class AsyncWebServerRequest {
|
class AsyncWebServerRequest {
|
||||||
private:
|
private:
|
||||||
|
@ -286,6 +306,6 @@ class AsyncWebServer {
|
||||||
void _handleRequest(AsyncWebServerRequest *request);
|
void _handleRequest(AsyncWebServerRequest *request);
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "AsyncWebServerResponseImpl.h"
|
#include "WebResponseImpl.h"
|
||||||
|
|
||||||
#endif /* _AsyncWebServer_H_ */
|
#endif /* _AsyncWebServer_H_ */
|
||||||
|
|
|
@ -1,10 +1,23 @@
|
||||||
/*
|
/*
|
||||||
* StringArray.h
|
Asynchronous WebServer library for Espressif MCUs
|
||||||
*
|
|
||||||
* Created on: 18.12.2015 г.
|
|
||||||
* Author: ficeto
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
Copyright (c) 2016 Hristo Gochkov. All rights reserved.
|
||||||
|
This file is part of the esp8266 core for Arduino environment.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
#ifndef STRINGARRAY_H_
|
#ifndef STRINGARRAY_H_
|
||||||
#define STRINGARRAY_H_
|
#define STRINGARRAY_H_
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,23 @@
|
||||||
/*
|
/*
|
||||||
* AsyncWebServerHandlerImpl.h
|
Asynchronous WebServer library for Espressif MCUs
|
||||||
*
|
|
||||||
* Created on: 19.12.2015 г.
|
|
||||||
* Author: ficeto
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
Copyright (c) 2016 Hristo Gochkov. All rights reserved.
|
||||||
|
This file is part of the esp8266 core for Arduino environment.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
#ifndef ASYNCWEBSERVERHANDLERIMPL_H_
|
#ifndef ASYNCWEBSERVERHANDLERIMPL_H_
|
||||||
#define ASYNCWEBSERVERHANDLERIMPL_H_
|
#define ASYNCWEBSERVERHANDLERIMPL_H_
|
||||||
|
|
|
@ -1,11 +1,25 @@
|
||||||
/*
|
/*
|
||||||
* WebHandlers.cpp
|
Asynchronous WebServer library for Espressif MCUs
|
||||||
*
|
|
||||||
* Created on: 18.12.2015 г.
|
Copyright (c) 2016 Hristo Gochkov. All rights reserved.
|
||||||
* Author: ficeto
|
This file is part of the esp8266 core for Arduino environment.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
*/
|
*/
|
||||||
#include "ESPAsyncWebServer.h"
|
#include "ESPAsyncWebServer.h"
|
||||||
#include "AsyncWebServerHandlerImpl.h"
|
#include "WebHandlerImpl.h"
|
||||||
|
|
||||||
bool AsyncStaticWebHandler::canHandle(AsyncWebServerRequest *request)
|
bool AsyncStaticWebHandler::canHandle(AsyncWebServerRequest *request)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,13 +1,26 @@
|
||||||
/*
|
/*
|
||||||
* WebServerClient.cpp
|
Asynchronous WebServer library for Espressif MCUs
|
||||||
*
|
|
||||||
* Created on: 18.12.2015 г.
|
|
||||||
* Author: ficeto
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
Copyright (c) 2016 Hristo Gochkov. All rights reserved.
|
||||||
|
This file is part of the esp8266 core for Arduino environment.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
#include "ESPAsyncWebServer.h"
|
#include "ESPAsyncWebServer.h"
|
||||||
#include "AsyncWebServerResponseImpl.h"
|
|
||||||
#include <libb64/cencode.h>
|
#include <libb64/cencode.h>
|
||||||
|
#include "WebResponseImpl.h"
|
||||||
|
|
||||||
#ifndef ESP8266
|
#ifndef ESP8266
|
||||||
#define os_strlen strlen
|
#define os_strlen strlen
|
|
@ -1,10 +1,23 @@
|
||||||
/*
|
/*
|
||||||
* AsyncWebImpl.h
|
Asynchronous WebServer library for Espressif MCUs
|
||||||
*
|
|
||||||
* Created on: 19.12.2015 г.
|
|
||||||
* Author: ficeto
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
Copyright (c) 2016 Hristo Gochkov. All rights reserved.
|
||||||
|
This file is part of the esp8266 core for Arduino environment.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
#ifndef ASYNCWEBSERVERRESPONSEIMPL_H_
|
#ifndef ASYNCWEBSERVERRESPONSEIMPL_H_
|
||||||
#define ASYNCWEBSERVERRESPONSEIMPL_H_
|
#define ASYNCWEBSERVERRESPONSEIMPL_H_
|
||||||
|
|
|
@ -1,5 +1,25 @@
|
||||||
|
/*
|
||||||
|
Asynchronous WebServer library for Espressif MCUs
|
||||||
|
|
||||||
|
Copyright (c) 2016 Hristo Gochkov. All rights reserved.
|
||||||
|
This file is part of the esp8266 core for Arduino environment.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
#include "ESPAsyncWebServer.h"
|
#include "ESPAsyncWebServer.h"
|
||||||
#include "AsyncWebServerResponseImpl.h"
|
#include "WebResponseImpl.h"
|
||||||
#include "cbuf.h"
|
#include "cbuf.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -265,6 +285,9 @@ size_t AsyncAbstractResponse::_ack(AsyncWebServerRequest *request, size_t len, u
|
||||||
|
|
||||||
if(outLen)
|
if(outLen)
|
||||||
outLen = request->client()->write((const char*)buf, outLen);
|
outLen = request->client()->write((const char*)buf, outLen);
|
||||||
|
if(_chunked)
|
||||||
|
_sentLength += readLen;
|
||||||
|
else
|
||||||
_sentLength += outLen;
|
_sentLength += outLen;
|
||||||
free(buf);
|
free(buf);
|
||||||
|
|
||||||
|
@ -381,7 +404,7 @@ AsyncCallbackResponse::AsyncCallbackResponse(String contentType, size_t len, Aws
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t AsyncCallbackResponse::_fillBuffer(uint8_t *data, size_t len){
|
size_t AsyncCallbackResponse::_fillBuffer(uint8_t *data, size_t len){
|
||||||
return _content(data, len);
|
return _content(data, len, _sentLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -398,7 +421,7 @@ AsyncChunkedResponse::AsyncChunkedResponse(String contentType, AwsResponseFiller
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t AsyncChunkedResponse::_fillBuffer(uint8_t *data, size_t len){
|
size_t AsyncChunkedResponse::_fillBuffer(uint8_t *data, size_t len){
|
||||||
return _content(data, len);
|
return _content(data, len, _sentLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,25 @@
|
||||||
|
/*
|
||||||
|
Asynchronous WebServer library for Espressif MCUs
|
||||||
|
|
||||||
|
Copyright (c) 2016 Hristo Gochkov. All rights reserved.
|
||||||
|
This file is part of the esp8266 core for Arduino environment.
|
||||||
|
|
||||||
|
This library is free software; you can redistribute it and/or
|
||||||
|
modify it under the terms of the GNU Lesser General Public
|
||||||
|
License as published by the Free Software Foundation; either
|
||||||
|
version 2.1 of the License, or (at your option) any later version.
|
||||||
|
|
||||||
|
This library is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||||
|
Lesser General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU Lesser General Public
|
||||||
|
License along with this library; if not, write to the Free Software
|
||||||
|
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
*/
|
||||||
#include "ESPAsyncWebServer.h"
|
#include "ESPAsyncWebServer.h"
|
||||||
#include "AsyncWebServerHandlerImpl.h"
|
#include "WebHandlerImpl.h"
|
||||||
|
|
||||||
|
|
||||||
AsyncWebServer::AsyncWebServer(uint16_t port):_server(port), _handlers(0), _catchAllHandler(new AsyncCallbackWebHandler()){
|
AsyncWebServer::AsyncWebServer(uint16_t port):_server(port), _handlers(0), _catchAllHandler(new AsyncCallbackWebHandler()){
|
||||||
|
|
Loading…
Reference in New Issue