Merge branch 'dev' into issue-37-selective-notifs

This commit is contained in:
zjs81 authored and GitHub committed 2026-10-24 21:04:26 -07:00
commit 471a2b6a5e
31 files changed
+593 -21

No files matched your search

+3 -3
View File
@@ -49,7 +49,7 @@ See the [user documentation](documentation/README.md), [connection guide](docume
- **Contact Groups**: Create custom groups to organize your mesh network contacts
- **Message Reactions**: React to messages with emoji responses
- **Message Replies**: Thread conversations with inline reply functionality
- **Android Auto & Watches**: Hear messages and reply by voice in Android Auto, or reply from the notification shade and Wear OS/Galaxy watches ([guide](documentation/notifications.md#android-auto))
- **Android Auto & Watches**: Reply from the notification shade and Wear OS/Galaxy watches, or hear messages and reply by voice in Android Auto (optional build flag) ([guide](documentation/notifications.md#android-auto))
- **Channel Muting**: Mute a channel from its chat screen, the channel list, or its notification
### Mesh Network
@@ -103,7 +103,7 @@ See the [user documentation](documentation/README.md), [connection guide](docume
| Map & Location | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Device Management | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Repeater Hub | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
| Notification replies | ✅<br>(incl. Android Auto, watches) | ❌ | ❌ | ❌ | ❌ | ❌ |
| Notification replies | ✅<br>(incl. watches; Android Auto optional) | ❌ | ❌ | ❌ | ❌ | ❌ |
The matrix describes implemented functionality, not a guarantee that every feature has been tested on every device. Web device connections use Web Serial and require Chrome and a secure origin. Image inference and translation require native runtimes and are unavailable on web. Android APKs currently include only `arm64-v8a`; the minimum Android API follows the Flutter SDK used to build.
@@ -228,7 +228,7 @@ Messages are transmitted as binary frames using a custom protocol optimized for
- **Theme**: System default, light, or dark mode
- **Language**: Use one of 18 languages (English, Chinese, French, Spanish, Portuguese, German, Dutch, Polish, Swedish, Italian, Slovak, Slovenian, Bulgarian, Russian, Ukrainian, Hungarian, Japanese, Korean)
- **Notifications**: Configurable for messages, channels, and node advertisements; per-channel muting; reply, mark-as-read, and mute actions on Android notifications and watches (reply and mark-as-read in Android Auto)
- **Notifications**: Configurable for messages, channels, and node advertisements; per-channel muting; reply, mark-as-read, and mute actions on Android notifications and watches (reply and mark-as-read in Android Auto when built with `--android-project-arg=androidAuto=true`)
- **Battery Chemistry**: Support for NMC, LiFePO4, LiPo, and LiPo HV battery types
- **Message Retry**: Automatic retry with configurable path clearing
+18
View File
@@ -98,6 +98,24 @@ android {
// }
}
// Android Auto (notification read-aloud and voice reply) is opt-in, because
// declaring it puts the app through Play's separate Android Auto review.
// Enable it with `flutter build apk --android-project-arg=androidAuto=true`
// or `./gradlew -PandroidAuto=true ...`.
val androidAutoEnabled = (findProperty("androidAuto") as String?)?.toBoolean() == true
if (androidAutoEnabled) {
android.sourceSets.getByName("main").res.srcDir("src/androidAuto/res")
}
androidComponents {
onVariants { variant ->
if (androidAutoEnabled) {
variant.sources.manifests.addStaticManifestFile("src/androidAuto/AndroidManifest.xml")
}
}
}
flutter {
source = "../.."
}
@@ -0,0 +1,9 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Merged only when built with -PandroidAuto=true; see app/build.gradle.kts -->
<application>
<!-- Android Auto: message notifications can be read aloud and replied to -->
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />
</application>
</manifest>
-4
View File
@@ -34,10 +34,6 @@
<receiver
android:name="com.dexterous.flutterlocalnotifications.ActionBroadcastReceiver"
android:exported="false" />
<!-- Android Auto: message notifications can be read aloud and replied to -->
<meta-data
android:name="com.google.android.gms.car.application"
android:resource="@xml/automotive_app_desc" />
<activity
android:name=".MainActivity"
android:exported="true"
+8
View File
@@ -52,6 +52,14 @@ iOS notifications do not have reply actions yet.
MeshCore Open works in Android Auto as a notification-based messaging app. There is no MeshCore screen in the car; Android Auto provides the interface.
Android Auto support is off by default and is compiled in only when the build passes the `androidAuto` Gradle property:
```bash
flutter build apk --release --android-project-arg=androidAuto=true
```
The flag merges `android/app/src/androidAuto/` (the `com.google.android.gms.car.application` manifest entry and `automotive_app_desc.xml`) into the app. Without it, Android Auto does not list the app. Notification replies from the shade and watches work either way.
- New direct and channel messages appear on the car display and can be read aloud.
- Reply by voice or with a suggested reply; replies follow the rules above (splitting, failure notifications, no translation).
- Android Auto shows **Reply** and **Mark as read**. **Mute channel** is marked as a mute action, but Android Auto only documents reply and mark-as-read for messaging apps, so mute may not appear in the car; use the phone, a watch, or the bell icon.
+90
View File
@@ -299,6 +299,22 @@ class MeshCoreConnector extends ChangeNotifier {
Stopwatch? _airtimeBumpStopwatch;
int _prevTotalAirSecs = 0;
int? _batteryMillivolts;
// Thresholds (percent) that trigger a low-battery notification once per
// crossing, re-arming 5 points above the threshold after recharge.
static const List<int> _lowBatteryThresholds = [25, 10];
final Set<int> _batteryAlertedThresholds = {};
// Consecutive readings that newly crossed a threshold. Alerts need
// [_lowBatteryConfirmReadings] in a row so a single TX-load voltage sag
// doesn't notify.
int _lowBatteryReadingStreak = 0;
// Device key the posted low-battery notifications were scoped to, kept so
// they can still be cancelled after the session's identity is cleared.
String? _lowBatteryAlertDeviceKey;
static const int _lowBatteryConfirmReadings = 2;
// Readings below this are treated as "no battery sensor" (boards without
// one report 0 mV). Any single Li cell, including LiFePO4 (2600 mV empty),
// is protection-cut well above 2 V, so lower values are not real readings.
static const int _minPlausibleBatteryMillivolts = 2000;
double? _selfLatitude;
double? _selfLongitude;
final List<DirectRepeater> _directRepeaters = List.empty(growable: true);
@@ -682,6 +698,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;
@@ -6473,6 +6492,7 @@ class MeshCoreConnector extends ChangeNotifier {
_batteryMillivolts = reader.readUInt16LE();
_storageUsedKb = reader.readUInt32LE();
_storageTotalKb = reader.readUInt32LE();
_checkLowBatteryThresholds();
final volts = (_batteryMillivolts! / 1000.0).toStringAsFixed(2);
_appDebugLogService?.info(
'Pulled battery: $volts V ($_batteryMillivolts mV)',
@@ -6487,6 +6507,64 @@ class MeshCoreConnector extends ChangeNotifier {
}
}
void _checkLowBatteryThresholds() {
final millivolts = _batteryMillivolts;
if (millivolts == null || millivolts < _minPlausibleBatteryMillivolts) {
return;
}
// Until the device identity (and so its saved chemistry) is known, the
// percentage falls back to NMC and can read low for e.g. LiFePO4 packs.
// Skip evaluation; the next battery poll re-checks once identity is set.
if (batteryDeviceKey == null || _appSettingsService == null) return;
final percent = batteryPercent;
if (percent == null) return;
// Only the lowest newly crossed threshold notifies; higher ones crossed
// in the same reading are marked as alerted silently.
final newlyCrossed = <int>[];
for (final threshold in _lowBatteryThresholds) {
if (percent <= threshold &&
!_batteryAlertedThresholds.contains(threshold)) {
newlyCrossed.add(threshold);
} else if (percent > threshold + 5 &&
_batteryAlertedThresholds.contains(threshold)) {
// Re-arm once the battery recovers 5 points above the threshold,
// so a recharge + discharge cycle alerts again without flapping.
_batteryAlertedThresholds.remove(threshold);
final alertDeviceKey = _lowBatteryAlertDeviceKey;
if (alertDeviceKey != null) {
unawaited(
_notificationService.clearLowBatteryNotifications(alertDeviceKey, [
threshold,
]),
);
}
}
}
if (newlyCrossed.isEmpty) {
_lowBatteryReadingStreak = 0;
return;
}
// Debounce: wait for consecutive low readings before alerting.
if (++_lowBatteryReadingStreak < _lowBatteryConfirmReadings) return;
_lowBatteryReadingStreak = 0;
_batteryAlertedThresholds.addAll(newlyCrossed);
final deviceKey = batteryDeviceKey!;
_lowBatteryAlertDeviceKey = deviceKey;
final lowestNewlyCrossed = newlyCrossed.reduce((a, b) => a < b ? a : b);
if (!(_appSettingsService?.settings.notificationsEnabled ?? false)) {
return;
}
unawaited(
_notificationService.showLowBatteryNotification(
deviceKey: deviceKey,
deviceName: deviceDisplayName,
batteryPercent: percent,
threshold: lowestNewlyCrossed,
),
);
}
void _checkManualAddContacts() async {
// If manual add contacts is enabled, set auto add config and other params.
// and disable it after
@@ -8599,6 +8677,18 @@ class MeshCoreConnector extends ChangeNotifier {
_hasReceivedDeviceInfo = false;
_batteryMillivolts = null;
_batteryRequested = false;
final alertDeviceKey = _lowBatteryAlertDeviceKey;
if (alertDeviceKey != null && _batteryAlertedThresholds.isNotEmpty) {
unawaited(
_notificationService.clearLowBatteryNotifications(
alertDeviceKey,
_batteryAlertedThresholds.toList(),
),
);
}
_batteryAlertedThresholds.clear();
_lowBatteryAlertDeviceKey = null;
_lowBatteryReadingStreak = 0;
_pathHashByteWidth = 1;
_maxContacts = _defaultMaxContacts;
_maxChannels = _defaultMaxChannels;
+17
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.",
@@ -2690,6 +2691,22 @@
"contacts_contactAdvertCopied": "Advert copied to Clipboard.",
"contacts_contactAdvertCopyFailed": "Copying advert to Clipboard failed.",
"notification_activityTitle": "MeshCore Activity",
"notification_lowBatteryTitle": "Low battery",
"@notification_lowBatteryTitle": {
"description": "Title of the low battery notification"
},
"notification_lowBatteryBody": "{deviceName} battery is at {percent}%",
"@notification_lowBatteryBody": {
"description": "Body of the low battery notification; deviceName is the connected radio's node name",
"placeholders": {
"deviceName": {
"type": "String"
},
"percent": {
"type": "int"
}
}
},
"notification_messagesCount": "{count} {count, plural, =1{message} other{messages}}",
"@notification_messagesCount": {
"placeholders": {
+18
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:
@@ -8138,6 +8144,18 @@ abstract class AppLocalizations {
/// **'MeshCore Activity'**
String get notification_activityTitle;
/// Title of the low battery notification
///
/// In en, this message translates to:
/// **'Low battery'**
String get notification_lowBatteryTitle;
/// Body of the low battery notification; deviceName is the connected radio's node name
///
/// In en, this message translates to:
/// **'{deviceName} battery is at {percent}%'**
String notification_lowBatteryBody(String deviceName, int percent);
/// No description provided for @notification_messagesCount.
///
/// In en, this message translates to:
+12
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 => 'Региони';
@@ -4744,6 +4748,14 @@ class AppLocalizationsBg extends AppLocalizations {
@override
String get notification_activityTitle => 'Активност на MeshCore';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
String _temp0 = intl.Intl.pluralLogic(
+12
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';
@@ -4755,6 +4759,14 @@ class AppLocalizationsDe extends AppLocalizations {
@override
String get notification_activityTitle => 'MeshCore Aktivität';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
String _temp0 = intl.Intl.pluralLogic(
+12
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';
@@ -4679,6 +4683,14 @@ class AppLocalizationsEn extends AppLocalizations {
@override
String get notification_activityTitle => 'MeshCore Activity';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
String _temp0 = intl.Intl.pluralLogic(
+12
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';
@@ -4746,6 +4750,14 @@ class AppLocalizationsEs extends AppLocalizations {
@override
String get notification_activityTitle => 'Actividad de MeshCore';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
String _temp0 = intl.Intl.pluralLogic(
+12
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';
@@ -4765,6 +4769,14 @@ class AppLocalizationsFr extends AppLocalizations {
@override
String get notification_activityTitle => 'Activité MeshCore';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
String _temp0 = intl.Intl.pluralLogic(
+12
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';
@@ -4743,6 +4747,14 @@ class AppLocalizationsHu extends AppLocalizations {
@override
String get notification_activityTitle => 'MeshCore tevékenység';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
String _temp0 = intl.Intl.pluralLogic(
+12
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';
@@ -4752,6 +4756,14 @@ class AppLocalizationsIt extends AppLocalizations {
@override
String get notification_activityTitle => 'Attività MeshCore';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
String _temp0 = intl.Intl.pluralLogic(
+12
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 => '地域';
@@ -4515,6 +4519,14 @@ class AppLocalizationsJa extends AppLocalizations {
@override
String get notification_activityTitle => 'メッシュコアの活動';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
String _temp0 = intl.Intl.pluralLogic(
+12
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 => '지역';
@@ -4526,6 +4530,14 @@ class AppLocalizationsKo extends AppLocalizations {
@override
String get notification_activityTitle => '메쉬코어 활동';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
String _temp0 = intl.Intl.pluralLogic(
+12
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';
@@ -4721,6 +4725,14 @@ class AppLocalizationsNl extends AppLocalizations {
@override
String get notification_activityTitle => 'MeshCore Activiteit';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
String _temp0 = intl.Intl.pluralLogic(
+12
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';
@@ -4772,6 +4776,14 @@ class AppLocalizationsPl extends AppLocalizations {
@override
String get notification_activityTitle => 'Aktywność MeshCore';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
String _temp0 = intl.Intl.pluralLogic(
+12
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';
@@ -4748,6 +4752,14 @@ class AppLocalizationsPt extends AppLocalizations {
@override
String get notification_activityTitle => 'Atividade MeshCore';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
String _temp0 = intl.Intl.pluralLogic(
+12
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 => 'Регионы';
@@ -4756,6 +4760,14 @@ class AppLocalizationsRu extends AppLocalizations {
@override
String get notification_activityTitle => 'Активность MeshCore';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
String _temp0 = intl.Intl.pluralLogic(
+12
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';
@@ -4729,6 +4733,14 @@ class AppLocalizationsSk extends AppLocalizations {
@override
String get notification_activityTitle => 'Aktivita MeshCore';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
String _temp0 = intl.Intl.pluralLogic(
+12
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';
@@ -4727,6 +4731,14 @@ class AppLocalizationsSl extends AppLocalizations {
@override
String get notification_activityTitle => 'Aktivnost MeshCore';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
String _temp0 = intl.Intl.pluralLogic(
+12
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';
@@ -4703,6 +4707,14 @@ class AppLocalizationsSv extends AppLocalizations {
@override
String get notification_activityTitle => 'MeshCore Aktivitet';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
String _temp0 = intl.Intl.pluralLogic(
+12
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 => 'Ріси';
@@ -4755,6 +4759,14 @@ class AppLocalizationsUk extends AppLocalizations {
@override
String get notification_activityTitle => 'Активність MeshCore';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
String _temp0 = intl.Intl.pluralLogic(
+12
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 => '地区';
@@ -4423,6 +4427,14 @@ class AppLocalizationsZh extends AppLocalizations {
@override
String get notification_activityTitle => 'MeshCore 活动';
@override
String get notification_lowBatteryTitle => 'Low battery';
@override
String notification_lowBatteryBody(String deviceName, int percent) {
return '$deviceName battery is at $percent%';
}
@override
String notification_messagesCount(int count) {
return '$count 条消息';
+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,
),
+68
View File
@@ -598,6 +598,54 @@ class NotificationService {
}
}
/// Posts a low-battery alert for the connected device.
///
/// Uses a per-device, per-threshold notification id so each alert level
/// updates its own notification instead of stacking, and alerts for
/// different radios don't overwrite each other. Bypasses the rate-limit
/// queue, which only handles message and advert notifications.
Future<void> showLowBatteryNotification({
required String deviceKey,
required String deviceName,
required int batteryPercent,
required int threshold,
}) async {
if (!await _ensureCanNotify()) return;
const androidDetails = AndroidNotificationDetails(
'low_battery',
'Low Battery',
channelDescription: 'Low battery alerts for the connected device',
importance: Importance.high,
priority: Priority.high,
icon: '@mipmap/ic_launcher',
);
const darwinDetails = DarwinNotificationDetails(
presentAlert: true,
presentBadge: false,
presentSound: true,
);
const notificationDetails = NotificationDetails(
android: androidDetails,
iOS: darwinDetails,
macOS: darwinDetails,
);
try {
await _notifications.show(
id: _lowBatteryNotificationId(deviceKey, threshold),
title: _l10n.notification_lowBatteryTitle,
body: _l10n.notification_lowBatteryBody(deviceName, batteryPercent),
notificationDetails: notificationDetails,
payload: 'low_battery',
);
} catch (e) {
debugPrint('Failed to show low battery notification: $e');
}
}
/// Returns a privacy-safe identifier for debug logging.
/// - advert: shows device name (body contains contactName)
/// - message: shows "from: sender" (avoids logging message content)
@@ -654,6 +702,26 @@ class NotificationService {
await _updateBadge(totalUnreadCount);
}
static int _lowBatteryNotificationId(String deviceKey, int threshold) =>
'low_battery:$deviceKey:$threshold'.hashCode;
/// Cancel a device's low-battery notifications for the given thresholds.
Future<void> clearLowBatteryNotifications(
String deviceKey,
Iterable<int> thresholds,
) async {
if (!await _ensureInitialized()) return;
for (final threshold in thresholds) {
try {
await _notifications.cancel(
id: _lowBatteryNotificationId(deviceKey, threshold),
);
} catch (e) {
debugPrint('Failed to clear low battery notification: $e');
}
}
}
/// Cancel advert notifications for the given contact public key hexes.
Future<void> clearAdvertNotifications(List<String> contactIds) async {
if (!await _ensureInitialized()) return;
+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'),
+65
View File
@@ -65,5 +65,70 @@
"zh": [
"channels_notificationModeTooltip"
"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"
]
}