Add LNB polarity toggle (V-pol 13V / H-pol 18V)

Bridge: set_lnb_voltage(mode) wraps firmware lnbdc command, enable_lna()
now delegates to it. MCP: new set_lnb_voltage tool + 3 tests. TUI: Signal
screen button toggles between V-pol and H-pol instead of one-way LNA enable.
This commit is contained in:
Ryan Malloy 2026-02-17 17:24:05 -07:00
parent 8a6b99bd8c
commit f8bfd69ceb
5 changed files with 123 additions and 19 deletions

View file

@ -55,14 +55,42 @@ def register(mcp):
async def enable_lna(ctx: Context) -> dict:
"""Enable the LNA by setting LNB voltage to 13V (V-pol).
This powers the low-noise amplifier in the dish's outdoor unit.
Boot default is 18V (H-pol). Required before meaningful RSSI
readings when used for radio astronomy.
Shortcut for set_lnb_voltage(mode='odu'). Use set_lnb_voltage
to switch back to 18V (H-pol) when done.
"""
state: BirdcageState = ctx.request_context.lifespan_context
_require_device(state)
state.device.enable_lna()
return {"status": "lna_enabled", "voltage": "13V"}
return {"status": "lna_enabled", "voltage": "13V", "polarity": "V"}
@mcp.tool()
async def set_lnb_voltage(ctx: Context, mode: str) -> dict:
"""Set LNB DC voltage and polarization.
Controls the LNB bias voltage on the coax feed line. This
determines both LNA power state and receive polarization:
- 'odu' = 13V (V-pol, LNA enabled) for radio astronomy / ham
- 'stb' = 18V (H-pol, boot default) standard consumer mode
V-pol and H-pol see different transponders. The PEAK submenu's
'rssits' command alternates between them for comparison.
Args:
mode: 'odu' for 13V/V-pol or 'stb' for 18V/H-pol.
"""
state: BirdcageState = ctx.request_context.lifespan_context
_require_device(state)
raw = state.device.set_lnb_voltage(mode)
voltage = "13V" if mode.lower() == "odu" else "18V"
polarity = "V" if mode.lower() == "odu" else "H"
return {
"status": "set",
"mode": mode.lower(),
"voltage": voltage,
"polarity": polarity,
"raw": raw,
}
@mcp.tool()
async def get_dvb_config(ctx: Context) -> dict:

View file

@ -3,6 +3,7 @@
import pytest
from conftest import parse_result
from fastmcp import Client
from fastmcp.exceptions import ToolError
@pytest.mark.anyio
@ -42,6 +43,37 @@ async def test_enable_lna(mcp_client: Client):
data = parse_result(result)
assert data["status"] == "lna_enabled"
assert data["voltage"] == "13V"
assert data["polarity"] == "V"
@pytest.mark.anyio
async def test_set_lnb_voltage_odu(mcp_client: Client):
result = await mcp_client.call_tool(
"set_lnb_voltage", {"mode": "odu"}
)
data = parse_result(result)
assert data["voltage"] == "13V"
assert data["polarity"] == "V"
assert data["mode"] == "odu"
@pytest.mark.anyio
async def test_set_lnb_voltage_stb(mcp_client: Client):
result = await mcp_client.call_tool(
"set_lnb_voltage", {"mode": "stb"}
)
data = parse_result(result)
assert data["voltage"] == "18V"
assert data["polarity"] == "H"
assert data["mode"] == "stb"
@pytest.mark.anyio
async def test_set_lnb_voltage_invalid(mcp_client: Client):
with pytest.raises(ToolError):
await mcp_client.call_tool(
"set_lnb_voltage", {"mode": "invalid"}
)
@pytest.mark.anyio