From c61fde9328503c2e34677fc7e091c716bdaec2e5 Mon Sep 17 00:00:00 2001 From: taco Date: Fri, 16 Jan 2026 12:17:22 +1100 Subject: [PATCH 1/2] always send PUSH_CODE_NEW_ADVERT when advert was not added to contacts[] --- examples/companion_radio/MyMesh.cpp | 2 +- src/helpers/BaseChatMesh.cpp | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index 28d60a0fe..3d8798b29 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -323,7 +323,7 @@ void MyMesh::onContactsFull() { void MyMesh::onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path_len, const uint8_t* path) { if (_serial->isConnected()) { - if (!shouldAutoAddContactType(contact.type) && is_new) { + if (is_new) { writeContactRespFrame(PUSH_CODE_NEW_ADVERT, contact); } else { out_frame[0] = PUSH_CODE_ADVERT; diff --git a/src/helpers/BaseChatMesh.cpp b/src/helpers/BaseChatMesh.cpp index 98b409622..aebfc1b64 100644 --- a/src/helpers/BaseChatMesh.cpp +++ b/src/helpers/BaseChatMesh.cpp @@ -133,7 +133,7 @@ void BaseChatMesh::onAdvertRecv(mesh::Packet* packet, const mesh::Identity& id, } putBlobByKey(id.pub_key, PUB_KEY_SIZE, temp_buf, plen); - bool is_new = false; + bool is_new = false; // true = not in contacts[], false = exists in contacts[] if (from == NULL) { if (!shouldAutoAddContactType(parser.getType())) { ContactInfo ci; @@ -142,7 +142,6 @@ void BaseChatMesh::onAdvertRecv(mesh::Packet* packet, const mesh::Identity& id, return; } - is_new = true; from = allocateContactSlot(); if (from == NULL) { ContactInfo ci; From b919119fafaa0ac46810fc1f4f0954eb1c4ec57f Mon Sep 17 00:00:00 2001 From: taco Date: Fri, 16 Jan 2026 13:14:51 +1100 Subject: [PATCH 2/2] only write contacts when changed --- examples/companion_radio/MyMesh.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index 3d8798b29..c80e28699 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -358,7 +358,7 @@ void MyMesh::onDiscoveredContact(ContactInfo &contact, bool is_new, uint8_t path memcpy(p->path, path, p->path_len); } - dirty_contacts_expiry = futureMillis(LAZY_CONTACTS_WRITE_DELAY); + if (!is_new) dirty_contacts_expiry = futureMillis(LAZY_CONTACTS_WRITE_DELAY); // only schedule lazy write for contacts that are in contacts[] } static int sort_by_recent(const void *a, const void *b) {