mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
Refactor contacts management and improve path handling
- Updated ContactsProvider to initialize with device public key for filtering out self contacts. - Added methods to check if a contact has a learned routing path and to get path quality indicators. - Enhanced AppProvider to initialize ContactsProvider with device public key. - Modified ConnectionProvider to log path status when sending messages. - Created ContactStorageService for persisting contacts to local storage. - Removed import/export functionality from MapManagementScreen. - Updated UI components in DirectMessageSheet and SarUpdateSheet to use theme colors. - Removed file_picker dependency from pubspec.yaml and generated plugin registrant.
This commit is contained in:
@@ -463,10 +463,12 @@ class ConnectionProvider with ChangeNotifier {
|
||||
/// only that it was queued on the companion radio.
|
||||
///
|
||||
/// [messageId] - optional message ID to track delivery status
|
||||
/// [contact] - optional contact object for path status logging
|
||||
Future<bool> sendTextMessage({
|
||||
required Uint8List contactPublicKey,
|
||||
required String text,
|
||||
String? messageId,
|
||||
Contact? contact,
|
||||
}) async {
|
||||
if (!_bleService.isConnected) {
|
||||
_error = 'Not connected to device';
|
||||
@@ -475,6 +477,18 @@ class ConnectionProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
try {
|
||||
// Log path status if contact info is available
|
||||
if (contact != null) {
|
||||
print('📤 [ConnectionProvider] Sending message to ${contact.advName}');
|
||||
print(' Type: ${contact.type.displayName}');
|
||||
print(' Path status: ${contact.pathDescription}');
|
||||
if (contact.hasPath) {
|
||||
print(' ✅ Using learned path (${contact.outPathLen} bytes)');
|
||||
} else {
|
||||
print(' ⚠️ No path available - will use flood mode');
|
||||
}
|
||||
}
|
||||
|
||||
// IMPORTANT: Track pending message BEFORE sending to avoid race condition
|
||||
// The SENT response can arrive so quickly that if we track after sending,
|
||||
// the callback will fire before we add the message ID to the queue.
|
||||
|
||||
Reference in New Issue
Block a user