Moved FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET into config-system
This commit is contained in:
@ -51,10 +51,11 @@ httpd_handle_t httpdHandle;
|
||||
|
||||
void initWebserver()
|
||||
{
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
{
|
||||
webserver_lock.construct();
|
||||
webserver_lock->take(portMAX_DELAY);
|
||||
#endif
|
||||
}
|
||||
|
||||
{
|
||||
httpd_config_t httpConfig HTTPD_DEFAULT_CONFIG();
|
||||
@ -100,11 +101,12 @@ void initWebserver()
|
||||
|
||||
void handleWebserver()
|
||||
{
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
{
|
||||
webserver_lock->give();
|
||||
vTaskDelay(1);
|
||||
webserver_lock->take(portMAX_DELAY);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
namespace {
|
||||
@ -165,7 +167,8 @@ bool menuDisplayChanged()
|
||||
|
||||
esp_err_t webserver_status_handler(httpd_req_t *req)
|
||||
{
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
{
|
||||
espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil<espcpputils::ticks>(5s).count()};
|
||||
if (!helper.locked())
|
||||
{
|
||||
@ -173,8 +176,10 @@ esp_err_t webserver_status_handler(httpd_req_t *req)
|
||||
ESP_LOGE(TAG, "%.*s", msg.size(), msg.data());
|
||||
CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Access-Control-Allow-Origin", "http://web.bobbycar.cloud");
|
||||
|
||||
std::string wants_json_query;
|
||||
if (auto result = esphttpdutils::webserver_get_query(req))
|
||||
wants_json_query = *result;
|
||||
|
@ -36,7 +36,8 @@ constexpr const char * const TAG = "BOBBYWEB";
|
||||
|
||||
esp_err_t webserver_root_handler(httpd_req_t *req)
|
||||
{
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
{
|
||||
espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil<espcpputils::ticks>(5s).count()};
|
||||
if (!helper.locked())
|
||||
{
|
||||
@ -44,7 +45,7 @@ esp_err_t webserver_root_handler(httpd_req_t *req)
|
||||
ESP_LOGE(TAG, "%.*s", msg.size(), msg.data());
|
||||
CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string body;
|
||||
|
||||
@ -288,7 +289,8 @@ esp_err_t webserver_root_handler(httpd_req_t *req)
|
||||
|
||||
esp_err_t webserver_triggerRawButton_handler(httpd_req_t *req)
|
||||
{
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
{
|
||||
espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil<espcpputils::ticks>(5s).count()};
|
||||
if (!helper.locked())
|
||||
{
|
||||
@ -296,7 +298,7 @@ esp_err_t webserver_triggerRawButton_handler(httpd_req_t *req)
|
||||
ESP_LOGE(TAG, "%.*s", msg.size(), msg.data());
|
||||
CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string query;
|
||||
if (auto result = esphttpdutils::webserver_get_query(req))
|
||||
@ -362,7 +364,8 @@ esp_err_t webserver_triggerRawButton_handler(httpd_req_t *req)
|
||||
|
||||
esp_err_t webserver_triggerButton_handler(httpd_req_t *req)
|
||||
{
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
{
|
||||
espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil<espcpputils::ticks>(5s).count()};
|
||||
if (!helper.locked())
|
||||
{
|
||||
@ -370,7 +373,7 @@ esp_err_t webserver_triggerButton_handler(httpd_req_t *req)
|
||||
ESP_LOGE(TAG, "%.*s", msg.size(), msg.data());
|
||||
CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string query;
|
||||
if (auto result = esphttpdutils::webserver_get_query(req))
|
||||
@ -436,7 +439,8 @@ esp_err_t webserver_triggerButton_handler(httpd_req_t *req)
|
||||
|
||||
esp_err_t webserver_triggerItem_handler(httpd_req_t *req)
|
||||
{
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
{
|
||||
espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil<espcpputils::ticks>(5s).count()};
|
||||
if (!helper.locked())
|
||||
{
|
||||
@ -444,7 +448,8 @@ esp_err_t webserver_triggerItem_handler(httpd_req_t *req)
|
||||
ESP_LOGE(TAG, "%.*s", msg.size(), msg.data());
|
||||
CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Access-Control-Allow-Origin", "http://web.bobbycar.cloud");
|
||||
|
||||
std::string query;
|
||||
@ -525,7 +530,8 @@ esp_err_t webserver_triggerItem_handler(httpd_req_t *req)
|
||||
|
||||
esp_err_t webserver_setValue_handler(httpd_req_t *req)
|
||||
{
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
{
|
||||
espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil<espcpputils::ticks>(5s).count()};
|
||||
if (!helper.locked())
|
||||
{
|
||||
@ -533,7 +539,7 @@ esp_err_t webserver_setValue_handler(httpd_req_t *req)
|
||||
ESP_LOGE(TAG, "%.*s", msg.size(), msg.data());
|
||||
CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Access-Control-Allow-Origin", "http://web.bobbycar.cloud");
|
||||
|
||||
|
@ -135,7 +135,8 @@ showInputForSetting(std::string_view key, T value, JsonObject &body)
|
||||
|
||||
esp_err_t webserver_dump_nvs_handler(httpd_req_t *req)
|
||||
{
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
{
|
||||
espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil<espcpputils::ticks>(5s).count()};
|
||||
if (!helper.locked())
|
||||
{
|
||||
@ -143,8 +144,7 @@ esp_err_t webserver_dump_nvs_handler(httpd_req_t *req)
|
||||
ESP_LOGE(TAG, "%.*s", msg.size(), msg.data());
|
||||
CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
DynamicJsonDocument doc(6144);
|
||||
const auto profile = settingsPersister.currentlyOpenProfileIndex();
|
||||
const auto switchBackProfile = profile ? int(*profile) : 0;
|
||||
|
@ -1,5 +1,3 @@
|
||||
#include "webserver_lock.h"
|
||||
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
cpputils::DelayedConstruction<espcpputils::mutex_semaphore> webserver_lock;
|
||||
#endif
|
||||
|
@ -4,6 +4,4 @@
|
||||
#include <delayedconstruction.h>
|
||||
#include <wrappers/mutex_semaphore.h>
|
||||
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
extern cpputils::DelayedConstruction<espcpputils::mutex_semaphore> webserver_lock;
|
||||
#endif
|
||||
|
@ -262,7 +262,8 @@ showInputForSetting(std::string_view key, T value, std::string &body)
|
||||
|
||||
esp_err_t webserver_newSettings_handler(httpd_req_t *req)
|
||||
{
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
{
|
||||
ESP_LOGI(TAG, "trying to lock...");
|
||||
espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil<espcpputils::ticks>(5s).count()};
|
||||
if (!helper.locked())
|
||||
@ -271,7 +272,7 @@ esp_err_t webserver_newSettings_handler(httpd_req_t *req)
|
||||
ESP_LOGE(TAG, "%.*s", msg.size(), msg.data());
|
||||
CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string body;
|
||||
|
||||
@ -507,7 +508,8 @@ saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
|
||||
|
||||
esp_err_t webserver_saveNewSettings_handler(httpd_req_t *req)
|
||||
{
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
{
|
||||
espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil<espcpputils::ticks>(5s).count()};
|
||||
if (!helper.locked())
|
||||
{
|
||||
@ -515,7 +517,7 @@ esp_err_t webserver_saveNewSettings_handler(httpd_req_t *req)
|
||||
ESP_LOGE(TAG, "%.*s", msg.size(), msg.data());
|
||||
CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string query;
|
||||
if (auto result = esphttpdutils::webserver_get_query(req))
|
||||
@ -576,7 +578,8 @@ esp_err_t webserver_saveNewSettings_handler(httpd_req_t *req)
|
||||
|
||||
esp_err_t webserver_resetNewSettings_handler(httpd_req_t *req)
|
||||
{
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
{
|
||||
espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil<espcpputils::ticks>(5s).count()};
|
||||
if (!helper.locked())
|
||||
{
|
||||
@ -584,7 +587,7 @@ esp_err_t webserver_resetNewSettings_handler(httpd_req_t *req)
|
||||
ESP_LOGE(TAG, "%.*s", msg.size(), msg.data());
|
||||
CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string query;
|
||||
if (auto result = esphttpdutils::webserver_get_query(req))
|
||||
|
@ -34,7 +34,8 @@ constexpr const char * const TAG = "BOBBYWEB";
|
||||
|
||||
esp_err_t webserver_ota_percentage_handler(httpd_req_t *req)
|
||||
{
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
{
|
||||
espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil<espcpputils::ticks>(5s).count()};
|
||||
if (!helper.locked())
|
||||
{
|
||||
@ -42,8 +43,10 @@ esp_err_t webserver_ota_percentage_handler(httpd_req_t *req)
|
||||
ESP_LOGE(TAG, "%.*s", msg.size(), msg.data());
|
||||
CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Access-Control-Allow-Origin", "http://web.bobbycar.cloud");
|
||||
|
||||
std::string body;
|
||||
|
||||
std::string wants_json_query;
|
||||
@ -93,7 +96,8 @@ esp_err_t webserver_ota_percentage_handler(httpd_req_t *req)
|
||||
|
||||
esp_err_t webserver_ota_handler(httpd_req_t *req)
|
||||
{
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
{
|
||||
espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil<espcpputils::ticks>(5s).count()};
|
||||
if (!helper.locked())
|
||||
{
|
||||
@ -101,8 +105,10 @@ esp_err_t webserver_ota_handler(httpd_req_t *req)
|
||||
ESP_LOGE(TAG, "%.*s", msg.size(), msg.data());
|
||||
CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Access-Control-Allow-Origin", "http://web.bobbycar.cloud");
|
||||
|
||||
std::string body;
|
||||
|
||||
std::string wants_json_query;
|
||||
@ -361,7 +367,8 @@ esp_err_t webserver_ota_handler(httpd_req_t *req)
|
||||
|
||||
esp_err_t webserver_trigger_ota_handler(httpd_req_t *req)
|
||||
{
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
{
|
||||
espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil<espcpputils::ticks>(5s).count()};
|
||||
if (!helper.locked())
|
||||
{
|
||||
@ -369,8 +376,10 @@ esp_err_t webserver_trigger_ota_handler(httpd_req_t *req)
|
||||
ESP_LOGE(TAG, "%.*s", msg.size(), msg.data());
|
||||
CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
CALL_AND_EXIT_ON_ERROR(httpd_resp_set_hdr, req, "Access-Control-Allow-Origin", "http://web.bobbycar.cloud");
|
||||
|
||||
std::string query;
|
||||
if (auto result = esphttpdutils::webserver_get_query(req))
|
||||
query = *result;
|
||||
|
@ -89,7 +89,8 @@ showInputForSetting(std::string_view key, T value, std::string &body)
|
||||
|
||||
esp_err_t webserver_settings_handler(httpd_req_t *req)
|
||||
{
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
{
|
||||
espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil<espcpputils::ticks>(5s).count()};
|
||||
if (!helper.locked())
|
||||
{
|
||||
@ -97,8 +98,7 @@ esp_err_t webserver_settings_handler(httpd_req_t *req)
|
||||
ESP_LOGE(TAG, "%.*s", msg.size(), msg.data());
|
||||
CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg);
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
std::string body;
|
||||
|
||||
{
|
||||
@ -257,7 +257,8 @@ saveSetting(T &value, std::string_view newValue, std::string &body)
|
||||
|
||||
esp_err_t webserver_saveSettings_handler(httpd_req_t *req)
|
||||
{
|
||||
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
if (!configs.feature.webserver_disable_lock.value)
|
||||
{
|
||||
espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil<espcpputils::ticks>(5s).count()};
|
||||
if (!helper.locked())
|
||||
{
|
||||
@ -265,7 +266,7 @@ esp_err_t webserver_saveSettings_handler(httpd_req_t *req)
|
||||
ESP_LOGE(TAG, "%.*s", msg.size(), msg.data());
|
||||
CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string query;
|
||||
if (auto result = esphttpdutils::webserver_get_query(req))
|
||||
|
Reference in New Issue
Block a user