Keep telemetry fixes off the advert timestamp and across full syncs
Writing the telemetry time into lastSeen sent the phone's clock back to the radio as the node's advert timestamp on the next path or flag write, which could later make the radio's record look newer and drop the fix. The fix now records its own telemetryFixAt and leaves lastSeen as the advert time; the map and lists show the later of the two as last heard. A full contact sync (pull to refresh, reconnect) cleared the list before the radio resent it, so fixes were lost even for an unchanged advert. They are now held for the sync and restored onto matching records.
This commit is contained in:
1 parent
979e1a7d2a
commit
dfc4cd54d8
7 files changed
+105
-52
No files matched your search
@@ -52,13 +52,43 @@ void main() {
|
||||
final fixed = connector.contacts.single;
|
||||
expect(fixed.latitude, 11.5);
|
||||
expect(fixed.longitude, 21.5);
|
||||
expect(fixed.lastSeen.isAfter(DateTime(2024)), isTrue);
|
||||
// lastSeen stays the advert time the radio holds (path and flag writes
|
||||
// send it back); the fix only moves lastHeard.
|
||||
final advertTime = DateTime.fromMillisecondsSinceEpoch(1700000000 * 1000);
|
||||
expect(fixed.lastSeen, advertTime);
|
||||
expect(fixed.lastHeard.isAfter(advertTime), isTrue);
|
||||
|
||||
connector.handleFrameForTest(frame);
|
||||
final refreshed = connector.contacts.single;
|
||||
expect(refreshed.latitude, 11.5);
|
||||
expect(refreshed.longitude, 21.5);
|
||||
expect(refreshed.lastSeen, fixed.lastSeen);
|
||||
expect(refreshed.lastSeen, advertTime);
|
||||
expect(refreshed.telemetryFixAt, fixed.telemetryFixAt);
|
||||
});
|
||||
|
||||
test('telemetry fix survives a full contact sync', () {
|
||||
final connector = MeshCoreConnector();
|
||||
final frame = _contactFrame(
|
||||
key,
|
||||
advertTimestamp: 1700000000,
|
||||
lat: 10,
|
||||
lon: 20,
|
||||
);
|
||||
connector.handleFrameForTest(frame);
|
||||
final keyHex = connector.contacts.single.publicKeyHex;
|
||||
connector.updateContactLocationFromTelemetry(keyHex, 11.5, 21.5);
|
||||
|
||||
// A full sync clears the list on CONTACTS_START and the radio resends
|
||||
// the same advert record.
|
||||
connector.handleFrameForTest([respCodeContactsStart]);
|
||||
expect(connector.contacts, isEmpty);
|
||||
connector.handleFrameForTest(frame);
|
||||
connector.handleFrameForTest([respCodeEndOfContacts]);
|
||||
|
||||
final contact = connector.contacts.single;
|
||||
expect(contact.latitude, 11.5);
|
||||
expect(contact.longitude, 21.5);
|
||||
expect(contact.telemetryFixAt, isNotNull);
|
||||
});
|
||||
|
||||
test('a newer advert replaces the telemetry fix', () {
|
||||
@@ -75,7 +105,7 @@ void main() {
|
||||
final contact = connector.contacts.single;
|
||||
expect(contact.latitude, 12);
|
||||
expect(contact.longitude, 22);
|
||||
expect(contact.telemetryFixAdvertSeen, isNull);
|
||||
expect(contact.telemetryFixAt, isNull);
|
||||
});
|
||||
|
||||
test('telemetryGpsFix skips missing and null-island fixes', () {
|
||||
|
||||
Reference in new issue
Block a user