mirror of
https://github.com/zjs81/meshcore-open.git
synced 2026-07-06 16:56:41 +10:00
Add option for automatic zerohop adverts on posision change.
This commit is contained in:
@@ -13,6 +13,14 @@ class AppSettingsService extends ChangeNotifier {
|
||||
|
||||
AppSettings get settings => _settings;
|
||||
|
||||
int resolvedGpsIntervalSeconds(Map<String, String>? deviceCustomVars) {
|
||||
final deviceValue = int.tryParse(deviceCustomVars?['gps_interval'] ?? '');
|
||||
if (deviceValue != null && deviceValue >= 0) {
|
||||
return deviceValue;
|
||||
}
|
||||
return _settings.gpsIntervalSeconds;
|
||||
}
|
||||
|
||||
String batteryChemistryForDevice(String deviceId) {
|
||||
final stored = _settings.batteryChemistryByDeviceId[deviceId];
|
||||
if (stored == 'liion') return 'nmc';
|
||||
@@ -128,6 +136,28 @@ class AppSettingsService extends ChangeNotifier {
|
||||
await updateSettings(_settings.copyWith(notifyOnNewAdvert: value));
|
||||
}
|
||||
|
||||
Future<void> setAutoSendZeroHopAdvertOnGpsUpdate(bool value) async {
|
||||
await updateSettings(
|
||||
_settings.copyWith(autoSendZeroHopAdvertOnGpsUpdate: value),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> setGpsIntervalSeconds(
|
||||
int value, {
|
||||
Future<void> Function(int value)? writeToDevice,
|
||||
}) async {
|
||||
await updateSettings(_settings.copyWith(gpsIntervalSeconds: value));
|
||||
if (writeToDevice == null) return;
|
||||
try {
|
||||
await writeToDevice(value);
|
||||
} catch (e) {
|
||||
appLogger.warn(
|
||||
'Failed to write GPS interval to device: $e',
|
||||
tag: 'AppSettings',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> setAutoRouteRotationEnabled(bool value) async {
|
||||
await updateSettings(_settings.copyWith(autoRouteRotationEnabled: value));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user