diff --git a/radio/src/storage/conversions/yaml/yaml_datastructs_funcs.cpp b/radio/src/storage/conversions/yaml/yaml_datastructs_funcs.cpp index 5c384a98e..0894b995e 100644 --- a/radio/src/storage/conversions/yaml/yaml_datastructs_funcs.cpp +++ b/radio/src/storage/conversions/yaml/yaml_datastructs_funcs.cpp @@ -458,11 +458,12 @@ extern const struct YamlIdStr enum_SwitchSources[]; #define r_swtchSrc nullptr -bool w_swtchSrc(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* opaque) +static bool w_swtchSrc_unquoted(const YamlNode* node, uint32_t val, + yaml_writer_func wf, void* opaque) { int32_t sval = yaml_to_signed(val, node->size); if (sval < 0) { - wf(opaque, "\\!", 2); + wf(opaque, "!", 1); sval = abs(sval); } @@ -509,6 +510,15 @@ bool w_swtchSrc(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* o return wf(opaque, str, strlen(str)); } +static bool w_swtchSrc(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* opaque) +{ + if (!wf(opaque,"\"",1) + || !w_swtchSrc_unquoted(node, val, wf, opaque) + || !wf(opaque,"\"",1)) + return false; + return true; +} + bool cfn_is_active(void* user, uint8_t* data, uint32_t bitoffs) { data += bitoffs >> 3UL; @@ -996,13 +1006,13 @@ bool w_logicSw(void* user, uint8_t* data, uint32_t bitoffs, case LS_FAMILY_BOOL: case LS_FAMILY_STICKY: - if (!w_swtchSrc(&_ls_node_v1, ls->v1, wf, opaque)) return false; + if (!w_swtchSrc_unquoted(&_ls_node_v1, ls->v1, wf, opaque)) return false; if (!wf(opaque,",",1)) return false; - if (!w_swtchSrc(&_ls_node_v2, ls->v2, wf, opaque)) return false; + if (!w_swtchSrc_unquoted(&_ls_node_v2, ls->v2, wf, opaque)) return false; break; case LS_FAMILY_EDGE: - if (!w_swtchSrc(&_ls_node_v1, ls->v1, wf, opaque)) return false; + if (!w_swtchSrc_unquoted(&_ls_node_v1, ls->v1, wf, opaque)) return false; if (!wf(opaque,",",1)) return false; str = yaml_unsigned2str(lswTimerValue(ls->v2)); if (!wf(opaque,str,strlen(str))) return false; diff --git a/radio/src/storage/yaml/yaml_datastructs_funcs.cpp b/radio/src/storage/yaml/yaml_datastructs_funcs.cpp index e32659e62..5af9c9299 100644 --- a/radio/src/storage/yaml/yaml_datastructs_funcs.cpp +++ b/radio/src/storage/yaml/yaml_datastructs_funcs.cpp @@ -44,7 +44,6 @@ namespace yaml_conv_220 { uint8_t select_sensor_cfg(void* user, uint8_t* data, uint32_t bitoffs); extern const struct YamlIdStr enum_SwitchConfig[]; - bool w_swtchSrc(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* opaque); bool cfn_is_active(void* user, uint8_t* data, uint32_t bitoffs); bool gvar_is_active(void* user, uint8_t* data, uint32_t bitoffs); @@ -757,11 +756,12 @@ static uint32_t r_swtchSrc(const YamlNode* node, const char* val, uint8_t val_le return neg ? -ival : ival; } -static bool w_swtchSrc(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* opaque) +static bool w_swtchSrc_unquoted(const YamlNode* node, uint32_t val, + yaml_writer_func wf, void* opaque) { int32_t sval = yaml_to_signed(val, node->size); if (sval < 0) { - wf(opaque, "\\!", 2); + wf(opaque, "!", 1); sval = abs(sval); } @@ -808,6 +808,15 @@ static bool w_swtchSrc(const YamlNode* node, uint32_t val, yaml_writer_func wf, return wf(opaque, str, strlen(str)); } +bool w_swtchSrc(const YamlNode* node, uint32_t val, yaml_writer_func wf, void* opaque) +{ + if (!wf(opaque,"\"",1) + || !w_swtchSrc_unquoted(node, val, wf, opaque) + || !wf(opaque,"\"",1)) + return false; + return true; +} + bool cfn_is_active(void* user, uint8_t* data, uint32_t bitoffs) { return yaml_conv_220::cfn_is_active(user, data, bitoffs); @@ -1541,13 +1550,13 @@ static bool w_logicSw(void* user, uint8_t* data, uint32_t bitoffs, case LS_FAMILY_BOOL: case LS_FAMILY_STICKY: - if (!w_swtchSrc(&_ls_node_v1, ls->v1, wf, opaque)) return false; + if (!w_swtchSrc_unquoted(&_ls_node_v1, ls->v1, wf, opaque)) return false; if (!wf(opaque,",",1)) return false; - if (!w_swtchSrc(&_ls_node_v2, ls->v2, wf, opaque)) return false; + if (!w_swtchSrc_unquoted(&_ls_node_v2, ls->v2, wf, opaque)) return false; break; case LS_FAMILY_EDGE: - if (!w_swtchSrc(&_ls_node_v1, ls->v1, wf, opaque)) return false; + if (!w_swtchSrc_unquoted(&_ls_node_v1, ls->v1, wf, opaque)) return false; if (!wf(opaque,",",1)) return false; str = yaml_unsigned2str(lswTimerValue(ls->v2)); if (!wf(opaque,str,strlen(str))) return false;