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 <FreeRTOS.h>
#include <freertos/FreeRTOS.h>
#include <freertos/semphr.h>

View File

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

View File

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

View File

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

View File

@ -8,28 +8,15 @@
; Please visit documentation for the other options and examples
; 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]
platform = espressif32
platform = espressif32 @ 5.2.0
board = esp32-evb
framework = arduino
monitor_speed = 115200
lib_deps =
ESP32 Digital RGB LED Drivers
esp32_https_server@0.3.0
ESP32 Digital RGB LED Drivers @ 1.5.4
esp32_https_server @ 1.0.0
build_flags = -std=c++11

View File

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

View File

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