mirror of
https://github.com/dz0ny/meshcore-sar.git
synced 2026-08-11 16:30:28 +00:00
feat: Add new contact and message tracking features, including unread status and removal functionality
This commit is contained in:
@@ -395,6 +395,15 @@ class MeshCoreBleService {
|
||||
await _commandSender.writeData(FrameBuilder.buildResetPath(contactPublicKey));
|
||||
}
|
||||
|
||||
/// Remove a contact from the companion radio
|
||||
Future<void> removeContact(Uint8List contactPublicKey) async {
|
||||
print('🗑️ [BLE] Removing contact from companion radio:');
|
||||
print(' Public key prefix: ${contactPublicKey.sublist(0, 6).map((b) => b.toRadixString(16).padLeft(2, '0')).join(':')}');
|
||||
|
||||
await _commandSender.writeData(FrameBuilder.buildRemoveContact(contactPublicKey));
|
||||
print('✅ [BLE] CMD_REMOVE_CONTACT sent');
|
||||
}
|
||||
|
||||
/// Clear packet logs
|
||||
void clearPacketLogs() {
|
||||
_commandSender.clearPacketLogs();
|
||||
|
||||
@@ -128,6 +128,7 @@ class MessageStorageService {
|
||||
'recipientPublicKey': message.recipientPublicKey != null
|
||||
? base64Encode(message.recipientPublicKey!)
|
||||
: null,
|
||||
'isRead': message.isRead,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -180,6 +181,7 @@ class MessageStorageService {
|
||||
? Uint8List.fromList(
|
||||
base64Decode(json['recipientPublicKey'] as String))
|
||||
: null,
|
||||
isRead: json['isRead'] as bool? ?? false,
|
||||
);
|
||||
} catch (e) {
|
||||
print('❌ [MessageStorage] Error parsing message from JSON: $e');
|
||||
|
||||
@@ -235,4 +235,12 @@ class FrameBuilder {
|
||||
writer.writeBytes(contactPublicKey); // 32 bytes
|
||||
return writer.toBytes();
|
||||
}
|
||||
|
||||
/// Build RemoveContact command - removes a contact from the device
|
||||
static Uint8List buildRemoveContact(Uint8List contactPublicKey) {
|
||||
final writer = BufferWriter();
|
||||
writer.writeByte(MeshCoreConstants.cmdRemoveContact); // 0x0F (15)
|
||||
writer.writeBytes(contactPublicKey); // 32 bytes
|
||||
return writer.toBytes();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user