Moved dns announce related stuff into newsettings
This commit is contained in:
@@ -96,7 +96,7 @@ set(BOBBYCAR_BUILDFLAGS
|
|||||||
-DLEDSTRIP_ANIMATION_DEFAULT=0
|
-DLEDSTRIP_ANIMATION_DEFAULT=0
|
||||||
-DLEDS_PER_METER=144
|
-DLEDS_PER_METER=144
|
||||||
-DOLD_NVS
|
-DOLD_NVS
|
||||||
# -DFEATURE_DNS_NS
|
-DFEATURE_DNS_NS
|
||||||
# -DSWITCH_BLINK
|
# -DSWITCH_BLINK
|
||||||
# -DFEATURE_ESPNOW
|
# -DFEATURE_ESPNOW
|
||||||
)
|
)
|
||||||
|
@@ -10,18 +10,32 @@
|
|||||||
#include "cpputils.h"
|
#include "cpputils.h"
|
||||||
#include "lwip/dns.h"
|
#include "lwip/dns.h"
|
||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
#include "newsettings.h"
|
||||||
|
|
||||||
|
std::string dns_lastIpAddress_v4;
|
||||||
|
std::string dns_lastIpAddress_v6;
|
||||||
|
std::string dns_lastIpAddress_v6_global;
|
||||||
|
|
||||||
void init_dns_announce()
|
void init_dns_announce()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void handle_dns_announce()
|
void handle_dns_announce()
|
||||||
{
|
{
|
||||||
const auto staStatus = wifi_stack::get_sta_status();
|
if (!configs.dns_announce_enabled.value)
|
||||||
const auto randDNSName = cpputils::randomNumber<uint16_t>(espcpputils::esp_random_device{});
|
return;
|
||||||
if (staStatus == wifi_stack::WiFiStaStatus::CONNECTED)
|
|
||||||
|
if (wifi_stack::get_sta_status() != wifi_stack::WiFiStaStatus::CONNECTED)
|
||||||
{
|
{
|
||||||
|
dns_lastIpAddress_v4 = "-";
|
||||||
|
dns_lastIpAddress_v6 = "-";
|
||||||
|
dns_lastIpAddress_v6_global = "-";
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const auto randDNSName = cpputils::randomNumber<uint16_t>(espcpputils::esp_random_device{});
|
||||||
|
|
||||||
EVERY_N_SECONDS ( 2 )
|
EVERY_N_SECONDS ( 2 )
|
||||||
{
|
{
|
||||||
// Get IPv4
|
// Get IPv4
|
||||||
@@ -50,6 +64,7 @@ void handle_dns_announce()
|
|||||||
{
|
{
|
||||||
ESP_LOGW("BOBBY", "get_ip_info() failed with %.*s", result.error().size(), result.error().data());
|
ESP_LOGW("BOBBY", "get_ip_info() failed with %.*s", result.error().size(), result.error().data());
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_ip6_addr_t tmpv6addr;
|
esp_ip6_addr_t tmpv6addr;
|
||||||
if (const auto result = esp_netif_get_ip6_linklocal(wifi_stack::esp_netifs[ESP_IF_WIFI_STA], &tmpv6addr); result == ESP_OK)
|
if (const auto result = esp_netif_get_ip6_linklocal(wifi_stack::esp_netifs[ESP_IF_WIFI_STA], &tmpv6addr); result == ESP_OK)
|
||||||
{
|
{
|
||||||
@@ -98,11 +113,4 @@ void handle_dns_announce()
|
|||||||
dns_lastIpAddress_v6_global = "-";
|
dns_lastIpAddress_v6_global = "-";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
dns_lastIpAddress_v4 = "-";
|
|
||||||
dns_lastIpAddress_v6 = "-";
|
|
||||||
dns_lastIpAddress_v6_global = "-";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -1,4 +1,13 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
// system includes
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#ifdef FEATURE_DNS_NS
|
||||||
|
extern std::string dns_lastIpAddress_v4;
|
||||||
|
extern std::string dns_lastIpAddress_v6;
|
||||||
|
extern std::string dns_lastIpAddress_v6_global;
|
||||||
|
|
||||||
void init_dns_announce();
|
void init_dns_announce();
|
||||||
void handle_dns_announce();
|
void handle_dns_announce();
|
||||||
|
#endif
|
||||||
|
@@ -24,12 +24,6 @@ bool simplified =
|
|||||||
#endif
|
#endif
|
||||||
;
|
;
|
||||||
|
|
||||||
#ifdef FEATURE_DNS_NS
|
|
||||||
std::string dns_lastIpAddress_v4 = "";
|
|
||||||
std::string dns_lastIpAddress_v6 = "";
|
|
||||||
std::string dns_lastIpAddress_v6_global = "";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
Settings settings;
|
Settings settings;
|
||||||
StringSettings stringSettings;
|
StringSettings stringSettings;
|
||||||
SettingsPersister settingsPersister;
|
SettingsPersister settingsPersister;
|
||||||
|
@@ -48,12 +48,6 @@ extern bool isLocked;
|
|||||||
#include GLOBALS_PLUGIN
|
#include GLOBALS_PLUGIN
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FEATURE_DNS_NS
|
|
||||||
extern std::string dns_lastIpAddress_v4;
|
|
||||||
extern std::string dns_lastIpAddress_v6;
|
|
||||||
extern std::string dns_lastIpAddress_v6_global;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
extern bool simplified;
|
extern bool simplified;
|
||||||
|
|
||||||
extern Settings settings;
|
extern Settings settings;
|
||||||
|
@@ -111,7 +111,8 @@ public:
|
|||||||
ConfigWrapper<std::string> cloudUrl {std::string{}, DoReset, StringOr<StringEmpty, StringValidUrl>, "cloudUrl" };
|
ConfigWrapper<std::string> cloudUrl {std::string{}, DoReset, StringOr<StringEmpty, StringValidUrl>, "cloudUrl" };
|
||||||
ConfigWrapper<std::string> udpCloudHost {std::string{}, DoReset, {}, "udpCloudHost" };
|
ConfigWrapper<std::string> udpCloudHost {std::string{}, DoReset, {}, "udpCloudHost" };
|
||||||
ConfigWrapper<std::string> otaUrl {std::string{}, DoReset, StringOr<StringEmpty, StringValidUrl>, "otaUrl" };
|
ConfigWrapper<std::string> otaUrl {std::string{}, DoReset, StringOr<StringEmpty, StringValidUrl>, "otaUrl" };
|
||||||
|
ConfigWrapper<bool> dns_announce_enabled{true, DoReset, {}, "dnsAnnounceEnab" };
|
||||||
|
ConfigWrapper<std::string> dns_announce_key {std::string{}, DoReset, {}, "dnsAnnounceKey" };
|
||||||
ConfigWrapper<std::string> webserverPassword {std::string{}, DoReset, {}, "websPassword" };
|
ConfigWrapper<std::string> webserverPassword {std::string{}, DoReset, {}, "websPassword" };
|
||||||
|
|
||||||
#define NEW_SETTINGS(x) \
|
#define NEW_SETTINGS(x) \
|
||||||
@@ -252,7 +253,8 @@ public:
|
|||||||
x(cloudUrl) \
|
x(cloudUrl) \
|
||||||
x(udpCloudHost) \
|
x(udpCloudHost) \
|
||||||
x(otaUrl) \
|
x(otaUrl) \
|
||||||
\
|
x(dns_announce_enabled) \
|
||||||
|
x(dns_announce_key) \
|
||||||
// x(webserverPassword)
|
// x(webserverPassword)
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@@ -25,9 +25,6 @@ struct StringSettings
|
|||||||
std::array<ConfiguredOtaServer, 5> otaServers;
|
std::array<ConfiguredOtaServer, 5> otaServers;
|
||||||
std::string otaServerUrl;
|
std::string otaServerUrl;
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_DNS_NS
|
|
||||||
std::string dns_key;
|
|
||||||
#endif
|
|
||||||
#ifdef FEATURE_OTA
|
#ifdef FEATURE_OTA
|
||||||
std::string otaServerBranch;
|
std::string otaServerBranch;
|
||||||
#endif
|
#endif
|
||||||
@@ -64,9 +61,6 @@ void StringSettings::executeForEveryCommonSetting(T &&callable)
|
|||||||
callable("otaserver", otaServerUrl);
|
callable("otaserver", otaServerUrl);
|
||||||
callable("otaBranch", otaServerBranch);
|
callable("otaBranch", otaServerBranch);
|
||||||
#endif
|
#endif
|
||||||
#ifdef FEATURE_DNS_NS
|
|
||||||
callable("dnskey", dns_key);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
Reference in New Issue
Block a user