Files
meshcore-bot-firmware/patches/meshcore/0009-Widen-hop-step-drop-ack-prefix-from-test-response.patch
cj-vana ee1b95cc9e forge: add patch 13 — quadratic hop delay growth
bias = hop * step + hop^2 * BOT_HOP_GROW_MILLIS

Bumps hop_step 3000->2000, adds BOT_HOP_GROW_MILLIS=400, raises cap
15000->50000 and TTL 75000->95000. Forces re-default of hop_step on
existing bots via BOT_PREFS_VERSION 5->6.

Gap between adjacent hops now grows with hop count (3200ms at hop 1
all the way to 8000ms at hop 8), so a far bot reliably has time to
hear a near bot's reply through the mesh before its own scheduled
fire time -- previous linear bias kept the gap constant at 3000ms,
which wasn't enough at 6+ hops where reply propagation takes ~5-10s.
2026-05-16 22:18:18 -06:00

93 lines
4.4 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: cj-vana <cj@depth23.online>
Date: Sat, 16 May 2026 20:05:19 -0600
Subject: [PATCH 09/13] Widen hop-step + drop "ack " prefix from test response
Two changes:
1. Coordination timing: bump BOT_HOP_STEP_MILLIS_DEFAULT 1500 -> 2500,
BOT_HOP_BIAS_MAX_MILLIS 8000 -> 12000, BOT_RESPONSE_PENDING_TTL_MILLIS
45000 -> 60000. Bumps BOT_PREFS_VERSION 3 -> 4 so existing bots
re-derive defaults instead of carrying the old 1500 ms hop step.
Why: a far bot (4 hops from request) was firing at ~7-10 s while a
near bot (1 hop) fired at ~3-6 s. Across 4-5 mesh hops, the near
bot's response took ~5-10 s of airtime+queueing to reach the far
bot, frequently arriving AFTER the far bot's scheduled fire time.
With 2500 ms/hop, the far bot now schedules at ~12 s, giving ~5-8 s
of margin for the near bot's response to arrive and trigger
token-based suppression.
2. Test command response: drop the literal "ack " prefix from
writeAckResponse and BotCommands::executeTest. Responses now start
directly with "@[sender] ..." which keeps the user mention and
metadata but matches user preference for less noise.
---
examples/companion_radio/BotCommands.cpp | 4 ++--
examples/companion_radio/BotTypes.h | 8 ++++----
examples/companion_radio/FirmwareBot.cpp | 2 +-
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/examples/companion_radio/BotCommands.cpp b/examples/companion_radio/BotCommands.cpp
index 44357a99..1aa4406d 100644
--- a/examples/companion_radio/BotCommands.cpp
+++ b/examples/companion_radio/BotCommands.cpp
@@ -536,9 +536,9 @@ BotCommandResult executeTest(const BotCommand& command, const BotCommandContext&
char received_at[9];
formatSecondsHms(context.uptime_seconds, received_at, sizeof(received_at));
if (command.args_len == 0) {
- return writeFormatted(output, output_len, "ack @[%s] local | recv %s", name, received_at);
+ return writeFormatted(output, output_len, "@[%s] local | recv %s", name, received_at);
}
- return writeFormatted(output, output_len, "ack @[%s] local | recv %s | %s", name, received_at, command.args);
+ return writeFormatted(output, output_len, "@[%s] local | recv %s | %s", name, received_at, command.args);
}
}
diff --git a/examples/companion_radio/BotTypes.h b/examples/companion_radio/BotTypes.h
index ad249300..5a953639 100644
--- a/examples/companion_radio/BotTypes.h
+++ b/examples/companion_radio/BotTypes.h
@@ -30,14 +30,14 @@
#define BOT_NEIGHBOR_RECENT_MILLIS (60UL * 60UL * 1000UL)
#define BOT_RESPONSE_DELAY_BASE_MILLIS 1200UL
#define BOT_RESPONSE_DELAY_JITTER_MILLIS 1800UL
-#define BOT_RESPONSE_PENDING_TTL_MILLIS 45000UL
+#define BOT_RESPONSE_PENDING_TTL_MILLIS 60000UL
#define BOT_RESPONSE_RECENT_TTL_MILLIS 30000UL
#define BOT_KNOWN_BOT_FLAG_SUPPRESS_NORMAL 0x01
#define BOT_SENDER_KEY_PREFIX_LEN 6
#define BOT_MIN_AUTH_SENDER_KEY_PREFIX_LEN 4
#define BOT_KNOWN_BOT_LABEL_LEN 12
#define BOT_PREFS_MAGIC 0x31504642UL
-#define BOT_PREFS_VERSION 3
+#define BOT_PREFS_VERSION 4
#define BOT_PREFS_DEFAULT_LOCAL_ADVERT_MILLIS (24UL * 60UL * 60UL * 1000UL)
#define BOT_PREFS_DEFAULT_FLOOD_ADVERT_MILLIS (24UL * 60UL * 60UL * 1000UL)
#define BOT_PREFS_INITIAL_LOCAL_ADVERT_MILLIS 60000UL
@@ -45,9 +45,9 @@
#define BOT_PREFS_MAX_DELAY_MILLIS 60000U
#define BOT_PREFS_MAX_ADVERT_MILLIS (7UL * 24UL * 60UL * 60UL * 1000UL)
#define BOT_PREFS_SERIALIZED_SIZE 296
-#define BOT_HOP_STEP_MILLIS_DEFAULT 1500U
+#define BOT_HOP_STEP_MILLIS_DEFAULT 2500U
#define BOT_HOP_STEP_MILLIS_MAX 30000U
-#define BOT_HOP_BIAS_MAX_MILLIS 8000UL
+#define BOT_HOP_BIAS_MAX_MILLIS 12000UL
enum BotChannelKind : uint8_t {
BOT_CHANNEL_DM = 0,
diff --git a/examples/companion_radio/FirmwareBot.cpp b/examples/companion_radio/FirmwareBot.cpp
index 3c310173..e228b7c8 100644
--- a/examples/companion_radio/FirmwareBot.cpp
+++ b/examples/companion_radio/FirmwareBot.cpp
@@ -322,7 +322,7 @@ BotWriteResult writeAckResponse(const BotMessage& message, const BotCommand& com
const char* connection = message.channel_kind == BOT_CHANNEL_DM
? "direct"
: (message.channel_name[0] ? message.channel_name : "channel");
- int n = snprintf(output, output_len, "ack @[%s] %s", sender, connection);
+ int n = snprintf(output, output_len, "@[%s] %s", sender, connection);
if (n < 0) {
output[0] = 0;
return BOT_WRITE_NO_SPACE;