send mqtt hearbeat as soon as we have a wifi connection

This commit is contained in:
proddy
2020-07-21 14:31:17 +02:00
parent 915f961828
commit a923236ecd

View File

@@ -28,25 +28,23 @@ EMSESPStatusService::EMSESPStatusService(AsyncWebServer * server, SecurityManage
void EMSESPStatusService::onStationModeConnected(WiFiEvent_t event, WiFiEventInfo_t info) { void EMSESPStatusService::onStationModeConnected(WiFiEvent_t event, WiFiEventInfo_t info) {
EMSESP::logger().debug(F("Wifi Connected")); EMSESP::logger().debug(F("Wifi Connected"));
} }
void EMSESPStatusService::onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) { void EMSESPStatusService::onStationModeDisconnected(WiFiEvent_t event, WiFiEventInfo_t info) {
EMSESP::logger().debug(F("WiFi Disconnected. Reason code=%d"), info.disconnected.reason); EMSESP::logger().debug(F("WiFi Disconnected. Reason code=%d"), info.disconnected.reason);
} }
void EMSESPStatusService::onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info) { void EMSESPStatusService::onStationModeGotIP(WiFiEvent_t event, WiFiEventInfo_t info) {
EMSESP::logger().debug(F("WiFi connected with IP=%s, hostname=%s"), WiFi.localIP().toString().c_str(), WiFi.getHostname()); EMSESP::logger().debug(F("WiFi connected with IP=%s, hostname=%s"), WiFi.localIP().toString().c_str(), WiFi.getHostname());
EMSESP::system_.send_heartbeat(); // send out heartbeat MQTT as soon as we have a connection
} }
#elif defined(ESP8266) #elif defined(ESP8266)
void EMSESPStatusService::onStationModeConnected(const WiFiEventStationModeConnected & event) { void EMSESPStatusService::onStationModeConnected(const WiFiEventStationModeConnected & event) {
EMSESP::logger().debug(F("Wifi connected with SSID %s"), event.ssid.c_str()); EMSESP::logger().debug(F("Wifi connected with SSID %s"), event.ssid.c_str());
} }
void EMSESPStatusService::onStationModeDisconnected(const WiFiEventStationModeDisconnected & event) { void EMSESPStatusService::onStationModeDisconnected(const WiFiEventStationModeDisconnected & event) {
EMSESP::logger().debug(F("WiFi Disconnected. Reason code=%d"), event.reason); EMSESP::logger().debug(F("WiFi Disconnected. Reason code=%d"), event.reason);
} }
void EMSESPStatusService::onStationModeGotIP(const WiFiEventStationModeGotIP & event) { void EMSESPStatusService::onStationModeGotIP(const WiFiEventStationModeGotIP & event) {
EMSESP::logger().debug(F("WiFi connected with IP=%s, hostname=%s"), event.ip.toString().c_str(), WiFi.hostname().c_str()); EMSESP::logger().debug(F("WiFi connected with IP=%s, hostname=%s"), event.ip.toString().c_str(), WiFi.hostname().c_str());
EMSESP::system_.send_heartbeat(); // send out heartbeat MQTT as soon as we have a connection
} }
#endif #endif