From 848b7e48fd5d9c0046793f233ecee6316262113a Mon Sep 17 00:00:00 2001 From: Christian Muehlhaeuser Date: Thu, 18 Dec 2025 00:19:03 +0100 Subject: [PATCH] fix: pause snapshots while a stream is active --- ESP32_PrusaConnectCam/system.cpp | 41 +++++++++++++++++++------------- 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/ESP32_PrusaConnectCam/system.cpp b/ESP32_PrusaConnectCam/system.cpp index 9a82c13..e12ddd5 100644 --- a/ESP32_PrusaConnectCam/system.cpp +++ b/ESP32_PrusaConnectCam/system.cpp @@ -505,25 +505,32 @@ void System_TaskCaptureAndSendPhoto(void *pvParameters) { TickType_t xLastWakeTime = xTaskGetTickCount(); while (1) { - if (Connect.CheckSendingIntervalExpired()) { - Connect.SetSendingIntervalCounter(0); - /* send network information to backend */ - if ((WL_CONNECTED == WiFi.status()) && (false == FirmwareUpdate.Processing)) { - SystemLog.AddEvent(LogLevel_Verbose, F("Task photo processing. Start sending info")); - esp_task_wdt_reset(); - Connect.SendInfoToBackend(); - } - - /* send photo to backend*/ - if ((WL_CONNECTED == WiFi.status()) && (false == FirmwareUpdate.Processing)) { - SystemLog.AddEvent(LogLevel_Verbose, F("Task photo processing. Start sending photo")); - esp_task_wdt_reset(); - Connect.TakePictureAndSendToBackend(); - } + /* Pause periodic snapshots while MJPG stream is active */ + if (SystemCamera.GetStreamStatus()) { + SystemLog.AddEvent(LogLevel_Verbose, F("Photo processing task: stream active, pausing periodic snapshots")); + /* do not increase the sending interval counter while streaming */ } else { - /* update counter */ - Connect.IncreaseSendingIntervalCounter(); + if (Connect.CheckSendingIntervalExpired()) { + Connect.SetSendingIntervalCounter(0); + /* send network information to backend */ + if ((WL_CONNECTED == WiFi.status()) && (false == FirmwareUpdate.Processing)) { + SystemLog.AddEvent(LogLevel_Verbose, F("Task photo processing. Start sending info")); + esp_task_wdt_reset(); + Connect.SendInfoToBackend(); + } + + /* send photo to backend*/ + if ((WL_CONNECTED == WiFi.status()) && (false == FirmwareUpdate.Processing)) { + SystemLog.AddEvent(LogLevel_Verbose, F("Task photo processing. Start sending photo")); + esp_task_wdt_reset(); + Connect.TakePictureAndSendToBackend(); + } + + } else { + /* update counter */ + Connect.IncreaseSendingIntervalCounter(); + } } SystemLog.AddEvent(LogLevel_Verbose, F("Photo processing task. Stack free size: "), String(uxTaskGetStackHighWaterMark(NULL)) + "B");