Skip to content

Chunk 3.4: extract the TD-H3 driver into radios/tidradio_tdh3 - #13

Merged
ww8l merged 1 commit into
mainfrom
chunk-3.4-tdh3-driver
Jul 18, 2026
Merged

ww8l merged 1 commit into
mainfrom
chunk-3.4-tdh3-driver

Conversation

@ww8l

@ww8l ww8l commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

Extracts the TD-H3 protocol verbatim from commands/tdh3.rs (was 1937 lines) into a self-contained driver module, mirroring the UV-5R extraction from Chunk 3.3 (PR #7).

  • src-tauri/src/radios/tidradio_tdh3/mod.rs — ImageProgrammer half: protocol + channel encode/decode + patch_image
  • src-tauri/src/radios/tidradio_tdh3/settings.rs — SettingsProgrammer half + the codebase's first real impl SettingsProgrammer (read_settings ← decode_profile_settings, write_settings ← apply_profile_settings)
  • commands/tdh3.rs is now the thin Tauri layer (~440 lines: DB + backup paths + 5 result DTOs). All 7 command signatures are UNCHANGED, so lib.rs and the frontend are untouched (that rewiring is 3.6/3.7).
  • TidradioTdh3 registered as driver version number #2 in radios/registry.rs (advertises BOTH image + settings caps).
  • No migration — migration 0014 + seed.rs already assign driver_key='tidradio_tdh3'.
  • Shift-bit + three-power-level quirks carried over verbatim, locked by unit tests.

Checks

  • 150 lib tests pass
  • cargo check --all-targets + npm run build clean
  • clippy unchanged (only the pre-existing verbatim needless_range_loop on patch_image)

Hardware verification

Verified on the real TD-H3 (ident P31183) via throwaway #[ignore]d in-crate tests that call the exact extracted functions (removed after the pass, so the committed tree is a clean extraction):

  • identify ✓
  • download ✓ (8200 B image, 82 channels decoded)
  • program + verify ✓ — RPT600 shift −0.600 + TX Tone 100.0, GMRS19 Med power + +5.000, both confirmed off the radio's own read-back
  • settings read/write ✓ (squelch 5→3, verified)
  • each step restored the radio's original image (left exactly as found)

🤖 Generated with Claude Code

Move the TIDRADIO TD-H3 clone protocol out of commands/tdh3.rs into a
per-radio driver folder, mirroring the s54 UV-5R refactor (3.3):

  - radios/tidradio_tdh3/mod.rs — ImageProgrammer half (protocol,
    channel encode/decode, patch_image) + `TidradioTdh3` implementing
    RadioDriver + ImageProgrammer.
  - radios/tidradio_tdh3/settings.rs — SettingsProgrammer half
    (Tdh3Settings, schema-keyed profile apply/decode) + the first real
    `impl SettingsProgrammer`.
  - commands/tdh3.rs is now the thin Tauri layer (DB, backup paths,
    result DTOs). All 7 command signatures are unchanged, so lib.rs and
    the frontend need no changes (that rewiring is 3.6/3.7).

Register TidradioTdh3 as the second driver in radios/registry.rs. No
migration: 0014 + seed.rs already assign driver_key='tidradio_tdh3'.

The shift-bit encoding (shift carried only by stored TX-freq bytes) and
the three-power-level fix (High=2/Med=1/Low=0) are carried over verbatim
and locked in by unit tests.

Verified: 150 lib tests pass, cargo check --all-targets + npm build
clean, clippy unchanged. HW-verified on a real TD-H3 (ident P31183):
identify + download (82 ch) + program/verify (both quirks confirmed off
the radio's read-back) + settings read/write, each restored to the
radio's original image afterward.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@ww8l
ww8l merged commit 266b89d into main Jul 18, 2026
3 checks passed
@ww8l
ww8l deleted the chunk-3.4-tdh3-driver branch July 18, 2026 20:08
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.

1 participant