* companion radio: new CMD_SHARE_CONTACT

* room server: push notify loop interval changed to 2 secs
This commit is contained in:
Scott Powell
2025-02-15 13:23:19 +11:00
parent 67c7fc070e
commit 65580c76d0
4 changed files with 79 additions and 2 deletions

View File

@@ -50,6 +50,10 @@ void BaseChatMesh::onAdvertRecv(mesh::Packet* packet, const mesh::Identity& id,
}
}
// save a copy of raw advert packet (to support "Share..." function)
int plen = packet->writeTo(temp_buf);
putBlobByKey(id.pub_key, PUB_KEY_SIZE, temp_buf, plen);
// update
strncpy(from->name, parser.getName(), sizeof(from->name)-1);
from->name[sizeof(from->name)-1] = 0;
@@ -246,6 +250,18 @@ bool BaseChatMesh::sendGroupMessage(uint32_t timestamp, mesh::GroupChannel& chan
return false;
}
bool BaseChatMesh::shareContactZeroHop(const ContactInfo& contact) {
int plen = getBlobByKey(contact.id.pub_key, PUB_KEY_SIZE, temp_buf); // retrieve last raw advert packet
if (plen == 0) return false; // not found
auto packet = obtainNewPacket();
if (packet == NULL) return false; // no Packets available
packet->readFrom(temp_buf, plen); // restore Packet from 'blob'
sendZeroHop(packet);
return true; // success
}
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