Moved udpCloudHost into newSettings

This commit is contained in:
2021-12-29 05:51:49 +01:00
parent c7fb30a870
commit c025001d86
4 changed files with 8 additions and 16 deletions

View File

@ -109,6 +109,7 @@ public:
ConfigWrapper<int16_t> reverseBeepDuration1{500, DoReset, {}, "revBeepDur1" };
ConfigWrapper<std::string> cloudUrl {std::string{}, DoReset, StringOr<StringEmpty, StringValidUrl>, "cloudUrl" };
ConfigWrapper<std::string> udpCloudHost {std::string{}, DoReset, {}, "udpCloudHost" };
#define NEW_SETTINGS(x) \
x(baseMacAddressOverride) \
@ -245,7 +246,8 @@ public:
x(reverseBeepDuration0) \
x(reverseBeepDuration1) \
\
//x(cloudUrl)
x(cloudUrl) \
x(udpCloudHost)
template<typename T>
void callForEveryConfig(T &&callback)
@ -253,7 +255,7 @@ public:
#define HELPER(x) callback(x);
NEW_SETTINGS(HELPER)
#undef HELPER
callback(cloudUrl);
callback(udpCloudHost);
}
auto getAllConfigParams()
@ -262,7 +264,7 @@ public:
#define HELPER(x) std::ref<ConfigWrapperInterface>(x),
NEW_SETTINGS(HELPER)
#undef HELPER
std::ref<ConfigWrapperInterface>(cloudUrl)
std::ref<ConfigWrapperInterface>(udpCloudHost)
);
}
};

View File

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

View File

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

View File

@ -19,6 +19,7 @@
#include "espchrono.h"
#include "battery.h"
#include "drivingstatistics.h"
#include "newsettings.h"
#ifdef FEATURE_UDPCLOUD
using namespace std::chrono_literals;
@ -315,7 +316,7 @@ void sendUdpCloudPacket()
return;
}
if (stringSettings.udpCloudUrl.empty())
if (configs.udpCloudHost.value.empty())
{
visualSendUdpPacket = false;
return;
@ -329,7 +330,7 @@ void sendUdpCloudPacket()
ip_addr_t udpCloudIp;
if (const auto res = dns_gethostbyname(stringSettings.udpCloudUrl.c_str(), &udpCloudIp, nullptr, nullptr); res != ERR_OK)
if (const auto res = dns_gethostbyname(configs.udpCloudHost.value.c_str(), &udpCloudIp, nullptr, nullptr); res != ERR_OK)
{
if (res == ERR_INPROGRESS)
{