From eb0cbcc0771c1777ccab128b1c82ccc6b6ebe89d Mon Sep 17 00:00:00 2001 From: serversdwn Date: Sat, 31 Jan 2026 05:15:00 +0000 Subject: [PATCH] =?UTF-8?q?fix:=2024hr=20restart=20schedule=20enchanced.?= =?UTF-8?q?=20Step=200:=20Pause=20polling=20Step=201:=20Stop=20measurement?= =?UTF-8?q?=20=E2=86=92=20wait=2010s=20Step=202:=20Disable=20FTP=20?= =?UTF-8?q?=E2=86=92=20wait=2010s=20Step=203:=20Enable=20FTP=20=E2=86=92?= =?UTF-8?q?=20wait=2010s=20Step=204:=20Download=20data=20Step=205:=20Wait?= =?UTF-8?q?=2030s=20for=20device=20to=20settle=20Step=206:=20Start=20new?= =?UTF-8?q?=20measurement=20Step=207:=20Re-enable=20polling?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/routers.py | 5 +++-- app/services.py | 9 +++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/routers.py b/app/routers.py index a84c91a..af62fde 100644 --- a/app/routers.py +++ b/app/routers.py @@ -657,8 +657,9 @@ async def stop_cycle(unit_id: str, payload: StopCyclePayload = None, db: Session return {"status": "ok", "unit_id": unit_id, **result} except Exception as e: - logger.error(f"Stop cycle failed for {unit_id}: {e}") - raise HTTPException(status_code=502, detail=str(e)) + error_msg = str(e) if str(e) else f"{type(e).__name__}: No details available" + logger.error(f"Stop cycle failed for {unit_id}: {error_msg}") + raise HTTPException(status_code=502, detail=error_msg) @router.post("/{unit_id}/store") diff --git a/app/services.py b/app/services.py index e4268f4..f7dbc72 100644 --- a/app/services.py +++ b/app/services.py @@ -1381,8 +1381,13 @@ class NL43Client: result["stopped"] = True logger.info(f"[STOP-CYCLE] Measurement stopped") - # Step 2: Enable FTP - logger.info(f"[STOP-CYCLE] Step 2: Enabling FTP") + # Step 2: Reset FTP (disable then enable) to clear any stale state + logger.info(f"[STOP-CYCLE] Step 2: Resetting FTP (disable then enable)") + try: + await self.disable_ftp() + logger.info(f"[STOP-CYCLE] FTP disabled") + except Exception as e: + logger.warning(f"[STOP-CYCLE] FTP disable failed (may already be off): {e}") await self.enable_ftp() result["ftp_enabled"] = True logger.info(f"[STOP-CYCLE] FTP enabled")