Merge branch 'dev' into ez_disable_discoveredContact_eviction_PR
This commit is contained in:
195 files changed
+26503
-6523
No files matched your search
@@ -89,6 +89,7 @@ class AppSettings {
|
||||
final String mapKeyPrefix;
|
||||
final bool mapShowMarkers;
|
||||
final bool mapShowGuessedLocations;
|
||||
final bool mapClusterNodes;
|
||||
final bool enableMessageTracing;
|
||||
final Map<String, double>? mapCacheBounds;
|
||||
final int mapCacheMinZoom;
|
||||
@@ -108,6 +109,9 @@ class AppSettings {
|
||||
final double routeWeightSuccessIncrement;
|
||||
final double routeWeightFailureDecrement;
|
||||
final int maxMessageRetries;
|
||||
final bool channelMinHopsEnabled;
|
||||
final int channelMinHops;
|
||||
final int channelMinHopsRetries;
|
||||
final String themeMode;
|
||||
final String? languageOverride; // null = system default
|
||||
final bool appDebugLogEnabled;
|
||||
@@ -187,12 +191,13 @@ class AppSettings {
|
||||
this.mapShowChatNodes = true,
|
||||
this.mapShowOtherNodes = true,
|
||||
this.mapShowOverlaps = false,
|
||||
this.mapTimeFilterHours = 0, // Default to all time
|
||||
this.mapTimeFilterHours = 168,
|
||||
this.mapKeyPrefixEnabled = false,
|
||||
this.mapKeyPrefix = '',
|
||||
this.mapShowMarkers = true,
|
||||
this.mapShowGuessedLocations = true,
|
||||
this.enableMessageTracing = true,
|
||||
this.mapClusterNodes = true,
|
||||
this.enableMessageTracing = false,
|
||||
this.mapCacheBounds,
|
||||
this.mapCacheMinZoom = 10,
|
||||
this.mapCacheMaxZoom = 15,
|
||||
@@ -211,6 +216,9 @@ class AppSettings {
|
||||
this.routeWeightSuccessIncrement = 0.5,
|
||||
this.routeWeightFailureDecrement = 0.2,
|
||||
this.maxMessageRetries = 5,
|
||||
this.channelMinHopsEnabled = false,
|
||||
this.channelMinHops = 2,
|
||||
this.channelMinHopsRetries = 1,
|
||||
this.themeMode = 'system',
|
||||
this.languageOverride,
|
||||
this.appDebugLogEnabled = false,
|
||||
@@ -267,6 +275,7 @@ class AppSettings {
|
||||
'map_key_prefix': mapKeyPrefix,
|
||||
'map_show_markers': mapShowMarkers,
|
||||
'map_show_guessed_locations': mapShowGuessedLocations,
|
||||
'map_cluster_nodes': mapClusterNodes,
|
||||
'enable_message_tracing': enableMessageTracing,
|
||||
'map_cache_bounds': mapCacheBounds,
|
||||
'map_cache_min_zoom': mapCacheMinZoom,
|
||||
@@ -287,6 +296,9 @@ class AppSettings {
|
||||
'route_weight_success_increment': routeWeightSuccessIncrement,
|
||||
'route_weight_failure_decrement': routeWeightFailureDecrement,
|
||||
'max_message_retries': maxMessageRetries,
|
||||
'channel_min_hops_enabled': channelMinHopsEnabled,
|
||||
'channel_min_hops': channelMinHops,
|
||||
'channel_min_hops_retries': channelMinHopsRetries,
|
||||
'theme_mode': themeMode,
|
||||
'language_override': languageOverride,
|
||||
'app_debug_log_enabled': appDebugLogEnabled,
|
||||
@@ -339,13 +351,14 @@ class AppSettings {
|
||||
mapShowOtherNodes: json['map_show_other_nodes'] as bool? ?? true,
|
||||
mapShowOverlaps: json['map_show_overlaps'] as bool? ?? false,
|
||||
mapTimeFilterHours:
|
||||
(json['map_time_filter_hours'] as num?)?.toDouble() ?? 0,
|
||||
(json['map_time_filter_hours'] as num?)?.toDouble() ?? 168,
|
||||
mapKeyPrefixEnabled: json['map_key_prefix_enabled'] as bool? ?? false,
|
||||
mapKeyPrefix: json['map_key_prefix'] as String? ?? '',
|
||||
mapShowMarkers: json['map_show_markers'] as bool? ?? true,
|
||||
mapShowGuessedLocations:
|
||||
json['map_show_guessed_locations'] as bool? ?? true,
|
||||
enableMessageTracing: json['enable_message_tracing'] as bool? ?? true,
|
||||
mapClusterNodes: json['map_cluster_nodes'] as bool? ?? true,
|
||||
enableMessageTracing: json['enable_message_tracing'] as bool? ?? false,
|
||||
mapCacheBounds: (json['map_cache_bounds'] as Map?)?.map(
|
||||
(key, value) => MapEntry(key.toString(), (value as num).toDouble()),
|
||||
),
|
||||
@@ -373,6 +386,9 @@ class AppSettings {
|
||||
routeWeightFailureDecrement:
|
||||
(json['route_weight_failure_decrement'] as num?)?.toDouble() ?? 0.2,
|
||||
maxMessageRetries: json['max_message_retries'] as int? ?? 5,
|
||||
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,
|
||||
themeMode: json['theme_mode'] as String? ?? 'system',
|
||||
languageOverride: json['language_override'] as String?,
|
||||
appDebugLogEnabled: json['app_debug_log_enabled'] as bool? ?? false,
|
||||
@@ -482,6 +498,7 @@ class AppSettings {
|
||||
String? mapKeyPrefix,
|
||||
bool? mapShowMarkers,
|
||||
bool? mapShowGuessedLocations,
|
||||
bool? mapClusterNodes,
|
||||
bool? enableMessageTracing,
|
||||
Object? mapCacheBounds = _unset,
|
||||
int? mapCacheMinZoom,
|
||||
@@ -501,6 +518,9 @@ class AppSettings {
|
||||
double? routeWeightSuccessIncrement,
|
||||
double? routeWeightFailureDecrement,
|
||||
int? maxMessageRetries,
|
||||
bool? channelMinHopsEnabled,
|
||||
int? channelMinHops,
|
||||
int? channelMinHopsRetries,
|
||||
String? themeMode,
|
||||
Object? languageOverride = _unset,
|
||||
bool? appDebugLogEnabled,
|
||||
@@ -542,6 +562,7 @@ class AppSettings {
|
||||
mapShowMarkers: mapShowMarkers ?? this.mapShowMarkers,
|
||||
mapShowGuessedLocations:
|
||||
mapShowGuessedLocations ?? this.mapShowGuessedLocations,
|
||||
mapClusterNodes: mapClusterNodes ?? this.mapClusterNodes,
|
||||
enableMessageTracing: enableMessageTracing ?? this.enableMessageTracing,
|
||||
mapCacheBounds: mapCacheBounds == _unset
|
||||
? this.mapCacheBounds
|
||||
@@ -571,6 +592,11 @@ class AppSettings {
|
||||
routeWeightFailureDecrement:
|
||||
routeWeightFailureDecrement ?? this.routeWeightFailureDecrement,
|
||||
maxMessageRetries: maxMessageRetries ?? this.maxMessageRetries,
|
||||
channelMinHopsEnabled:
|
||||
channelMinHopsEnabled ?? this.channelMinHopsEnabled,
|
||||
channelMinHops: channelMinHops ?? this.channelMinHops,
|
||||
channelMinHopsRetries:
|
||||
channelMinHopsRetries ?? this.channelMinHopsRetries,
|
||||
themeMode: themeMode ?? this.themeMode,
|
||||
languageOverride: languageOverride == _unset
|
||||
? this.languageOverride
|
||||
|
||||
@@ -25,6 +25,9 @@ class Channel {
|
||||
|
||||
bool get isEmpty => name.isEmpty && psk.every((b) => b == 0);
|
||||
|
||||
/// Key used for per-channel notification muting.
|
||||
String get muteKey => name.isEmpty ? 'Channel $index' : name;
|
||||
|
||||
bool get isPublicChannel => pskHex == publicChannelPsk;
|
||||
|
||||
bool get isHashtagChannel => name.startsWith('#');
|
||||
@@ -107,7 +110,7 @@ class Channel {
|
||||
/// Normalize a hashtag name for consistent community PSK derivation.
|
||||
/// Strips leading #, converts to lowercase, trims whitespace.
|
||||
static String _normalizeCommunityHashtag(String hashtag) {
|
||||
return hashtag.replaceFirst(RegExp(r'^#'), '').toLowerCase().trim();
|
||||
return hashtag.trim().replaceFirst(RegExp(r'^#'), '').toLowerCase().trim();
|
||||
}
|
||||
|
||||
static String formatPskHex(Uint8List psk) {
|
||||
|
||||
@@ -45,6 +45,7 @@ class ChannelMessage {
|
||||
final Uint8List pathBytes;
|
||||
final List<Uint8List> pathVariants;
|
||||
final int? channelIndex;
|
||||
final String? region;
|
||||
final String messageId;
|
||||
final String? packetHash;
|
||||
final String? replyToMessageId;
|
||||
@@ -71,6 +72,7 @@ class ChannelMessage {
|
||||
Uint8List? pathBytes,
|
||||
List<Uint8List>? pathVariants,
|
||||
this.channelIndex,
|
||||
this.region,
|
||||
String? messageId,
|
||||
this.packetHash,
|
||||
this.replyToMessageId,
|
||||
@@ -98,6 +100,7 @@ class ChannelMessage {
|
||||
int? pathHashWidth,
|
||||
Uint8List? pathBytes,
|
||||
List<Uint8List>? pathVariants,
|
||||
Object? region = _unset,
|
||||
String? packetHash,
|
||||
String? replyToMessageId,
|
||||
String? replyToSenderName,
|
||||
@@ -136,6 +139,7 @@ class ChannelMessage {
|
||||
pathBytes: pathBytes ?? this.pathBytes,
|
||||
pathVariants: pathVariants ?? this.pathVariants,
|
||||
channelIndex: channelIndex,
|
||||
region: region == _unset ? this.region : region as String?,
|
||||
messageId: messageId,
|
||||
packetHash: packetHash ?? this.packetHash,
|
||||
replyToMessageId: replyToMessageId ?? this.replyToMessageId,
|
||||
@@ -157,7 +161,7 @@ class ChannelMessage {
|
||||
return null;
|
||||
}
|
||||
|
||||
int pathLen;
|
||||
int? pathLen;
|
||||
int txtType;
|
||||
int? packetPathHashWidth;
|
||||
Uint8List pathBytes = Uint8List(0);
|
||||
@@ -169,20 +173,24 @@ class ChannelMessage {
|
||||
reader.skipBytes(1); // Skip reserved byte
|
||||
channelIdx = reader.readByte();
|
||||
final pathByte = reader.readUInt8();
|
||||
// pathByte packs: top 2 bits = hash width mode, low 6 bits = hop count
|
||||
packetPathHashWidth = ((pathByte & 0xC0) >> 6) + 1;
|
||||
final hopCount = pathByte & 0x3F;
|
||||
pathLen = hopCount;
|
||||
// If a path is present, read hopCount * width bytes
|
||||
if (hasPath && hopCount > 0) {
|
||||
final totalPathBytes = hopCount * packetPathHashWidth;
|
||||
pathBytes = reader.readBytes(totalPathBytes);
|
||||
// 0xFF = direct-routed; hop count is not reported.
|
||||
if (pathByte != 0xFF) {
|
||||
// pathByte packs: top 2 bits = hash width mode, low 6 bits = hop count
|
||||
packetPathHashWidth = ((pathByte & 0xC0) >> 6) + 1;
|
||||
final hopCount = pathByte & 0x3F;
|
||||
pathLen = hopCount;
|
||||
// If a path is present, read hopCount * width bytes
|
||||
if (hasPath && hopCount > 0) {
|
||||
final totalPathBytes = hopCount * packetPathHashWidth;
|
||||
pathBytes = reader.readBytes(totalPathBytes);
|
||||
}
|
||||
}
|
||||
// After consuming optional path bytes, read the text type byte.
|
||||
txtType = reader.readByte();
|
||||
} else {
|
||||
channelIdx = reader.readByte();
|
||||
pathLen = reader.readInt8();
|
||||
final pathByte = reader.readUInt8();
|
||||
pathLen = pathByte == 0xFF ? null : pathByte & 0x3F;
|
||||
txtType = reader.readByte();
|
||||
}
|
||||
final timestampRaw = reader.readUInt32LE();
|
||||
@@ -238,6 +246,8 @@ class ChannelMessage {
|
||||
String? originalText,
|
||||
String? translatedLanguageCode,
|
||||
String? translationModelId,
|
||||
String? region,
|
||||
ChannelMessage? replyTo,
|
||||
}) {
|
||||
return ChannelMessage(
|
||||
senderKey: null,
|
||||
@@ -246,6 +256,9 @@ class ChannelMessage {
|
||||
originalText: originalText,
|
||||
translatedLanguageCode: translatedLanguageCode,
|
||||
translationModelId: translationModelId,
|
||||
replyToMessageId: replyTo?.messageId,
|
||||
replyToSenderName: replyTo?.senderName,
|
||||
replyToText: replyTo?.text,
|
||||
timestamp: DateTime.now(),
|
||||
isOutgoing: true,
|
||||
status: ChannelMessageStatus.pending,
|
||||
@@ -253,6 +266,7 @@ class ChannelMessage {
|
||||
pathBytes: Uint8List(0),
|
||||
pathVariants: const [],
|
||||
channelIndex: channelIndex,
|
||||
region: region,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,12 +76,14 @@ class Community {
|
||||
factory Community.fromJson(Map<String, dynamic> json) {
|
||||
return Community(
|
||||
id: json['id'] as String,
|
||||
name: json['name'] as String,
|
||||
name: json['name'] as String? ?? '',
|
||||
secret: base64Decode(json['secret'] as String),
|
||||
createdAt: DateTime.fromMillisecondsSinceEpoch(json['created_at'] as int),
|
||||
createdAt: DateTime.fromMillisecondsSinceEpoch(
|
||||
json['created_at'] as int? ?? 0,
|
||||
),
|
||||
hashtagChannels:
|
||||
(json['hashtag_channels'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
?.whereType<String>()
|
||||
.toList() ??
|
||||
[],
|
||||
);
|
||||
@@ -157,7 +159,7 @@ class Community {
|
||||
/// Normalize a hashtag name for consistent PSK derivation.
|
||||
/// Strips leading #, converts to lowercase, trims whitespace.
|
||||
static String _normalizeCommunityHashtag(String hashtag) {
|
||||
return hashtag.replaceFirst(RegExp(r'^#'), '').toLowerCase().trim();
|
||||
return hashtag.trim().replaceFirst(RegExp(r'^#'), '').toLowerCase().trim();
|
||||
}
|
||||
|
||||
/// Returns true if this is the community's public channel
|
||||
|
||||
+14
-2
@@ -10,6 +10,7 @@ class Contact {
|
||||
final int flags;
|
||||
final int pathLength; // -1 = flood, 0+ = direct hops (from device)
|
||||
final Uint8List path; // Path bytes from device
|
||||
final int pathHashWidth; // Bytes per hop in [path], as learned by the device
|
||||
final int?
|
||||
pathOverride; // User's path override: -1 = force flood, null = auto
|
||||
final Uint8List? pathOverrideBytes; // User's path override bytes
|
||||
@@ -29,6 +30,7 @@ class Contact {
|
||||
this.flags = 0,
|
||||
required this.pathLength,
|
||||
required this.path,
|
||||
this.pathHashWidth = 1,
|
||||
this.pathOverride,
|
||||
this.pathOverrideBytes,
|
||||
this.latitude,
|
||||
@@ -81,6 +83,7 @@ class Contact {
|
||||
int? flags,
|
||||
int? pathLength,
|
||||
Uint8List? path,
|
||||
int? pathHashWidth,
|
||||
int? pathOverride,
|
||||
Uint8List? pathOverrideBytes,
|
||||
bool clearPathOverride = false,
|
||||
@@ -99,6 +102,7 @@ class Contact {
|
||||
flags: flags ?? this.flags,
|
||||
pathLength: pathLength ?? this.pathLength,
|
||||
path: path ?? this.path,
|
||||
pathHashWidth: pathHashWidth ?? this.pathHashWidth,
|
||||
pathOverride: clearPathOverride
|
||||
? null
|
||||
: (pathOverride ?? this.pathOverride),
|
||||
@@ -140,6 +144,13 @@ class Contact {
|
||||
return "<${publicKeyHex.substring(0, 8)}...${publicKeyHex.substring(publicKeyHex.length - 8)}>";
|
||||
}
|
||||
|
||||
/// Infers bytes per hop for stored paths that predate [pathHashWidth].
|
||||
static int inferPathHashWidth(int hopCount, int byteLen) {
|
||||
if (hopCount <= 0 || byteLen % hopCount != 0) return 1;
|
||||
final width = byteLen ~/ hopCount;
|
||||
return width >= 1 && width <= 3 ? width : 1;
|
||||
}
|
||||
|
||||
Uint8List get pathBytesForDisplay {
|
||||
if (pathOverride != null) {
|
||||
if (pathOverride! < 0) return Uint8List(0);
|
||||
@@ -168,12 +179,12 @@ class Contact {
|
||||
final pathLen = reader.readByte();
|
||||
int hopCount = 0;
|
||||
int byteLen = 0;
|
||||
int width = 1;
|
||||
if (pathLen == 0xFF) {
|
||||
hopCount = -1;
|
||||
} else {
|
||||
final mode = (pathLen & 0xC0) >> 6;
|
||||
width = ((pathLen & 0xC0) >> 6) + 1;
|
||||
hopCount = pathLen & 0x3F;
|
||||
final width = mode + 1;
|
||||
byteLen = hopCount * width;
|
||||
}
|
||||
final safePathLen = byteLen > 0
|
||||
@@ -225,6 +236,7 @@ class Contact {
|
||||
flags: flags,
|
||||
pathLength: hopCount,
|
||||
path: pathBytes,
|
||||
pathHashWidth: width,
|
||||
latitude: lat,
|
||||
longitude: lon,
|
||||
lastSeen: DateTime.fromMillisecondsSinceEpoch(
|
||||
|
||||
@@ -35,7 +35,7 @@ class DeliveryObservation {
|
||||
pathLength: json['path_length'] as int,
|
||||
messageBytes: json['message_bytes'] as int,
|
||||
secondsSinceLastRx: json['seconds_since_last_rx'] as int? ?? 0,
|
||||
isFlood: json['is_flood'] as bool,
|
||||
isFlood: json['is_flood'] as bool? ?? false,
|
||||
deliveryMs: json['delivery_ms'] as int,
|
||||
timestamp: DateTime.parse(json['timestamp'] as String),
|
||||
);
|
||||
|
||||
@@ -525,7 +525,7 @@ class RadioSettings {
|
||||
(
|
||||
'Off-Grid 869',
|
||||
RadioSettings(
|
||||
frequencyMHz: 869.0,
|
||||
frequencyMHz: 869.495,
|
||||
bandwidth: LoRaBandwidth.bw250,
|
||||
spreadingFactor: LoRaSpreadingFactor.sf11,
|
||||
codingRate: LoRaCodingRate.cr4_8,
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
import 'dart:typed_data';
|
||||
|
||||
/// Binary status reply pushed as PUSH_CODE_STATUS_RESPONSE.
|
||||
///
|
||||
/// The first 48 bytes are shared by repeater `RepeaterStats` and room
|
||||
/// `ServerStats`. After that, repeaters send `total_rx_air_time_secs` and
|
||||
/// `n_recv_errors` (uint32 each), rooms send `n_posted` and `n_post_push`
|
||||
/// (uint16 each).
|
||||
class RemoteNodeStats {
|
||||
static const int payloadOffset = 8;
|
||||
static const int commonSize = 48;
|
||||
|
||||
final int batteryMv;
|
||||
final int queueLen;
|
||||
final int noiseFloor;
|
||||
final int lastRssi;
|
||||
final int packetsRecv;
|
||||
final int packetsSent;
|
||||
final int txAirSecs;
|
||||
final int uptimeSecs;
|
||||
final int floodTx;
|
||||
final int directTx;
|
||||
final int floodRx;
|
||||
final int directRx;
|
||||
final int errEvents;
|
||||
final double lastSnr;
|
||||
final int directDups;
|
||||
final int floodDups;
|
||||
final int? rxAirSecs;
|
||||
final int? recvErrors;
|
||||
final int? posted;
|
||||
final int? postPushes;
|
||||
|
||||
const RemoteNodeStats({
|
||||
required this.batteryMv,
|
||||
required this.queueLen,
|
||||
required this.noiseFloor,
|
||||
required this.lastRssi,
|
||||
required this.packetsRecv,
|
||||
required this.packetsSent,
|
||||
required this.txAirSecs,
|
||||
required this.uptimeSecs,
|
||||
required this.floodTx,
|
||||
required this.directTx,
|
||||
required this.floodRx,
|
||||
required this.directRx,
|
||||
required this.errEvents,
|
||||
required this.lastSnr,
|
||||
required this.directDups,
|
||||
required this.floodDups,
|
||||
this.rxAirSecs,
|
||||
this.recvErrors,
|
||||
this.posted,
|
||||
this.postPushes,
|
||||
});
|
||||
|
||||
static RemoteNodeStats? tryParse(Uint8List frame, {required bool isRoom}) {
|
||||
if (frame.length < payloadOffset + commonSize) return null;
|
||||
final data = ByteData.sublistView(frame, payloadOffset);
|
||||
int u16(int o) => data.getUint16(o, Endian.little);
|
||||
int i16(int o) => data.getInt16(o, Endian.little);
|
||||
int u32(int o) => data.getUint32(o, Endian.little);
|
||||
bool has(int o, int size) => data.lengthInBytes >= o + size;
|
||||
|
||||
return RemoteNodeStats(
|
||||
batteryMv: u16(0),
|
||||
queueLen: u16(2),
|
||||
noiseFloor: i16(4),
|
||||
lastRssi: i16(6),
|
||||
packetsRecv: u32(8),
|
||||
packetsSent: u32(12),
|
||||
txAirSecs: u32(16),
|
||||
uptimeSecs: u32(20),
|
||||
floodTx: u32(24),
|
||||
directTx: u32(28),
|
||||
floodRx: u32(32),
|
||||
directRx: u32(36),
|
||||
errEvents: u16(40),
|
||||
lastSnr: i16(42) / 4.0,
|
||||
directDups: u16(44),
|
||||
floodDups: u16(46),
|
||||
rxAirSecs: !isRoom && has(48, 4) ? u32(48) : null,
|
||||
recvErrors: !isRoom && has(52, 4) ? u32(52) : null,
|
||||
posted: isRoom && has(48, 2) ? u16(48) : null,
|
||||
postPushes: isRoom && has(50, 2) ? u16(50) : null,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user