Pi Zero 2 W + ST7789 패널에 노드 상태(누수/온습도/미세먼지·오프라인·정체)를 상시 표시하는 디스플레이 노드 신설. 배포 전 렌더 검증 원칙에 따라 합성 최악 프레임 11종을 패널 실해상도로 render_preview/ 에 PNG 로 선렌더. - st7789_driver.py · display_dashboard.py · render_preview.py(합성 프레임 생성) - install.sh · vendor.sh · systemd/display-dashboard.service · 배선(WIRING)·연결테스트 - render_preview/01~11: 요약/통합/메트릭/오프라인/stale/legacy-무PM 최악 케이스
36 lines
1.4 KiB
Python
36 lines
1.4 KiB
Python
#!/usr/bin/env python3
|
|
# =============================================================================
|
|
# test_connection.py — 표시기 → 서버 status_summary 연결 검증 (하드닝 전 필수 통과)
|
|
# 성공: 시스템 상태/센서 수 출력 후 exit 0. 실패: 원인 출력 후 exit 1.
|
|
# =============================================================================
|
|
import sys
|
|
|
|
import requests
|
|
|
|
import config
|
|
|
|
|
|
def main() -> int:
|
|
print(f"[TEST] GET {config.STATUS_URL}")
|
|
try:
|
|
r = requests.get(config.STATUS_URL,
|
|
headers={"X-Status-Key": config.STATUS_KEY,
|
|
"User-Agent": "LeakDisplay/2.0"},
|
|
timeout=config.FETCH_TIMEOUT)
|
|
except Exception as e:
|
|
print(f"[FAIL] 네트워크 오류: {e}")
|
|
return 1
|
|
if r.status_code != 200:
|
|
print(f"[FAIL] HTTP {r.status_code}: {r.text[:200]}")
|
|
if r.status_code == 403:
|
|
print(" → STATUS_KEY 불일치: php -r 'echo hash_hmac(\"sha256\",\"status\",\"<서버 API_KEY>\");' 로 재계산.")
|
|
return 1
|
|
data = r.json()
|
|
sys_ = data.get("system", {})
|
|
print(f"[OK] state={sys_.get('state')} online={sys_.get('online')}/{sys_.get('total')} "
|
|
f"sensors={len(data.get('sensors', []))} ts={data.get('ts')}")
|
|
return 0
|
|
|
|
|
|
if __name__ == "__main__":
|
|
sys.exit(main())
|