Skip to content

fix(xvtr): use status index not order for Flex band-stack key (#2342)#2511

Merged
ten9876 merged 1 commit into
mainfrom
issue/2342-xvtr-band-buttons
May 9, 2026
Merged

fix(xvtr): use status index not order for Flex band-stack key (#2342)#2511
ten9876 merged 1 commit into
mainfrom
issue/2342-xvtr-band-buttons

Conversation

@jensenpat

Copy link
Copy Markdown
Collaborator

Fixes #2342

Root cause

XvtrPolicy::resolveBandStackKey was returning X<order> for XVTR band buttons, but the Flex radio expects X<index> — where index is the 0-based number from xvtr <n> status messages. The radio's order field is 1-based (SmartSDR labels them "Transverter 1, 2, 3"), so every button was shifted by +1:

Button index order Was sending Radio tuned to
144 MHz 0 1 band=X1 432 MHz ❌
432 MHz 1 2 band=X2 70 MHz ❌
70 MHz 2 3 band=X3 (no match) ❌

This regression was introduced in PR #1887 which swapped the pcap-verified X<index> (from PR #1615) for X<order> without new pcap evidence.

Changes

  • src/models/XvtrPolicy.cpp — revert xvtr.orderxvtr.index; drop the now-unnecessary order < 0 guard
  • src/gui/MainWindow.cpp — update the maintainer comment to reflect X<index>
  • tests/xvtr_policy_test.cpp — update assertions to X<index> values; rename test; update the "missing order" case (order is now irrelevant for key resolution)

Test plan

  • ./build/xvtr_policy_test — all 21 tests pass ✅
  • On radio: XVTR band buttons select the correct band (144 MHz button → 144 MHz, etc.)

🤖 Generated with Claude Code

Flex's `display pan set band=X<n>` expects the xvtr status-object index
(the number from `xvtr <n>` messages, 0-based), not the radio's 1-based
`order` field.  Using `order` produced a +1 shift: pressing the 144 MHz
button sent `band=X1` instead of `band=X0`, tuning to 432 MHz instead.

Reverts the index→order swap from PR #1887 back to the pcap-verified
`X<index>` form from PR #1615.  Updates the test assertions and renames
the test function to reflect the correct semantics.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

@aethersdr-agent aethersdr-agent Bot 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.

Thanks @jensenpat — the fix is correct and well-scoped.

I traced the data flow to confirm the change is safe:

  • Transverter::index is populated from the integer key in xvtr <n> status messages (RadioModel.cpp:2963x.index = idx;), so it's always a non-negative value once the entry exists. Dropping the order < 0 guard is therefore fine — index doesn't need a sentinel-missing check the way the optional order field did.
  • The PR description's pcap reference (PR #1615 vs the #1887 regression) matches what the radio's wire protocol actually expects, and the user-visible symptom table (button N tunes band N+1) follows directly from the off-by-one between 0-based index and 1-based order.
  • The test rename + updated assertions (X12/X4/X1 for the new fixture) and the rewritten "missing order" case correctly reflect that order is no longer load-bearing for key resolution.
  • The MainWindow.cpp comment update is the only other touch and stays in the same maintainer block — scope is tight.

No conventions, RAII, or boundary-handling concerns. Nice clean revert with tests pinning the contract.

@ten9876 ten9876 merged commit e653aed into main May 9, 2026
5 checks passed
@ten9876 ten9876 deleted the issue/2342-xvtr-band-buttons branch May 9, 2026 20:04
@ten9876

ten9876 commented May 9, 2026

Copy link
Copy Markdown
Collaborator

Claude here — thank you @jensenpat, this is a clean revert of an off-by-one regression with great forensics in the PR body. The index/order table makes the bug obvious at a glance, and dropping the now-redundant order < 0 guard is exactly the right cleanup. All 21 existing XVTR policy tests updated correctly, real-hardware verified. Merged and shipping in the next release; credit will land in the release notes.

73, Jeremy KK7GWY & Claude (AI dev partner)

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.

Transverter

2 participants