Fix review findings in radio settings path hash size

- Presets no longer reset the path hash size; the unused preset field is gone
- Confirm the new path hash size from the refreshed DEVICE_INFO and show a
  specific error when the radio does not apply it
- Log path hash size with the other radio settings and on manual edits
- Add MeshCoreConnector.supportsPathHashMode and use it in both screens
- Use the same 0-2 mode values and helper text as the other selectors
This commit is contained in:
zjs81 committed 2026-10-24 20:43:00 -07:00
1 parent f8a9922ba4
commit 143ca57279
25 files changed
+205 -32

No files matched your search

+3
View File
@@ -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;
+1
View File
@@ -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.",
+6
View File
@@ -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:
+4
View File
@@ -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 => 'Региони';
+4
View File
@@ -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';
+4
View File
@@ -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';
+4
View File
@@ -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';
+4
View File
@@ -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';
+4
View File
@@ -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';
+4
View File
@@ -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';
+4
View File
@@ -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 => '地域';
+4
View File
@@ -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 => '지역';
+4
View File
@@ -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';
+4
View File
@@ -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';
+4
View File
@@ -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';
+4
View File
@@ -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 => 'Регионы';
+4
View File
@@ -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';
+4
View File
@@ -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';
+4
View File
@@ -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';
+4
View File
@@ -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 => 'Ріси';
+4
View File
@@ -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 => '地区';
-2
View File
@@ -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
+2 -9
View File
@@ -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<SettingsScreen> {
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,
),
+52 -20
View File
@@ -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<RadioSettingsDialog> {
String? _frequencyError;
String? _txPowerError;
bool get _supportsPathHashMode =>
(widget.connector.firmwareVerCode ?? 0) >=
_minFirmwareVerCodeForPathHashMode;
bool get _supportsPathHashMode => widget.connector.supportsPathHashMode;
AppDebugLogService get _appLog =>
Provider.of<AppDebugLogService>(context, listen: false);
@@ -284,7 +279,6 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
_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<RadioSettingsDialog> {
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<RadioSettingsDialog> {
),
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<RadioSettingsDialog> {
);
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<RadioSettingsDialog> {
'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<RadioSettingsDialog> {
),
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,
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),
+69 -1
View File
@@ -1 +1,69 @@
{}
{
"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"
]
}