From a65534c6fcfb2dc70cac5c3b4d9352f5406bdfc6 Mon Sep 17 00:00:00 2001 From: diffwireauto <330573775+diffwireauto@users.noreply.github.com> Date: Thu, 1 Oct 2026 14:57:04 -0400 Subject: [PATCH] fix(#747): remote preset matching also checks the node's path hash mode Same gap as the companion form: a repeater on the USA values with a 1- or 2-byte path hash matched MeshCore's "Canada" (3-byte). The remote matcher now takes the node's path hash mode and applies the same rule. Epic: #733 Agent: MagentaHawk (session 5a8922d6) Co-Authored-By: Claude Opus 5.5 --- lib/helpers/remote_radio_commands.dart | 7 ++-- lib/screens/repeater_settings_screen.dart | 1 + test/helpers/remote_radio_commands_test.dart | 35 ++++++++++++++++++++ 3 files changed, 41 insertions(+), 2 deletions(-) diff --git a/lib/helpers/remote_radio_commands.dart b/lib/helpers/remote_radio_commands.dart index bd929536..06059e2e 100644 --- a/lib/helpers/remote_radio_commands.dart +++ b/lib/helpers/remote_radio_commands.dart @@ -71,13 +71,15 @@ bool sendsPresetPathHash({ /// The preset whose radio values match the form's, or null for custom values. /// The form holds frequency as text (the repeater reports e.g. "908.205017"), /// so frequency matches to the nearest kHz. TX power is not compared: the -/// remote screen sets it separately. +/// remote screen sets it separately. A preset with a path hash only matches +/// a node on that mode (#747): MeshCore's "Canada" and "USA" differ only there. String? matchRemotePresetId( List presets, { required String frequencyText, required int? bandwidthHz, required int? spreadingFactor, required int? codingRate, + required int pathHashMode, }) { final mhz = double.tryParse(frequencyText.trim()); if (mhz == null || @@ -91,7 +93,8 @@ String? matchRemotePresetId( if (p.frequencyKHz == khz && p.bandwidth.hz == bandwidthHz && p.spreadingFactor.value == spreadingFactor && - p.codingRate.value == codingRate) { + p.codingRate.value == codingRate && + presetPathHashMatches(p, pathHashMode + 1)) { return p.id; } } diff --git a/lib/screens/repeater_settings_screen.dart b/lib/screens/repeater_settings_screen.dart index c7bd901f..f1a87478 100644 --- a/lib/screens/repeater_settings_screen.dart +++ b/lib/screens/repeater_settings_screen.dart @@ -236,6 +236,7 @@ class _RepeaterSettingsScreenState extends State { bandwidthHz: _bandwidth, spreadingFactor: _spreadingFactor, codingRate: _codingRate, + pathHashMode: _pathHashMode, ); @override diff --git a/test/helpers/remote_radio_commands_test.dart b/test/helpers/remote_radio_commands_test.dart index 8204b204..5271f2b0 100644 --- a/test/helpers/remote_radio_commands_test.dart +++ b/test/helpers/remote_radio_commands_test.dart @@ -147,6 +147,7 @@ void main() { bandwidthHz: 62500, spreadingFactor: 9, codingRate: 8, + pathHashMode: 0, ), 'arizona', ); @@ -157,6 +158,7 @@ void main() { bandwidthHz: 500000, spreadingFactor: 10, codingRate: 5, + pathHashMode: 0, ), 'oki', ); @@ -170,6 +172,7 @@ void main() { bandwidthHz: 62500, spreadingFactor: 9, codingRate: 5, + pathHashMode: 0, ), isNull, ); @@ -180,6 +183,7 @@ void main() { bandwidthHz: 62500, spreadingFactor: 9, codingRate: 8, + pathHashMode: 0, ), isNull, ); @@ -193,6 +197,7 @@ void main() { bandwidthHz: 62500, spreadingFactor: 9, codingRate: 8, + pathHashMode: 0, ), isNull, ); @@ -203,9 +208,39 @@ void main() { bandwidthHz: null, spreadingFactor: 9, codingRate: 8, + pathHashMode: 0, ), isNull, ); }); + + test('a path hash preset only matches a node on that mode (#747)', () { + final usaPair = [ + preset( + 'canada', + mhz: 910.525, + sf: LoRaSpreadingFactor.sf7, + cr: LoRaCodingRate.cr4_5, + hashBytes: 3, + ), + preset( + 'usa', + mhz: 910.525, + sf: LoRaSpreadingFactor.sf7, + cr: LoRaCodingRate.cr4_5, + ), + ]; + String? match(int mode) => matchRemotePresetId( + usaPair, + frequencyText: '910.525', + bandwidthHz: 62500, + spreadingFactor: 7, + codingRate: 5, + pathHashMode: mode, + ); + expect(match(0), 'usa'); + expect(match(1), 'usa'); + expect(match(2), 'canada'); + }); }); }