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.
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 -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,
),
+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).
const int _minTxPowerDbm = -9;
/// 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;
@@ -49,11 +49,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.supportsPathHashMode;
AppDebugLogService get _appLog =>
Provider.of<AppDebugLogService>(context, listen: false);
@@ -106,6 +109,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) {
@@ -439,11 +443,34 @@ class _RadioSettingsDialogState extends State<RadioSettingsDialog> {
return;
}
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
.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,
@@ -454,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(
@@ -463,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();
@@ -539,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)}',
@@ -673,6 +712,41 @@ 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 - 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(
controller: _txPowerController,
onChanged: (_) => _handleManualSettingsChanged('tx power'),
+17 -34
View File
@@ -1,86 +1,69 @@
{
"bg": [
"notification_lowBatteryTitle",
"notification_lowBatteryBody"
"settings_pathHashModeNotApplied"
],
"de": [
"notification_lowBatteryTitle",
"notification_lowBatteryBody"
"settings_pathHashModeNotApplied"
],
"es": [
"notification_lowBatteryTitle",
"notification_lowBatteryBody"
"settings_pathHashModeNotApplied"
],
"fr": [
"notification_lowBatteryTitle",
"notification_lowBatteryBody"
"settings_pathHashModeNotApplied"
],
"hu": [
"notification_lowBatteryTitle",
"notification_lowBatteryBody"
"settings_pathHashModeNotApplied"
],
"it": [
"notification_lowBatteryTitle",
"notification_lowBatteryBody"
"settings_pathHashModeNotApplied"
],
"ja": [
"notification_lowBatteryTitle",
"notification_lowBatteryBody"
"settings_pathHashModeNotApplied"
],
"ko": [
"notification_lowBatteryTitle",
"notification_lowBatteryBody"
"settings_pathHashModeNotApplied"
],
"nl": [
"notification_lowBatteryTitle",
"notification_lowBatteryBody"
"settings_pathHashModeNotApplied"
],
"pl": [
"notification_lowBatteryTitle",
"notification_lowBatteryBody"
"settings_pathHashModeNotApplied"
],
"pt": [
"notification_lowBatteryTitle",
"notification_lowBatteryBody"
"settings_pathHashModeNotApplied"
],
"ru": [
"notification_lowBatteryTitle",
"notification_lowBatteryBody"
"settings_pathHashModeNotApplied"
],
"sk": [
"notification_lowBatteryTitle",
"notification_lowBatteryBody"
"settings_pathHashModeNotApplied"
],
"sl": [
"notification_lowBatteryTitle",
"notification_lowBatteryBody"
"settings_pathHashModeNotApplied"
],
"sv": [
"notification_lowBatteryTitle",
"notification_lowBatteryBody"
"settings_pathHashModeNotApplied"
],
"uk": [
"notification_lowBatteryTitle",
"notification_lowBatteryBody"
"settings_pathHashModeNotApplied"
],
"zh": [
"notification_lowBatteryTitle",
"notification_lowBatteryBody"
"settings_pathHashModeNotApplied"
]
}