From c161bffc837adcc12dc38fda8dc6b241f47eddf5 Mon Sep 17 00:00:00 2001 From: shortwavesurfer2009 Date: Mon, 5 Oct 2026 19:19:08 -0400 Subject: [PATCH] fold path hash size into radio settings --- lib/models/radio_settings.dart | 2 ++ lib/screens/settings_screen.dart | 38 ++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/lib/models/radio_settings.dart b/lib/models/radio_settings.dart index f7c4709c..6b3eee84 100644 --- a/lib/models/radio_settings.dart +++ b/lib/models/radio_settings.dart @@ -50,6 +50,7 @@ class RadioSettings { final LoRaSpreadingFactor spreadingFactor; final LoRaCodingRate codingRate; final int txPowerDbm; + final int pathHashByteWidth; RadioSettings({ required this.frequencyMHz, @@ -57,6 +58,7 @@ class RadioSettings { required this.spreadingFactor, required this.codingRate, required this.txPowerDbm, + this.pathHashByteWidth = 1, // app default; presets override if needed }); // Regional preset configurations diff --git a/lib/screens/settings_screen.dart b/lib/screens/settings_screen.dart index 502e0f18..c94e23f2 100644 --- a/lib/screens/settings_screen.dart +++ b/lib/screens/settings_screen.dart @@ -1526,10 +1526,14 @@ class _RadioSettingsDialogState extends State<_RadioSettingsDialog> { LoRaCodingRate _codingRate = LoRaCodingRate.cr4_5; final _txPowerController = TextEditingController(text: '20'); bool _clientRepeat = false; + int _pathHashByteWidth = 1; int? _selectedPresetIndex; _RadioSettingsSnapshot? _lastNonRepeatSnapshot; String? _frequencyError; String? _txPowerError; + bool get _supportsPathHashMode => + (widget.connector.firmwareVerCode ?? 0) >= + _minFirmwareVerCodeForPathHashMode; AppDebugLogService get _appLog => Provider.of(context, listen: false); @@ -1583,6 +1587,7 @@ class _RadioSettingsDialogState extends State<_RadioSettingsDialog> { _txPowerController.text = widget.connector.currentTxPower.toString(); } + _pathHashByteWidth = widget.connector.pathHashByteWidth; _clientRepeat = widget.connector.clientRepeat ?? false; _selectedPresetIndex = _findMatchingPresetIndex(); if (_clientRepeat) { @@ -1752,6 +1757,7 @@ class _RadioSettingsDialogState extends State<_RadioSettingsDialog> { _spreadingFactor = preset.spreadingFactor; _codingRate = preset.codingRate; _txPowerController.text = preset.txPowerDbm.toString(); + _pathHashByteWidth = preset.pathHashByteWidth; _selectedPresetIndex = index; _lastNonRepeatSnapshot = baseSnapshot; } @@ -1911,6 +1917,10 @@ class _RadioSettingsDialogState extends State<_RadioSettingsDialog> { return; } await widget.connector.sendFrame(buildSetRadioTxPowerFrame(txPower)); + if (_supportsPathHashMode && + _pathHashByteWidth != widget.connector.pathHashByteWidth) { + await widget.connector.setPathHashMode(_pathHashByteWidth - 1); + } final selfInfo = widget.connector.receivedFrames .firstWhere((f) => f.isNotEmpty && f[0] == respCodeSelfInfo) .timeout(const Duration(seconds: 5)); @@ -2144,6 +2154,34 @@ class _RadioSettingsDialogState extends State<_RadioSettingsDialog> { }, ), const SizedBox(height: 16), + if (_supportsPathHashMode) ...[ + DropdownButtonFormField( + initialValue: _pathHashByteWidth, + decoration: InputDecoration( + labelText: l10n.repeater_pathHashMode, + border: const OutlineInputBorder(), + ), + items: [ + DropdownMenuItem( + value: 1, + child: Text(l10n.repeater_pathHashModeOption0), + ), + DropdownMenuItem( + value: 2, + child: Text(l10n.repeater_pathHashModeOption1), + ), + DropdownMenuItem( + value: 3, + child: Text(l10n.repeater_pathHashModeOption2), + ), + ], + onChanged: (value) { + if (value == null) return; + setState(() => _pathHashByteWidth = value); + }, + ), + const SizedBox(height: 16), + ], TextField( controller: _txPowerController, onChanged: (_) => _handleManualSettingsChanged('tx power'),