mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-06 07:49:52 +03:00
network/mqtt init fix #42
This commit is contained in:
@@ -101,17 +101,10 @@ void MqttSettingsService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
|||||||
switch (event) {
|
switch (event) {
|
||||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
|
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
|
||||||
case ARDUINO_EVENT_ETH_GOT_IP:
|
case ARDUINO_EVENT_ETH_GOT_IP:
|
||||||
emsesp::EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) {
|
|
||||||
if (!networkSettings.enableIPv6 && _state.enabled) {
|
|
||||||
// emsesp::EMSESP::logger().info(F("IPv4 Network connection found, starting MQTT client"));
|
|
||||||
onConfigUpdated();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
case ARDUINO_EVENT_ETH_GOT_IP6:
|
case ARDUINO_EVENT_ETH_GOT_IP6:
|
||||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
|
case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
|
||||||
if (_state.enabled) {
|
if (_state.enabled) {
|
||||||
// emsesp::EMSESP::logger().info(F("IPv6 Network connection found, starting MQTT client"));
|
// emsesp::EMSESP::logger().info(F("Network connection found, starting MQTT client"));
|
||||||
onConfigUpdated();
|
onConfigUpdated();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -42,12 +42,8 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
|||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
EMSESP::logger().info(F("WiFi connected with IP=%s, hostname=%s"), WiFi.localIP().toString().c_str(), WiFi.getHostname());
|
EMSESP::logger().info(F("WiFi connected with IP=%s, hostname=%s"), WiFi.localIP().toString().c_str(), WiFi.getHostname());
|
||||||
#endif
|
#endif
|
||||||
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) {
|
// EMSESP::system_.send_heartbeat(); // send from mqtt start
|
||||||
if (!networkSettings.enableIPv6) {
|
|
||||||
EMSESP::system_.send_heartbeat();
|
|
||||||
EMSESP::system_.syslog_init();
|
EMSESP::system_.syslog_init();
|
||||||
}
|
|
||||||
});
|
|
||||||
mDNS_start();
|
mDNS_start();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -70,12 +66,8 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
|||||||
#ifndef EMSESP_STANDALONE
|
#ifndef EMSESP_STANDALONE
|
||||||
EMSESP::logger().info(F("Ethernet connected with IP=%s, speed %d Mbps"), ETH.localIP().toString().c_str(), ETH.linkSpeed());
|
EMSESP::logger().info(F("Ethernet connected with IP=%s, speed %d Mbps"), ETH.localIP().toString().c_str(), ETH.linkSpeed());
|
||||||
#endif
|
#endif
|
||||||
EMSESP::esp8266React.getNetworkSettingsService()->read([&](NetworkSettings & networkSettings) {
|
// EMSESP::system_.send_heartbeat(); // send from mqtt start
|
||||||
if (!networkSettings.enableIPv6) {
|
|
||||||
EMSESP::system_.send_heartbeat();
|
|
||||||
EMSESP::system_.syslog_init();
|
EMSESP::system_.syslog_init();
|
||||||
}
|
|
||||||
});
|
|
||||||
EMSESP::system_.ethernet_connected(true);
|
EMSESP::system_.ethernet_connected(true);
|
||||||
mDNS_start();
|
mDNS_start();
|
||||||
}
|
}
|
||||||
@@ -111,11 +103,11 @@ void WebStatusService::WiFiEvent(WiFiEvent_t event, WiFiEventInfo_t info) {
|
|||||||
case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
|
case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
|
||||||
case ARDUINO_EVENT_ETH_GOT_IP6:
|
case ARDUINO_EVENT_ETH_GOT_IP6:
|
||||||
if (EMSESP::system_.ethernet_connected()) {
|
if (EMSESP::system_.ethernet_connected()) {
|
||||||
EMSESP::logger().info(F("Ethernet connected with IP=%s, speed %d Mbps"), ETH.localIPv6().toString().c_str(), ETH.linkSpeed());
|
EMSESP::logger().info(F("Ethernet connected with IPv6=%s, speed %d Mbps"), ETH.localIPv6().toString().c_str(), ETH.linkSpeed());
|
||||||
} else {
|
} else {
|
||||||
EMSESP::logger().info(F("WiFi connected with IP=%s, hostname=%s"), WiFi.localIPv6().toString().c_str(), WiFi.getHostname());
|
EMSESP::logger().info(F("WiFi connected with IPv6=%s, hostname=%s"), WiFi.localIPv6().toString().c_str(), WiFi.getHostname());
|
||||||
}
|
}
|
||||||
EMSESP::system_.send_heartbeat();
|
// EMSESP::system_.send_heartbeat(); // send from mqtt start
|
||||||
EMSESP::system_.syslog_init();
|
EMSESP::system_.syslog_init();
|
||||||
mDNS_start();
|
mDNS_start();
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user