diff --git a/docker/web/nspanelmanager/data_file.bin b/docker/web/nspanelmanager/data_file.bin index 6f55e968..78d03d76 100644 Binary files a/docker/web/nspanelmanager/data_file.bin and b/docker/web/nspanelmanager/data_file.bin differ diff --git a/docker/web/nspanelmanager/firmware.bin b/docker/web/nspanelmanager/firmware.bin index 07e67d95..2feb6db8 100644 Binary files a/docker/web/nspanelmanager/firmware.bin and b/docker/web/nspanelmanager/firmware.bin differ diff --git a/docker/web/nspanelmanager/merged_flash.bin b/docker/web/nspanelmanager/merged_flash.bin index c96e329a..daa1a5a9 100644 Binary files a/docker/web/nspanelmanager/merged_flash.bin and b/docker/web/nspanelmanager/merged_flash.bin differ diff --git a/firmware/NSPanelManagerFirmware/include/nspm-bin-version.h b/firmware/NSPanelManagerFirmware/include/nspm-bin-version.h index 71c46385..edd2409a 100644 --- a/firmware/NSPanelManagerFirmware/include/nspm-bin-version.h +++ b/firmware/NSPanelManagerFirmware/include/nspm-bin-version.h @@ -1 +1 @@ -#define NSPanelManagerFirmwareVersion "0.1.150" +#define NSPanelManagerFirmwareVersion "0.1.152" diff --git a/firmware/NSPanelManagerFirmware/lib/MqttManager/MqttManager.cpp b/firmware/NSPanelManagerFirmware/lib/MqttManager/MqttManager.cpp index 4ba1074e..81fc2870 100644 --- a/firmware/NSPanelManagerFirmware/lib/MqttManager/MqttManager.cpp +++ b/firmware/NSPanelManagerFirmware/lib/MqttManager/MqttManager.cpp @@ -195,11 +195,13 @@ void MqttManager::_taskMqttRunTask(void *param) { bool MqttManager::_connect() { if (!MqttManager::_hasStarted) { + LOG_DEBUG("MQTT Manager has not yet started. Will not try to connect to MQTT Server."); return false; } // Stop processing if not connected to WiFi if (!WiFi.isConnected()) { + LOG_DEBUG("WiFi is not yet connected. Will not try to connect to MQTT Server."); return false; } @@ -228,6 +230,7 @@ bool MqttManager::_connect() { MqttManager::_mqttClient->setSocketTimeout(5); // Set tighter timeout. Default: 15 seconds. Serial.println(NSPMConfig::instance->mqtt_server.c_str()); MqttManager::_mqttClient->setServer(NSPMConfig::instance->mqtt_server.c_str(), NSPMConfig::instance->mqtt_port); + LOG_DEBUG("Will try to connect to MQTT Server '", NSPMConfig::instance->mqtt_server.c_str(), "' as user '", NSPMConfig::instance->mqtt_username.c_str(), "' with password '", NSPMConfig::instance->mqtt_password.c_str(), "'."); MqttManager::_mqttClient->connect(mqtt_device_name.c_str(), NSPMConfig::instance->mqtt_username.c_str(), NSPMConfig::instance->mqtt_password.c_str(), NSPMConfig::instance->mqtt_availability_topic.c_str(), 1, true, offline_message_buffer); vTaskDelay(1000 / portTICK_PERIOD_MS); if (MqttManager::connected()) { diff --git a/firmware/NSPanelManagerFirmware/merged-flash.bin b/firmware/NSPanelManagerFirmware/merged-flash.bin index c96e329a..daa1a5a9 100644 Binary files a/firmware/NSPanelManagerFirmware/merged-flash.bin and b/firmware/NSPanelManagerFirmware/merged-flash.bin differ diff --git a/firmware/NSPanelManagerFirmware/src/main.cpp b/firmware/NSPanelManagerFirmware/src/main.cpp index 061c8598..25bf5a24 100644 --- a/firmware/NSPanelManagerFirmware/src/main.cpp +++ b/firmware/NSPanelManagerFirmware/src/main.cpp @@ -259,24 +259,26 @@ void taskManageWifiAndMqtt(void *param) { Serial.println(config.wifi_ssid.c_str()); WiFi.begin(config.wifi_ssid.c_str(), config.wifi_psk.c_str()); vTaskDelay(2000 / portTICK_PERIOD_MS); - if (WiFi.isConnected()) { - Serial.println("Connected to WiFi!"); - LOG_INFO("Connected to WiFi ", config.wifi_ssid.c_str()); - Serial.print("Connected to WiFi "); - Serial.println(config.wifi_ssid.c_str()); - LOG_INFO("IP Address: ", WiFi.localIP().toString()); - LOG_INFO("Netmask: ", WiFi.subnetMask().toString()); - LOG_INFO("Gateway: ", WiFi.gatewayIP().toString()); - - // We successfully connected to WiFi. Init the rest of the components. - webMan.init(NSPanelManagerFirmwareVersion); - mqttManager.start(); - } else { + if (!WiFi.isConnected()) { LOG_ERROR("Failed to connect to WiFi. Will try again in 5 seconds"); Serial.println("Failed to connect to WiFi. Will try again in 5 seconds"); vTaskDelay(5000 / portTICK_PERIOD_MS); } } + + if (WiFi.isConnected()) { + Serial.println("Connected to WiFi!"); + LOG_INFO("Connected to WiFi ", config.wifi_ssid.c_str()); + Serial.print("Connected to WiFi "); + Serial.println(config.wifi_ssid.c_str()); + LOG_INFO("IP Address: ", WiFi.localIP().toString()); + LOG_INFO("Netmask: ", WiFi.subnetMask().toString()); + LOG_INFO("Gateway: ", WiFi.gatewayIP().toString()); + + // We successfully connected to WiFi. Init the rest of the components. + webMan.init(NSPanelManagerFirmwareVersion); + mqttManager.start(); + } } else if (!config.wifi_ssid.empty() && !WiFi.isConnected() && millis() - lastWiFiconnected >= 180 * 1000) { // Three minutes or more has passed since last successfull WiFi connection. Start the AP by breaking the loop. startAndManageWiFiAccessPoint();