mirror of
https://github.com/meshcore-dev/MeshCore.git
synced 2026-04-20 22:13:47 +00:00
discover.neighbors sends a tagged repeater discovery request and only accepts matching repeater responses
This commit is contained in:
parent
e8785dd9b0
commit
87c78a98bd
2 changed files with 20 additions and 3 deletions
|
|
@ -748,6 +748,16 @@ void MyMesh::onControlDataRecv(mesh::Packet* packet) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pending_discover_tag == 0 || millisHasNowPassed(pending_discover_until)) {
|
||||||
|
pending_discover_tag = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
uint32_t tag;
|
||||||
|
memcpy(&tag, &packet->payload[2], 4);
|
||||||
|
if (tag != pending_discover_tag) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
mesh::Identity id(&packet->payload[6]);
|
mesh::Identity id(&packet->payload[6]);
|
||||||
if (id.matches(self_id)) {
|
if (id.matches(self_id)) {
|
||||||
return;
|
return;
|
||||||
|
|
@ -763,6 +773,8 @@ void MyMesh::sendNodeDiscoverReq() {
|
||||||
data[0] = CTL_TYPE_NODE_DISCOVER_REQ; // prefix_only=0
|
data[0] = CTL_TYPE_NODE_DISCOVER_REQ; // prefix_only=0
|
||||||
data[1] = (1 << ADV_TYPE_REPEATER);
|
data[1] = (1 << ADV_TYPE_REPEATER);
|
||||||
getRNG()->random(&data[2], 4); // tag
|
getRNG()->random(&data[2], 4); // tag
|
||||||
|
memcpy(&pending_discover_tag, &data[2], 4);
|
||||||
|
pending_discover_until = futureMillis(30000);
|
||||||
uint32_t since = 0;
|
uint32_t since = 0;
|
||||||
memcpy(&data[6], &since, 4);
|
memcpy(&data[6], &since, 4);
|
||||||
|
|
||||||
|
|
@ -832,6 +844,9 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
|
||||||
_prefs.advert_loc_policy = ADVERT_LOC_PREFS;
|
_prefs.advert_loc_policy = ADVERT_LOC_PREFS;
|
||||||
|
|
||||||
_prefs.adc_multiplier = 0.0f; // 0.0f means use default board multiplier
|
_prefs.adc_multiplier = 0.0f; // 0.0f means use default board multiplier
|
||||||
|
|
||||||
|
pending_discover_tag = 0;
|
||||||
|
pending_discover_until = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MyMesh::begin(FILESYSTEM *fs) {
|
void MyMesh::begin(FILESYSTEM *fs) {
|
||||||
|
|
@ -1199,11 +1214,11 @@ void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply
|
||||||
} else {
|
} else {
|
||||||
strcpy(reply, "Err - ??");
|
strcpy(reply, "Err - ??");
|
||||||
}
|
}
|
||||||
} else if (memcmp(command, "discover", 8) == 0) {
|
} else if (memcmp(command, "discover.neighbors", 18) == 0) {
|
||||||
const char* sub = command + 8;
|
const char* sub = command + 18;
|
||||||
while (*sub == ' ') sub++;
|
while (*sub == ' ') sub++;
|
||||||
if (*sub != 0) {
|
if (*sub != 0) {
|
||||||
strcpy(reply, "Err - discover has no options");
|
strcpy(reply, "Err - discover.neighbors has no options");
|
||||||
} else {
|
} else {
|
||||||
sendNodeDiscoverReq();
|
sendNodeDiscoverReq();
|
||||||
strcpy(reply, "OK - Discover sent");
|
strcpy(reply, "OK - Discover sent");
|
||||||
|
|
|
||||||
|
|
@ -97,6 +97,8 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
|
||||||
RegionEntry* load_stack[8];
|
RegionEntry* load_stack[8];
|
||||||
RegionEntry* recv_pkt_region;
|
RegionEntry* recv_pkt_region;
|
||||||
RateLimiter discover_limiter, anon_limiter;
|
RateLimiter discover_limiter, anon_limiter;
|
||||||
|
uint32_t pending_discover_tag;
|
||||||
|
unsigned long pending_discover_until;
|
||||||
bool region_load_active;
|
bool region_load_active;
|
||||||
unsigned long dirty_contacts_expiry;
|
unsigned long dirty_contacts_expiry;
|
||||||
#if MAX_NEIGHBOURS
|
#if MAX_NEIGHBOURS
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue