Skip to content

feat(api): expose sdr_connected in /api/status#24

Merged
buckleypaul merged 1 commit into
mainfrom
feat/expose-sdr-connected-status
Jun 16, 2026
Merged

feat(api): expose sdr_connected in /api/status#24
buckleypaul merged 1 commit into
mainfrom
feat/expose-sdr-connected-status

Conversation

@buckleypaul

Copy link
Copy Markdown
Contributor

Summary

Adds an sdr_connected boolean to the GET /api/status response, derived from the existing internal state.rx_connected event.

Motivation

When no PlutoSDR is attached, the container still comes up: Flask serves /api/status and /api/packets normally (empty), while the RX thread (gnuradio_rx._connect) catches the open failure and retries forever in the background ([RX] SDR not found, retrying...). Because the RX work runs in a daemon thread and Flask starts unconditionally, clients had no way to tell "no hardware plugged in" from "hardware present but quiet sky."

The hardware state was already tracked precisely via state.rx_connected — it just wasn't surfaced over the API. This exposes it.

This unblocks downstream clients (e.g. pyhubblenetwork's sat scan) raising a clear "no PlutoSDR detected" error instead of silently scanning forever.

Changes

  • app.py: add sdr_connected=state.rx_connected.is_set() to the /api/status JSON.
  • test_mock_sdr.py: test asserting sdr_connected flips with rx_connected.
  • CLAUDE.md: document the new field.

Testing

  • SDR_TYPE=mock pytest tests/test_mock_sdr.py — 12 passed.
  • ruff check — clean.

Add an sdr_connected boolean to the /api/status response, derived from
state.rx_connected, so clients can detect whether the SDR hardware is
currently open. With no Pluto attached the RX thread retries the open
forever in the background while Flask still serves the API, so callers
previously had no way to distinguish 'no hardware' from 'quiet sky'.

@HongNguyen635 HongNguyen635 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, I actually encoutered this exact issue recently when using pyhubblenetwork when I thought the SDR is connected when it's not.

@buckleypaul buckleypaul merged commit 9630c79 into main Jun 16, 2026
4 checks passed
@buckleypaul buckleypaul deleted the feat/expose-sdr-connected-status branch June 16, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants