Import/Export config over MQTT

This commit is contained in:
iranl
2025-01-31 20:21:26 +01:00
parent 57456f42f9
commit 24bbe22e87
25 changed files with 1792 additions and 1206 deletions

View File

@@ -72,7 +72,7 @@ void EthernetDevice::initialize()
if(ethCriticalFailure)
{
ethCriticalFailure = false;
Log->println(("Failed to initialize ethernet hardware"));
Log->println("Failed to initialize ethernet hardware");
Log->println("Network device has a critical failure, enable fallback to Wi-Fi and reboot.");
wifiFallback = true;
delay(200);
@@ -80,11 +80,11 @@ void EthernetDevice::initialize()
return;
}
Log->println(("Init Ethernet"));
Log->println("Init Ethernet");
if(_useSpi)
{
Log->println(("Use SPI"));
Log->println("Use SPI");
ethCriticalFailure = true;
SPI.begin(_spi_sck, _spi_miso, _spi_mosi);
_hardwareInitialized = ETH.begin(_type, _phy_addr, _cs, _irq, _rst, SPI);
@@ -93,7 +93,7 @@ void EthernetDevice::initialize()
#ifdef CONFIG_IDF_TARGET_ESP32
else
{
Log->println(("Use RMII"));
Log->println("Use RMII");
// Workaround for failing RMII initialization with pioarduino 3.1.0
// Revoke all GPIO's some of them set by init PSRAM in IDF
@@ -118,7 +118,7 @@ void EthernetDevice::initialize()
if(_hardwareInitialized)
{
Log->println(("Ethernet hardware Initialized"));
Log->println("Ethernet hardware Initialized");
wifiFallback = false;
if(_useSpi && !_ipConfiguration->dhcpEnabled())
@@ -133,7 +133,7 @@ void EthernetDevice::initialize()
}
else
{
Log->println(("Failed to initialize ethernet hardware"));
Log->println("Failed to initialize ethernet hardware");
Log->println("Network device has a critical failure, enable fallback to Wi-Fi and reboot.");
wifiFallback = true;
delay(200);
@@ -150,7 +150,7 @@ void EthernetDevice::update()
{
if(_ipConfiguration->ipAddress() != ETH.localIP())
{
Log->println(("ETH Set static IP"));
Log->println("ETH Set static IP");
ETH.config(_ipConfiguration->ipAddress(), _ipConfiguration->defaultGateway(), _ipConfiguration->subnet(), _ipConfiguration->dnsServer());
_checkIpTs = espMillis() + 5000;
return;

View File

@@ -16,20 +16,20 @@ IPConfiguration::IPConfiguration(Preferences *preferences)
_gateway.fromString(_preferences->getString(preference_ip_gateway, ""));
_dnsServer.fromString(_preferences->getString(preference_ip_dns_server, ""));
Log->print(("IP configuration: "));
Log->print("IP configuration: ");
if(dhcpEnabled())
{
Log->println(("DHCP"));
Log->println("DHCP");
}
else
{
Log->print(("IP address: "));
Log->print("IP address: ");
Log->print(ipAddress());
Log->print((", Subnet: "));
Log->print(", Subnet: ");
Log->print(subnet());
Log->print((", Gateway: "));
Log->print(", Gateway: ");
Log->print(defaultGateway());
Log->print((", DNS: "));
Log->print(", DNS: ");
Log->println(dnsServer());
}
}

View File

@@ -32,7 +32,7 @@ void NetworkDevice::init()
if(ca_cert.length() > 1)
{
_useEncryption = true;
Log->println(("MQTT over TLS."));
Log->println("MQTT over TLS.");
_mqttClientSecure = new espMqttClientSecure(espMqttClientTypes::UseInternalTask::NO);
_mqttClientSecure->setCACert(caDest);
@@ -57,7 +57,7 @@ void NetworkDevice::init()
if(cert.length() > 1 && key.length() > 1)
{
Log->println(("MQTT with client certificate."));
Log->println("MQTT with client certificate.");
_mqttClientSecure->setCertificate(certDest);
_mqttClientSecure->setPrivateKey(keyDest);
}
@@ -69,7 +69,7 @@ void NetworkDevice::init()
if (!_useEncryption)
{
Log->println(("MQTT without TLS."));
Log->println("MQTT without TLS.");
_mqttClient = new espMqttClient(espMqttClientTypes::UseInternalTask::NO);
}
@@ -251,6 +251,11 @@ void NetworkDevice::mqttDisable()
_mqttEnabled = false;
}
bool NetworkDevice::isEncrypted()
{
return _useEncryption;
}
MqttClient *NetworkDevice::getMqttClient() const
{
if (_useEncryption)

View File

@@ -29,6 +29,7 @@ public:
virtual String BSSIDstr() = 0;
#ifndef NUKI_HUB_UPDATER
virtual bool isEncrypted();
virtual bool mqttConnect();
virtual bool mqttDisconnect(bool force);
virtual void mqttDisable();