fold path hash size into radio settings

This commit is contained in:
shortwavesurfer2009 committed 2026-10-05 19:19:08 -04:00
1 parent 9334d556fe
commit c161bffc83
2 files changed
+40

No files matched your search

+2
View File
@@ -50,6 +50,7 @@ class RadioSettings {
final LoRaSpreadingFactor spreadingFactor; final LoRaSpreadingFactor spreadingFactor;
final LoRaCodingRate codingRate; final LoRaCodingRate codingRate;
final int txPowerDbm; final int txPowerDbm;
final int pathHashByteWidth;
RadioSettings({ RadioSettings({
required this.frequencyMHz, required this.frequencyMHz,
@@ -57,6 +58,7 @@ class RadioSettings {
required this.spreadingFactor, required this.spreadingFactor,
required this.codingRate, required this.codingRate,
required this.txPowerDbm, required this.txPowerDbm,
this.pathHashByteWidth = 1, // app default; presets override if needed
}); });
// Regional preset configurations // Regional preset configurations
+38
View File
@@ -1526,10 +1526,14 @@ class _RadioSettingsDialogState extends State<_RadioSettingsDialog> {
LoRaCodingRate _codingRate = LoRaCodingRate.cr4_5; LoRaCodingRate _codingRate = LoRaCodingRate.cr4_5;
final _txPowerController = TextEditingController(text: '20'); final _txPowerController = TextEditingController(text: '20');
bool _clientRepeat = false; bool _clientRepeat = false;
int _pathHashByteWidth = 1;
int? _selectedPresetIndex; int? _selectedPresetIndex;
_RadioSettingsSnapshot? _lastNonRepeatSnapshot; _RadioSettingsSnapshot? _lastNonRepeatSnapshot;
String? _frequencyError; String? _frequencyError;
String? _txPowerError; String? _txPowerError;
bool get _supportsPathHashMode =>
(widget.connector.firmwareVerCode ?? 0) >=
_minFirmwareVerCodeForPathHashMode;
AppDebugLogService get _appLog => AppDebugLogService get _appLog =>
Provider.of<AppDebugLogService>(context, listen: false); Provider.of<AppDebugLogService>(context, listen: false);
@@ -1583,6 +1587,7 @@ class _RadioSettingsDialogState extends State<_RadioSettingsDialog> {
_txPowerController.text = widget.connector.currentTxPower.toString(); _txPowerController.text = widget.connector.currentTxPower.toString();
} }
_pathHashByteWidth = widget.connector.pathHashByteWidth;
_clientRepeat = widget.connector.clientRepeat ?? false; _clientRepeat = widget.connector.clientRepeat ?? false;
_selectedPresetIndex = _findMatchingPresetIndex(); _selectedPresetIndex = _findMatchingPresetIndex();
if (_clientRepeat) { if (_clientRepeat) {
@@ -1752,6 +1757,7 @@ class _RadioSettingsDialogState extends State<_RadioSettingsDialog> {
_spreadingFactor = preset.spreadingFactor; _spreadingFactor = preset.spreadingFactor;
_codingRate = preset.codingRate; _codingRate = preset.codingRate;
_txPowerController.text = preset.txPowerDbm.toString(); _txPowerController.text = preset.txPowerDbm.toString();
_pathHashByteWidth = preset.pathHashByteWidth;
_selectedPresetIndex = index; _selectedPresetIndex = index;
_lastNonRepeatSnapshot = baseSnapshot; _lastNonRepeatSnapshot = baseSnapshot;
} }
@@ -1911,6 +1917,10 @@ class _RadioSettingsDialogState extends State<_RadioSettingsDialog> {
return; return;
} }
await widget.connector.sendFrame(buildSetRadioTxPowerFrame(txPower)); await widget.connector.sendFrame(buildSetRadioTxPowerFrame(txPower));
if (_supportsPathHashMode &&
_pathHashByteWidth != widget.connector.pathHashByteWidth) {
await widget.connector.setPathHashMode(_pathHashByteWidth - 1);
}
final selfInfo = widget.connector.receivedFrames final selfInfo = widget.connector.receivedFrames
.firstWhere((f) => f.isNotEmpty && f[0] == respCodeSelfInfo) .firstWhere((f) => f.isNotEmpty && f[0] == respCodeSelfInfo)
.timeout(const Duration(seconds: 5)); .timeout(const Duration(seconds: 5));
@@ -2144,6 +2154,34 @@ class _RadioSettingsDialogState extends State<_RadioSettingsDialog> {
}, },
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
if (_supportsPathHashMode) ...[
DropdownButtonFormField<int>(
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( TextField(
controller: _txPowerController, controller: _txPowerController,
onChanged: (_) => _handleManualSettingsChanged('tx power'), onChanged: (_) => _handleManualSettingsChanged('tx power'),