diff --git a/src/rbprotocol.cpp b/src/rbprotocol.cpp index 7981056..61e71c2 100644 --- a/src/rbprotocol.cpp +++ b/src/rbprotocol.cpp @@ -15,6 +15,13 @@ namespace rb { using namespace rb::internal; +const ProtocolConfig Protocol::DEFAULT_CONFIG = { + .enable_udp = true, + .enable_ws = true, + .ws_register_with_webserver = true, + .udp_port = 42424, +}; + Protocol::Protocol(const char* owner, const char* name, const char* description, Protocol::callback_t callback) { m_owner = owner; m_name = name; diff --git a/src/rbprotocol.h b/src/rbprotocol.h index 54ea942..1e6ccfe 100644 --- a/src/rbprotocol.h +++ b/src/rbprotocol.h @@ -10,6 +10,7 @@ #include #include #include +#include #include "rbjson.h" @@ -64,12 +65,7 @@ class Protocol { public: typedef std::function callback_t; - static constexpr const ProtocolConfig DEFAULT_CONFIG = { - .enable_udp = true, - .enable_ws = true, - .ws_register_with_webserver = true, - .udp_port = 42424, - }; + static const ProtocolConfig DEFAULT_CONFIG; Protocol(const char* owner, const char* name, const char* description, callback_t callback = nullptr); ~Protocol(); diff --git a/src/rbwebserver.c b/src/rbwebserver.c index ed6b271..9746da8 100644 --- a/src/rbwebserver.c +++ b/src/rbwebserver.c @@ -338,7 +338,7 @@ static void parse_request(int fd, http_request* req) { int length = strlen(filename); if (length == 0) { - filename = "."; + filename = (char*)"."; } else { for (int i = 0; i < length; ++i) { if (filename[i] == '?') { @@ -450,8 +450,7 @@ static void process_serve_file(int fd, struct sockaddr_in* clientaddr, http_requ int ffd = prepare_gzip(req); if (ffd <= 0) { status = 404; - char* msg = "File not found"; - client_error(fd, status, "Not found", msg); + client_error(fd, status, "Not found", "File not found"); } else { fstat(ffd, &sbuf); if (S_ISREG(sbuf.st_mode)) { @@ -464,8 +463,7 @@ static void process_serve_file(int fd, struct sockaddr_in* clientaddr, http_requ serve_static(fd, ffd, req, sbuf.st_size); } else { status = 400; - char* msg = "Unknow Error"; - client_error(fd, status, "Error", msg); + client_error(fd, status, "Error", "Unknow Error"); } close(ffd); } diff --git a/src/rbwifi.h b/src/rbwifi.h index 7ef9e43..a66f561 100644 --- a/src/rbwifi.h +++ b/src/rbwifi.h @@ -1,6 +1,7 @@ #pragma once #include +#include #if defined(ESP_IDF_VERSION_VAL) #if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 1, 0)