16 lines
599 B
Python
16 lines
599 B
Python
"""Report the ReinLoop application's Server reachability for Panel status."""
|
|
|
|
|
|
def heartbeat_device(timeout=5):
|
|
"""Refresh the current device's Server heartbeat and return its timestamp."""
|
|
from api import device_post
|
|
|
|
try:
|
|
result = device_post({
|
|
"type": "deviceHeartbeat",
|
|
}, timeout=timeout)
|
|
except Exception as exc:
|
|
raise ValueError(f"设备心跳请求失败: {exc}") from exc
|
|
if not result.get("success"):
|
|
raise ValueError(result.get("errMsg", "设备心跳被服务端拒绝"))
|
|
return result.get("lastSeenAt") |