Moved FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET into config-system

This commit is contained in:
CommanderRedYT
2022-01-17 11:23:22 +01:00
parent cb11ca3c9e
commit 9125a968d5
8 changed files with 141 additions and 121 deletions

View File

@ -51,10 +51,11 @@ httpd_handle_t httpdHandle;
void initWebserver()
{
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
webserver_lock.construct();
webserver_lock->take(portMAX_DELAY);
#endif
if (!configs.feature.webserver_disable_lock.value)
{
webserver_lock.construct();
webserver_lock->take(portMAX_DELAY);
}
{
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
webserver_lock->give();
vTaskDelay(1);
webserver_lock->take(portMAX_DELAY);
#endif
if (!configs.feature.webserver_disable_lock.value)
{
webserver_lock->give();
vTaskDelay(1);
webserver_lock->take(portMAX_DELAY);
}
}
namespace {
@ -165,16 +167,19 @@ bool menuDisplayChanged()
esp_err_t webserver_status_handler(httpd_req_t *req)
{
#ifndef FEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil<espcpputils::ticks>(5s).count()};
if (!helper.locked())
if (!configs.feature.webserver_disable_lock.value)
{
constexpr const std::string_view msg = "could not lock webserver_lock";
ESP_LOGE(TAG, "%.*s", msg.size(), msg.data());
CALL_AND_EXIT(esphttpdutils::webserver_resp_send, req, esphttpdutils::ResponseStatus::BadRequest, "text/plain", msg);
espcpputils::LockHelper helper{webserver_lock->handle, std::chrono::ceil<espcpputils::ticks>(5s).count()};
if (!helper.locked())
{
constexpr const std::string_view msg = "could not lock webserver_lock";
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;