Merge branch 'dev-shareContacts' into dev-shareContact

This commit is contained in:
Winston Lowe
2026-01-31 08:02:35 -08:00
3 changed files with 204 additions and 19 deletions
+27
View File
@@ -102,6 +102,14 @@ class BufferWriter {
}
writeBytes(bytes);
}
void writeHex(String hex) {
List<int> result = [];
for (int i = 0; i < hex.length ~/ 2; i++) {
result.add(int.parse(hex.substring(i * 2, i * 2 + 2), radix: 16));
}
writeBytes(Uint8List.fromList(result));
}
}
// Command codes (to device)
@@ -164,6 +172,7 @@ const int respCodeContactMsgRecv = 7;
const int respCodeChannelMsgRecv = 8;
const int respCodeCurrTime = 9;
const int respCodeNoMoreMessages = 10;
const int respCodeExportContact = 11;
const int respCodeBattAndStorage = 12;
const int respCodeDeviceInfo = 13;
const int respCodeContactMsgRecvV3 = 16;
@@ -728,4 +737,22 @@ Uint8List buildTraceReq(int tag, int auth, int flag, {Uint8List? payload})
writer.writeBytes(payload);
}
return writer.toBytes();
}
// Build a export contact frame
// [cmd][pub_key x32 / if empty exports your contact info]
Uint8List buildExportContactFrame(Uint8List pubKey) {
final writer = BufferWriter();
writer.writeByte(cmdExportContact);
writer.writeBytes(pubKey);
return writer.toBytes();
}
// Build a import contact frame
// [cmd][contact_frame x98+]
Uint8List buildImportContactFrame(String contactFrame) {
final writer = BufferWriter();
writer.writeByte(cmdImportContact);
writer.writeHex(contactFrame);
return writer.toBytes();
}