fix: cpn - Yaml rawswitch decode fix and housekeeping (#1801)

Whereby some SF and GF "switches" were not being read by Companion
This commit is contained in:
Neil Horne
2022-04-05 15:07:05 +10:00
committed by GitHub
parent 4dfff74dd2
commit c4904be508
3 changed files with 9 additions and 22 deletions
@@ -43,7 +43,7 @@ std::string YamlRawSwitchEncode(const RawSwitch& rhs)
sw_str += "L";
sw_str += std::to_string(sval);
break;
case SWITCH_TYPE_FUNCTIONSWITCH:
if (IS_JUMPER_TPRO(getCurrentBoard())) {
c += Boards::getCapability(getCurrentBoard(), Board::Switches);
@@ -74,10 +74,6 @@ std::string YamlRawSwitchEncode(const RawSwitch& rhs)
sw_str += std::to_string(sval + 1);
break;
case SWITCH_TYPE_TIMER_MODE:
// TODO: check as it appears to be depreciated as not in RawSwitch data model and not in radio yaml export
break;
default:
sw_str += getCurrentFirmware()->getRawSwitchTypesTag(rhs.type);
break;
@@ -166,25 +162,16 @@ RawSwitch YamlRawSwitchDecode(const std::string& sw_str)
}
}
// these types use index = 1
} else if (val_len > 4 && (
(val[0] == 'R' && val[1] == 'A' && val[2] == 'D' && val[3] == 'I' && val[4] == 'O') ||
(val[0] == 'T' && val[1] == 'E' && val[2] == 'L' && val[3] == 'E' && val[4] == 'M'))) {
int sw_type = getCurrentFirmware()->getRawSwitchTypesIndex(sw_str_tmp.c_str());
if (sw_type >= 0) {
rhs.type = (RawSwitchType)sw_type;
rhs.index = 1;
}
// TODO: SWITCH_TYPE_TIMER_MODE
// check as it appears to be depreciated as not in RawSwitch data model and not in radio yaml export
} else {
// types which do not use index
int sw_type = getCurrentFirmware()->getRawSwitchTypesIndex(sw_str_tmp.c_str());
if (sw_type >= 0) {
rhs.type = (RawSwitchType)sw_type;
rhs.index = 0;
if (rhs.type == SWITCH_TYPE_TELEMETRY || rhs.type == SWITCH_TYPE_ACT || rhs.type == SWITCH_TYPE_ONE)
// these types use index = 1
rhs.index = 1;
else
// types which do not use index
rhs.index = 0;
}
}
+1 -1
View File
@@ -267,6 +267,7 @@ StringTagMappingTable RawSwitch::getRawSwitchTypesLookupTable()
tbl.insert(tbl.end(), {
{std::to_string(SWITCH_TYPE_NONE), "NONE"},
{std::to_string(SWITCH_TYPE_SWITCH), "Sxn"},
{std::to_string(SWITCH_TYPE_FUNCTIONSWITCH), "Sxn"},
{std::to_string(SWITCH_TYPE_VIRTUAL), "Ln"},
{std::to_string(SWITCH_TYPE_MULTIPOS_POT), "6Pn"},
{std::to_string(SWITCH_TYPE_TRIM), "Trim"},
@@ -274,7 +275,6 @@ StringTagMappingTable RawSwitch::getRawSwitchTypesLookupTable()
{std::to_string(SWITCH_TYPE_ON), "ON"},
{std::to_string(SWITCH_TYPE_OFF), "OFF"},
{std::to_string(SWITCH_TYPE_ONE), "ONE"},
{std::to_string(SWITCH_TYPE_FUNCTIONSWITCH), "Sxn"},
{std::to_string(SWITCH_TYPE_FLIGHT_MODE), "FMn"},
{std::to_string(SWITCH_TYPE_TIMER_MODE), "Timer"},
{std::to_string(SWITCH_TYPE_TELEMETRY), "TELEMETRY_STREAMING"},
+1 -1
View File
@@ -43,7 +43,7 @@ enum RawSwitchType {
SWITCH_TYPE_OFF,
SWITCH_TYPE_ONE,
SWITCH_TYPE_FLIGHT_MODE,
SWITCH_TYPE_TIMER_MODE,
SWITCH_TYPE_TIMER_MODE, // depreciated kept to preserve following enums
SWITCH_TYPE_TELEMETRY,
SWITCH_TYPE_SENSOR,
SWITCH_TYPE_ACT,