mirror of
https://github.com/agessaman/MeshCore.git
synced 2026-10-23 19:22:39 +00:00
fix(repeater): report the entries 'discover.regions list' could not fit
The reply is capped at 134 chars, so a pass over several neighbours with long region lists silently showed only the first few. Count what doesn't fit and append '+N more', so a short list isn't mistaken for the whole pass. The serial output is unchanged, and still shows every result.
This commit is contained in:
1 parent
7a04967ca8
commit
b905423f31
3 files changed
+16
-4
No files matched your search
@@ -142,8 +142,9 @@ the serial terminal as they land.
|
||||
**Note:** `discover.regions list` reports the results of the last run, as `{pubkey-prefix}:{regions}`
|
||||
per line. A `?` in place of the regions means that neighbor did not answer — it may be out of range,
|
||||
running older firmware, or simply rate-limiting anonymous requests (repeaters answer at most 4 per
|
||||
3 minutes). This reply is capped at 134 characters, so on a node with many neighbors it may not
|
||||
show them all — the serial output always does.
|
||||
3 minutes). This reply is capped at 134 characters, so on a node with many neighbors it may not show
|
||||
them all; when entries do not fit, the last line is `+N more`. The serial output always shows every
|
||||
result.
|
||||
|
||||
**Note:** The pubkey prefixes reported here can be passed straight to `regions.subscribe`.
|
||||
|
||||
|
||||
@@ -997,6 +997,7 @@ void MyMesh::startRegionDiscover(char *reply) {
|
||||
region_query_mode = REGION_QUERY_DISCOVER;
|
||||
region_discover_next = 0;
|
||||
region_discover_reply[0] = 0;
|
||||
region_discover_dropped = 0;
|
||||
advanceRegionDiscover(NULL, 0); // query the first neighbour
|
||||
|
||||
if (region_query_mode == REGION_QUERY_NONE) {
|
||||
@@ -1031,9 +1032,11 @@ void MyMesh::advanceRegionDiscover(const uint8_t *names, size_t len) {
|
||||
Serial.printf("regions: %s\n", entry); // ..for the serial CLI, as they arrive
|
||||
|
||||
int used = strlen(region_discover_reply);
|
||||
if (used + 1 + (dp - entry) < (int) sizeof(region_discover_reply)) { // else drop, reply is full
|
||||
if (used + 1 + (dp - entry) < (int) sizeof(region_discover_reply)) {
|
||||
if (used > 0) { region_discover_reply[used++] = '\n'; }
|
||||
strcpy(®ion_discover_reply[used], entry);
|
||||
} else if (region_discover_dropped < 0xFF) {
|
||||
region_discover_dropped++; // 'list' is full, so just report how many are missing
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1118,6 +1121,7 @@ MyMesh::MyMesh(mesh::MainBoard &board, mesh::Radio &radio, mesh::MillisecondCloc
|
||||
region_query_until = 0;
|
||||
region_discover_next = 0;
|
||||
region_discover_reply[0] = 0;
|
||||
region_discover_dropped = 0;
|
||||
next_region_fetch = 0;
|
||||
region_fetch_at = 0;
|
||||
region_fetch_added = region_fetch_known = region_fetch_fails = 0;
|
||||
@@ -1521,7 +1525,13 @@ void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply
|
||||
if (*sub == 0) {
|
||||
startRegionDiscover(reply);
|
||||
} else if (strcmp(sub, "list") == 0) {
|
||||
strcpy(reply, region_discover_reply[0] ? region_discover_reply : "-none-");
|
||||
if (region_discover_reply[0] == 0) {
|
||||
strcpy(reply, "-none-");
|
||||
} else if (region_discover_dropped > 0) { // ..so a short list isn't mistaken for the whole pass
|
||||
sprintf(reply, "%s\n+%d more", region_discover_reply, (int) region_discover_dropped);
|
||||
} else {
|
||||
strcpy(reply, region_discover_reply);
|
||||
}
|
||||
} else {
|
||||
strcpy(reply, "Err - unknown option");
|
||||
}
|
||||
|
||||
@@ -120,6 +120,7 @@ class MyMesh : public mesh::Mesh, public CommonCLICallbacks {
|
||||
uint8_t region_query_mode; // one of SCOPE_QUERY_*
|
||||
uint8_t region_discover_next; // index into neighbours[], for the 'discover.regions' pass
|
||||
char region_discover_reply[134]; // results of last pass, for 'discover.regions list'
|
||||
uint8_t region_discover_dropped; // ..entries from that pass which did not fit
|
||||
unsigned long next_region_fetch; // when to re-fetch from the subscribed node (0 = never)
|
||||
uint32_t region_fetch_at; // when the last fetch completed (0 = not yet)
|
||||
uint8_t region_fetch_added, region_fetch_known;
|
||||
|
||||
Reference in new issue
Block a user