From f3a6ad1b0f8c4e8d629e3662ba0a4817e08f8ef3 Mon Sep 17 00:00:00 2001 From: DigiH Date: Sat, 27 Apr 2024 19:16:05 +0200 Subject: [PATCH] Otodata RC1010 propane tank transponder decoder --- docs/devices/OTOD.md | 12 ++++++++++ src/decoder.cpp | 3 ++- src/decoder.h | 1 + src/devices.h | 2 ++ src/devices/OTOD_json.h | 53 +++++++++++++++++++++++++++++++++++++++++ tests/BLE/test_ble.cpp | 9 +++++++ 6 files changed, 79 insertions(+), 1 deletion(-) create mode 100644 docs/devices/OTOD.md create mode 100644 src/devices/OTOD_json.h diff --git a/docs/devices/OTOD.md b/docs/devices/OTOD.md new file mode 100644 index 00000000..0471e5fd --- /dev/null +++ b/docs/devices/OTOD.md @@ -0,0 +1,12 @@ +# Otodata RC1010 Rotarex-compatible Monitor + +|Model Id|[RC1010](https://github.com/theengs/decoder/blob/development/src/devices/OTOD_json.h)| +|-|-| +|Brand|Otodata| +|Model|RC1010 Rotarex-compatible Monitor| +|Short Description|BLE monitor for Rotarex Level Gauges| +|Communication|BLE broadcast| +|Frequency|2.4Ghz| +|Power Source|sealed in non-changeable| +|Exchanged Data|level, status, serial, model type| +|Encrypted|No| diff --git a/src/decoder.cpp b/src/decoder.cpp index 22c1c2a0..dab19cb8 100644 --- a/src/decoder.cpp +++ b/src/decoder.cpp @@ -754,7 +754,8 @@ int TheengsDecoder::decodeBLEJson(JsonObject& jsondata) { temp_val -= post_proc[i + 1].as(); } } else if (strncmp(post_proc[i].as(), "abs", 3) == 0) { - temp_val = abs(temp_val); + long long val = (long long)temp_val; + temp_val = abs(val); } else if (strncmp(post_proc[i].as(), "SBBT-dir", 8) == 0) { // "SBBT" decoder specific post_proc if (temp_val < 0) { proc_str = "down"; diff --git a/src/decoder.h b/src/decoder.h index 3d662a55..4090dee9 100644 --- a/src/decoder.h +++ b/src/decoder.h @@ -128,6 +128,7 @@ class TheengsDecoder { AMPHIRO, ORALB_BT, ORAS, + OTOD, PH10, XOSSX2, TPTH, diff --git a/src/devices.h b/src/devices.h index ec944940..25cfabf0 100644 --- a/src/devices.h +++ b/src/devices.h @@ -81,6 +81,7 @@ #include "devices/Amphiro_json.h" #include "devices/OralB_json.h" #include "devices/Oras_json.h" +#include "devices/OTOD_json.h" #include "devices/PH10_json.h" #include "devices/XOSSX2_json.h" #include "devices/TPTH_json.h" @@ -200,6 +201,7 @@ const char* _devices[][2] = { {_AMPHIRO_json, _AMPHIRO_json_props}, {_OralB_json, _OralB_json_props}, {_Oras_json, _Oras_json_props}, + {_OTOD_json, _OTOD_json_props}, {_PH10_json, _PH10_json_props}, {_XOSSX2_json, _XOSSX2_json_props}, {_TPTH_json, _TPTH_json_props}, diff --git a/src/devices/OTOD_json.h b/src/devices/OTOD_json.h new file mode 100644 index 00000000..4378fb27 --- /dev/null +++ b/src/devices/OTOD_json.h @@ -0,0 +1,53 @@ +const char* _OTOD_json = "{\"brand\":\"Otodata\",\"model\":\"Rotarex-compatible Monitor\",\"model_id\":\"RC1010\",\"tag\":\"ff\",\"condition\":[\"manufacturerdata\",\"=\",42,\"index\",0,\"b103\",\"|\",\"manufacturerdata\",\"=\",48,\"index\",0,\"b103\"],\"properties\":{\"level\":{\"condition\":[\"manufacturerdata\",\"=\",42],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",22,4,true,false],\"post_proc\":[\"/\",100]},\"status\":{\"condition\":[\"manufacturerdata\",\"=\",42],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",26,4,true,false]},\"serial\":{\"condition\":[\"manufacturerdata\",\"=\",48],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",18,8,true,false],\"post_proc\":[\"abs\"]},\"modeltype\":{\"condition\":[\"manufacturerdata\",\"=\",48],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",40,8,true,false],\"post_proc\":[\"abs\"]}}}"; +/*R""""( +{ + "brand":"Otodata", + "model":"Rotarex-compatible Monitor", + "model_id":"RC1010", + "tag":"ff", + "condition":["manufacturerdata", "=", 42, "index", 0, "b103", "|", "manufacturerdata", "=", 48, "index", 0, "b103"], + "properties":{ + "level":{ + "condition":["manufacturerdata", "=", 42], + "decoder":["value_from_hex_data", "manufacturerdata", 22, 4, true, false], + "post_proc":["/", 100] + }, + "status":{ + "condition":["manufacturerdata", "=", 42], + "decoder":["value_from_hex_data", "manufacturerdata", 26, 4, true, false] + }, + "serial":{ + "condition":["manufacturerdata", "=", 48], + "decoder":["value_from_hex_data", "manufacturerdata", 18, 8, true, false], + "post_proc":["abs"] + }, + "modeltype":{ + "condition":["manufacturerdata", "=", 48], + "decoder":["value_from_hex_data", "manufacturerdata", 40, 8, true, false], + "post_proc":["abs"] + } + } +})"""";*/ + +const char* _OTOD_json_props = "{\"properties\":{\"level\":{\"unit\":\"%\",\"name\":\"level\"},\"status\":{\"unit\":\"int\",\"name\":\"status\"},\"serial\":{\"unit\":\"int\",\"name\":\"serial\"},\"modeltype\":{\"unit\":\"int\",\"name\":\"model type\"}}}"; +/*R""""( +{ + "properties":{ + "level":{ + "unit":"%", + "name":"level" + }, + "status":{ + "unit":"int", + "name":"status" + }, + "serial":{ + "unit":"int", + "name":"serial" + }, + "modeltype":{ + "unit":"int", + "name":"model type" + } + } +})"""";*/ diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp index 186f2a9c..f83bd89a 100644 --- a/tests/BLE/test_ble.cpp +++ b/tests/BLE/test_ble.cpp @@ -156,6 +156,9 @@ const char* expected_mfg[] = { "{\"brand\":\"Tilt\",\"model\":\"Brewing Hydro- Thermometer\",\"model_id\":\"TILT\",\"type\":\"THBX\",\"cidc\":false,\"color\":\"red\",\"tempf\":68,\"tempc\":20,\"gravity\":1.016,\"txpower\":-59}", "{\"brand\":\"Oras\",\"model\":\"Smart faucet\",\"model_id\":\"ORAS\",\"type\":\"BATT\",\"cidc\":false,\"serial\":\"2111007935\",\"batt\":100}", "{\"brand\":\"Oras\",\"model\":\"Smart faucet\",\"model_id\":\"ORAS\",\"type\":\"BATT\",\"cidc\":false,\"serial\":\"TheengsABC\",\"batt\":72}", + "{\"brand\":\"Otodata\",\"model\":\"Rotarex-compatible Monitor\",\"model_id\":\"RC1010\",\"type\":\"UNIQ\",\"level\":100,\"status\":0}", + "{\"brand\":\"Otodata\",\"model\":\"Rotarex-compatible Monitor\",\"model_id\":\"RC1010\",\"type\":\"UNIQ\",\"level\":98.35,\"status\":0}", + "{\"brand\":\"Otodata\",\"model\":\"Rotarex-compatible Monitor\",\"model_id\":\"RC1010\",\"type\":\"UNIQ\",\"serial\":56001608,\"modeltype\":67367466}", }; const char* expected_name_uuid_mfgsvcdata[] = { @@ -581,6 +584,9 @@ const char* test_mfgdata[][3] = { {"Tilt Hydrothermometer", "Tilt", "4c000215a495bb10c5b14b44b5121370f02d74de004403f8c5"}, {"Oras", "Smart Faucet", "3101006400323131313030373933350020202020"}, {"Oras", "Smart Faucet", "3101004800546865656e67734142430020202020"}, + {"Otodata RC1010", "", "b1034f544f54454c45020010270000366e0f000000"}, + {"Otodata RC1010", "", "b1034f544f54454c4502006b260000366e0f000000"}, + {"Otodata RC1010", "", "b1034f544f3332383148845603132111010400022af20304"}, }; TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{ @@ -720,6 +726,9 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{ TheengsDecoder::BLE_ID_NUM::TILT, TheengsDecoder::BLE_ID_NUM::ORAS, TheengsDecoder::BLE_ID_NUM::ORAS, + TheengsDecoder::BLE_ID_NUM::OTOD, + TheengsDecoder::BLE_ID_NUM::OTOD, + TheengsDecoder::BLE_ID_NUM::OTOD, }; // uuid test input [test name] [device name] [uuid] [manufacturer data] [service data]