Moved cloudUrl into newsettings
This commit is contained in:
@@ -6,6 +6,17 @@
|
|||||||
// esp-idf includes
|
// esp-idf includes
|
||||||
#include <esp_log.h>
|
#include <esp_log.h>
|
||||||
|
|
||||||
|
// 3rdparty lib includes
|
||||||
|
#include <espwifistack.h>
|
||||||
|
#include <esphttpdutils.h>
|
||||||
|
#include <fmt/core.h>
|
||||||
|
#include <tickchrono.h>
|
||||||
|
|
||||||
|
// local includes
|
||||||
|
#include "globals.h"
|
||||||
|
#include "utils.h"
|
||||||
|
#include "newsettings.h"
|
||||||
|
|
||||||
using namespace std::chrono_literals;
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -26,8 +37,7 @@ std::optional<espchrono::millis_clock::time_point> lastCloudSend;
|
|||||||
void initCloud()
|
void initCloud()
|
||||||
{
|
{
|
||||||
if (settings.cloudSettings.cloudEnabled &&
|
if (settings.cloudSettings.cloudEnabled &&
|
||||||
!stringSettings.cloudUrl.empty() &&
|
!configs.cloudUrl.value.empty())
|
||||||
esphttpdutils::urlverify(stringSettings.cloudUrl))
|
|
||||||
{
|
{
|
||||||
createCloud();
|
createCloud();
|
||||||
if (!cloudClient)
|
if (!cloudClient)
|
||||||
@@ -156,8 +166,7 @@ void cloudCollect()
|
|||||||
void cloudSend()
|
void cloudSend()
|
||||||
{
|
{
|
||||||
if (settings.cloudSettings.cloudEnabled &&
|
if (settings.cloudSettings.cloudEnabled &&
|
||||||
!stringSettings.cloudUrl.empty() &&
|
!configs.cloudUrl.value.empty())
|
||||||
esphttpdutils::urlverify(stringSettings.cloudUrl))
|
|
||||||
{
|
{
|
||||||
if (!cloudClient)
|
if (!cloudClient)
|
||||||
{
|
{
|
||||||
@@ -222,7 +231,7 @@ void createCloud()
|
|||||||
lastCreateTry = espchrono::millis_clock::now();
|
lastCreateTry = espchrono::millis_clock::now();
|
||||||
|
|
||||||
const esp_websocket_client_config_t config = {
|
const esp_websocket_client_config_t config = {
|
||||||
.uri = stringSettings.cloudUrl.c_str(),
|
.uri = configs.cloudUrl.value.c_str(),
|
||||||
};
|
};
|
||||||
|
|
||||||
cloudClient = espcpputils::websocket_client{&config};
|
cloudClient = espcpputils::websocket_client{&config};
|
||||||
|
12
main/cloud.h
12
main/cloud.h
@@ -1,15 +1,11 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
// system includes
|
||||||
|
#include <string>
|
||||||
|
|
||||||
// 3rdparty lib includes
|
// 3rdparty lib includes
|
||||||
#include <wrappers/websocket_client.h>
|
#include <wrappers/websocket_client.h>
|
||||||
#include <espwifistack.h>
|
#include <espchrono.h>
|
||||||
#include <esphttpdutils.h>
|
|
||||||
#include <fmt/core.h>
|
|
||||||
#include <tickchrono.h>
|
|
||||||
|
|
||||||
// local includes
|
|
||||||
#include "globals.h"
|
|
||||||
#include "utils.h"
|
|
||||||
|
|
||||||
#ifdef FEATURE_CLOUD
|
#ifdef FEATURE_CLOUD
|
||||||
extern espcpputils::websocket_client cloudClient;
|
extern espcpputils::websocket_client cloudClient;
|
||||||
|
@@ -108,6 +108,8 @@ public:
|
|||||||
ConfigWrapper<int16_t> reverseBeepDuration0{500, DoReset, {}, "revBeepDur0" };
|
ConfigWrapper<int16_t> reverseBeepDuration0{500, DoReset, {}, "revBeepDur0" };
|
||||||
ConfigWrapper<int16_t> reverseBeepDuration1{500, DoReset, {}, "revBeepDur1" };
|
ConfigWrapper<int16_t> reverseBeepDuration1{500, DoReset, {}, "revBeepDur1" };
|
||||||
|
|
||||||
|
ConfigWrapper<std::string> cloudUrl {std::string{}, DoReset, StringOr<StringEmpty, StringValidUrl>, "cloudUrl" };
|
||||||
|
|
||||||
#define NEW_SETTINGS(x) \
|
#define NEW_SETTINGS(x) \
|
||||||
x(baseMacAddressOverride) \
|
x(baseMacAddressOverride) \
|
||||||
x(hostname) \
|
x(hostname) \
|
||||||
@@ -241,7 +243,9 @@ public:
|
|||||||
x(reverseBeepFreq0) \
|
x(reverseBeepFreq0) \
|
||||||
x(reverseBeepFreq1) \
|
x(reverseBeepFreq1) \
|
||||||
x(reverseBeepDuration0) \
|
x(reverseBeepDuration0) \
|
||||||
//x(reverseBeepDuration1)
|
x(reverseBeepDuration1) \
|
||||||
|
\
|
||||||
|
//x(cloudUrl)
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void callForEveryConfig(T &&callback)
|
void callForEveryConfig(T &&callback)
|
||||||
@@ -249,7 +253,7 @@ public:
|
|||||||
#define HELPER(x) callback(x);
|
#define HELPER(x) callback(x);
|
||||||
NEW_SETTINGS(HELPER)
|
NEW_SETTINGS(HELPER)
|
||||||
#undef HELPER
|
#undef HELPER
|
||||||
callback(reverseBeepDuration1);
|
callback(cloudUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto getAllConfigParams()
|
auto getAllConfigParams()
|
||||||
@@ -258,7 +262,7 @@ public:
|
|||||||
#define HELPER(x) std::ref<ConfigWrapperInterface>(x),
|
#define HELPER(x) std::ref<ConfigWrapperInterface>(x),
|
||||||
NEW_SETTINGS(HELPER)
|
NEW_SETTINGS(HELPER)
|
||||||
#undef HELPER
|
#undef HELPER
|
||||||
std::ref<ConfigWrapperInterface>(reverseBeepDuration1)
|
std::ref<ConfigWrapperInterface>(cloudUrl)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -9,9 +9,6 @@ StringSettings makeDefaultStringSettings()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
return {
|
return {
|
||||||
#ifdef FEATURE_CLOUD
|
|
||||||
.cloudUrl = {},
|
|
||||||
#endif
|
|
||||||
#ifdef FEATURE_UDPCLOUD
|
#ifdef FEATURE_UDPCLOUD
|
||||||
.udpCloudUrl = {},
|
.udpCloudUrl = {},
|
||||||
#endif
|
#endif
|
||||||
|
@@ -6,10 +6,6 @@
|
|||||||
|
|
||||||
struct StringSettings
|
struct StringSettings
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_CLOUD
|
|
||||||
std::string cloudUrl;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FEATURE_UDPCLOUD
|
#ifdef FEATURE_UDPCLOUD
|
||||||
std::string udpCloudUrl;
|
std::string udpCloudUrl;
|
||||||
#endif
|
#endif
|
||||||
@@ -53,10 +49,6 @@ struct StringSettings
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
void StringSettings::executeForEveryCommonSetting(T &&callable)
|
void StringSettings::executeForEveryCommonSetting(T &&callable)
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_CLOUD
|
|
||||||
callable("cloudUrl", cloudUrl);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FEATURE_UDPCLOUD
|
#ifdef FEATURE_UDPCLOUD
|
||||||
callable("udpUrl", udpCloudUrl);
|
callable("udpUrl", udpCloudUrl);
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user