mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
feat: Enhance MeshCoreBleService with new callbacks and message handling
- Added new callback types for path updates, message sent, message delivered, status responses, binary responses, and battery/storage information. - Implemented handling for binary responses and path updates, including parsing and notifying via callbacks. - Updated message sending logic to include acknowledgment and delivery confirmation. - Enhanced log parsing for received data, including detailed interpretations and analysis. - Introduced status request functionality to query operational status from repeater or sensor nodes. - Updated battery and storage information handling to provide detailed metrics and trigger callbacks. - Deprecated legacy methods in favor of more robust alternatives.
This commit is contained in:
@@ -25,6 +25,15 @@ enum MessageType {
|
||||
channel,
|
||||
}
|
||||
|
||||
/// Message delivery status
|
||||
enum MessageDeliveryStatus {
|
||||
sending, // Message is being sent
|
||||
sent, // Message queued with expected ACK
|
||||
delivered, // Delivery confirmed (ACK received)
|
||||
failed, // Delivery failed
|
||||
received, // Message received from another contact
|
||||
}
|
||||
|
||||
/// MeshCore message model
|
||||
class Message {
|
||||
final String id;
|
||||
@@ -45,6 +54,13 @@ class Message {
|
||||
final DateTime receivedAt;
|
||||
final String? senderName;
|
||||
|
||||
// Delivery tracking (for sent messages)
|
||||
final MessageDeliveryStatus deliveryStatus;
|
||||
final int? expectedAckTag; // Expected ACK/TAG from SENT response
|
||||
final int? suggestedTimeoutMs; // Suggested timeout from SENT response
|
||||
final int? roundTripTimeMs; // RTT from SEND_CONFIRMED
|
||||
final DateTime? deliveredAt; // When delivery was confirmed
|
||||
|
||||
Message({
|
||||
required this.id,
|
||||
required this.messageType,
|
||||
@@ -59,6 +75,11 @@ class Message {
|
||||
this.sarGpsCoordinates,
|
||||
required this.receivedAt,
|
||||
this.senderName,
|
||||
this.deliveryStatus = MessageDeliveryStatus.received,
|
||||
this.expectedAckTag,
|
||||
this.suggestedTimeoutMs,
|
||||
this.roundTripTimeMs,
|
||||
this.deliveredAt,
|
||||
});
|
||||
|
||||
/// Get sender public key as hex string
|
||||
@@ -120,6 +141,28 @@ class Message {
|
||||
);
|
||||
}
|
||||
|
||||
/// Get friendly delivery status description
|
||||
String get deliveryStatusText {
|
||||
switch (deliveryStatus) {
|
||||
case MessageDeliveryStatus.sending:
|
||||
return 'Sending...';
|
||||
case MessageDeliveryStatus.sent:
|
||||
return 'Sent';
|
||||
case MessageDeliveryStatus.delivered:
|
||||
if (roundTripTimeMs != null) {
|
||||
return 'Delivered (${roundTripTimeMs}ms)';
|
||||
}
|
||||
return 'Delivered';
|
||||
case MessageDeliveryStatus.failed:
|
||||
return 'Failed';
|
||||
case MessageDeliveryStatus.received:
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/// Check if this is a sent message (not received)
|
||||
bool get isSentMessage => deliveryStatus != MessageDeliveryStatus.received;
|
||||
|
||||
Message copyWith({
|
||||
String? id,
|
||||
MessageType? messageType,
|
||||
@@ -134,6 +177,11 @@ class Message {
|
||||
LatLng? sarGpsCoordinates,
|
||||
DateTime? receivedAt,
|
||||
String? senderName,
|
||||
MessageDeliveryStatus? deliveryStatus,
|
||||
int? expectedAckTag,
|
||||
int? suggestedTimeoutMs,
|
||||
int? roundTripTimeMs,
|
||||
DateTime? deliveredAt,
|
||||
}) {
|
||||
return Message(
|
||||
id: id ?? this.id,
|
||||
@@ -149,6 +197,11 @@ class Message {
|
||||
sarGpsCoordinates: sarGpsCoordinates ?? this.sarGpsCoordinates,
|
||||
receivedAt: receivedAt ?? this.receivedAt,
|
||||
senderName: senderName ?? this.senderName,
|
||||
deliveryStatus: deliveryStatus ?? this.deliveryStatus,
|
||||
expectedAckTag: expectedAckTag ?? this.expectedAckTag,
|
||||
suggestedTimeoutMs: suggestedTimeoutMs ?? this.suggestedTimeoutMs,
|
||||
roundTripTimeMs: roundTripTimeMs ?? this.roundTripTimeMs,
|
||||
deliveredAt: deliveredAt ?? this.deliveredAt,
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user