Merge branch 'dev' of https://github.com/zjs81/meshcore-open into fold_path_size_into_radio_presets

This commit is contained in:
shortwavesurfer2009 committed 2026-10-12 09:26:06 -04:00
commit f8a9922ba4
231 files changed
+45401 -9099

No files matched your search

+44
View File
@@ -91,6 +91,7 @@ class AppSettings {
final bool mapShowGuessedLocations;
final bool mapClusterNodes;
final bool enableMessageTracing;
final bool regionOnHopsLine;
final Map<String, double>? mapCacheBounds;
final int mapCacheMinZoom;
final int mapCacheMaxZoom;
@@ -112,6 +113,10 @@ class AppSettings {
final bool channelMinHopsEnabled;
final int channelMinHops;
final int channelMinHopsRetries;
/// When on, hearing the message repeated by at least [channelMinHops]
/// different first-hop repeaters also satisfies the channel resend.
final bool channelMinHopsCountRepeaters;
final String themeMode;
final String? languageOverride; // null = system default
final bool appDebugLogEnabled;
@@ -120,11 +125,18 @@ class AppSettings {
final UnitSystem unitSystem;
final Set<String> mutedChannels;
final bool mapShowDiscoveryContacts;
final bool evictDiscoveredContactsEnabled;
final String tcpServerAddress;
final int tcpServerPort;
final bool jumpToOldestUnread;
final bool imageMessagesEnabled;
/// Opt-in upload of header-only packet records to the network map.
final bool networkMapUploadEnabled;
/// Whether the one-time network map opt-in dialog has been shown.
final bool networkMapPromptShown;
/// Whether a received image is decoded as soon as it is reassembled.
///
/// Off by default and deliberately so: a decode peaks around 2.16 GiB
@@ -197,6 +209,7 @@ class AppSettings {
this.mapShowGuessedLocations = true,
this.mapClusterNodes = true,
this.enableMessageTracing = false,
this.regionOnHopsLine = false,
this.mapCacheBounds,
this.mapCacheMinZoom = 10,
this.mapCacheMaxZoom = 15,
@@ -218,6 +231,7 @@ class AppSettings {
this.channelMinHopsEnabled = false,
this.channelMinHops = 2,
this.channelMinHopsRetries = 1,
this.channelMinHopsCountRepeaters = false,
this.themeMode = 'system',
this.languageOverride,
this.appDebugLogEnabled = false,
@@ -226,10 +240,13 @@ class AppSettings {
this.unitSystem = UnitSystem.metric,
Set<String>? mutedChannels,
this.mapShowDiscoveryContacts = true,
this.evictDiscoveredContactsEnabled = true,
this.tcpServerAddress = '',
this.tcpServerPort = 0,
this.jumpToOldestUnread = false,
this.imageMessagesEnabled = false,
this.networkMapUploadEnabled = false,
this.networkMapPromptShown = false,
this.imageProcessAutomatically = false,
this.imageCodecEnabled = false,
this.imageCodecSelectedModelId,
@@ -275,6 +292,7 @@ class AppSettings {
'map_show_guessed_locations': mapShowGuessedLocations,
'map_cluster_nodes': mapClusterNodes,
'enable_message_tracing': enableMessageTracing,
'region_on_hops_line': regionOnHopsLine,
'map_cache_bounds': mapCacheBounds,
'map_cache_min_zoom': mapCacheMinZoom,
'map_cache_max_zoom': mapCacheMaxZoom,
@@ -297,6 +315,7 @@ class AppSettings {
'channel_min_hops_enabled': channelMinHopsEnabled,
'channel_min_hops': channelMinHops,
'channel_min_hops_retries': channelMinHopsRetries,
'channel_min_hops_count_repeaters': channelMinHopsCountRepeaters,
'theme_mode': themeMode,
'language_override': languageOverride,
'app_debug_log_enabled': appDebugLogEnabled,
@@ -305,10 +324,13 @@ class AppSettings {
'unit_system': unitSystem.value,
'muted_channels': mutedChannels.toList(),
'map_show_discovery_contacts': mapShowDiscoveryContacts,
'evict_discovered_contacts_enabled': evictDiscoveredContactsEnabled,
'tcp_server_address': tcpServerAddress,
'tcp_server_port': tcpServerPort,
'jump_to_oldest_unread': jumpToOldestUnread,
'image_messages_enabled': imageMessagesEnabled,
'network_map_upload_enabled': networkMapUploadEnabled,
'network_map_prompt_shown': networkMapPromptShown,
'image_process_automatically': imageProcessAutomatically,
'image_codec_enabled': imageCodecEnabled,
'image_codec_selected_model_id': imageCodecSelectedModelId,
@@ -356,6 +378,7 @@ class AppSettings {
json['map_show_guessed_locations'] as bool? ?? true,
mapClusterNodes: json['map_cluster_nodes'] as bool? ?? true,
enableMessageTracing: json['enable_message_tracing'] as bool? ?? false,
regionOnHopsLine: json['region_on_hops_line'] as bool? ?? false,
mapCacheBounds: (json['map_cache_bounds'] as Map?)?.map(
(key, value) => MapEntry(key.toString(), (value as num).toDouble()),
),
@@ -386,6 +409,8 @@ class AppSettings {
channelMinHopsEnabled: json['channel_min_hops_enabled'] as bool? ?? false,
channelMinHops: json['channel_min_hops'] as int? ?? 2,
channelMinHopsRetries: json['channel_min_hops_retries'] as int? ?? 1,
channelMinHopsCountRepeaters:
json['channel_min_hops_count_repeaters'] as bool? ?? false,
themeMode: json['theme_mode'] as String? ?? 'system',
languageOverride: json['language_override'] as String?,
appDebugLogEnabled: json['app_debug_log_enabled'] as bool? ?? false,
@@ -407,10 +432,15 @@ class AppSettings {
{},
mapShowDiscoveryContacts:
json['map_show_discovery_contacts'] as bool? ?? true,
evictDiscoveredContactsEnabled:
json['evict_discovered_contacts_enabled'] as bool? ?? true,
tcpServerAddress: json['tcp_server_address'] as String? ?? '',
tcpServerPort: json['tcp_server_port'] as int? ?? 0,
jumpToOldestUnread: json['jump_to_oldest_unread'] as bool? ?? false,
imageMessagesEnabled: json['image_messages_enabled'] as bool? ?? false,
networkMapUploadEnabled:
json['network_map_upload_enabled'] as bool? ?? false,
networkMapPromptShown: json['network_map_prompt_shown'] as bool? ?? false,
imageProcessAutomatically:
json['image_process_automatically'] as bool? ?? false,
imageCodecEnabled: json['image_codec_enabled'] as bool? ?? false,
@@ -495,6 +525,7 @@ class AppSettings {
bool? mapShowGuessedLocations,
bool? mapClusterNodes,
bool? enableMessageTracing,
bool? regionOnHopsLine,
Object? mapCacheBounds = _unset,
int? mapCacheMinZoom,
int? mapCacheMaxZoom,
@@ -516,6 +547,7 @@ class AppSettings {
bool? channelMinHopsEnabled,
int? channelMinHops,
int? channelMinHopsRetries,
bool? channelMinHopsCountRepeaters,
String? themeMode,
Object? languageOverride = _unset,
bool? appDebugLogEnabled,
@@ -524,10 +556,13 @@ class AppSettings {
UnitSystem? unitSystem,
Set<String>? mutedChannels,
bool? mapShowDiscoveryContacts,
bool? evictDiscoveredContactsEnabled,
String? tcpServerAddress,
int? tcpServerPort,
bool? jumpToOldestUnread,
bool? imageMessagesEnabled,
bool? networkMapUploadEnabled,
bool? networkMapPromptShown,
bool? imageProcessAutomatically,
bool? imageCodecEnabled,
Object? imageCodecSelectedModelId = _unset,
@@ -558,6 +593,7 @@ class AppSettings {
mapShowGuessedLocations ?? this.mapShowGuessedLocations,
mapClusterNodes: mapClusterNodes ?? this.mapClusterNodes,
enableMessageTracing: enableMessageTracing ?? this.enableMessageTracing,
regionOnHopsLine: regionOnHopsLine ?? this.regionOnHopsLine,
mapCacheBounds: mapCacheBounds == _unset
? this.mapCacheBounds
: mapCacheBounds as Map<String, double>?,
@@ -591,6 +627,8 @@ class AppSettings {
channelMinHops: channelMinHops ?? this.channelMinHops,
channelMinHopsRetries:
channelMinHopsRetries ?? this.channelMinHopsRetries,
channelMinHopsCountRepeaters:
channelMinHopsCountRepeaters ?? this.channelMinHopsCountRepeaters,
themeMode: themeMode ?? this.themeMode,
languageOverride: languageOverride == _unset
? this.languageOverride
@@ -604,10 +642,16 @@ class AppSettings {
mutedChannels: mutedChannels ?? this.mutedChannels,
mapShowDiscoveryContacts:
mapShowDiscoveryContacts ?? this.mapShowDiscoveryContacts,
evictDiscoveredContactsEnabled:
evictDiscoveredContactsEnabled ?? this.evictDiscoveredContactsEnabled,
tcpServerAddress: tcpServerAddress ?? this.tcpServerAddress,
tcpServerPort: tcpServerPort ?? this.tcpServerPort,
jumpToOldestUnread: jumpToOldestUnread ?? this.jumpToOldestUnread,
imageMessagesEnabled: imageMessagesEnabled ?? this.imageMessagesEnabled,
networkMapUploadEnabled:
networkMapUploadEnabled ?? this.networkMapUploadEnabled,
networkMapPromptShown:
networkMapPromptShown ?? this.networkMapPromptShown,
imageProcessAutomatically:
imageProcessAutomatically ?? this.imageProcessAutomatically,
imageCodecEnabled: imageCodecEnabled ?? this.imageCodecEnabled,
+19
View File
@@ -25,6 +25,25 @@ class Channel {
bool get isEmpty => name.isEmpty && psk.every((b) => b == 0);
/// Key for this channel's persisted data (messages, settings, region,
/// order, images). Derived from the PSK so it follows the channel across
/// radio slots; null for an empty slot.
late final String? storageId = storageIdForPsk(psk);
static const String _storageIdDomain = 'meshcore-channel:';
/// First 8 bytes of SHA-256("meshcore-channel:" + psk) as 16 hex chars, or
/// null for an all-zero PSK. Not the 1-byte on-air channel hash, which
/// collides.
static String? storageIdForPsk(Uint8List psk) {
if (psk.every((b) => b == 0)) return null;
final digest = crypto.sha256.convert([
...utf8.encode(_storageIdDomain),
...psk,
]);
return _bytesToHex(Uint8List.fromList(digest.bytes.sublist(0, 8)));
}
/// Key used for per-channel notification muting.
String get muteKey => name.isEmpty ? 'Channel $index' : name;
+17 -1
View File
@@ -2,6 +2,7 @@ import 'dart:typed_data';
import '../connector/meshcore_protocol.dart';
import '../helpers/reaction_helper.dart';
import '../helpers/smaz.dart';
import 'message.dart' show futureTimestampTolerance;
import 'translation_support.dart';
import '../utils/app_logger.dart';
@@ -36,6 +37,11 @@ class ChannelMessage {
final MessageTranslationStatus translationStatus;
final String? translationModelId;
final DateTime timestamp;
/// Local clock time when this message was added (received or sent). Feeds
/// are ordered by it so a sender clock running ahead cannot pin a message
/// to the bottom; [timestamp] stays the sender's identity time.
final DateTime receivedAt;
final bool isOutgoing;
final ChannelMessageStatus status;
final List<Repeat> repeats;
@@ -63,6 +69,7 @@ class ChannelMessage {
this.translationStatus = MessageTranslationStatus.none,
this.translationModelId,
required this.timestamp,
DateTime? receivedAt,
required this.isOutgoing,
this.status = ChannelMessageStatus.pending,
this.repeats = const [],
@@ -82,6 +89,7 @@ class ChannelMessage {
}) : messageId =
messageId ??
'${timestamp.millisecondsSinceEpoch}_${senderName.hashCode}_${text.hashCode}',
receivedAt = receivedAt ?? timestamp,
reactions = reactions ?? {},
pathBytes = pathBytes ?? Uint8List(0),
pathVariants = _mergePathVariants(
@@ -92,6 +100,11 @@ class ChannelMessage {
String? get senderKeyHex =>
senderKey != null ? pubKeyToHex(senderKey!) : null;
/// True when the sender's clock put [timestamp] clearly ahead of the time
/// this device received the message.
bool get hasFutureTimestamp =>
timestamp.difference(receivedAt) > futureTimestampTolerance;
ChannelMessage copyWith({
ChannelMessageStatus? status,
List<Repeat>? repeats,
@@ -111,6 +124,7 @@ class ChannelMessage {
MessageTranslationStatus? translationStatus,
Object? translationModelId = _unset,
Map<String, List<String?>>? reactions,
int? channelIndex,
}) {
return ChannelMessage(
senderKey: senderKey,
@@ -130,6 +144,7 @@ class ChannelMessage {
? this.translationModelId
: translationModelId as String?,
timestamp: timestamp,
receivedAt: receivedAt,
isOutgoing: isOutgoing,
status: status ?? this.status,
repeats: repeats ?? this.repeats,
@@ -138,7 +153,7 @@ class ChannelMessage {
pathHashWidth: pathHashWidth ?? this.pathHashWidth,
pathBytes: pathBytes ?? this.pathBytes,
pathVariants: pathVariants ?? this.pathVariants,
channelIndex: channelIndex,
channelIndex: channelIndex ?? this.channelIndex,
region: region == _unset ? this.region : region as String?,
messageId: messageId,
packetHash: packetHash ?? this.packetHash,
@@ -225,6 +240,7 @@ class ChannelMessage {
senderName: senderName,
text: decodedText,
timestamp: DateTime.fromMillisecondsSinceEpoch(timestampRaw * 1000),
receivedAt: DateTime.now(),
isOutgoing: false,
status: ChannelMessageStatus.sent,
pathLength: pathLen,
-2
View File
@@ -20,7 +20,6 @@ class Contact {
final DateTime lastMessageAt;
final DateTime? lastModified;
final bool isActive;
final bool wasPulled;
final Uint8List? rawPacket;
Contact({
@@ -39,7 +38,6 @@ class Contact {
this.lastModified,
DateTime? lastMessageAt,
this.isActive = true,
this.wasPulled = false,
this.rawPacket,
}) : lastMessageAt = lastMessageAt ?? lastSeen;
+31
View File
@@ -5,12 +5,34 @@ import 'translation_support.dart';
enum MessageStatus { pending, sent, delivered, failed }
/// How far a sender timestamp may run ahead of the local receive time before
/// the UI flags it as a wrong clock.
const Duration futureTimestampTolerance = Duration(minutes: 5);
/// Receive time for a persisted message JSON record. Records written before
/// `receivedAt` existed fall back to the sender timestamp, capped at now so a
/// stored future-dated message stops sorting below everything received later.
DateTime legacyAwareReceivedAt(Map<String, dynamic> json) {
final stored = json['receivedAt'];
if (stored is int) return DateTime.fromMillisecondsSinceEpoch(stored);
final timestamp = DateTime.fromMillisecondsSinceEpoch(
json['timestamp'] as int,
);
final now = DateTime.now();
return timestamp.isAfter(now) ? now : timestamp;
}
class Message {
static const Object _unset = Object();
final Uint8List senderKey; // For outgoing msgs, gets used as recipientKey
final String text;
final DateTime timestamp;
/// Local clock time when this message was added (received or sent). Feeds
/// are ordered by it so a sender clock running ahead cannot pin a message
/// to the bottom; [timestamp] stays the sender's identity time.
final DateTime receivedAt;
final bool isOutgoing;
final bool isCli;
final MessageStatus status;
@@ -38,6 +60,7 @@ class Message {
required this.senderKey,
required this.text,
required this.timestamp,
DateTime? receivedAt,
required this.isOutgoing,
this.isCli = false,
this.status = MessageStatus.pending,
@@ -61,6 +84,7 @@ class Message {
}) : messageId =
messageId ??
'${timestamp.millisecondsSinceEpoch}_${pubKeyToHex(senderKey)}_${text.hashCode}',
receivedAt = receivedAt ?? timestamp,
pathBytes = pathBytes ?? Uint8List(0),
fourByteRoomContactKey = fourByteRoomContactKey ?? Uint8List(0),
reactions = reactions ?? {},
@@ -68,6 +92,11 @@ class Message {
String get senderKeyHex => pubKeyToHex(senderKey);
/// True when the sender's clock put [timestamp] clearly ahead of the time
/// this device received the message.
bool get hasFutureTimestamp =>
timestamp.difference(receivedAt) > futureTimestampTolerance;
Message copyWith({
MessageStatus? status,
int? retryCount,
@@ -92,6 +121,7 @@ class Message {
senderKey: senderKey,
text: text,
timestamp: timestamp,
receivedAt: receivedAt,
isOutgoing: isOutgoing,
isCli: isCli ?? this.isCli,
status: status ?? this.status,
@@ -145,6 +175,7 @@ class Message {
senderKey: senderKey,
text: text,
timestamp: DateTime.fromMillisecondsSinceEpoch(timestampRaw * 1000),
receivedAt: DateTime.now(),
isOutgoing: false,
isCli: false,
status: MessageStatus.delivered,