Merge pull request #582 from shortwavesurfer2009/fold_path_size_into_radio_presets

fold path hash size into radio settings
This commit is contained in:
zjs81 authored and GitHub committed 2026-10-24 21:02:53 -07:00
commit ef60cd71f1
24 files changed
+180 -48

No files matched your search

+3
View File
@@ -697,6 +697,9 @@ class MeshCoreConnector extends ChangeNotifier {
/// from ver code 8. /// from ver code 8.
bool get supportsNodeDiscover => (_firmwareVerCode ?? 0) >= 8; bool get supportsNodeDiscover => (_firmwareVerCode ?? 0) >= 8;
/// CMD_SET_PATH_HASH_MODE exists from ver code 10 (v1.14.0).
bool get supportsPathHashMode => (_firmwareVerCode ?? 0) >= 10;
/// CMD_GET/SET_DEFAULT_FLOOD_SCOPE exist from ver code 11 (v1.15.0). /// CMD_GET/SET_DEFAULT_FLOOD_SCOPE exist from ver code 11 (v1.15.0).
bool get supportsDefaultFloodScope => (_firmwareVerCode ?? 0) >= 11; bool get supportsDefaultFloodScope => (_firmwareVerCode ?? 0) >= 11;
+1
View File
@@ -198,6 +198,7 @@
"settings_radioSettingsSubtitle": "Frequency, power, spreading factor", "settings_radioSettingsSubtitle": "Frequency, power, spreading factor",
"settings_radioSettingsUpdated": "Radio settings updated", "settings_radioSettingsUpdated": "Radio settings updated",
"settings_radioSettingsNotApplied": "The radio did not apply these settings", "settings_radioSettingsNotApplied": "The radio did not apply these settings",
"settings_pathHashModeNotApplied": "Radio settings were applied, but the radio did not confirm the new path hash size",
"settings_regionSettings": "Regions", "settings_regionSettings": "Regions",
"settings_regionSettingsSubtitle": "Limit channel floods to an area", "settings_regionSettingsSubtitle": "Limit channel floods to an area",
"settings_regionEmptyExplanation": "Regions limit flood messages to repeaters in an area. Fetch them from nearby repeaters or add one by name.", "settings_regionEmptyExplanation": "Regions limit flood messages to repeaters in an area. Fetch them from nearby repeaters or add one by name.",
+6
View File
@@ -862,6 +862,12 @@ abstract class AppLocalizations {
/// **'The radio did not apply these settings'** /// **'The radio did not apply these settings'**
String get settings_radioSettingsNotApplied; String get settings_radioSettingsNotApplied;
/// No description provided for @settings_pathHashModeNotApplied.
///
/// In en, this message translates to:
/// **'Radio settings were applied, but the radio did not confirm the new path hash size'**
String get settings_pathHashModeNotApplied;
/// No description provided for @settings_regionSettings. /// No description provided for @settings_regionSettings.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
+4
View File
@@ -425,6 +425,10 @@ class AppLocalizationsBg extends AppLocalizations {
String get settings_radioSettingsNotApplied => String get settings_radioSettingsNotApplied =>
'Радиото не приложи тези настройки'; 'Радиото не приложи тези настройки';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => 'Региони'; String get settings_regionSettings => 'Региони';
+4
View File
@@ -427,6 +427,10 @@ class AppLocalizationsDe extends AppLocalizations {
String get settings_radioSettingsNotApplied => String get settings_radioSettingsNotApplied =>
'Das Funkgerät hat diese Einstellungen nicht übernommen'; 'Das Funkgerät hat diese Einstellungen nicht übernommen';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => 'Regionen'; String get settings_regionSettings => 'Regionen';
+4
View File
@@ -421,6 +421,10 @@ class AppLocalizationsEn extends AppLocalizations {
String get settings_radioSettingsNotApplied => String get settings_radioSettingsNotApplied =>
'The radio did not apply these settings'; 'The radio did not apply these settings';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => 'Regions'; String get settings_regionSettings => 'Regions';
+4
View File
@@ -425,6 +425,10 @@ class AppLocalizationsEs extends AppLocalizations {
String get settings_radioSettingsNotApplied => String get settings_radioSettingsNotApplied =>
'La radio no aplicó esta configuración'; 'La radio no aplicó esta configuración';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => 'Regiones'; String get settings_regionSettings => 'Regiones';
+4
View File
@@ -427,6 +427,10 @@ class AppLocalizationsFr extends AppLocalizations {
String get settings_radioSettingsNotApplied => String get settings_radioSettingsNotApplied =>
'La radio n\'a pas appliqué ces paramètres'; 'La radio n\'a pas appliqué ces paramètres';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => 'Régions'; String get settings_regionSettings => 'Régions';
+4
View File
@@ -423,6 +423,10 @@ class AppLocalizationsHu extends AppLocalizations {
String get settings_radioSettingsNotApplied => String get settings_radioSettingsNotApplied =>
'A rádió nem alkalmazta ezeket a beállításokat'; 'A rádió nem alkalmazta ezeket a beállításokat';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => 'Tájak'; String get settings_regionSettings => 'Tájak';
+4
View File
@@ -427,6 +427,10 @@ class AppLocalizationsIt extends AppLocalizations {
String get settings_radioSettingsNotApplied => String get settings_radioSettingsNotApplied =>
'La radio non ha applicato queste impostazioni'; 'La radio non ha applicato queste impostazioni';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => 'Regioni'; String get settings_regionSettings => 'Regioni';
+4
View File
@@ -407,6 +407,10 @@ class AppLocalizationsJa extends AppLocalizations {
@override @override
String get settings_radioSettingsNotApplied => 'ラジオがこれらの設定を適用しませんでした'; String get settings_radioSettingsNotApplied => 'ラジオがこれらの設定を適用しませんでした';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => '地域'; String get settings_regionSettings => '地域';
+4
View File
@@ -407,6 +407,10 @@ class AppLocalizationsKo extends AppLocalizations {
@override @override
String get settings_radioSettingsNotApplied => '라디오가 이 설정을 적용하지 않았습니다'; String get settings_radioSettingsNotApplied => '라디오가 이 설정을 적용하지 않았습니다';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => '지역'; String get settings_regionSettings => '지역';
+4
View File
@@ -423,6 +423,10 @@ class AppLocalizationsNl extends AppLocalizations {
String get settings_radioSettingsNotApplied => String get settings_radioSettingsNotApplied =>
'De radio heeft deze instellingen niet toegepast'; 'De radio heeft deze instellingen niet toegepast';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => 'Regio\'s'; String get settings_regionSettings => 'Regio\'s';
+4
View File
@@ -431,6 +431,10 @@ class AppLocalizationsPl extends AppLocalizations {
String get settings_radioSettingsNotApplied => String get settings_radioSettingsNotApplied =>
'Radio nie zastosowało tych ustawień'; 'Radio nie zastosowało tych ustawień';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => 'Regiony'; String get settings_regionSettings => 'Regiony';
+4
View File
@@ -427,6 +427,10 @@ class AppLocalizationsPt extends AppLocalizations {
String get settings_radioSettingsNotApplied => String get settings_radioSettingsNotApplied =>
'O rádio não aplicou estas configurações'; 'O rádio não aplicou estas configurações';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => 'Regiões'; String get settings_regionSettings => 'Regiões';
+4
View File
@@ -426,6 +426,10 @@ class AppLocalizationsRu extends AppLocalizations {
String get settings_radioSettingsNotApplied => String get settings_radioSettingsNotApplied =>
'Радиомодуль не применил эти настройки'; 'Радиомодуль не применил эти настройки';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => 'Регионы'; String get settings_regionSettings => 'Регионы';
+4
View File
@@ -426,6 +426,10 @@ class AppLocalizationsSk extends AppLocalizations {
String get settings_radioSettingsNotApplied => String get settings_radioSettingsNotApplied =>
'Rádio tieto nastavenia neuplatnilo'; 'Rádio tieto nastavenia neuplatnilo';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => 'Regiony'; String get settings_regionSettings => 'Regiony';
+4
View File
@@ -425,6 +425,10 @@ class AppLocalizationsSl extends AppLocalizations {
String get settings_radioSettingsNotApplied => String get settings_radioSettingsNotApplied =>
'Radio teh nastavitev ni uveljavil'; 'Radio teh nastavitev ni uveljavil';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => 'Regioni'; String get settings_regionSettings => 'Regioni';
+4
View File
@@ -423,6 +423,10 @@ class AppLocalizationsSv extends AppLocalizations {
String get settings_radioSettingsNotApplied => String get settings_radioSettingsNotApplied =>
'Radion tillämpade inte dessa inställningar'; 'Radion tillämpade inte dessa inställningar';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => 'Regioner'; String get settings_regionSettings => 'Regioner';
+4
View File
@@ -425,6 +425,10 @@ class AppLocalizationsUk extends AppLocalizations {
String get settings_radioSettingsNotApplied => String get settings_radioSettingsNotApplied =>
'Радіомодуль не застосував ці налаштування'; 'Радіомодуль не застосував ці налаштування';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => 'Ріси'; String get settings_regionSettings => 'Ріси';
+4
View File
@@ -401,6 +401,10 @@ class AppLocalizationsZh extends AppLocalizations {
@override @override
String get settings_radioSettingsNotApplied => '收音机未应用这些设置'; String get settings_radioSettingsNotApplied => '收音机未应用这些设置';
@override
String get settings_pathHashModeNotApplied =>
'Radio settings were applied, but the radio did not confirm the new path hash size';
@override @override
String get settings_regionSettings => '地区'; String get settings_regionSettings => '地区';
+2 -9
View File
@@ -25,9 +25,6 @@ import '../widgets/sync_progress_overlay.dart';
import 'region_management_screen.dart'; import 'region_management_screen.dart';
import '../utils/share_origin.dart'; import '../utils/share_origin.dart';
/// Companion firmware version that added CMD_SET_PATH_HASH_MODE (v1.14.0).
const int _minFirmwareVerCodeForPathHashMode = 10;
class SettingsScreen extends StatefulWidget { class SettingsScreen extends StatefulWidget {
const SettingsScreen({super.key}); const SettingsScreen({super.key});
@@ -566,14 +563,10 @@ class _SettingsScreenState extends State<SettingsScreen> {
title: l10n.repeater_pathHashMode, title: l10n.repeater_pathHashMode,
subtitle: !connected subtitle: !connected
? offline ? offline
: (connector.firmwareVerCode ?? 0) < : !connector.supportsPathHashMode
_minFirmwareVerCodeForPathHashMode
? l10n.settings_requiresFirmware('v1.14') ? l10n.settings_requiresFirmware('v1.14')
: _pathHashModeSubtitle(context, connector.pathHashByteWidth), : _pathHashModeSubtitle(context, connector.pathHashByteWidth),
onTap: onTap: connector.isConnected && connector.supportsPathHashMode
connector.isConnected &&
(connector.firmwareVerCode ?? 0) >=
_minFirmwareVerCodeForPathHashMode
? () => _editPathHashMode(context, connector) ? () => _editPathHashMode(context, connector)
: null, : null,
), ),
+79 -5
View File
@@ -30,9 +30,9 @@ bool _isAllowedRepeatFreqKHz(MeshCoreConnector connector, int freqKHz) {
/// Lowest TX power companion firmware accepts (CMD_SET_RADIO_TX_POWER). /// Lowest TX power companion firmware accepts (CMD_SET_RADIO_TX_POWER).
const int _minTxPowerDbm = -9; const int _minTxPowerDbm = -9;
/// Radio parameter editor (preset, frequency, bandwidth, SF, CR, TX power and /// Radio parameter editor (preset, frequency, bandwidth, SF, CR, TX power,
/// off-grid client repeat). Stays open when the radio rejects or fails to /// path-hash size and off-grid client repeat). Stays open when the radio
/// apply the settings so the user's edits are not lost. /// rejects or fails to apply the settings so the user's edits are not lost.
class RadioSettingsDialog extends StatefulWidget { class RadioSettingsDialog extends StatefulWidget {
final MeshCoreConnector connector; final MeshCoreConnector connector;
@@ -49,11 +49,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.supportsPathHashMode;
AppDebugLogService get _appLog => AppDebugLogService get _appLog =>
Provider.of<AppDebugLogService>(context, listen: false); Provider.of<AppDebugLogService>(context, listen: false);
@@ -106,6 +109,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) {
@@ -439,11 +443,34 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
return; return;
} }
await widget.connector.sendFrame(buildSetRadioTxPowerFrame(txPower)); await widget.connector.sendFrame(buildSetRadioTxPowerFrame(txPower));
// setPathHashMode updates the local width optimistically; the refreshed
// DEVICE_INFO below overwrites it with what the radio actually stored.
final requestedPathHashWidth =
_supportsPathHashMode &&
_pathHashByteWidth != widget.connector.pathHashByteWidth
? _pathHashByteWidth
: null;
if (requestedPathHashWidth != null) {
await widget.connector.setPathHashMode(requestedPathHashWidth - 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));
final deviceInfo = requestedPathHashWidth == null
? null
: widget.connector.receivedFrames
.firstWhere((f) => f.isNotEmpty && f[0] == respCodeDeviceInfo)
.timeout(const Duration(seconds: 5));
await widget.connector.refreshDeviceInfo(); await widget.connector.refreshDeviceInfo();
final applied = await selfInfo.then( // Without a refreshed DEVICE_INFO the path hash change is unconfirmed
// (this also covers setPathHashMode skipping a disconnected radio).
final pathHashApplied =
deviceInfo == null ||
await deviceInfo.then(
(_) => widget.connector.pathHashByteWidth == requestedPathHashWidth,
onError: (_) => false,
);
final radioApplied = await selfInfo.then(
(_) => _deviceMatches( (_) => _deviceMatches(
freqHz: freqHz, freqHz: freqHz,
bwHz: bwHz, bwHz: bwHz,
@@ -454,7 +481,7 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
), ),
onError: (_) => true, onError: (_) => true,
); );
if (!applied) { if (!radioApplied) {
_logRadioSettingsState('Radio did not apply requested settings'); _logRadioSettingsState('Radio did not apply requested settings');
if (!mounted) return; if (!mounted) return;
showDismissibleSnackBar( showDismissibleSnackBar(
@@ -463,6 +490,17 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
); );
return; return;
} }
if (!pathHashApplied) {
// Radio params and TX power were already applied; only the path
// hash size is outstanding, so say that rather than a generic error.
_logRadioSettingsState('Radio did not apply requested path hash size');
if (!mounted) return;
showDismissibleSnackBar(
context,
content: Text(l10n.settings_pathHashModeNotApplied),
);
return;
}
final rememberedSnapshot = _clientRepeat final rememberedSnapshot = _clientRepeat
? _lastNonRepeatSnapshot ? _lastNonRepeatSnapshot
: _currentSnapshot(); : _currentSnapshot();
@@ -539,6 +577,7 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
'sf=${_spreadingFactor.label} ' 'sf=${_spreadingFactor.label} '
'cr=${_codingRate.label} ' 'cr=${_codingRate.label} '
'tx=${_txPowerController.text}dBm ' 'tx=${_txPowerController.text}dBm '
'pathHash=${_pathHashByteWidth}B '
'repeat=$_clientRepeat ' 'repeat=$_clientRepeat '
'preset=${_presetLabel(_selectedPresetIndex)} ' 'preset=${_presetLabel(_selectedPresetIndex)} '
'lastNonRepeat=${_formatSnapshot(_lastNonRepeatSnapshot)}', 'lastNonRepeat=${_formatSnapshot(_lastNonRepeatSnapshot)}',
@@ -673,6 +712,41 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
}, },
), ),
const SizedBox(height: 16), const SizedBox(height: 16),
if (_supportsPathHashMode) ...[
// Values are path hash modes (0-2, byte width - 1), matching
// the selectors in settings_screen and repeater_settings_screen.
DropdownButtonFormField<int>(
initialValue: (_pathHashByteWidth - 1).clamp(0, 2).toInt(),
decoration: InputDecoration(
labelText: l10n.repeater_pathHashMode,
helperText: l10n.settings_pathHashModeHelper,
helperMaxLines: 5,
border: const OutlineInputBorder(),
),
items: [
DropdownMenuItem(
value: 0,
child: Text(l10n.repeater_pathHashModeOption0),
),
DropdownMenuItem(
value: 1,
child: Text(l10n.repeater_pathHashModeOption1),
),
DropdownMenuItem(
value: 2,
child: Text(l10n.repeater_pathHashModeOption2),
),
],
onChanged: (value) {
if (value == null) return;
setState(() => _pathHashByteWidth = value + 1);
_logRadioSettingsState(
'Manual settings edit: path hash size',
);
},
),
const SizedBox(height: 16),
],
TextField( TextField(
controller: _txPowerController, controller: _txPowerController,
onChanged: (_) => _handleManualSettingsChanged('tx power'), onChanged: (_) => _handleManualSettingsChanged('tx power'),
+17 -34
View File
@@ -1,86 +1,69 @@
{ {
"bg": [ "bg": [
"notification_lowBatteryTitle", "settings_pathHashModeNotApplied"
"notification_lowBatteryBody"
], ],
"de": [ "de": [
"notification_lowBatteryTitle", "settings_pathHashModeNotApplied"
"notification_lowBatteryBody"
], ],
"es": [ "es": [
"notification_lowBatteryTitle", "settings_pathHashModeNotApplied"
"notification_lowBatteryBody"
], ],
"fr": [ "fr": [
"notification_lowBatteryTitle", "settings_pathHashModeNotApplied"
"notification_lowBatteryBody"
], ],
"hu": [ "hu": [
"notification_lowBatteryTitle", "settings_pathHashModeNotApplied"
"notification_lowBatteryBody"
], ],
"it": [ "it": [
"notification_lowBatteryTitle", "settings_pathHashModeNotApplied"
"notification_lowBatteryBody"
], ],
"ja": [ "ja": [
"notification_lowBatteryTitle", "settings_pathHashModeNotApplied"
"notification_lowBatteryBody"
], ],
"ko": [ "ko": [
"notification_lowBatteryTitle", "settings_pathHashModeNotApplied"
"notification_lowBatteryBody"
], ],
"nl": [ "nl": [
"notification_lowBatteryTitle", "settings_pathHashModeNotApplied"
"notification_lowBatteryBody"
], ],
"pl": [ "pl": [
"notification_lowBatteryTitle", "settings_pathHashModeNotApplied"
"notification_lowBatteryBody"
], ],
"pt": [ "pt": [
"notification_lowBatteryTitle", "settings_pathHashModeNotApplied"
"notification_lowBatteryBody"
], ],
"ru": [ "ru": [
"notification_lowBatteryTitle", "settings_pathHashModeNotApplied"
"notification_lowBatteryBody"
], ],
"sk": [ "sk": [
"notification_lowBatteryTitle", "settings_pathHashModeNotApplied"
"notification_lowBatteryBody"
], ],
"sl": [ "sl": [
"notification_lowBatteryTitle", "settings_pathHashModeNotApplied"
"notification_lowBatteryBody"
], ],
"sv": [ "sv": [
"notification_lowBatteryTitle", "settings_pathHashModeNotApplied"
"notification_lowBatteryBody"
], ],
"uk": [ "uk": [
"notification_lowBatteryTitle", "settings_pathHashModeNotApplied"
"notification_lowBatteryBody"
], ],
"zh": [ "zh": [
"notification_lowBatteryTitle", "settings_pathHashModeNotApplied"
"notification_lowBatteryBody"
] ]
} }