fix: 24hr restart schedule enchanced.

Step 0: Pause polling
Step 1: Stop measurement → wait 10s
Step 2: Disable FTP → wait 10s
Step 3: Enable FTP → wait 10s
Step 4: Download data
Step 5: Wait 30s for device to settle
Step 6: Start new measurement
Step 7: Re-enable polling
This commit is contained in:
serversdwn
2026-01-31 05:15:00 +00:00
parent cc0a5bdf84
commit eb0cbcc077
2 changed files with 10 additions and 4 deletions

View File

@@ -657,8 +657,9 @@ async def stop_cycle(unit_id: str, payload: StopCyclePayload = None, db: Session
return {"status": "ok", "unit_id": unit_id, **result} return {"status": "ok", "unit_id": unit_id, **result}
except Exception as e: except Exception as e:
logger.error(f"Stop cycle failed for {unit_id}: {e}") error_msg = str(e) if str(e) else f"{type(e).__name__}: No details available"
raise HTTPException(status_code=502, detail=str(e)) logger.error(f"Stop cycle failed for {unit_id}: {error_msg}")
raise HTTPException(status_code=502, detail=error_msg)
@router.post("/{unit_id}/store") @router.post("/{unit_id}/store")

View File

@@ -1381,8 +1381,13 @@ class NL43Client:
result["stopped"] = True result["stopped"] = True
logger.info(f"[STOP-CYCLE] Measurement stopped") logger.info(f"[STOP-CYCLE] Measurement stopped")
# Step 2: Enable FTP # Step 2: Reset FTP (disable then enable) to clear any stale state
logger.info(f"[STOP-CYCLE] Step 2: Enabling FTP") 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() await self.enable_ftp()
result["ftp_enabled"] = True result["ftp_enabled"] = True
logger.info(f"[STOP-CYCLE] FTP enabled") logger.info(f"[STOP-CYCLE] FTP enabled")