Trim remaining validation wording in small Companion profiles

This commit is contained in:
mikecarper committed 2026-10-28 04:44:06 -07:00
1 parent f973e4a952
commit 8f20fe5d83
6 files changed
+111 -19

No files matched your search

+8 -7
View File
@@ -1,3 +1,4 @@
#include "CLIReplyText.h"
#include "CommonRadioPrefs.h"
#include "TxtDataHelpers.h"
#include "target.h"
@@ -284,7 +285,7 @@ bool CommonRadioPrefs::handleCommand(const char* command, uint32_t sender_timest
if (strcmp(command, "get dutycycle") == 0) {
const float factor = getAirtimeFactor();
if (!isfinite(factor) || factor < 0.0f) {
strcpy(reply, "Error: invalid airtime factor");
strcpy(reply, MESH_CLI_REPLY_TEXT("Error: invalid airtime factor", "Error: bad airtime factor"));
} else {
const int tenths = static_cast<int>(1000.0f / (factor + 1.0f) + 0.5f);
sprintf(reply, "> %d.%d%%", tenths / 10, tenths % 10);
@@ -315,7 +316,7 @@ bool CommonRadioPrefs::handleCommand(const char* command, uint32_t sender_timest
setIntThresh(static_cast<uint8_t>(threshold));
strcpy(reply, "OK");
} else {
strcpy(reply, "Error, must be 0-255");
strcpy(reply, MESH_CLI_REPLY_TEXT("Error, must be 0-255", "Error, 0-255"));
}
return true;
}
@@ -330,7 +331,7 @@ bool CommonRadioPrefs::handleCommand(const char* command, uint32_t sender_timest
setCadEnabled(strcmp(value, "on") == 0);
strcpy(reply, "OK");
} else {
strcpy(reply, "Error: use set cad on|off");
strcpy(reply, MESH_CLI_REPLY_TEXT("Error: use set cad on|off", "Error: set cad on|off"));
}
return true;
}
@@ -342,7 +343,7 @@ bool CommonRadioPrefs::handleCommand(const char* command, uint32_t sender_timest
if (startsWith(command, "set radio.rxgain ")) {
const char* value = command + strlen("set radio.rxgain ");
if (strcmp(value, "on") != 0 && strcmp(value, "off") != 0) {
strcpy(reply, "Error: use set radio.rxgain on|off");
strcpy(reply, MESH_CLI_REPLY_TEXT("Error: use set radio.rxgain on|off", "Error: set radio.rxgain on|off"));
return true;
}
@@ -363,7 +364,7 @@ bool CommonRadioPrefs::handleCommand(const char* command, uint32_t sender_timest
if (startsWith(command, "set tx ")) {
int32_t dbm = 0;
if (!parseIntStrict(command + strlen("set tx "), -128, 127, dbm)) {
strcpy(reply, "Error: invalid TX power");
strcpy(reply, MESH_CLI_REPLY_TEXT("Error: invalid TX power", "Error: bad TX power"));
} else if (!radio_driver.setTxPower(static_cast<int8_t>(dbm))) {
strcpy(reply, "Error: TX power rejected");
} else {
@@ -399,7 +400,7 @@ bool CommonRadioPrefs::handleCommand(const char* command, uint32_t sender_timest
setAgcResetInt(static_cast<uint8_t>(seconds));
sprintf(reply, "OK - interval rounded to %d", (uint32_t) getAgcResetInt());
} else {
strcpy(reply, "Error, must be 0-255");
strcpy(reply, MESH_CLI_REPLY_TEXT("Error, must be 0-255", "Error, 0-255"));
}
return true;
}
@@ -429,7 +430,7 @@ bool CommonRadioPrefs::handleCommand(const char* command, uint32_t sender_timest
setMultiAcks(static_cast<uint8_t>(enabled));
strcpy(reply, "OK");
} else {
strcpy(reply, "Error, must be 0 or 1");
strcpy(reply, MESH_CLI_REPLY_TEXT("Error, must be 0 or 1", "Error, 0|1"));
}
return true;
}
+6 -6
View File
@@ -1106,7 +1106,7 @@ bool RadioProfileCLI::handle(const char* command, char* reply, size_t capacity,
const bool status = kind == Status;
const bool scan = kind == Scan;
const bool timing = kind == Timing || kind == TimingAlias;
if (!radio_ || !radio_->profiles()) { cli::formatError(reply, capacity, "radio profiles unsupported"); return true; }
if (!radio_ || !radio_->profiles()) { cli::formatError(reply, capacity, MESH_CLI_REPLY_TEXT("radio profiles unsupported", "profiles unsupported")); return true; }
if (command == text && *args && verb == Get && (temporary || base)) verb = Set;
if (remote_origin && !remote_command_
&& (((base || temporary) && verb == Set) || (scheduled_temp && verb == Delete))) {
@@ -1138,7 +1138,7 @@ bool RadioProfileCLI::handle(const char* command, char* reply, size_t capacity,
if (verb != Set || length >= sizeof(mode) || !parseRadioTxPolicy(mode, policy)
|| (*suffix && !force)
|| (force && policy != RADIO_TX_BOTH && policy != RADIO_TX_SECONDARY)) {
cli::formatError(reply, capacity, "use get/set tx.reply auto|radio|radio2|both|off [force for radio2/both]");
cli::formatError(reply, capacity, MESH_CLI_REPLY_TEXT("use get/set tx.reply auto|radio|radio2|both|off [force for radio2/both]", "get/set tx.reply auto|radio|radio2|both|off [force for radio2/both]"));
return true;
}
const uint8_t previous = reply_setting_;
@@ -1184,7 +1184,7 @@ bool RadioProfileCLI::handle(const char* command, char* reply, size_t capacity,
auto mode = !strcmp(args, "auto") ? RadioCrossMode::Auto : !strcmp(args, "on") ? RadioCrossMode::On : RadioCrossMode::Off;
if (save(saved_, primary_preamble_, mode)) { cross_ = mode; publish(); snprintf(reply, capacity, "OK"); }
else cli::formatError(reply, capacity, MESH_CLI_REPLY_TEXT("settings could not be saved", "settings not saved"));
} else cli::formatError(reply, capacity, "use get/set radio2.cross [auto|on|off]");
} else cli::formatError(reply, capacity, MESH_CLI_REPLY_TEXT("use get/set radio2.cross [auto|on|off]", "get/set radio2.cross [auto|on|off]"));
return true;
}
if (scan) {
@@ -1371,10 +1371,10 @@ bool RadioProfileCLI::handle(const char* command, char* reply, size_t capacity,
: 0;
const uint64_t session_left = pending_left > temp_remaining_ms_ ? pending_left : temp_remaining_ms_;
if ((temp_active_ || temp_pending_) && (uint64_t)(start-epoch)*1000 < session_left) {
cli::formatError(reply, capacity, "temporary schedule overlaps active session"); return true;
cli::formatError(reply, capacity, MESH_CLI_REPLY_TEXT("temporary schedule overlaps active session", "temp schedule overlaps active session")); return true;
}
for (const auto& s : schedules_) if (s.active && s.temporary && start < s.end && end > s.start) {
cli::formatError(reply, capacity, "temporary schedules overlap"); return true;
cli::formatError(reply, capacity, MESH_CLI_REPLY_TEXT("temporary schedules overlap", "temp schedules overlap")); return true;
}
}
const unsigned first = scheduled_temp ? 4 : 0;
@@ -1402,7 +1402,7 @@ bool RadioProfileCLI::handle(const char* command, char* reply, size_t capacity,
}
if (temporary) {
for (const auto& s : schedules_) if (s.active && s.temporary) {
cli::formatError(reply, capacity, "clear tempradioat2 schedules first"); return true;
cli::formatError(reply, capacity, MESH_CLI_REPLY_TEXT("clear tempradioat2 schedules first", "clear tempradioat2 first")); return true;
}
if (remote_command_) stageRemoteMutation(RemoteMutation::Temporary, config, minutes * 60000UL);
else {