mirror of
https://github.com/Colorado-Mesh/meshcore-bot-firmware.git
synced 2026-08-11 16:20:29 +00:00
forge: add patch 15 — report DM flood paths
This commit is contained in:
@@ -0,0 +1,45 @@
|
|||||||
|
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||||
|
From: cj-vana <cj@depth23.online>
|
||||||
|
Date: Sun, 17 May 2026 21:07:25 -0600
|
||||||
|
Subject: [PATCH] Report flood paths in bot DM diagnostics
|
||||||
|
|
||||||
|
---
|
||||||
|
examples/companion_radio/FirmwareBot.cpp | 6 +-----
|
||||||
|
examples/companion_radio/MyMesh.cpp | 7 ++++++-
|
||||||
|
2 files changed, 7 insertions(+), 6 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/examples/companion_radio/FirmwareBot.cpp b/examples/companion_radio/FirmwareBot.cpp
|
||||||
|
index 21312c55..3b4a008e 100644
|
||||||
|
--- a/examples/companion_radio/FirmwareBot.cpp
|
||||||
|
+++ b/examples/companion_radio/FirmwareBot.cpp
|
||||||
|
@@ -320,11 +320,7 @@ BotWriteResult writeAckResponse(const BotMessage& message, const BotCommand& com
|
||||||
|
|
||||||
|
const char* sender = message.sender_name[0] ? message.sender_name : "unknown";
|
||||||
|
int n;
|
||||||
|
- if (message.channel_kind == BOT_CHANNEL_DM) {
|
||||||
|
- n = snprintf(output, output_len, "@[%s] direct", sender);
|
||||||
|
- } else {
|
||||||
|
- n = snprintf(output, output_len, "@[%s]", sender);
|
||||||
|
- }
|
||||||
|
+ n = snprintf(output, output_len, "@[%s]", sender);
|
||||||
|
if (n < 0) {
|
||||||
|
output[0] = 0;
|
||||||
|
return BOT_WRITE_NO_SPACE;
|
||||||
|
diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp
|
||||||
|
index 1a7ddb7a..bfed7f98 100644
|
||||||
|
--- a/examples/companion_radio/MyMesh.cpp
|
||||||
|
+++ b/examples/companion_radio/MyMesh.cpp
|
||||||
|
@@ -1083,7 +1083,12 @@ void MyMesh::observeBotDirectMessage(const ContactInfo &from, uint32_t sender_ti
|
||||||
|
if (rssi < -32768.0f) rssi = -32768.0f;
|
||||||
|
recordBotNeighbor(from.id.pub_key, (int16_t)rssi, (int8_t)(packet->getSNR() * 4));
|
||||||
|
}
|
||||||
|
- if (from.out_path_len != OUT_PATH_UNKNOWN && mesh::Packet::isValidPathLen(from.out_path_len)) {
|
||||||
|
+ if (packet && packet->isRouteFlood() && packet->path_len <= 0xFF && mesh::Packet::isValidPathLen((uint8_t)packet->path_len)) {
|
||||||
|
+ message.path_len = (uint8_t)packet->path_len;
|
||||||
|
+ message.path_hash_size = packet->getPathHashSize();
|
||||||
|
+ message.path_hash_count = packet->getPathHashCount();
|
||||||
|
+ message.path = packet->path;
|
||||||
|
+ } else if (from.out_path_len != OUT_PATH_UNKNOWN && mesh::Packet::isValidPathLen(from.out_path_len)) {
|
||||||
|
message.path_len = from.out_path_len;
|
||||||
|
message.path_hash_size = (from.out_path_len >> 6) + 1;
|
||||||
|
message.path_hash_count = from.out_path_len & 63;
|
||||||
@@ -547,7 +547,7 @@ static void test_ack_response_format() {
|
|||||||
message.channel_name[0] = 0;
|
message.channel_name[0] = 0;
|
||||||
assert(FirmwareBot::parseCommand("!t", 2, &command));
|
assert(FirmwareBot::parseCommand("!t", 2, &command));
|
||||||
assert(FirmwareBot::writeAckResponse(message, command, out, sizeof(out), &written) == BOT_WRITE_OK);
|
assert(FirmwareBot::writeAckResponse(message, command, out, sizeof(out), &written) == BOT_WRITE_OK);
|
||||||
assert(strcmp(out, "@[unknown] direct | 0 hops, SNR 0.00 | recv 21:25:45") == 0);
|
assert(strcmp(out, "@[unknown] | 0 hops, SNR 0.00 | recv 21:25:45") == 0);
|
||||||
|
|
||||||
uint8_t path[] = { 0x12, 0x34, 0xab, 0xcd };
|
uint8_t path[] = { 0x12, 0x34, 0xab, 0xcd };
|
||||||
message.channel_kind = BOT_CHANNEL_BOT;
|
message.channel_kind = BOT_CHANNEL_BOT;
|
||||||
@@ -561,6 +561,11 @@ static void test_ack_response_format() {
|
|||||||
assert(strcmp(out, "@[bob] | 2 hops, 2-byte hashes, SNR -1.25 | recv 21:25:45") == 0);
|
assert(strcmp(out, "@[bob] | 2 hops, 2-byte hashes, SNR -1.25 | recv 21:25:45") == 0);
|
||||||
assert(strstr(out, "Bot test OK") == NULL);
|
assert(strstr(out, "Bot test OK") == NULL);
|
||||||
|
|
||||||
|
message.channel_kind = BOT_CHANNEL_DM;
|
||||||
|
message.channel_name[0] = 0;
|
||||||
|
assert(FirmwareBot::writeAckResponse(message, command, out, sizeof(out), &written) == BOT_WRITE_OK);
|
||||||
|
assert(strcmp(out, "@[bob] | 2 hops, 2-byte hashes, SNR -1.25 | recv 21:25:45") == 0);
|
||||||
|
|
||||||
char small[16];
|
char small[16];
|
||||||
assert(FirmwareBot::writeAckResponse(message, command, small, sizeof(small), &written) == BOT_WRITE_TRUNCATED);
|
assert(FirmwareBot::writeAckResponse(message, command, small, sizeof(small), &written) == BOT_WRITE_TRUNCATED);
|
||||||
assert(strncmp(small, "@[bob]", 6) == 0);
|
assert(strncmp(small, "@[bob]", 6) == 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user