mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
refactor: extract BLE protocol stack into meshcore_client package
Move BLE communication layer (command queue, frame parser/builder, protocol constants, data models) into a standalone reusable Dart package at ../meshcore_client. App model files become thin re-export wrappers, keeping all existing consumers working without import changes.
This commit is contained in:
@@ -1,40 +1 @@
|
||||
import 'package:latlong2/latlong.dart';
|
||||
|
||||
/// Single advertisement location point in a contact's movement history
|
||||
class AdvertLocation {
|
||||
final LatLng location;
|
||||
final DateTime timestamp;
|
||||
|
||||
AdvertLocation({
|
||||
required this.location,
|
||||
required this.timestamp,
|
||||
});
|
||||
|
||||
/// Get friendly time ago display
|
||||
String get timeAgo {
|
||||
final diff = DateTime.now().difference(timestamp);
|
||||
if (diff.inMinutes < 1) return 'Just now';
|
||||
if (diff.inMinutes < 60) return '${diff.inMinutes}m ago';
|
||||
if (diff.inHours < 24) return '${diff.inHours}h ago';
|
||||
return '${diff.inDays}d ago';
|
||||
}
|
||||
|
||||
@override
|
||||
String toString() {
|
||||
return 'AdvertLocation(lat: ${location.latitude.toStringAsFixed(6)}, '
|
||||
'lon: ${location.longitude.toStringAsFixed(6)}, '
|
||||
'time: ${timestamp.toIso8601String()})';
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(Object other) {
|
||||
if (identical(this, other)) return true;
|
||||
return other is AdvertLocation &&
|
||||
other.location.latitude == location.latitude &&
|
||||
other.location.longitude == location.longitude &&
|
||||
other.timestamp == timestamp;
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hash(location.latitude, location.longitude, timestamp);
|
||||
}
|
||||
export 'package:meshcore_client/meshcore_client.dart' show AdvertLocation;
|
||||
|
||||
Reference in New Issue
Block a user