feat: replace advert scan with active node discovery in NearbyScreen

NearbyScreen now sends CTL_TYPE_NODE_DISCOVER_REQ (same protocol as the
companion app) instead of a plain self-advert. Nearby repeaters, sensors
and room servers respond with their pub_key and type. Known contacts get
their lastmod refreshed; unknown nodes appear as temporary entries (e.g.
"Repeater") in the list until their advert is received.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Jakub
2026-05-21 00:16:53 +02:00
co-authored by Claude Sonnet 4.6
parent 9427fa1999
commit 9cabcd5ac7
3 changed files with 95 additions and 6 deletions
+14
View File
@@ -85,6 +85,12 @@ struct AdvertPath {
uint8_t path[MAX_PATH_SIZE];
};
struct DiscoveredEntry {
uint8_t pub_key_prefix[4];
uint8_t type; // ADV_TYPE_REPEATER / ADV_TYPE_SENSOR / ADV_TYPE_ROOM
uint32_t timestamp; // RTC timestamp of discovery
};
#define EXPECTED_ACK_TABLE_SIZE 8
class MyMesh : public BaseChatMesh, public DataStoreHost {
@@ -101,9 +107,11 @@ public:
void loop();
void handleCmdFrame(size_t len);
bool advert();
void sendNodeDiscoverReq();
void enterCLIRescue();
int getRecentlyHeard(AdvertPath dest[], int max_num);
int getDiscoveredNodes(DiscoveredEntry dest[], int max_count);
protected:
float getAirtimeBudgetFactor() const override;
@@ -263,6 +271,12 @@ private:
#define ADVERT_PATH_TABLE_SIZE 16
AdvertPath advert_paths[ADVERT_PATH_TABLE_SIZE]; // circular table
#define DISCOVERED_NODES_MAX 8
DiscoveredEntry _discovered[DISCOVERED_NODES_MAX];
int _discovered_count;
uint32_t _pending_node_discover_tag;
unsigned long _pending_node_discover_until;
};
extern MyMesh the_mesh;