* companion radio: new command frames: CMD_SET_ADVERT_LATLON, CMD_REMOVE_CONTACT

This commit is contained in:
Scott Powell
2025-02-11 12:02:27 +11:00
parent 5d4a5dce36
commit eb7fec6f1d
3 changed files with 44 additions and 1 deletions

View File

@@ -281,6 +281,22 @@ bool BaseChatMesh::addContact(const ContactInfo& contact) {
return false;
}
bool BaseChatMesh::removeContact(ContactInfo& contact) {
int idx = 0;
while (idx < num_contacts && !contacts[idx].id.matches(contact.id)) {
idx++;
}
if (idx >= num_contacts) return false; // not found
// remove from contacts array
num_contacts--;
while (idx < num_contacts) {
contacts[idx] = contacts[idx + 1];
idx++;
}
return true; // Success
}
#ifdef MAX_GROUP_CHANNELS
#include <base64.hpp>

View File

@@ -102,6 +102,7 @@ public:
void scanRecentContacts(int last_n, ContactVisitor* visitor);
ContactInfo* searchContactsByPrefix(const char* name_prefix);
ContactInfo* lookupContactByPubKey(const uint8_t* pub_key, int prefix_len);
bool removeContact(ContactInfo& contact);
bool addContact(const ContactInfo& contact);
int getNumContacts() const { return num_contacts; }
ContactsIterator startContactsIterator();