diff --git a/lib/connector/meshcore_connector.dart b/lib/connector/meshcore_connector.dart index 03b03944..1d7dfa0a 100644 --- a/lib/connector/meshcore_connector.dart +++ b/lib/connector/meshcore_connector.dart @@ -681,6 +681,9 @@ class MeshCoreConnector extends ChangeNotifier { /// from ver code 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). bool get supportsDefaultFloodScope => (_firmwareVerCode ?? 0) >= 11; diff --git a/lib/l10n/app_en.arb b/lib/l10n/app_en.arb index f62a038b..6d29965a 100644 --- a/lib/l10n/app_en.arb +++ b/lib/l10n/app_en.arb @@ -198,6 +198,7 @@ "settings_radioSettingsSubtitle": "Frequency, power, spreading factor", "settings_radioSettingsUpdated": "Radio settings updated", "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_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.", diff --git a/lib/l10n/app_localizations.dart b/lib/l10n/app_localizations.dart index b5e7efc5..b7d98c28 100644 --- a/lib/l10n/app_localizations.dart +++ b/lib/l10n/app_localizations.dart @@ -862,6 +862,12 @@ abstract class AppLocalizations { /// **'The radio did not apply these settings'** 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. /// /// In en, this message translates to: diff --git a/lib/l10n/app_localizations_bg.dart b/lib/l10n/app_localizations_bg.dart index b9f79a6f..62a52ade 100644 --- a/lib/l10n/app_localizations_bg.dart +++ b/lib/l10n/app_localizations_bg.dart @@ -425,6 +425,10 @@ class AppLocalizationsBg extends AppLocalizations { 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 String get settings_regionSettings => 'Региони'; diff --git a/lib/l10n/app_localizations_de.dart b/lib/l10n/app_localizations_de.dart index d7893ccf..3b45ccb5 100644 --- a/lib/l10n/app_localizations_de.dart +++ b/lib/l10n/app_localizations_de.dart @@ -427,6 +427,10 @@ class AppLocalizationsDe extends AppLocalizations { String get settings_radioSettingsNotApplied => '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 String get settings_regionSettings => 'Regionen'; diff --git a/lib/l10n/app_localizations_en.dart b/lib/l10n/app_localizations_en.dart index 0265ac8b..da8144d5 100644 --- a/lib/l10n/app_localizations_en.dart +++ b/lib/l10n/app_localizations_en.dart @@ -421,6 +421,10 @@ class AppLocalizationsEn extends AppLocalizations { String get settings_radioSettingsNotApplied => '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 String get settings_regionSettings => 'Regions'; diff --git a/lib/l10n/app_localizations_es.dart b/lib/l10n/app_localizations_es.dart index 75c2ab0e..e40f0fa2 100644 --- a/lib/l10n/app_localizations_es.dart +++ b/lib/l10n/app_localizations_es.dart @@ -425,6 +425,10 @@ class AppLocalizationsEs extends AppLocalizations { String get settings_radioSettingsNotApplied => '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 String get settings_regionSettings => 'Regiones'; diff --git a/lib/l10n/app_localizations_fr.dart b/lib/l10n/app_localizations_fr.dart index 85de8bbb..3c6ee155 100644 --- a/lib/l10n/app_localizations_fr.dart +++ b/lib/l10n/app_localizations_fr.dart @@ -427,6 +427,10 @@ class AppLocalizationsFr extends AppLocalizations { String get settings_radioSettingsNotApplied => '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 String get settings_regionSettings => 'Régions'; diff --git a/lib/l10n/app_localizations_hu.dart b/lib/l10n/app_localizations_hu.dart index ef4b3d9b..5bf2522a 100644 --- a/lib/l10n/app_localizations_hu.dart +++ b/lib/l10n/app_localizations_hu.dart @@ -423,6 +423,10 @@ class AppLocalizationsHu extends AppLocalizations { String get settings_radioSettingsNotApplied => '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 String get settings_regionSettings => 'Tájak'; diff --git a/lib/l10n/app_localizations_it.dart b/lib/l10n/app_localizations_it.dart index 50bb49d9..bcb282ef 100644 --- a/lib/l10n/app_localizations_it.dart +++ b/lib/l10n/app_localizations_it.dart @@ -427,6 +427,10 @@ class AppLocalizationsIt extends AppLocalizations { String get settings_radioSettingsNotApplied => '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 String get settings_regionSettings => 'Regioni'; diff --git a/lib/l10n/app_localizations_ja.dart b/lib/l10n/app_localizations_ja.dart index 2aabf56e..7d98b2a7 100644 --- a/lib/l10n/app_localizations_ja.dart +++ b/lib/l10n/app_localizations_ja.dart @@ -407,6 +407,10 @@ class AppLocalizationsJa extends AppLocalizations { @override 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 String get settings_regionSettings => '地域'; diff --git a/lib/l10n/app_localizations_ko.dart b/lib/l10n/app_localizations_ko.dart index 98a81ac1..c2a268f9 100644 --- a/lib/l10n/app_localizations_ko.dart +++ b/lib/l10n/app_localizations_ko.dart @@ -407,6 +407,10 @@ class AppLocalizationsKo extends AppLocalizations { @override 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 String get settings_regionSettings => '지역'; diff --git a/lib/l10n/app_localizations_nl.dart b/lib/l10n/app_localizations_nl.dart index 082f2a18..edadc900 100644 --- a/lib/l10n/app_localizations_nl.dart +++ b/lib/l10n/app_localizations_nl.dart @@ -423,6 +423,10 @@ class AppLocalizationsNl extends AppLocalizations { String get settings_radioSettingsNotApplied => '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 String get settings_regionSettings => 'Regio\'s'; diff --git a/lib/l10n/app_localizations_pl.dart b/lib/l10n/app_localizations_pl.dart index 3db02722..6662f4e0 100644 --- a/lib/l10n/app_localizations_pl.dart +++ b/lib/l10n/app_localizations_pl.dart @@ -431,6 +431,10 @@ class AppLocalizationsPl extends AppLocalizations { String get settings_radioSettingsNotApplied => '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 String get settings_regionSettings => 'Regiony'; diff --git a/lib/l10n/app_localizations_pt.dart b/lib/l10n/app_localizations_pt.dart index 9b89ff31..f1943007 100644 --- a/lib/l10n/app_localizations_pt.dart +++ b/lib/l10n/app_localizations_pt.dart @@ -427,6 +427,10 @@ class AppLocalizationsPt extends AppLocalizations { String get settings_radioSettingsNotApplied => '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 String get settings_regionSettings => 'Regiões'; diff --git a/lib/l10n/app_localizations_ru.dart b/lib/l10n/app_localizations_ru.dart index a1686804..c1a8ed10 100644 --- a/lib/l10n/app_localizations_ru.dart +++ b/lib/l10n/app_localizations_ru.dart @@ -426,6 +426,10 @@ class AppLocalizationsRu extends AppLocalizations { 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 String get settings_regionSettings => 'Регионы'; diff --git a/lib/l10n/app_localizations_sk.dart b/lib/l10n/app_localizations_sk.dart index 9cd7cc6d..a8d0887b 100644 --- a/lib/l10n/app_localizations_sk.dart +++ b/lib/l10n/app_localizations_sk.dart @@ -426,6 +426,10 @@ class AppLocalizationsSk extends AppLocalizations { String get settings_radioSettingsNotApplied => '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 String get settings_regionSettings => 'Regiony'; diff --git a/lib/l10n/app_localizations_sl.dart b/lib/l10n/app_localizations_sl.dart index 8602eb0d..2fd1903a 100644 --- a/lib/l10n/app_localizations_sl.dart +++ b/lib/l10n/app_localizations_sl.dart @@ -425,6 +425,10 @@ class AppLocalizationsSl extends AppLocalizations { String get settings_radioSettingsNotApplied => '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 String get settings_regionSettings => 'Regioni'; diff --git a/lib/l10n/app_localizations_sv.dart b/lib/l10n/app_localizations_sv.dart index 1d87483d..face6140 100644 --- a/lib/l10n/app_localizations_sv.dart +++ b/lib/l10n/app_localizations_sv.dart @@ -423,6 +423,10 @@ class AppLocalizationsSv extends AppLocalizations { String get settings_radioSettingsNotApplied => '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 String get settings_regionSettings => 'Regioner'; diff --git a/lib/l10n/app_localizations_uk.dart b/lib/l10n/app_localizations_uk.dart index ebd6d5eb..47888b9e 100644 --- a/lib/l10n/app_localizations_uk.dart +++ b/lib/l10n/app_localizations_uk.dart @@ -425,6 +425,10 @@ class AppLocalizationsUk extends AppLocalizations { 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 String get settings_regionSettings => 'Ріси'; diff --git a/lib/l10n/app_localizations_zh.dart b/lib/l10n/app_localizations_zh.dart index 703a27fe..1ab063c1 100644 --- a/lib/l10n/app_localizations_zh.dart +++ b/lib/l10n/app_localizations_zh.dart @@ -401,6 +401,10 @@ class AppLocalizationsZh extends AppLocalizations { @override 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 String get settings_regionSettings => '地区'; diff --git a/lib/models/radio_settings.dart b/lib/models/radio_settings.dart index 6b3eee84..f7c4709c 100644 --- a/lib/models/radio_settings.dart +++ b/lib/models/radio_settings.dart @@ -50,7 +50,6 @@ class RadioSettings { final LoRaSpreadingFactor spreadingFactor; final LoRaCodingRate codingRate; final int txPowerDbm; - final int pathHashByteWidth; RadioSettings({ required this.frequencyMHz, @@ -58,7 +57,6 @@ 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 dff41c0b..74ca3e2c 100644 --- a/lib/screens/settings_screen.dart +++ b/lib/screens/settings_screen.dart @@ -25,9 +25,6 @@ import '../widgets/sync_progress_overlay.dart'; import 'region_management_screen.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 { const SettingsScreen({super.key}); @@ -566,14 +563,10 @@ class _SettingsScreenState extends State { title: l10n.repeater_pathHashMode, subtitle: !connected ? offline - : (connector.firmwareVerCode ?? 0) < - _minFirmwareVerCodeForPathHashMode + : !connector.supportsPathHashMode ? l10n.settings_requiresFirmware('v1.14') : _pathHashModeSubtitle(context, connector.pathHashByteWidth), - onTap: - connector.isConnected && - (connector.firmwareVerCode ?? 0) >= - _minFirmwareVerCodeForPathHashMode + onTap: connector.isConnected && connector.supportsPathHashMode ? () => _editPathHashMode(context, connector) : null, ), diff --git a/lib/widgets/radio_settings_dialog.dart b/lib/widgets/radio_settings_dialog.dart index 7f9834ab..aa00e3d9 100644 --- a/lib/widgets/radio_settings_dialog.dart +++ b/lib/widgets/radio_settings_dialog.dart @@ -30,12 +30,9 @@ bool _isAllowedRepeatFreqKHz(MeshCoreConnector connector, int freqKHz) { /// Lowest TX power companion firmware accepts (CMD_SET_RADIO_TX_POWER). const int _minTxPowerDbm = -9; -/// Companion firmware version that added CMD_SET_PATH_HASH_MODE (v1.14.0). -const int _minFirmwareVerCodeForPathHashMode = 10; - -/// Radio parameter editor (preset, frequency, bandwidth, SF, CR, TX power and -/// off-grid client repeat). Stays open when the radio rejects or fails to -/// apply the settings so the user's edits are not lost. +/// Radio parameter editor (preset, frequency, bandwidth, SF, CR, TX power, +/// path-hash size and off-grid client repeat). Stays open when the radio +/// rejects or fails to apply the settings so the user's edits are not lost. class RadioSettingsDialog extends StatefulWidget { final MeshCoreConnector connector; @@ -58,9 +55,7 @@ class _RadioSettingsDialogState extends State { String? _frequencyError; String? _txPowerError; - bool get _supportsPathHashMode => - (widget.connector.firmwareVerCode ?? 0) >= - _minFirmwareVerCodeForPathHashMode; + bool get _supportsPathHashMode => widget.connector.supportsPathHashMode; AppDebugLogService get _appLog => Provider.of(context, listen: false); @@ -284,7 +279,6 @@ class _RadioSettingsDialogState extends State { _spreadingFactor = preset.spreadingFactor; _codingRate = preset.codingRate; _txPowerController.text = preset.txPowerDbm.toString(); - _pathHashByteWidth = preset.pathHashByteWidth; _selectedPresetIndex = index; _lastNonRepeatSnapshot = baseSnapshot; // Programmatic writes skip TextField.onChanged, so clear any stale @@ -449,15 +443,34 @@ class _RadioSettingsDialogState extends State { return; } await widget.connector.sendFrame(buildSetRadioTxPowerFrame(txPower)); - if (_supportsPathHashMode && - _pathHashByteWidth != widget.connector.pathHashByteWidth) { - await widget.connector.setPathHashMode(_pathHashByteWidth - 1); + // 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 .firstWhere((f) => f.isNotEmpty && f[0] == respCodeSelfInfo) .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(); - 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( freqHz: freqHz, bwHz: bwHz, @@ -468,7 +481,7 @@ class _RadioSettingsDialogState extends State { ), onError: (_) => true, ); - if (!applied) { + if (!radioApplied) { _logRadioSettingsState('Radio did not apply requested settings'); if (!mounted) return; showDismissibleSnackBar( @@ -477,6 +490,17 @@ class _RadioSettingsDialogState extends State { ); 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 ? _lastNonRepeatSnapshot : _currentSnapshot(); @@ -553,6 +577,7 @@ class _RadioSettingsDialogState extends State { 'sf=${_spreadingFactor.label} ' 'cr=${_codingRate.label} ' 'tx=${_txPowerController.text}dBm ' + 'pathHash=${_pathHashByteWidth}B ' 'repeat=$_clientRepeat ' 'preset=${_presetLabel(_selectedPresetIndex)} ' 'lastNonRepeat=${_formatSnapshot(_lastNonRepeatSnapshot)}', @@ -688,29 +713,36 @@ class _RadioSettingsDialogState extends State { ), 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( - initialValue: _pathHashByteWidth, + 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: 1, + value: 0, child: Text(l10n.repeater_pathHashModeOption0), ), DropdownMenuItem( - value: 2, + value: 1, child: Text(l10n.repeater_pathHashModeOption1), ), DropdownMenuItem( - value: 3, + value: 2, child: Text(l10n.repeater_pathHashModeOption2), ), ], onChanged: (value) { if (value == null) return; - setState(() => _pathHashByteWidth = value); + setState(() => _pathHashByteWidth = value + 1); + _logRadioSettingsState( + 'Manual settings edit: path hash size', + ); }, ), const SizedBox(height: 16), diff --git a/untranslated.json b/untranslated.json index 9e26dfee..648cd980 100644 --- a/untranslated.json +++ b/untranslated.json @@ -1 +1,69 @@ -{} \ No newline at end of file +{ + "bg": [ + "settings_pathHashModeNotApplied" + ], + + "de": [ + "settings_pathHashModeNotApplied" + ], + + "es": [ + "settings_pathHashModeNotApplied" + ], + + "fr": [ + "settings_pathHashModeNotApplied" + ], + + "hu": [ + "settings_pathHashModeNotApplied" + ], + + "it": [ + "settings_pathHashModeNotApplied" + ], + + "ja": [ + "settings_pathHashModeNotApplied" + ], + + "ko": [ + "settings_pathHashModeNotApplied" + ], + + "nl": [ + "settings_pathHashModeNotApplied" + ], + + "pl": [ + "settings_pathHashModeNotApplied" + ], + + "pt": [ + "settings_pathHashModeNotApplied" + ], + + "ru": [ + "settings_pathHashModeNotApplied" + ], + + "sk": [ + "settings_pathHashModeNotApplied" + ], + + "sl": [ + "settings_pathHashModeNotApplied" + ], + + "sv": [ + "settings_pathHashModeNotApplied" + ], + + "uk": [ + "settings_pathHashModeNotApplied" + ], + + "zh": [ + "settings_pathHashModeNotApplied" + ] +}