Fixes/Enhancements for pio/preferences, new info page, add reboot button, remove old files (#451)

* Preferences

* Info page

* Info page

* Remove old files + Info page
This commit is contained in:
iranl
2024-08-12 17:53:00 +02:00
committed by GitHub
parent 21adca01e7
commit 346c5c65d1
59 changed files with 1459 additions and 1403 deletions

View File

@@ -5,16 +5,16 @@
IPConfiguration::IPConfiguration(Preferences *preferences)
: _preferences(preferences)
{
if(_preferences->getString(preference_ip_address).length() <= 0)
if(_preferences->getString(preference_ip_address, "").length() <= 0)
{
Log->println("IP address empty, falling back to DHCP.");
_preferences->putBool(preference_ip_dhcp_enabled, true);
}
_ipAddress.fromString(_preferences->getString(preference_ip_address));
_subnet.fromString(_preferences->getString(preference_ip_subnet));
_gateway.fromString(_preferences->getString(preference_ip_gateway));
_dnsServer.fromString(_preferences->getString(preference_ip_dns_server));
_ipAddress.fromString(_preferences->getString(preference_ip_address, ""));
_subnet.fromString(_preferences->getString(preference_ip_subnet, ""));
_gateway.fromString(_preferences->getString(preference_ip_gateway, ""));
_dnsServer.fromString(_preferences->getString(preference_ip_dns_server, ""));
Log->print(F("IP configuration: "));
if(dhcpEnabled())
@@ -32,7 +32,7 @@ IPConfiguration::IPConfiguration(Preferences *preferences)
bool IPConfiguration::dhcpEnabled() const
{
return _preferences->getBool(preference_ip_dhcp_enabled);
return _preferences->getBool(preference_ip_dhcp_enabled, true);
}
const IPAddress IPConfiguration::ipAddress() const

View File

@@ -197,7 +197,7 @@ void W5500Device::initializeMacAddress(byte *mac)
mac[1] = 0x08; // wiznet prefix
mac[2] = 0xDC; // wiznet prefix
if(_preferences->getBool(preference_has_mac_saved))
if(_preferences->getBool(preference_has_mac_saved, false))
{
mac[3] = _preferences->getChar(preference_has_mac_byte_0);
mac[4] = _preferences->getChar(preference_has_mac_byte_1);

View File

@@ -13,12 +13,12 @@ RTC_NOINIT_ATTR char WiFiDevice_reconfdetect[17];
WifiDevice::WifiDevice(const String& hostname, Preferences* preferences, const IPConfiguration* ipConfiguration)
: NetworkDevice(hostname, ipConfiguration),
_preferences(preferences),
_wm(preferences->getString(preference_cred_user).c_str(), preferences->getString(preference_cred_password).c_str())
_wm(preferences->getString(preference_cred_user, "").c_str(), preferences->getString(preference_cred_password, "").c_str())
{
_startAp = strcmp(WiFiDevice_reconfdetect, "reconfigure_wifi") == 0;
#ifndef NUKI_HUB_UPDATER
_restartOnDisconnect = preferences->getBool(preference_restart_on_disconnect);
_restartOnDisconnect = preferences->getBool(preference_restart_on_disconnect, false);
size_t caLength = preferences->getString(preference_mqtt_ca, _ca, TLS_CA_MAX_SIZE);
size_t crtLength = preferences->getString(preference_mqtt_crt, _cert, TLS_CERT_MAX_SIZE);
@@ -75,7 +75,7 @@ void WifiDevice::initialize()
std::vector<const char *> wm_menu;
wm_menu.push_back("wifi");
wm_menu.push_back("exit");
_wm.setEnableConfigPortal(_startAp || !_preferences->getBool(preference_network_wifi_fallback_disabled));
_wm.setEnableConfigPortal(_startAp || !_preferences->getBool(preference_network_wifi_fallback_disabled, false));
// reduced timeout if ESP is set to restart on disconnect
_wm.setFindBestRSSI(_preferences->getBool(preference_find_best_rssi));
_wm.setConnectTimeout(20);
@@ -167,14 +167,14 @@ ReconnectStatus WifiDevice::reconnect(bool force)
_isReconnecting = false;
}
if(!isConnected() && _disconnectTs > (esp_timer_get_time() / 1000) - 120000) _wm.setEnableConfigPortal(_startAp || !_preferences->getBool(preference_network_wifi_fallback_disabled));
if(!isConnected() && _disconnectTs > (esp_timer_get_time() / 1000) - 120000) _wm.setEnableConfigPortal(_startAp || !_preferences->getBool(preference_network_wifi_fallback_disabled, false));
return isConnected() ? ReconnectStatus::Success : ReconnectStatus::Failure;
}
void WifiDevice::onConnected()
{
_isReconnecting = false;
_wm.setEnableConfigPortal(_startAp || !_preferences->getBool(preference_network_wifi_fallback_disabled));
_wm.setEnableConfigPortal(_startAp || !_preferences->getBool(preference_network_wifi_fallback_disabled, false));
}
void WifiDevice::onDisconnected()