1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-14 20:10:18 +03:00

Merge pull request #7714 from etracer65/revise_cli_vtx_command

Fix CLI vtx command parsing to allow reset
This commit is contained in:
Michael Keller 2019-03-07 03:48:07 +13:00 committed by GitHub
commit f2db4bae11
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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 {