diff --git a/docs/cli_commands.md b/docs/cli_commands.md index a9392bd6..46c4661e 100644 --- a/docs/cli_commands.md +++ b/docs/cli_commands.md @@ -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`. diff --git a/examples/simple_repeater/MyMesh.cpp b/examples/simple_repeater/MyMesh.cpp index 73492af4..56a54f9d 100644 --- a/examples/simple_repeater/MyMesh.cpp +++ b/examples/simple_repeater/MyMesh.cpp @@ -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"); } diff --git a/examples/simple_repeater/MyMesh.h b/examples/simple_repeater/MyMesh.h index dd1e533a..2e5e2f30 100644 --- a/examples/simple_repeater/MyMesh.h +++ b/examples/simple_repeater/MyMesh.h @@ -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;