mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-09 21:55:51 +00:00
* companion radio: new CMD_EXPORT_CONTACT, CMD_IMPORT_CONTACT
This commit is contained in:
@@ -262,6 +262,24 @@ bool BaseChatMesh::shareContactZeroHop(const ContactInfo& contact) {
|
||||
return true; // success
|
||||
}
|
||||
|
||||
uint8_t BaseChatMesh::exportContact(const ContactInfo& contact, uint8_t dest_buf[]) {
|
||||
return getBlobByKey(contact.id.pub_key, PUB_KEY_SIZE, dest_buf); // retrieve last raw advert packet
|
||||
}
|
||||
|
||||
bool BaseChatMesh::importContact(const uint8_t src_buf[], uint8_t len) {
|
||||
auto pkt = obtainNewPacket();
|
||||
if (pkt) {
|
||||
if (pkt->readFrom(src_buf, len) && pkt->getPayloadType() == PAYLOAD_TYPE_ADVERT) {
|
||||
pkt->header |= ROUTE_TYPE_FLOOD; // simulate it being received flood-mode
|
||||
_pendingLoopback = pkt; // loop-back, as if received over radio
|
||||
return true; // success
|
||||
} else {
|
||||
releasePacket(pkt); // undo the obtainNewPacket()
|
||||
}
|
||||
}
|
||||
return false; // error
|
||||
}
|
||||
|
||||
bool BaseChatMesh::sendLogin(const ContactInfo& recipient, const char* password, uint32_t& est_timeout) {
|
||||
uint8_t shared_secret[32];
|
||||
self_id.calcSharedSecret(shared_secret, recipient.id); // TODO: cache this
|
||||
@@ -416,4 +434,10 @@ void BaseChatMesh::loop() {
|
||||
onSendTimeout();
|
||||
txt_send_timeout = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (_pendingLoopback) {
|
||||
onRecvPacket(_pendingLoopback); // loop-back, as if received over radio
|
||||
releasePacket(_pendingLoopback); // undo the obtainNewPacket()
|
||||
_pendingLoopback = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user