feat: Add new contact and message tracking features, including unread status and removal functionality

This commit is contained in:
Janez T
2025-10-15 21:49:33 +02:00
parent 2849ab92aa
commit 6be182e20a
13 changed files with 463 additions and 48 deletions

View File

@@ -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();

View File

@@ -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');

View File

@@ -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();
}
}