Added FCC Check API calls - #35
hunterhubble wants to merge 2 commits into
Conversation
- No new tests were designed here - Add API Call to see if current tone is FCC compliant with spurious emissions and the occupied bandwidth. - Previously, this was only visual in the spectrum analyzer view. - Returns dict with pass/fail, carrier wave stats (frequence, power, snr, offset), and test stats of occupied bandwidth and spurious emissions tests Signed-off-by: hunterhubble <hunter@hubble.com>
1fa6959 to
167dad4
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The new API response reports an incorrect DC-notch span value and the new endpoint lacks test coverage in a codebase that already tests Flask routes.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR adds a machine-readable FCC 15.247 compliance check endpoint and refactors the spectrum-analyzer overlay logic so both the UI overlay and the new API share a single measurement implementation.
Changes:
- Introduces
evaluate_fcc_compliance()to compute occupied-bandwidth and spur checks (no plotting/I/O). - Refactors spectrum averaging/peak-hold computation into
spectrum_traces()and reuses it in both rendering and the API. - Adds
GET /api/fcc_checkto capture fresh IQ, compute a spectrum window, and return pass/fail/no-signal results as JSON.
File summaries
| File | Description |
|---|---|
| src/stream_web/spectrogram.py | Extracts spectrum trace reduction and FCC compliance evaluation into reusable helpers; updates overlay rendering to consume computed results. |
| src/stream_web/app.py | Adds /api/fcc_check endpoint that captures IQ and returns FCC compliance verdict/details using the shared measurement helpers. |
Review details
- Files reviewed: 2/2 changed files
- Comments generated: 3
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
- Added tests to generate artificial signals and verify if they pass/fai - Testing clean tones, noise only, wide band tone, nearby spurs, and dict formatting Signed-off-by: hunterhubble <hunter@hubble.com>
| return resp | ||
|
|
||
|
|
||
| _FCC_CHECK_DEFAULT_SECONDS = int(config.SPECTRUM_AVG_CHUNKS * config.SPEC_CHUNK_S) |
There was a problem hiding this comment.
usually constants are placed together for easy readable (at the top of a class for per class constants and top of file for per module constants). Not a big deal in this commit because constants in this file are all over the place, but imo it would make it a bit challenging for new people to pick up the file and have to hunt for the constants.
| SR = config.SAMPLE_RATE | ||
| # Arbitrary test LO -- evaluate_fcc_compliance only cares about frequencies | ||
| # relative to it, so this doesn't need to match any real config default. | ||
| _TEST_LO_HZ = 903_000_000.0 |
There was a problem hiding this comment.
agree that it is arbitrary, but it'd be nice to put the LO close to the one our sat signal is at 🙂
| # Frequency axis: bins run -fs/2 .. +fs/2 (ascending), centred on the LO. | ||
| fs = config.SAMPLE_RATE | ||
| freqs_mhz = (np.linspace(-fs / 2.0, fs / 2.0, n_bins) + lo_freq_hz) / 1e6 | ||
| freqs_hz = np.linspace(-fs / 2.0, fs / 2.0, n_bins) + lo_freq_hz |
There was a problem hiding this comment.
if I understand linspace correctly, this will produced freq_hz = fs/(n_bins-1), while what we want is fs/(n_bins). Can you double check this please?
No description provided.