Skip to content

Commit d30bd80

Browse files
committed
Fix neighbours command: show details via remote CLI, add name and CB state
The neighbours output was gated by !ctx.buf so details were only visible on local Serial. Removed the guard and added buffer overflow check like the nodes command. Output now shows resolved node name and circuit breaker state instead of raw 6-byte pubkey prefix.
1 parent 4e13514 commit d30bd80

1 file changed

Lines changed: 16 additions & 9 deletions

File tree

src/main.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,23 @@ static bool dispatchSharedCommand(const char* cmd, CmdCtx& ctx, bool isAdmin) {
188188
NeighbourTracker& nb = repeaterHelper.getNeighbours();
189189
uint8_t cnt = nb.getCount();
190190
CP("Nbr:%d\n", cnt);
191-
if (!ctx.buf) {
192-
for (uint8_t i = 0; i < cnt; i++) {
193-
const NeighbourInfo* n = nb.getNeighbour(i);
194-
if (n) {
195-
uint32_t ago = (millis() - n->lastHeard) / 1000;
196-
CP(" %02X%02X%02X%02X%02X%02X rssi=%d snr=%d.%ddB ago=%lus\n",
197-
n->pubKeyPrefix[0], n->pubKeyPrefix[1], n->pubKeyPrefix[2],
198-
n->pubKeyPrefix[3], n->pubKeyPrefix[4], n->pubKeyPrefix[5],
199-
n->rssi, n->snr/4, abs(n->snr%4)*25, ago);
191+
for (uint8_t i = 0; i < cnt; i++) {
192+
const NeighbourInfo* n = nb.getNeighbour(i);
193+
if (n) {
194+
if (ctx.buf && ctx.len >= ctx.maxLen - 48) break;
195+
uint32_t ago = (millis() - n->lastHeard) / 1000;
196+
// Resolve name from SeenNodesTracker via hash (pubKeyPrefix[0])
197+
const char* name = "-";
198+
for (uint8_t j = 0; j < seenNodes.getCount(); j++) {
199+
const SeenNode* sn = seenNodes.getNode(j);
200+
if (sn && sn->hash == n->pubKeyPrefix[0] && sn->name[0]) {
201+
name = sn->name; break;
202+
}
200203
}
204+
const char* cb = n->cbState == 0 ? "ok" : (n->cbState == 1 ? "OPEN" : "half");
205+
CP(" %02X %s %ddBm s:%d.%ddB cb:%s %lus\n",
206+
n->pubKeyPrefix[0], name,
207+
n->rssi, n->snr/4, abs(n->snr%4)*25, cb, ago);
201208
}
202209
}
203210
}

0 commit comments

Comments
 (0)