Moved otaUrl into newSettings

This commit is contained in:
2021-12-29 06:00:48 +01:00
parent c025001d86
commit 1aa556dca1
7 changed files with 13 additions and 20 deletions

View File

@ -13,6 +13,7 @@
#include "buildserver.h"
#include "displays/menus/otamenu.h"
#include "utils.h"
#include "newsettings.h"
#ifdef FEATURE_OTA
@ -34,7 +35,7 @@ public:
stringSettings.otaServerUrl = m_buildserver_url;
if (m_buildserver_url.substr(m_buildserver_url.length() - 4) == ".bin")
{
stringSettings.otaUrl = m_buildserver_url;
configs.write_config(configs.otaUrl, m_buildserver_url); // mir egal ob es succeeded
}
saveSettings();
url_for_latest.clear();

View File

@ -12,8 +12,8 @@
#include "actions/switchscreenaction.h"
#include "icons/back.h"
#include "displays/menus/otamenu.h"
#include "globals.h"
#include "newsettings.h"
#ifdef FEATURE_OTA
#define MESSAGE(text) constructMenuItem<makeComponent<MenuItem, StaticText<text>, DefaultFont, StaticColor<TFT_RED>, DummyAction>>()
@ -34,8 +34,7 @@ public:
void triggered() override
{
stringSettings.otaUrl = m_url;
saveSettings();
configs.write_config(configs.otaUrl, m_url); // mir egal ob succeeded
}
int color() const override

View File

@ -20,6 +20,7 @@
#include "texts.h"
#include "ota.h"
#include "displays/menus/otamenu.h"
#include "newsettings.h"
#ifdef FEATURE_OTA
void UpdateDisplay::initScreen()
@ -112,7 +113,7 @@ void UpdateDisplay::buttonPressed(espgui::Button button)
espgui::switchScreen<OtaMenu>();
break;
case Button::Right:
if (const auto result = triggerOta(stringSettings.otaUrl); !result)
if (const auto result = triggerOta(configs.otaUrl.value); !result)
ESP_LOGE("BOBBY", "triggerOta() failed with %.*s", result.error().size(), result.error().data());
break;
default:;

View File

@ -110,6 +110,7 @@ public:
ConfigWrapper<std::string> cloudUrl {std::string{}, DoReset, StringOr<StringEmpty, StringValidUrl>, "cloudUrl" };
ConfigWrapper<std::string> udpCloudHost {std::string{}, DoReset, {}, "udpCloudHost" };
ConfigWrapper<std::string> otaUrl {std::string{}, DoReset, StringOr<StringEmpty, StringValidUrl>, "otaUrl" };
#define NEW_SETTINGS(x) \
x(baseMacAddressOverride) \
@ -247,7 +248,8 @@ public:
x(reverseBeepDuration1) \
\
x(cloudUrl) \
x(udpCloudHost)
x(udpCloudHost) \
// x(otaUrl)
template<typename T>
void callForEveryConfig(T &&callback)
@ -255,7 +257,7 @@ public:
#define HELPER(x) callback(x);
NEW_SETTINGS(HELPER)
#undef HELPER
callback(udpCloudHost);
callback(otaUrl);
}
auto getAllConfigParams()
@ -264,7 +266,7 @@ public:
#define HELPER(x) std::ref<ConfigWrapperInterface>(x),
NEW_SETTINGS(HELPER)
#undef HELPER
std::ref<ConfigWrapperInterface>(udpCloudHost)
std::ref<ConfigWrapperInterface>(otaUrl)
);
}
};

View File

@ -9,9 +9,6 @@ StringSettings makeDefaultStringSettings()
#endif
return {
#ifdef FEATURE_OTA
.otaUrl = {},
#endif
#ifdef FEATURE_GARAGE
.garageUrl = {},
#endif

View File

@ -6,10 +6,6 @@
struct StringSettings
{
#ifdef FEATURE_OTA
std::string otaUrl;
#endif
#ifdef FEATURE_GARAGE
std::string garageUrl;
#endif
@ -45,10 +41,6 @@ struct StringSettings
template<typename T>
void StringSettings::executeForEveryCommonSetting(T &&callable)
{
#ifdef FEATURE_OTA
callable("otaUrl", otaUrl);
#endif
#ifdef FEATURE_GARAGE
callable("garageUrl", garageUrl);
#endif

View File

@ -22,6 +22,7 @@
#endif
#include "webserver_lock.h"
#include "globals.h"
#include "newsettings.h"
#if defined(FEATURE_WEBSERVER) && defined(FEATURE_OTA)
using namespace std::chrono_literals;
@ -344,7 +345,7 @@ esp_err_t webserver_ota_handler(httpd_req_t *req)
body += "Trigger Update";
}
body += fmt::format("<input type=\"text\" name=\"url\" value=\"{}\" />", esphttpdutils::htmlentities(stringSettings.otaUrl));
body += fmt::format("<input type=\"text\" name=\"url\" value=\"{}\" />", esphttpdutils::htmlentities(configs.otaUrl.value));
{
HtmlTag buttonTag{"button", "type=\"submit\"", body};