Merge branch 'master' into bnb

This commit is contained in:
Thomas Kolb 2023-08-11 19:56:24 +02:00
commit f76c71e1d2
7 changed files with 30 additions and 39 deletions

View file

@ -4,7 +4,7 @@
#include "Animation.h" #include "Animation.h"
#include <FreeRTOS.h> #include <freertos/FreeRTOS.h>
#include <freertos/semphr.h> #include <freertos/semphr.h>

View file

@ -2,6 +2,8 @@
#include <vector> #include <vector>
#include <cstdint>
class Fader class Fader
{ {
public: public:

View file

@ -2,7 +2,7 @@
#include <string> #include <string>
#include <FreeRTOS.h> #include <freertos/FreeRTOS.h>
#include <freertos/semphr.h> #include <freertos/semphr.h>
#include "ChallengeResponse.h" #include "ChallengeResponse.h"

View file

@ -4,7 +4,7 @@
#include <HTTPResponse.hpp> #include <HTTPResponse.hpp>
#include <HTTPServer.hpp> #include <HTTPServer.hpp>
#include <FreeRTOS.h> #include <freertos/FreeRTOS.h>
#include <freertos/semphr.h> #include <freertos/semphr.h>
#include "ChallengeResponse.h" #include "ChallengeResponse.h"

View file

@ -8,28 +8,15 @@
; Please visit documentation for the other options and examples ; Please visit documentation for the other options and examples
; https://docs.platformio.org/page/projectconf.html ; https://docs.platformio.org/page/projectconf.html
[env:nodemcu-32s]
platform = espressif32
board = nodemcu-32s
framework = arduino
monitor_speed = 115200
lib_deps =
ESP32 Digital RGB LED Drivers
esp32_https_server
build_flags = -std=c++11
[env:esp32-evb] [env:esp32-evb]
platform = espressif32 platform = espressif32 @ 5.2.0
board = esp32-evb board = esp32-evb
framework = arduino framework = arduino
monitor_speed = 115200 monitor_speed = 115200
lib_deps = lib_deps =
ESP32 Digital RGB LED Drivers ESP32 Digital RGB LED Drivers @ 1.5.4
esp32_https_server@0.3.0 esp32_https_server @ 1.0.0
build_flags = -std=c++11 build_flags = -std=c++11

View file

@ -115,13 +115,12 @@ void WebServer::handleColor(httpsserver::HTTPRequest *req, httpsserver::HTTPResp
httpsserver::ResourceParameters * params = req->getParams(); httpsserver::ResourceParameters * params = req->getParams();
if(!params->isRequestParameterSet("color")) { std::string colorstr;
if(!params->getQueryParameter("color", colorstr)) {
error400(res, "Parameter 'color' not set."); error400(res, "Parameter 'color' not set.");
return; return;
} }
std::string colorstr = params->getRequestParameter("color");
Fader::Color color; Fader::Color color;
std::string errorMessage; std::string errorMessage;
if(!parseColor(colorstr, &color, &errorMessage)) { if(!parseColor(colorstr, &color, &errorMessage)) {
@ -150,17 +149,18 @@ void WebServer::handleSetAnim(httpsserver::HTTPRequest *req, httpsserver::HTTPRe
httpsserver::ResourceParameters * params = req->getParams(); httpsserver::ResourceParameters * params = req->getParams();
if(!params->isRequestParameterSet("anim")) { std::string animstr;
if(!params->getQueryParameter("anim", animstr)) {
error400(res, "Parameter 'anim' not set."); error400(res, "Parameter 'anim' not set.");
return; return;
} }
std::istringstream animstr(params->getRequestParameter("anim")); std::istringstream animstream(animstr);
uint32_t anim_id; uint32_t anim_id;
animstr >> anim_id; animstream >> anim_id;
if(animstr.bad() || animstr.fail()) { if(animstream.bad() || animstream.fail()) {
error400(res, "Parameter 'anim' could not be parsed as number."); error400(res, "Parameter 'anim' could not be parsed as number.");
return; return;
} }
@ -203,16 +203,10 @@ void WebServer::handleText(httpsserver::HTTPRequest *req, httpsserver::HTTPRespo
httpsserver::ResourceParameters * params = req->getParams(); httpsserver::ResourceParameters * params = req->getParams();
if(!params->isRequestParameterSet("text")) {
error400(res, "Required parameter 'text' not set.");
return;
}
Fader::Color color; Fader::Color color;
if(params->isRequestParameterSet("color")) { std::string colorstr;
std::string colorstr = params->getRequestParameter("color"); if(params->getQueryParameter("color", colorstr)) {
std::string errorMessage; std::string errorMessage;
if(!parseColor(colorstr, &color, &errorMessage)) { if(!parseColor(colorstr, &color, &errorMessage)) {
error400(res, errorMessage); error400(res, errorMessage);
@ -222,8 +216,14 @@ void WebServer::handleText(httpsserver::HTTPRequest *req, httpsserver::HTTPRespo
color = Fader::Color{0, 0, 0, 32}; color = Fader::Color{0, 0, 0, 32};
} }
std::string text;
if(!params->getQueryParameter("text", text)) {
error400(res, "Required parameter 'text' not set.");
return;
}
Bitmap bmp; Bitmap bmp;
Font::textToBitmap(params->getRequestParameter("text").c_str(), &bmp, color); Font::textToBitmap(text.c_str(), &bmp, color);
WebServer::instance().m_animController->changeAnimation( WebServer::instance().m_animController->changeAnimation(
std::unique_ptr<Animation>( std::unique_ptr<Animation>(
@ -237,7 +237,7 @@ void WebServer::handleUpdate(httpsserver::HTTPRequest *req, httpsserver::HTTPRes
httpsserver::ResourceParameters * params = req->getParams(); httpsserver::ResourceParameters * params = req->getParams();
if(!params->isRequestParameterSet("content")) { if(!params->isQueryParameterSet("content")) {
error400(res, "Send update image as 'content'."); error400(res, "Send update image as 'content'.");
} }
@ -290,12 +290,12 @@ void WebServer::handleAuthTest(httpsserver::HTTPRequest *req, httpsserver::HTTPR
httpsserver::ResourceParameters * params = req->getParams(); httpsserver::ResourceParameters * params = req->getParams();
if(!params->isRequestParameterSet("response")) { std::string response;
if(!params->getQueryParameter("response", response)) {
error400(res, "Parameter 'response' not set."); error400(res, "Parameter 'response' not set.");
return; return;
} }
std::string response = params->getRequestParameter("response");
bool result = WebServer::instance().m_cr.verify(response); bool result = WebServer::instance().m_cr.verify(response);
if(result) { if(result) {

View file

@ -8,7 +8,7 @@
#include <ETH.h> #include <ETH.h>
#include <FreeRTOS.h> #include <freertos/FreeRTOS.h>
#include <freertos/semphr.h> #include <freertos/semphr.h>
#include "WebServer.h" #include "WebServer.h"
@ -236,6 +236,8 @@ static void ledFSM(void)
// UDP packet received -> transition to UDP state // UDP packet received -> transition to UDP state
nextState = UDP; nextState = UDP;
ledState = TRANSITION; ledState = TRANSITION;
// ensure the correct animation plays after UDP transfers stop
animController.changeAnimation(loadSavedAnimation(), false);
} }
// change to last used animation after some time // change to last used animation after some time