mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
Add localization support for German, Spanish, French, and Italian
- Updated localization files for French, Croatian, Italian, Slovenian to include translations for German, Spanish, French, and Italian. - Added new methods for handling drawing messages sent to the public channel in multiple languages. - Enhanced the Contact model to identify public channels using a dedicated method. - Implemented echo detection for public channel messages, including tracking and reporting of echoes. - Updated BLE response handling to support echo detection and tracking of sent messages. - Modified UI components to reflect new localization strings and echo statuses.
This commit is contained in:
@@ -208,6 +208,12 @@ class AppProvider with ChangeNotifier {
|
||||
messagesProvider.markMessageDelivered(ackCode, roundTripTimeMs);
|
||||
};
|
||||
|
||||
// When an echo is detected for a public channel message (PUSH_CODE_LOG_RX_DATA matched)
|
||||
connectionProvider.onMessageEchoDetected = (messageId, echoCount, snrRaw, rssiDbm) {
|
||||
debugPrint('🔊 [AppProvider] Echo detected - Message: $messageId, Count: $echoCount');
|
||||
messagesProvider.handleMessageEcho(messageId, echoCount, snrRaw, rssiDbm);
|
||||
};
|
||||
|
||||
// Wire up MessagesProvider's sendMessageCallback for retry logic
|
||||
messagesProvider.sendMessageCallback = ({
|
||||
required contactPublicKey,
|
||||
@@ -284,7 +290,7 @@ class AppProvider with ChangeNotifier {
|
||||
try {
|
||||
// Get all room contacts (excluding Public Channel)
|
||||
final rooms = contactsProvider.rooms
|
||||
.where((room) => room.advName != 'Public Channel')
|
||||
.where((room) => !room.isPublicChannel)
|
||||
.toList();
|
||||
|
||||
if (rooms.isEmpty) {
|
||||
|
||||
@@ -133,6 +133,8 @@ class ConnectionProvider with ChangeNotifier {
|
||||
Function(String messageId, int expectedAckTag, int suggestedTimeoutMs)?
|
||||
onMessageSent;
|
||||
Function(int ackCode, int roundTripTimeMs)? onMessageDelivered;
|
||||
Function(String messageId, int echoCount, int snrRaw, int rssiDbm)?
|
||||
onMessageEchoDetected;
|
||||
Function(Uint8List publicKeyPrefix, Uint8List statusData)? onStatusResponse;
|
||||
|
||||
// Track pending send operations for auto-recovery
|
||||
@@ -381,6 +383,13 @@ class ConnectionProvider with ChangeNotifier {
|
||||
onMessageDelivered?.call(ackCode, roundTripTimeMs);
|
||||
};
|
||||
|
||||
_bleService.onMessageEchoDetected = (messageId, echoCount, snrRaw, rssiDbm) {
|
||||
print(
|
||||
'🔊 [Provider] Echo detected - Message: $messageId, Count: $echoCount',
|
||||
);
|
||||
onMessageEchoDetected?.call(messageId, echoCount, snrRaw, rssiDbm);
|
||||
};
|
||||
|
||||
_bleService.onStatusResponse = (publicKeyPrefix, statusData) {
|
||||
print('📥 [Provider] Status response received from node');
|
||||
print(
|
||||
@@ -774,8 +783,16 @@ class ConnectionProvider with ChangeNotifier {
|
||||
}
|
||||
|
||||
try {
|
||||
debugPrint('📨 [ConnectionProvider] sendChannelMessage called:');
|
||||
debugPrint(' Channel: $channelIdx');
|
||||
debugPrint(' Text: $text');
|
||||
debugPrint(' MessageID: $messageId');
|
||||
|
||||
await _bleService.sendChannelMessage(channelIdx: channelIdx, text: text);
|
||||
|
||||
debugPrint('✅ [ConnectionProvider] BLE send completed');
|
||||
debugPrint(' Checking messageId: ${messageId != null ? "Present ($messageId)" : "NULL"}');
|
||||
|
||||
// Channel messages are ephemeral (not persisted) - mark as "sent" immediately
|
||||
// They don't have ACK/TAG mechanism like direct messages
|
||||
if (messageId != null) {
|
||||
@@ -783,6 +800,12 @@ class ConnectionProvider with ChangeNotifier {
|
||||
print(' Message ID: $messageId');
|
||||
print(' onMessageSent callback exists: ${onMessageSent != null}');
|
||||
|
||||
// Track for echo detection
|
||||
// The BLE handler will capture the packet via LOG_RX_DATA and associate it
|
||||
debugPrint(' Calling trackSentChannelMessage...');
|
||||
_bleService.trackSentChannelMessage(messageId);
|
||||
debugPrint(' trackSentChannelMessage completed');
|
||||
|
||||
// Small delay to ensure the message is in the MessagesProvider list
|
||||
// before we try to mark it as sent
|
||||
await Future.delayed(const Duration(milliseconds: 50));
|
||||
|
||||
@@ -602,6 +602,36 @@ class MessagesProvider with ChangeNotifier {
|
||||
}
|
||||
}
|
||||
|
||||
/// Handle echo detection for public channel messages
|
||||
void handleMessageEcho(String messageId, int echoCount, int snrRaw, int rssiDbm) {
|
||||
print('🔊 [MessagesProvider] handleMessageEcho called');
|
||||
print(' Message ID: $messageId');
|
||||
print(' Echo count: $echoCount');
|
||||
print(' SNR: ${(snrRaw.toSigned(8) / 4.0).toStringAsFixed(2)} dB');
|
||||
print(' RSSI: ${rssiDbm.toSigned(8)} dBm');
|
||||
|
||||
// Find the message
|
||||
final index = _messages.indexWhere((m) => m.id == messageId);
|
||||
if (index != -1) {
|
||||
final message = _messages[index];
|
||||
print(' ✅ Found message: ${message.text.substring(0, message.text.length > 30 ? 30 : message.text.length)}...');
|
||||
|
||||
// Update echo count
|
||||
final updatedMessage = message.copyWith(
|
||||
echoCount: echoCount,
|
||||
firstEchoAt: message.firstEchoAt ?? DateTime.now(),
|
||||
);
|
||||
_messages[index] = updatedMessage;
|
||||
|
||||
print(' Updated echo count to: $echoCount');
|
||||
_persistMessages();
|
||||
notifyListeners();
|
||||
print(' ✅ Echo update complete, UI notified');
|
||||
} else {
|
||||
print(' ⚠️ Message not found in messages list');
|
||||
}
|
||||
}
|
||||
|
||||
/// Update message status to delivered with RTT
|
||||
void markMessageDelivered(int ackCode, int roundTripTimeMs) {
|
||||
print('🔍 [MessagesProvider] markMessageDelivered called with ACK: $ackCode, RTT: ${roundTripTimeMs}ms');
|
||||
|
||||
Reference in New Issue
Block a user