mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-25 09:26:17 -05:00
Adding bluetooth radio toggle to Controller. Writing controller.yaml to media drive on startup, if it doesn't exist.
This commit is contained in:
parent
9e80683b9a
commit
1c55745884
13 changed files with 624 additions and 7 deletions
|
|
@ -5,6 +5,8 @@ Admin API endpoints for WROLPi Controller.
|
|||
from fastapi import APIRouter, HTTPException
|
||||
|
||||
from controller.api.schemas import (
|
||||
BluetoothActionResponse,
|
||||
BluetoothStatusResponse,
|
||||
HotspotActionResponse,
|
||||
HotspotStatusResponse,
|
||||
RestartServicesResponse,
|
||||
|
|
@ -17,10 +19,13 @@ from controller.api.schemas import (
|
|||
TimezoneStatusResponse,
|
||||
)
|
||||
from controller.lib.admin import (
|
||||
disable_bluetooth,
|
||||
disable_hotspot,
|
||||
disable_throttle,
|
||||
enable_bluetooth,
|
||||
enable_hotspot,
|
||||
enable_throttle,
|
||||
get_bluetooth_status_dict,
|
||||
get_hotspot_status_dict,
|
||||
get_throttle_status_dict,
|
||||
get_timezone_status_dict,
|
||||
|
|
@ -60,6 +65,32 @@ async def hotspot_disable() -> HotspotActionResponse:
|
|||
return HotspotActionResponse(**result)
|
||||
|
||||
|
||||
# --- Bluetooth ---
|
||||
|
||||
@router.get("/api/bluetooth/status", response_model=BluetoothStatusResponse)
|
||||
async def bluetooth_status() -> BluetoothStatusResponse:
|
||||
"""Get Bluetooth radio status."""
|
||||
return BluetoothStatusResponse(**await get_bluetooth_status_dict())
|
||||
|
||||
|
||||
@router.post("/api/bluetooth/enable", response_model=BluetoothActionResponse)
|
||||
async def bluetooth_enable() -> BluetoothActionResponse:
|
||||
"""Enable Bluetooth radio."""
|
||||
result = await enable_bluetooth()
|
||||
if not result.get("success"):
|
||||
raise HTTPException(status_code=500, detail=result.get("error", "Failed"))
|
||||
return BluetoothActionResponse(**result)
|
||||
|
||||
|
||||
@router.post("/api/bluetooth/disable", response_model=BluetoothActionResponse)
|
||||
async def bluetooth_disable() -> BluetoothActionResponse:
|
||||
"""Disable Bluetooth radio."""
|
||||
result = await disable_bluetooth()
|
||||
if not result.get("success"):
|
||||
raise HTTPException(status_code=500, detail=result.get("error", "Failed"))
|
||||
return BluetoothActionResponse(**result)
|
||||
|
||||
|
||||
# --- Throttle ---
|
||||
|
||||
@router.get("/api/throttle/status", response_model=ThrottleStatusResponse)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue