From fb19c04304b1b9f063be8662e26c345598261177 Mon Sep 17 00:00:00 2001 From: Jared Dohrman Date: Fri, 1 May 2026 08:38:38 +1000 Subject: [PATCH] fix: tighten repeater CLI getters and build metadata --- build.sh | 23 +++++++++++++++++++++-- docs/custom-cli.md | 2 ++ examples/simple_repeater/MyMesh.cpp | 24 ++++++++++++------------ release-notes.yml | 6 ++++++ 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/build.sh b/build.sh index 1a46bcfa..2129518e 100755 --- a/build.sh +++ b/build.sh @@ -146,6 +146,21 @@ disable_debug_flags() { fi } +get_firmware_build_date() { + local env_name="$1" + local header="examples/simple_repeater/MyMesh.h" + + if [[ "$env_name" == *companion_radio* ]]; then + header="examples/companion_radio/MyMesh.h" + elif [[ "$env_name" == *room_server* ]]; then + header="examples/simple_room_server/MyMesh.h" + elif [[ "$env_name" == *sensor* ]]; then + header="examples/simple_sensor/SensorMesh.h" + fi + + sed -n 's/^[[:space:]]*#define[[:space:]][[:space:]]*FIRMWARE_BUILD_DATE[[:space:]][[:space:]]*"\([^"]*\)".*/\1/p' "$header" | head -n 1 +} + # build firmware for the provided pio env in $1 build_firmware() { # get env platform for post build actions @@ -154,8 +169,12 @@ build_firmware() { # get git commit sha COMMIT_HASH=$(git rev-parse --short HEAD) - # set firmware build date - FIRMWARE_BUILD_DATE=$(date '+%d-%b-%Y') + # use the same fallback build date as direct PlatformIO builds + FIRMWARE_BUILD_DATE=$(get_firmware_build_date "$1") + if [ -z "$FIRMWARE_BUILD_DATE" ]; then + echo "FIRMWARE_BUILD_DATE could not be read for $1" + exit 1 + fi # get FIRMWARE_VERSION, which should be provided by the environment if [ -z "$FIRMWARE_VERSION" ]; then diff --git a/docs/custom-cli.md b/docs/custom-cli.md index 4250e927..84421883 100644 --- a/docs/custom-cli.md +++ b/docs/custom-cli.md @@ -8,6 +8,8 @@ It does not try to repeat the full upstream MeshCore CLI surface. These commands are available on `*_repeater_mqtt` firmware targets. +No-argument `get` commands must be entered exactly as shown. + ### MQTT Status And Routing - `get mqtt.status`: shows WiFi, NTP, IATA, endpoint status, status publishing state, and TX state. diff --git a/examples/simple_repeater/MyMesh.cpp b/examples/simple_repeater/MyMesh.cpp index 4b2a0714..5df5387b 100644 --- a/examples/simple_repeater/MyMesh.cpp +++ b/examples/simple_repeater/MyMesh.cpp @@ -2233,11 +2233,11 @@ void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply } #endif #if defined(ESP_PLATFORM) - } else if (memcmp(command, "get wifi.status", 15) == 0) { + } else if (strcmp(command, "get wifi.status") == 0) { network.formatWifiStatusReply(reply, 160); - } else if (memcmp(command, "get wifi.ssid", 13) == 0) { + } else if (strcmp(command, "get wifi.ssid") == 0) { sprintf(reply, "> %s", network.getWifiSSID()[0] ? network.getWifiSSID() : "-"); - } else if (memcmp(command, "get wifi.powersaving", 20) == 0) { + } else if (strcmp(command, "get wifi.powersaving") == 0) { sprintf(reply, "> %s", network.getWifiPowerSave()); #endif #if defined(ESP_PLATFORM) && WITH_WEB_PANEL @@ -2308,23 +2308,23 @@ void MyMesh::handleCommand(uint32_t sender_timestamp, char *command, char *reply mqtt.formatStatusReply(reply, 160); } else if (strcmp(command, "get mqtt.client_version") == 0) { sprintf(reply, "> %s", mqtt.getClientVersion()); - } else if (memcmp(command, "get mqtt.iata", 13) == 0) { + } else if (strcmp(command, "get mqtt.iata") == 0) { sprintf(reply, "> %s", mqtt.getIata()); - } else if (memcmp(command, "get mqtt.owner", 14) == 0) { + } else if (strcmp(command, "get mqtt.owner") == 0) { sprintf(reply, "> %s", mqtt.getOwnerPublicKey()[0] ? mqtt.getOwnerPublicKey() : "-"); - } else if (memcmp(command, "get mqtt.email", 14) == 0) { + } else if (strcmp(command, "get mqtt.email") == 0) { sprintf(reply, "> %s", mqtt.getOwnerEmail()[0] ? mqtt.getOwnerEmail() : "-"); - } else if (memcmp(command, "get mqtt.packets", 16) == 0) { + } else if (strcmp(command, "get mqtt.packets") == 0) { sprintf(reply, "> %s", mqtt.isPacketsEnabled() ? "on" : "off"); - } else if (memcmp(command, "get mqtt.raw", 12) == 0) { + } else if (strcmp(command, "get mqtt.raw") == 0) { sprintf(reply, "> %s", mqtt.isRawEnabled() ? "on" : "off"); - } else if (memcmp(command, "get mqtt.tx", 11) == 0) { + } else if (strcmp(command, "get mqtt.tx") == 0) { sprintf(reply, "> %s", mqtt.isTxEnabled() ? "on" : "off"); - } else if (memcmp(command, "get mqtt.eastmesh-au", 20) == 0 || memcmp(command, "get mqtt.eastmesh.au", 20) == 0) { + } else if (strcmp(command, "get mqtt.eastmesh-au") == 0 || strcmp(command, "get mqtt.eastmesh.au") == 0) { sprintf(reply, "> %s", mqtt.isEndpointEnabled(0x01) ? "on" : "off"); - } else if (memcmp(command, "get mqtt.letsmesh-eu", 21) == 0 || memcmp(command, "get mqtt.letsmesh.eu", 21) == 0) { + } else if (strcmp(command, "get mqtt.letsmesh-eu") == 0 || strcmp(command, "get mqtt.letsmesh.eu") == 0) { sprintf(reply, "> %s", mqtt.isEndpointEnabled(0x02) ? "on" : "off"); - } else if (memcmp(command, "get mqtt.letsmesh-us", 21) == 0 || memcmp(command, "get mqtt.letsmesh.us", 21) == 0) { + } else if (strcmp(command, "get mqtt.letsmesh-us") == 0 || strcmp(command, "get mqtt.letsmesh.us") == 0) { sprintf(reply, "> %s", mqtt.isEndpointEnabled(0x04) ? "on" : "off"); } else if (memcmp(command, "set mqtt.tx ", 12) == 0) { mqtt.setTxEnabled(memcmp(&command[12], "on", 2) == 0); diff --git a/release-notes.yml b/release-notes.yml index e053bf0f..1e61e9fa 100644 --- a/release-notes.yml +++ b/release-notes.yml @@ -574,4 +574,10 @@ releases: - type: docs area: mqtt text: "Updated the CLI and web-panel docs to describe retained offline status publishing for broker toggles and IATA changes." + - type: fixed + area: cli + text: "Matched no-argument MQTT and Wi-Fi `get` commands exactly so malformed commands with trailing text no longer execute as valid getters." + - type: changed + area: build + text: "Aligned release-style builds with direct PlatformIO builds by using the firmware source build date instead of stamping the current build day into `ver` output." breaking_changes: []