mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
Fix channel refresh telemetry how
This commit is contained in:
@@ -1257,6 +1257,10 @@ class ConnectionProvider with ChangeNotifier {
|
|||||||
channelName: channelName,
|
channelName: channelName,
|
||||||
secret: secretBytes,
|
secret: secretBytes,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Reconcile local state from the device after the write completes,
|
||||||
|
// matching the delete flow so channel/contact lists refresh immediately.
|
||||||
|
await _activeService.getChannel(slotIdx);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (_isChannelRefreshTimeoutError(e)) {
|
if (_isChannelRefreshTimeoutError(e)) {
|
||||||
debugPrint(
|
debugPrint(
|
||||||
|
|||||||
@@ -875,7 +875,7 @@ class ContactsProvider with ChangeNotifier {
|
|||||||
telemetry.gpsLocation,
|
telemetry.gpsLocation,
|
||||||
)) {
|
)) {
|
||||||
debugPrint(
|
debugPrint(
|
||||||
' ⚠️ Retaining last valid GPS. Incoming telemetry GPS is invalid/missing: $incomingGps',
|
' ⚠️ Incoming telemetry GPS is invalid/missing; keeping last known contact location as fallback: $incomingGps',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
telemetry = ContactTelemetry(
|
telemetry = ContactTelemetry(
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ void main() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test(
|
test(
|
||||||
'retains last valid gps for any contact when telemetry gps is invalid or missing',
|
'clears telemetry gps on refresh when gps is invalid or missing but keeps fallback display location',
|
||||||
() {
|
() {
|
||||||
final contactTypes = <ContactType>[
|
final contactTypes = <ContactType>[
|
||||||
ContactType.chat,
|
ContactType.chat,
|
||||||
@@ -165,23 +165,24 @@ void main() {
|
|||||||
);
|
);
|
||||||
scopedProvider.updateTelemetry(scopedKey.sublist(0, 6), validGps);
|
scopedProvider.updateTelemetry(scopedKey.sublist(0, 6), validGps);
|
||||||
|
|
||||||
// No GPS frame should keep previous valid GPS.
|
// No GPS frame should clear telemetry GPS but keep the last known
|
||||||
|
// contact location as display fallback.
|
||||||
final batteryOnly = CayenneLppParser.createBatteryData(3.8);
|
final batteryOnly = CayenneLppParser.createBatteryData(3.8);
|
||||||
scopedProvider.updateTelemetry(scopedKey.sublist(0, 6), batteryOnly);
|
scopedProvider.updateTelemetry(scopedKey.sublist(0, 6), batteryOnly);
|
||||||
|
|
||||||
var updated = scopedProvider.findContactByKey(scopedKey)!;
|
var updated = scopedProvider.findContactByKey(scopedKey)!;
|
||||||
expect(updated.telemetry, isNotNull);
|
expect(updated.telemetry, isNotNull);
|
||||||
expect(updated.telemetry!.gpsLocation, isNotNull);
|
expect(updated.telemetry!.gpsLocation, isNull);
|
||||||
expect(
|
expect(
|
||||||
updated.telemetry!.gpsLocation!.latitude,
|
updated.displayLocation!.latitude,
|
||||||
closeTo(45.1234, 0.0001),
|
closeTo(45.1234, 0.0001),
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
updated.telemetry!.gpsLocation!.longitude,
|
updated.displayLocation!.longitude,
|
||||||
closeTo(13.8765, 0.0001),
|
closeTo(13.8765, 0.0001),
|
||||||
);
|
);
|
||||||
|
|
||||||
// Invalid 0,0 GPS frame should also keep previous valid GPS.
|
// Invalid 0,0 GPS frame should behave the same way.
|
||||||
final invalidGps = CayenneLppParser.createGpsData(
|
final invalidGps = CayenneLppParser.createGpsData(
|
||||||
latitude: 0.0,
|
latitude: 0.0,
|
||||||
longitude: 0.0,
|
longitude: 0.0,
|
||||||
@@ -190,13 +191,13 @@ void main() {
|
|||||||
|
|
||||||
updated = scopedProvider.findContactByKey(scopedKey)!;
|
updated = scopedProvider.findContactByKey(scopedKey)!;
|
||||||
expect(updated.telemetry, isNotNull);
|
expect(updated.telemetry, isNotNull);
|
||||||
expect(updated.telemetry!.gpsLocation, isNotNull);
|
expect(updated.telemetry!.gpsLocation, isNull);
|
||||||
expect(
|
expect(
|
||||||
updated.telemetry!.gpsLocation!.latitude,
|
updated.displayLocation!.latitude,
|
||||||
closeTo(45.1234, 0.0001),
|
closeTo(45.1234, 0.0001),
|
||||||
);
|
);
|
||||||
expect(
|
expect(
|
||||||
updated.telemetry!.gpsLocation!.longitude,
|
updated.displayLocation!.longitude,
|
||||||
closeTo(13.8765, 0.0001),
|
closeTo(13.8765, 0.0001),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -360,13 +361,22 @@ void main() {
|
|||||||
|
|
||||||
final updated = provider.findContactByKey(publicKey)!;
|
final updated = provider.findContactByKey(publicKey)!;
|
||||||
expect(updated.telemetry, isNotNull);
|
expect(updated.telemetry, isNotNull);
|
||||||
expect(updated.telemetry!.gpsLocation, const LatLng(46.0569, 14.5058));
|
expect(updated.telemetry!.gpsLocation, isNull);
|
||||||
|
expect(updated.displayLocation, const LatLng(46.0569, 14.5058));
|
||||||
expect(updated.telemetry!.batteryMilliVolts, isNotNull);
|
expect(updated.telemetry!.batteryMilliVolts, isNotNull);
|
||||||
expect(updated.telemetry!.batteryPercentage, isNotNull);
|
expect(updated.telemetry!.batteryPercentage, isNotNull);
|
||||||
expect(updated.telemetry!.temperature, equals(19.5));
|
expect(updated.telemetry!.temperature, equals(19.5));
|
||||||
expect(updated.telemetry!.humidity, equals(58.0));
|
expect(updated.telemetry!.humidity, equals(58.0));
|
||||||
expect(updated.telemetry!.pressure, equals(1011.2));
|
expect(updated.telemetry!.pressure, equals(1011.2));
|
||||||
expect(updated.telemetry!.extraSensorData, isNull);
|
expect(
|
||||||
|
updated.telemetry!.extraSensorData,
|
||||||
|
containsPair('__source_channel:battery', 0),
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
updated.telemetry!.extraSensorData,
|
||||||
|
containsPair('__source_channel:voltage', 0),
|
||||||
|
);
|
||||||
|
expect(updated.telemetry!.extraSensorData, isNot(contains('pm25')));
|
||||||
});
|
});
|
||||||
|
|
||||||
test('replaces old source-channel mappings when a metric moves channels', () {
|
test('replaces old source-channel mappings when a metric moves channels', () {
|
||||||
|
|||||||
Reference in New Issue
Block a user