mirror of
https://github.com/jkingsman/Remote-Terminal-for-MeshCore.git
synced 2026-03-28 17:43:05 +01:00
18 lines
621 B
Python
18 lines
621 B
Python
"""Shared dependencies for FastAPI routers."""
|
|
|
|
from fastapi import HTTPException
|
|
|
|
from app.radio import radio_manager
|
|
|
|
|
|
def require_connected():
|
|
"""Dependency that ensures radio is connected and returns meshcore instance.
|
|
|
|
Raises HTTPException 503 if radio is not connected.
|
|
"""
|
|
if getattr(radio_manager, "is_setup_in_progress", False) is True:
|
|
raise HTTPException(status_code=503, detail="Radio is initializing")
|
|
if not radio_manager.is_connected or radio_manager.meshcore is None:
|
|
raise HTTPException(status_code=503, detail="Radio not connected")
|
|
return radio_manager.meshcore
|