Fix CLI vtx command parsing to allow reset
Previously the validation was checking for channel and band values > 0 which caused a parsing error. Unfortunately this also prevented the ability to reset the entry. This resulted in the output from the `vtx` command not being usable to paste back in as any indexes not configured would cause errors.
This commit is contained in:
parent
a646c09c2c
commit
d62168378f
|
@ -2312,8 +2312,9 @@ static void cliVtx(char *cmdline)
|
|||
ptr = nextArg(ptr);
|
||||
if (ptr) {
|
||||
val = atoi(ptr);
|
||||
// FIXME Use VTX API to get min/max
|
||||
if (val >= VTX_SETTINGS_MIN_BAND && val <= VTX_SETTINGS_MAX_BAND) {
|
||||
// FIXME Use VTX API to get max
|
||||
// We check for the min value in final validation below
|
||||
if (val >= 0 && val <= VTX_SETTINGS_MAX_BAND) {
|
||||
cac->band = val;
|
||||
validArgumentCount++;
|
||||
}
|
||||
|
@ -2321,15 +2322,30 @@ static void cliVtx(char *cmdline)
|
|||
ptr = nextArg(ptr);
|
||||
if (ptr) {
|
||||
val = atoi(ptr);
|
||||
// FIXME Use VTX API to get min/max
|
||||
if (val >= VTX_SETTINGS_MIN_CHANNEL && val <= VTX_SETTINGS_MAX_CHANNEL) {
|
||||
// FIXME Use VTX API to get max
|
||||
// We check for the min value in final validation below
|
||||
if (val >= 0 && val <= VTX_SETTINGS_MAX_CHANNEL) {
|
||||
cac->channel = val;
|
||||
validArgumentCount++;
|
||||
}
|
||||
}
|
||||
ptr = processChannelRangeArgs(ptr, &cac->range, &validArgumentCount);
|
||||
|
||||
bool parseError = false;
|
||||
if (validArgumentCount != 5) {
|
||||
parseError = true;
|
||||
} else {
|
||||
// check for an empty activation condition for reset
|
||||
vtxChannelActivationCondition_t emptyCac;
|
||||
memset(&emptyCac, 0, sizeof(emptyCac));
|
||||
if (memcmp(cac, &emptyCac, sizeof(emptyCac)) != 0
|
||||
// FIXME Use VTX API to get min
|
||||
&& ((cac->band < VTX_SETTINGS_MIN_BAND) || (cac->channel < VTX_SETTINGS_MIN_CHANNEL))) {
|
||||
parseError = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (parseError) {
|
||||
memset(cac, 0, sizeof(vtxChannelActivationCondition_t));
|
||||
cliShowParseError();
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue