From 919e6d380c039db3d4b259798d688d8a3bd122c6 Mon Sep 17 00:00:00 2001 From: Scott Powell Date: Sun, 19 Jan 2025 20:22:02 +1100 Subject: [PATCH] * extra debug diagnostics for repeater --- examples/simple_repeater/main.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/examples/simple_repeater/main.cpp b/examples/simple_repeater/main.cpp index 145c0b5..9f6f88e 100644 --- a/examples/simple_repeater/main.cpp +++ b/examples/simple_repeater/main.cpp @@ -197,9 +197,11 @@ protected: if (memcmp(&data[4], ADMIN_PASSWORD, 8) == 0) { // check for valid password auto client = putClient(sender); // add to known clients (if not already known) if (client == NULL || timestamp <= client->last_timestamp) { + MESH_DEBUG_PRINTLN("Client table full, or replay attack!"); return; // FATAL: client table is full -OR- replay attack } + MESH_DEBUG_PRINTLN("Login success!"); client->last_timestamp = timestamp; uint32_t now = getRTCClock()->getCurrentTime(); @@ -221,6 +223,9 @@ protected: } } } + } else { + data[4+8] = 0; // ensure null terminator + MESH_DEBUG_PRINTLN("Incorrect password: %s", &data[4]); } } } @@ -290,7 +295,7 @@ protected: int i = matching_peer_indexes[sender_idx]; if (i >= 0 && i < num_clients) { // get from our known_clients table (sender SHOULD already be known in this context) - Serial.printf("PATH to client, path_len=%d\n", (uint32_t) path_len); + MESH_DEBUG_PRINTLN("PATH to client, path_len=%d", (uint32_t) path_len); auto client = &known_clients[i]; memcpy(client->out_path, path, client->out_path_len = path_len); // store a copy of path, for sendDirect() } else { @@ -364,7 +369,7 @@ static char command[80]; void setup() { Serial.begin(115200); - delay(5000); + delay(1000); board.begin();