feat: RF spectrum scanner for clean frequency selection - #1
Open
wkumik wants to merge 4 commits into
Open
Conversation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JiQhEG8VApL39xVyJLXJ79
Adds a new "Scan for Clean Channel" menu item to the vehicle radio link settings. Opens a full-width spectrum bar chart showing noise floor per channel (shorter bar = less noise = cleaner, spectrum-analyser style). Router-side (rf_scan.cpp): hops through all band channels at 280 ms/ch, reads per-channel noise floor via `iw dev survey dump`, writes live results to /tmp/ruby_rf_scan_results.txt, signals completion via IPC. UI-side (menu_rf_scan.cpp): reads results file in periodicLoop, draws bar chart with colour-coding (green/yellow/red) and an annotation bubble over the cleanest channel. "Use Recommended" applies the winner via the existing sendNewRadioLinkFrequency() path. Only shown for 2.3/2.4/2.5/5.8 GHz links (not SiK/serial). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JiQhEG8VApL39xVyJLXJ79
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JiQhEG8VApL39xVyJLXJ79
Addresses review feedback on the RF spectrum scanner: 1. Safety: do not scan while flying. The scan hops the GS across the whole band, dropping video/telemetry/RC to the vehicle for several seconds. - Block opening the scan while the vehicle is armed (informational dialog). - Stop auto-starting the scan on menu open; require explicit "Start Scan". - Warn about the link interruption in the menu item description. 2. No fabricated data: the noise read returned a hard-coded -75 dBm when the card reported no survey data, silently recommending channel 0. Now an unreadable channel is marked invalid and excluded; if no channel yields data, the UI states the card does not support channel survey. 3. Better metric: replace noise floor (near-constant across a band) with the channel busy ratio (busy/active time) from `iw survey dump`. Chart now plots 0-100% busy; lower = cleaner. Recommendation = lowest busy %. 4. Remove dead RESULT packet path (no central handler existed); the UI reads the results file directly. Drops the unused IPC-to-central plumbing. 5. Abort on exit: send RF_SCAN_STOP on Cancel / Back / menu destruction so an in-progress scan restores the radio links immediately instead of running to completion after the user leaves. Also fix the apply path: MenuRFScan's id was matched with iChildMenuId/1000 (=> 140==0, never true), so "Use Recommended" never applied the frequency. Match the full child menu id instead. GS-only change (local control packets 231/232); no vehicle rebuild needed. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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
Architecture
Router side (
code/r_station/rf_scan.cpp):PACKET_TYPE_LOCAL_CONTROLLER_RF_SCAN_START(band flags invehicle_id_dest)router_periodic_loop()— one channel per tickradio_links_set_cards_frequencies_for_search()iw dev <iface> survey dump(supported by RTL8812AU, ath9k_htc)/tmp/ruby_rf_scan_results.txtas each channel completesPACKET_TYPE_LOCAL_CONTROLLER_RF_SCAN_RESULTback to central with best frequencyUI side (
code/r_central/menu/menu_rf_scan.cpp):periodicLoop()reads results file progressively — live graph updates as scan proceedsFiles changed
code/radio/local_packets.hcode/r_central/menu/menu_objects.hMENU_ID_RF_SCAN 140code/r_station/rf_scan.hcode/r_station/rf_scan.cppcode/r_station/process_local_packets.cppRF_SCAN_STARTmessagecode/r_station/periodic_loop.cpprf_scan_periodic_loop()code/r_central/menu/menu_rf_scan.hcode/r_central/menu/menu_rf_scan.cppcode/r_central/menu/menu_vehicle_radio_link.hm_IndexScanFreqmembercode/r_central/menu/menu_vehicle_radio_link.cpponReturnFromChildhandlerMakefilerf_scan.oandmenu_rf_scan.o.gitignore.claude/worktree directoryTest plan
ruby_rt_stationandruby_centralon target hardwareiw dev survey dumppopulates noise floor for RTL8812AU on 5.8 GHz🤖 Generated with Claude Code
https://claude.ai/code/session_01JiQhEG8VApL39xVyJLXJ79
Generated by Claude Code