mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-12 00:40:28 +00:00
fix: retain voice codec settings now
ref:
This commit is contained in:
@@ -10,12 +10,15 @@ extension MessageLocalization on Message {
|
||||
|
||||
// For channel messages, show echo count instead of delivery status
|
||||
if (isChannelMessage && deliveryStatus == MessageDeliveryStatus.sent) {
|
||||
final latestMeta = _formatEchoMeta(context);
|
||||
if (echoCount == 0) {
|
||||
return l10n.broadcast; // "Broadcast (no echoes yet)"
|
||||
} else if (echoCount == 1) {
|
||||
return 'Rebroadcast by 1 node';
|
||||
return latestMeta == null ? '1 node' : '1 node • $latestMeta';
|
||||
} else {
|
||||
return 'Rebroadcast by $echoCount nodes';
|
||||
return latestMeta == null
|
||||
? '$echoCount nodes'
|
||||
: '$echoCount nodes • $latestMeta';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,4 +49,53 @@ extension MessageLocalization on Message {
|
||||
if (diff.inHours < 24) return l10n.hoursAgo(diff.inHours);
|
||||
return l10n.daysAgo(diff.inDays);
|
||||
}
|
||||
|
||||
String? _formatEchoMeta(BuildContext context) {
|
||||
if (lastEchoSnrRaw == null &&
|
||||
lastEchoRssiDbm == null &&
|
||||
lastEchoAt == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
final parts = <String>[];
|
||||
if (lastEchoRssiDbm != null) {
|
||||
parts.add('R ${_barsForRssi(lastEchoRssiDbm!)} $lastEchoRssiDbm dBm');
|
||||
}
|
||||
if (lastEchoSnrRaw != null) {
|
||||
final snrDb = lastEchoSnrRaw!.toSigned(8) / 4.0;
|
||||
parts.add('S ${_barsForSnr(snrDb)} ${snrDb.toStringAsFixed(1)} dB');
|
||||
}
|
||||
if (lastEchoAt != null) {
|
||||
final diff = DateTime.now().difference(lastEchoAt!);
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
if (diff.inMinutes < 1) {
|
||||
parts.add(l10n.justNow);
|
||||
} else if (diff.inMinutes < 60) {
|
||||
parts.add(l10n.minutesAgo(diff.inMinutes));
|
||||
} else if (diff.inHours < 24) {
|
||||
parts.add(l10n.hoursAgo(diff.inHours));
|
||||
} else {
|
||||
parts.add(l10n.daysAgo(diff.inDays));
|
||||
}
|
||||
}
|
||||
|
||||
if (parts.isEmpty) return null;
|
||||
return parts.join(' • ');
|
||||
}
|
||||
|
||||
String _barsForRssi(int rssiDbm) {
|
||||
// Approximate useful RSSI range: -120..-70 dBm
|
||||
final score = ((rssiDbm + 120) / 10).round().clamp(0, 5);
|
||||
return _asciiBars(score, 5);
|
||||
}
|
||||
|
||||
String _barsForSnr(double snrDb) {
|
||||
// Approximate useful SNR range: -5..+20 dB
|
||||
final score = ((snrDb + 5.0) / 5.0).round().clamp(0, 5);
|
||||
return _asciiBars(score, 5);
|
||||
}
|
||||
|
||||
String _asciiBars(int filled, int total) {
|
||||
return '[${'#' * filled}${'-' * (total - filled)}]';
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user