diff --git a/docs/cli_commands.md b/docs/cli_commands.md index 116a4914..395deb46 100644 --- a/docs/cli_commands.md +++ b/docs/cli_commands.md @@ -738,7 +738,9 @@ This document provides an overview of CLI commands that can be sent to MeshCore - `set region.autotag.max.hops ` **Parameters:** -- `value`: Maximum path hash count (0-8). `0` means only auto-tag packets without scope received directly (zero-hop); higher values also auto-tag packets without scope that already traversed that many repeaters. +- `value`: Maximum path hash count. `0` means only auto-tag packets without scope received directly (zero-hop); higher values also auto-tag packets without scope that already traversed that many repeaters. + +**Range:** `0` to `8` (inclusive). Values outside this range are rejected by `set` and clamped to this range on load. The upper bound of `8` is intentionally well below the default `flood.max` of `64`, because auto-tagging packets from far across the mesh almost always produces incorrect region assignments — the limit exists to keep admins honest about the geographic scope they can actually account for. **Default:** `1` diff --git a/src/helpers/CommonCLI.cpp b/src/helpers/CommonCLI.cpp index 2d348f8f..81fc5764 100644 --- a/src/helpers/CommonCLI.cpp +++ b/src/helpers/CommonCLI.cpp @@ -122,7 +122,7 @@ void CommonCLI::loadPrefsInt(FILESYSTEM* fs, const char* filename) { // sanitise settings _prefs->rx_boosted_gain = constrain(_prefs->rx_boosted_gain, 0, 1); // boolean _prefs->region_autotag = constrain(_prefs->region_autotag, 0, 1); // boolean - _prefs->region_autotag_max_hops = constrain(_prefs->region_autotag_max_hops, 0, 8); + _prefs->region_autotag_max_hops = constrain(_prefs->region_autotag_max_hops, 0, REGION_AUTOTAG_MAX_HOPS_LIMIT); file.close(); } @@ -630,12 +630,12 @@ void CommonCLI::handleCommand(uint32_t sender_timestamp, const char* command, ch strcpy(reply, "OK"); } else if (memcmp(config, "region.autotag.max.hops ", 24) == 0) { int h = atoi(&config[24]); - if (h >= 0 && h <= 8) { + if (h >= 0 && h <= REGION_AUTOTAG_MAX_HOPS_LIMIT) { _prefs->region_autotag_max_hops = (uint8_t)h; savePrefs(); strcpy(reply, "OK"); } else { - strcpy(reply, "Error, range is 0-8"); + sprintf(reply, "Error, range is 0-%d", REGION_AUTOTAG_MAX_HOPS_LIMIT); } } else if (memcmp(config, "region.autotag ", 15) == 0) { _prefs->region_autotag = memcmp(&config[15], "on", 2) == 0; diff --git a/src/helpers/CommonCLI.h b/src/helpers/CommonCLI.h index f0bd2aba..72c200c0 100644 --- a/src/helpers/CommonCLI.h +++ b/src/helpers/CommonCLI.h @@ -13,6 +13,8 @@ #define ADVERT_LOC_SHARE 1 #define ADVERT_LOC_PREFS 2 +#define REGION_AUTOTAG_MAX_HOPS_LIMIT 8 // upper bound for region.autotag.max.hops pref + #define LOOP_DETECT_OFF 0 #define LOOP_DETECT_MINIMAL 1 #define LOOP_DETECT_MODERATE 2