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 <noreply@anthropic.com>
pull/746/head
diffwireauto 2 months ago
parent 868d88568d
commit a65534c6fc

@ -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<RadioPreset> 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;
}
}

@ -236,6 +236,7 @@ class _RepeaterSettingsScreenState extends State<RepeaterSettingsScreen> {
bandwidthHz: _bandwidth,
spreadingFactor: _spreadingFactor,
codingRate: _codingRate,
pathHashMode: _pathHashMode,
);
@override

@ -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');
});
});
}

Loading…
Cancel
Save

Powered by TurnKey Linux.