Repeater, room server, sensor, companion: set commands refuse out-of-range or non-numeric values instead of saving them
Changelog: Repeater, room server, sensor, companion: `set tx`, `set radio`, `set freq` and other number settings now refuse a value that is out of range or not a number, instead of saving it and answering OK. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
c58274a2e1
commit
14f5892033
9 files changed
+260
-56
No files matched your search
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "MyMesh.h"
|
||||
#include <helpers/NodeMaintenance.h>
|
||||
#include <helpers/CliArgs.h>
|
||||
|
||||
// ===========================================================================
|
||||
// CUSTOM (TeTeHacko): `blink [n]` -- make THIS board flash its LED on demand,
|
||||
@@ -625,7 +626,12 @@ MyMesh the_mesh(board, radio_driver, *new ArduinoMillis(), fast_rng, rtc_clock,
|
||||
bool txPwrHandleCommand(const char* command, char* reply) {
|
||||
if (memcmp(command, "txpwr", 5) != 0 || (command[5] != 0 && command[5] != ' ')) return false;
|
||||
if (command[5] == ' ') {
|
||||
int dbm = atoi(&command[6]);
|
||||
long dbm_l; // atoi() into int8_t: "250" went out as -6 dBm, "abc" as 0
|
||||
if (!cli_args::parseInt(&command[6], -9, 30, &dbm_l)) {
|
||||
strcpy(reply, "ERR - txpwr <-9..30 dBm>");
|
||||
return true;
|
||||
}
|
||||
int dbm = dbm_l;
|
||||
radio_driver.setTxPower((int8_t) dbm);
|
||||
int16_t st = radio_driver.getLastTxPowerStatus();
|
||||
sprintf(reply, "%s - txpwr %d dBm, RadioLib status %d%s", st == RADIOLIB_ERR_NONE ? "OK" : "ERR",
|
||||
|
||||
Reference in new issue
Block a user