diff --git a/examples/companion_radio/CompanionRetry.h b/examples/companion_radio/CompanionRetry.h index 168fe3d4c..b96431fc7 100644 --- a/examples/companion_radio/CompanionRetry.h +++ b/examples/companion_radio/CompanionRetry.h @@ -1,5 +1,7 @@ #pragma once +#include + #include #include #include @@ -87,7 +89,7 @@ bool handleRetryCommand(CompanionNodePrefs& prefs, const char* command, prefs.flood_retry_max_path = old_path; prefs.flood_retry_group_max_path = old_group_path; prefs.flood_retry_advert_enabled = old_advert; - snprintf(reply, reply_size, "Error: retry setting could not be saved"); + snprintf(reply, reply_size, MESH_CLI_REPLY_TEXT("Error: retry setting could not be saved", "Error: retry setting not saved")); return true; } if (old_count != 0 && prefs.flood_retry_attempts == 0) cancel_flood_retries(); diff --git a/examples/companion_radio/MyMesh.cpp b/examples/companion_radio/MyMesh.cpp index 4d752e184..56a4482a6 100644 --- a/examples/companion_radio/MyMesh.cpp +++ b/examples/companion_radio/MyMesh.cpp @@ -9398,7 +9398,7 @@ bool MyMesh::handleRxPowerSavingGetCommand(const char* command, char* reply, const bool config = strcmp(command, "get radio.rxps.config") == 0; if (!config && strcmp(command, "get radio.rxps") != 0) return false; if (!radio_driver.supportsRxPowerSaving()) { - mesh::cli::formatError(reply, reply_size, "RX power saving is unsupported on this radio"); + mesh::cli::formatError(reply, reply_size, MESH_CLI_REPLY_TEXT("RX power saving is unsupported on this radio", "RX power saving unsupported on radio")); return true; } @@ -11007,7 +11007,7 @@ bool MyMesh::handleDirectCommand(const char* command, char* reply, size_t reply_ #else if (strcmp(command, "get dm.one_key") == 0 || strcmp(command, "get dm.held") == 0 || strncmp(command, "set dm.one_key ", 15) == 0) { - mesh::cli::formatError(reply, reply_size, "one-key DMs unsupported on this build"); + mesh::cli::formatError(reply, reply_size, MESH_CLI_REPLY_TEXT("one-key DMs unsupported on this build", "one-key DMs unsupported in build")); return true; } #endif @@ -11359,7 +11359,7 @@ bool MyMesh::handleCommand(const char* command, uint32_t sender_timestamp, if (strncmp(command, "set tx ", 7) == 0) { int32_t parsed = 0; if (!mesh::cli::parseIntegerStrict(command + 7, parsed)) { - mesh::cli::formatError(reply, reply_capacity, "invalid TX power"); + mesh::cli::formatError(reply, reply_capacity, MESH_CLI_REPLY_TEXT("invalid TX power", "bad TX power")); } else if (parsed < -9 || parsed > MAX_LORA_TX_POWER) { snprintf(reply, reply_capacity, "Error: TX -9..%d dBm", MAX_LORA_TX_POWER); diff --git a/examples/companion_radio/Notifications.cpp b/examples/companion_radio/Notifications.cpp index 9dc50ce98..b025b7a6d 100644 --- a/examples/companion_radio/Notifications.cpp +++ b/examples/companion_radio/Notifications.cpp @@ -1,3 +1,4 @@ +#include #include "MyMesh.h" #include "target.h" #include "NotificationSettingsFile.h" @@ -160,7 +161,7 @@ bool MyMesh::handleNotificationCommand(const char* command,char* reply,size_t si bool MyMesh::handleNotificationCommand(const char* command,char* reply,size_t size) { if(strncmp(command,"set notify.",11)&&strncmp(command,"get notify",10) &&strncmp(command,"notify.",7))return false; - snprintf(reply,size,"Error: programmable alerts unavailable on this compact STM32 build"); + snprintf(reply,size,MESH_CLI_REPLY_TEXT("Error: programmable alerts unavailable on this compact STM32 build", "Error: programmable alerts unavailable on compact STM32")); return true; } #endif diff --git a/src/helpers/CommonRadioPrefs.cpp b/src/helpers/CommonRadioPrefs.cpp index 42481b3f1..94ada63c6 100644 --- a/src/helpers/CommonRadioPrefs.cpp +++ b/src/helpers/CommonRadioPrefs.cpp @@ -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(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(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(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(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(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; } diff --git a/src/helpers/RadioProfileCLI.cpp b/src/helpers/RadioProfileCLI.cpp index d6dbbd5c1..66e75d4c0 100644 --- a/src/helpers/RadioProfileCLI.cpp +++ b/src/helpers/RadioProfileCLI.cpp @@ -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 { diff --git a/test/fixtures/cli_reply_text.json b/test/fixtures/cli_reply_text.json index c476044c5..0f444e7da 100644 --- a/test/fixtures/cli_reply_text.json +++ b/test/fixtures/cli_reply_text.json @@ -853,6 +853,91 @@ "file": "examples/companion_radio/MyMesh.cpp", "verbose": "Error, must be from -12 to +14", "concise": "Error, -12 to +14" + }, + { + "file": "examples/companion_radio/MyMesh.cpp", + "verbose": "RX power saving is unsupported on this radio", + "concise": "RX power saving unsupported on radio" + }, + { + "file": "examples/companion_radio/MyMesh.cpp", + "verbose": "one-key DMs unsupported on this build", + "concise": "one-key DMs unsupported in build" + }, + { + "file": "examples/companion_radio/MyMesh.cpp", + "verbose": "invalid TX power", + "concise": "bad TX power" + }, + { + "file": "src/helpers/RadioProfileCLI.cpp", + "verbose": "radio profiles unsupported", + "concise": "profiles unsupported" + }, + { + "file": "src/helpers/RadioProfileCLI.cpp", + "verbose": "use get/set tx.reply auto|radio|radio2|both|off [force for radio2/both]", + "concise": "get/set tx.reply auto|radio|radio2|both|off [force for radio2/both]" + }, + { + "file": "src/helpers/RadioProfileCLI.cpp", + "verbose": "use get/set radio2.cross [auto|on|off]", + "concise": "get/set radio2.cross [auto|on|off]" + }, + { + "file": "src/helpers/RadioProfileCLI.cpp", + "verbose": "clear tempradioat2 schedules first", + "concise": "clear tempradioat2 first" + }, + { + "file": "src/helpers/RadioProfileCLI.cpp", + "verbose": "temporary schedule overlaps active session", + "concise": "temp schedule overlaps active session" + }, + { + "file": "src/helpers/RadioProfileCLI.cpp", + "verbose": "temporary schedules overlap", + "concise": "temp schedules overlap" + }, + { + "file": "src/helpers/CommonRadioPrefs.cpp", + "verbose": "Error: invalid airtime factor", + "concise": "Error: bad airtime factor" + }, + { + "file": "src/helpers/CommonRadioPrefs.cpp", + "verbose": "Error, must be 0-255", + "concise": "Error, 0-255" + }, + { + "file": "src/helpers/CommonRadioPrefs.cpp", + "verbose": "Error: use set cad on|off", + "concise": "Error: set cad on|off" + }, + { + "file": "src/helpers/CommonRadioPrefs.cpp", + "verbose": "Error: use set radio.rxgain on|off", + "concise": "Error: set radio.rxgain on|off" + }, + { + "file": "src/helpers/CommonRadioPrefs.cpp", + "verbose": "Error: invalid TX power", + "concise": "Error: bad TX power" + }, + { + "file": "src/helpers/CommonRadioPrefs.cpp", + "verbose": "Error, must be 0 or 1", + "concise": "Error, 0|1" + }, + { + "file": "examples/companion_radio/CompanionRetry.h", + "verbose": "Error: retry setting could not be saved", + "concise": "Error: retry setting not saved" + }, + { + "file": "examples/companion_radio/Notifications.cpp", + "verbose": "Error: programmable alerts unavailable on this compact STM32 build", + "concise": "Error: programmable alerts unavailable on compact STM32" } ], "noncompact_tokens_sha256": { @@ -864,6 +949,9 @@ "src/helpers/FloodAdvertCLI.h": "0f378e4d0f6c3b9b79991068a4b4208139484d2144ee1d7c5094d39043463be4", "src/helpers/LedSettings.cpp": "df0681234ca1337148ad59caa935857bc692f98bf18603ca6d099c0382028400", "src/helpers/StorageLayout.cpp": "5dd1c8bcbe2902e1f22d14f9ab425465bdc38926fae23989987d850b484cbb18", - "examples/companion_radio/MyMesh.cpp": "4ed72908fa1b986edb27c7a74acaccd5fda212c68f2f41537692739c040bb392" + "examples/companion_radio/MyMesh.cpp": "4ed72908fa1b986edb27c7a74acaccd5fda212c68f2f41537692739c040bb392", + "src/helpers/CommonRadioPrefs.cpp": "16b1fb499426abde83566b6481df89b80302c72e00f0f4aa3843b6c9b9de4218", + "examples/companion_radio/CompanionRetry.h": "e0ae10c7b2f778346f4645c4e147d87e1fbc7f8b99484752a8eed914bb21380f", + "examples/companion_radio/Notifications.cpp": "173fb0d452fdd383585dd88ab35fbb079a90e068adca2db9bc44d604557d3873" } }