feat(api): expose sdr_connected in /api/status#24
Merged
Conversation
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
approved these changes
Jun 15, 2026
HongNguyen635
left a comment
Contributor
There was a problem hiding this comment.
Nice, I actually encoutered this exact issue recently when using pyhubblenetwork when I thought the SDR is connected when it's not.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an
sdr_connectedboolean to theGET /api/statusresponse, derived from the existing internalstate.rx_connectedevent.Motivation
When no PlutoSDR is attached, the container still comes up: Flask serves
/api/statusand/api/packetsnormally (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'ssat scan) raising a clear "no PlutoSDR detected" error instead of silently scanning forever.Changes
app.py: addsdr_connected=state.rx_connected.is_set()to the/api/statusJSON.test_mock_sdr.py: test assertingsdr_connectedflips withrx_connected.CLAUDE.md: document the new field.Testing
SDR_TYPE=mock pytest tests/test_mock_sdr.py— 12 passed.ruff check— clean.