"""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.""" import requests from api import data_record_url, the_folder try: response = requests.post(data_record_url, json={ "type": "deviceHeartbeat", "deviceId": the_folder, }, timeout=timeout) response.raise_for_status() result = response.json() except Exception as exc: raise ValueError(f"设备心跳请求失败: {exc}") from exc if not result.get("success"): raise ValueError(result.get("errMsg", "设备心跳被服务端拒绝")) return result.get("lastSeenAt")