diff --git a/docs/participate/adding-decoders.md b/docs/participate/adding-decoders.md index 775fb6ef..0fa965ff 100644 --- a/docs/participate/adding-decoders.md +++ b/docs/participate/adding-decoders.md @@ -315,6 +315,7 @@ Valid operations are: - "*" multiply - "+" add - "-" subtract +- "±" signed conditional add or subtract - "%" modulo - "<" shift left - ">" shift right @@ -323,6 +324,7 @@ Valid operations are: - "^" Logical XOR the values - "min" the minimum allowed value - "max" the maximum allowed value +- "abs" absolute value `lookup` This specifies a lookup table for any decoded "string_from_hex_data" string. If the string is defined in the table its related string will be assigned to the property. If no matching hex string is present the property is defined as not decoded. diff --git a/src/decoder.cpp b/src/decoder.cpp index b5eecc63..697f1a1b 100644 --- a/src/decoder.cpp +++ b/src/decoder.cpp @@ -743,7 +743,15 @@ int TheengsDecoder::decodeBLEJson(JsonObject& jsondata) { if (temp_val < post_proc[i + 1].as()) { temp_val = post_proc[i + 1].as(); } - } + } else if (strncmp(post_proc[i].as(), "±", 1) == 0) { + if (temp_val < 0) { + temp_val += post_proc[i + 1].as(); + } else { + temp_val -= post_proc[i + 1].as(); + } + } else if (strncmp(post_proc[i].as(), "abs", 3) == 0) { + temp_val = abs(temp_val); + } } } }