From 050633b6fc8017839c006b586c66b299fe4ec44e Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Mon, 31 Aug 2026 20:20:41 +0200 Subject: [PATCH] fix(bot): normalize GPS reply casing, dedupe channel sender-split Reuse the existing botChannelSenderSplit() helper for the channel [LOC]-share sender name instead of re-implementing the same "Name: " split inline, and fix a stray lowercase "gps:" reply that didn't match the rest of the !gps command's replies. --- examples/companion_radio/MyMesh.cpp | 13 ++++--------- examples/companion_radio/MyMeshBot.h | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index 37b4fe91..55a7bd3f 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -882,15 +882,10 @@ void MyMesh::onChannelMessageRecv(const mesh::GroupChannel &channel, mesh::Packe // chatter is ignored. int32_t loc_lat, loc_lon; if (_ui && geo::parseLocShare(text, loc_lat, loc_lon)) { - char sender[32] = {0}; - const char* sep = strstr(text, ": "); - if (sep && sep > text) { - int n = (int)(sep - text); - if (n > (int)sizeof(sender) - 1) n = sizeof(sender) - 1; - memcpy(sender, text, n); - sender[n] = '\0'; - } - _ui->onSharedLocation(nullptr, sender[0] ? sender : "?", loc_lat, loc_lon, timestamp, false); + char sender[32]; + const char* msg; + botChannelSenderSplit(text, sender, sizeof(sender), &msg); + _ui->onSharedLocation(nullptr, sender, loc_lat, loc_lon, timestamp, false); } #endif diff --git a/examples/companion_radio/MyMeshBot.h b/examples/companion_radio/MyMeshBot.h index bb3d4e78..45e3ab81 100644 --- a/examples/companion_radio/MyMeshBot.h +++ b/examples/companion_radio/MyMeshBot.h @@ -300,7 +300,7 @@ bool MyMesh::botCommandReply(const char* cmd, const char* arg, const char* arg2, } bool on = !strcmp(arg, "on"); // arg was lowercased while parsing (see botScanCommands) bool off = !strcmp(arg, "off"); - if (!on && !off) { snprintf(out, out_len, "gps: on|off|fix?"); return true; } + if (!on && !off) { snprintf(out, out_len, "GPS: on|off|fix?"); return true; } // Deferred: applyPendingBotActions() actually flips the GPS state, once // quiet-hours/cooldown/throttle have passed (see MyMesh.h). _bot_gps_action_pending = true;