mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 08:20:36 +00:00
@@ -1263,11 +1263,17 @@ class ContactsProvider with ChangeNotifier {
|
||||
Map<String, dynamic>? existingExtraSensorData,
|
||||
Map<String, dynamic>? incomingExtraSensorData,
|
||||
) {
|
||||
final merged = <String, dynamic>{...?existingExtraSensorData};
|
||||
if (incomingExtraSensorData == null || incomingExtraSensorData.isEmpty) {
|
||||
return merged;
|
||||
return <String, dynamic>{...?existingExtraSensorData};
|
||||
}
|
||||
|
||||
final isFullTelemetryRefresh = incomingExtraSensorData.containsKey(
|
||||
_rawTelemetryHexKey,
|
||||
);
|
||||
final merged = <String, dynamic>{
|
||||
if (!isFullTelemetryRefresh) ...?existingExtraSensorData,
|
||||
};
|
||||
|
||||
final incomingMetricFamilies = incomingExtraSensorData.keys
|
||||
.map(_telemetryMetricFamilyForKey)
|
||||
.whereType<String>()
|
||||
|
||||
@@ -328,9 +328,16 @@ class _RecipientSelectorSheetState extends State<RecipientSelectorSheet> {
|
||||
MessagesProvider? messagesProvider,
|
||||
) {
|
||||
final previewData = _channelPreviewData(context, channel, messagesProvider);
|
||||
final sharingMode = context.watch<AppProvider>().channelLocationSharingModeForChannel(
|
||||
channel.publicKey.length > 1 ? channel.publicKey[1] : 0,
|
||||
);
|
||||
ChannelLocationSharingMode? sharingMode;
|
||||
try {
|
||||
sharingMode = context
|
||||
.watch<AppProvider>()
|
||||
.channelLocationSharingModeForChannel(
|
||||
channel.publicKey.length > 1 ? channel.publicKey[1] : 0,
|
||||
);
|
||||
} on ProviderNotFoundException {
|
||||
sharingMode = null;
|
||||
}
|
||||
|
||||
return _buildRecipientCard(
|
||||
context: context,
|
||||
|
||||
@@ -238,15 +238,27 @@ List<SensorMetricOption> sensorMetricOptionsFor(
|
||||
final coreFieldKeys = <String>{
|
||||
if (batteryMilliVolts != null || batteryPercentage != null)
|
||||
...extraSensorData?.keys.where(
|
||||
(k) => k.startsWith('voltage_') || k.startsWith('analog_input_'),
|
||||
(k) =>
|
||||
_isSourceChannelMetric(extraSensorData, 'voltage', k) ||
|
||||
_isSourceChannelMetric(extraSensorData, 'battery', k) ||
|
||||
k.startsWith('analog_input_'),
|
||||
) ??
|
||||
[],
|
||||
if (temperature != null)
|
||||
...extraSensorData?.keys.where((k) => k.startsWith('temperature_')) ?? [],
|
||||
...extraSensorData?.keys.where(
|
||||
(k) => _isSourceChannelMetric(extraSensorData, 'temperature', k),
|
||||
) ??
|
||||
[],
|
||||
if (humidity != null)
|
||||
...extraSensorData?.keys.where((k) => k.startsWith('humidity_')) ?? [],
|
||||
...extraSensorData?.keys.where(
|
||||
(k) => _isSourceChannelMetric(extraSensorData, 'humidity', k),
|
||||
) ??
|
||||
[],
|
||||
if (pressure != null)
|
||||
...extraSensorData?.keys.where((k) => k.startsWith('pressure_')) ?? [],
|
||||
...extraSensorData?.keys.where(
|
||||
(k) => _isSourceChannelMetric(extraSensorData, 'pressure', k),
|
||||
) ??
|
||||
[],
|
||||
};
|
||||
|
||||
if (extraSensorData != null) {
|
||||
@@ -3117,6 +3129,18 @@ int? _sourceChannelForField(
|
||||
return null;
|
||||
}
|
||||
|
||||
bool _isSourceChannelMetric(
|
||||
Map<String, dynamic>? extraSensorData,
|
||||
String fieldKey,
|
||||
String metricKey,
|
||||
) {
|
||||
final sourceChannel = _sourceChannelForField(extraSensorData, fieldKey);
|
||||
if (sourceChannel == null) {
|
||||
return false;
|
||||
}
|
||||
return metricKey == '${fieldKey}_$sourceChannel';
|
||||
}
|
||||
|
||||
String _resolvedMetricLabel(
|
||||
String fieldKey,
|
||||
String defaultLabel, {
|
||||
|
||||
@@ -926,7 +926,9 @@ void main() {
|
||||
);
|
||||
provider.markMessageSent('m2', 88, 10);
|
||||
|
||||
async.elapse(const Duration(milliseconds: 11));
|
||||
final timeoutMs = provider.messages.single.suggestedTimeoutMs!;
|
||||
|
||||
async.elapse(Duration(milliseconds: timeoutMs + 1));
|
||||
async.flushMicrotasks();
|
||||
|
||||
expect(provider.messages.single.retryAttempt, 1);
|
||||
|
||||
@@ -201,7 +201,10 @@ void main() {
|
||||
addTearDown(tester.view.reset);
|
||||
|
||||
final connectionProvider = _TcpConnectableFakeConnectionProvider();
|
||||
final networkScanner = _FakeNetworkScannerService(initiallyScanning: true);
|
||||
final networkScanner = _FakeNetworkScannerService(
|
||||
initiallyScanning: true,
|
||||
keepScanning: true,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(
|
||||
ChangeNotifierProvider<ConnectionProvider>.value(
|
||||
|
||||
@@ -5,6 +5,7 @@ import 'package:http/http.dart' as http;
|
||||
import 'package:http/testing.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'package:meshcore_sar_app/l10n/app_localizations.dart';
|
||||
import 'package:meshcore_sar_app/services/traffic_stats_reporting_service.dart';
|
||||
import 'package:meshcore_sar_app/widgets/settings/traffic_stats_reporting_section.dart';
|
||||
|
||||
@@ -57,6 +58,8 @@ void main() {
|
||||
|
||||
await tester.pumpWidget(
|
||||
MaterialApp(
|
||||
localizationsDelegates: AppLocalizations.localizationsDelegates,
|
||||
supportedLocales: AppLocalizations.supportedLocales,
|
||||
home: Scaffold(
|
||||
body: ListenableBuilder(
|
||||
listenable: service,
|
||||
@@ -68,27 +71,22 @@ void main() {
|
||||
),
|
||||
);
|
||||
|
||||
expect(find.text('Anonymous RX stats reporting'), findsOneWidget);
|
||||
expect(
|
||||
find.text(
|
||||
'Upload RX live-traffic packet type and path mode totals to the fixed Cloudflare worker every 5 minutes.',
|
||||
),
|
||||
findsOneWidget,
|
||||
);
|
||||
expect(find.text('Anonymous RX stats'), findsOneWidget);
|
||||
expect(find.text('Upload packet totals every 5 min'), findsOneWidget);
|
||||
expect(find.text('Reporting interval'), findsNothing);
|
||||
expect(service.isEnabled, isTrue);
|
||||
|
||||
await tester.tap(find.widgetWithText(TextButton, 'View'));
|
||||
await tester.pump();
|
||||
|
||||
expect(launchedUrls, ['https://mcstats.dz0ny.dev']);
|
||||
|
||||
await tester.tap(find.byType(Switch));
|
||||
await tester.pumpAndSettle();
|
||||
|
||||
expect(service.isEnabled, isFalse);
|
||||
expect(service.intervalMinutes, 5);
|
||||
|
||||
await tester.tap(find.widgetWithText(TextButton, 'View public stats'));
|
||||
await tester.pump();
|
||||
|
||||
expect(launchedUrls, ['https://mcstats.dz0ny.dev']);
|
||||
|
||||
service.dispose();
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user