mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 08:20:36 +00:00
feat: Add fast GPS send logs
This commit is contained in:
@@ -2879,8 +2879,13 @@ class AppProvider with ChangeNotifier {
|
||||
timestampSeconds: DateTime.now().millisecondsSinceEpoch ~/ 1000,
|
||||
);
|
||||
debugPrint(
|
||||
'📍 [AppProvider] Sending fast GPS update ($reason): '
|
||||
'${position.latitude}, ${position.longitude} via channel $channelIdx',
|
||||
'📤 [AppProvider] Fast GPS send '
|
||||
'reason=$reason '
|
||||
'sender=$senderKey6 '
|
||||
'channel=$channelIdx '
|
||||
'lat=${position.latitude} '
|
||||
'lon=${position.longitude} '
|
||||
'ts=${packet.timestampSeconds}',
|
||||
);
|
||||
try {
|
||||
await connectionProvider.sendChannelData(
|
||||
@@ -2888,11 +2893,32 @@ class AppProvider with ChangeNotifier {
|
||||
dataType: MeshCoreConstants.dataTypeDev,
|
||||
payload: packet.encodeBinary(),
|
||||
);
|
||||
debugPrint(
|
||||
'✅ [AppProvider] Fast GPS sent '
|
||||
'sender=$senderKey6 channel=$channelIdx ts=${packet.timestampSeconds}',
|
||||
);
|
||||
} catch (e) {
|
||||
debugPrint('⚠️ [AppProvider] Fast GPS send failed: $e');
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> sendTestFastLocationUpdate() async {
|
||||
if (!connectionProvider.deviceInfo.isConnected) {
|
||||
return false;
|
||||
}
|
||||
|
||||
final position = await locationTrackingService.getCurrentPosition(
|
||||
timeLimit: const Duration(seconds: 10),
|
||||
retryCount: 1,
|
||||
);
|
||||
if (position == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
await _sendFastLocationUpdate(position, reason: 'test');
|
||||
return true;
|
||||
}
|
||||
|
||||
Contact? _resolveVoiceFetchRequester(VoiceFetchRequest request) {
|
||||
final liveContact = _resolveContactByPrefixHex(request.requesterKey6);
|
||||
if (liveContact != null) {
|
||||
|
||||
@@ -1143,13 +1143,34 @@ class ContactsProvider with ChangeNotifier {
|
||||
),
|
||||
);
|
||||
|
||||
debugPrint(
|
||||
'📥 [ContactsProvider] Fast GPS received '
|
||||
'sender=${packet.senderKey6} '
|
||||
'contact=${contact.displayName} '
|
||||
'contactKey=${contact.publicKeyHex} '
|
||||
'lat=${packet.latitude} '
|
||||
'lon=${packet.longitude} '
|
||||
'ts=${packet.timestampSeconds}',
|
||||
);
|
||||
|
||||
final updatedContact = contact.copyWith(
|
||||
telemetry: updatedTelemetry,
|
||||
lastAdvert: packet.timestampSeconds,
|
||||
lastMod: packet.timestampSeconds,
|
||||
advLat: _coordinateToAdvertMicrodegrees(packet.latitude),
|
||||
advLon: _coordinateToAdvertMicrodegrees(packet.longitude),
|
||||
);
|
||||
_contacts[contact.publicKeyHex] = updatedContact;
|
||||
_estimatedLocations[contact.publicKeyHex] = LatLng(
|
||||
packet.latitude,
|
||||
packet.longitude,
|
||||
);
|
||||
debugPrint(
|
||||
'✅ [ContactsProvider] Fast GPS applied '
|
||||
'contact=${updatedContact.displayName} '
|
||||
'contactKey=${updatedContact.publicKeyHex} '
|
||||
'lastAdvert=${updatedContact.lastAdvert}',
|
||||
);
|
||||
_persistContacts();
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
@@ -426,6 +426,23 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
return 'Channel $channelIdx unavailable';
|
||||
}
|
||||
|
||||
Future<void> _sendTestFastLocationUpdate() async {
|
||||
final appProvider = context.read<AppProvider>();
|
||||
final sent = await appProvider.sendTestFastLocationUpdate();
|
||||
if (!mounted) return;
|
||||
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(
|
||||
content: Text(
|
||||
sent
|
||||
? 'Test fast GPS update sent.'
|
||||
: 'Unable to send test fast GPS update.',
|
||||
),
|
||||
backgroundColor: sent ? Colors.green : Colors.orange,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _editFastLocationChannel() async {
|
||||
final channels =
|
||||
List<Contact>.from(context.read<ContactsProvider>().channels)
|
||||
@@ -1854,6 +1871,15 @@ class _SettingsScreenState extends State<SettingsScreen> {
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: _editFastLocationChannel,
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.send),
|
||||
title: const Text('Test send update'),
|
||||
subtitle: const Text(
|
||||
'Send one fast GPS update immediately to the configured channel.',
|
||||
),
|
||||
trailing: const Icon(Icons.chevron_right),
|
||||
onTap: _sendTestFastLocationUpdate,
|
||||
),
|
||||
ListTile(
|
||||
leading: Icon(Icons.location_on),
|
||||
title: Text(AppLocalizations.of(context)!.locationPermission),
|
||||
|
||||
Reference in New Issue
Block a user