Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Otodata RC1010 propane tank transponder decoder #546

Merged
merged 1 commit into from
Apr 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/devices/OTOD.md
Original file line number Diff line number Diff line change
@@ -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|
3 changes: 2 additions & 1 deletion src/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,8 @@ int TheengsDecoder::decodeBLEJson(JsonObject& jsondata) {
temp_val -= post_proc[i + 1].as<double>();
}
} else if (strncmp(post_proc[i].as<const char*>(), "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<const char*>(), "SBBT-dir", 8) == 0) { // "SBBT" decoder specific post_proc
if (temp_val < 0) {
proc_str = "down";
Expand Down
1 change: 1 addition & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ class TheengsDecoder {
AMPHIRO,
ORALB_BT,
ORAS,
OTOD,
PH10,
XOSSX2,
TPTH,
Expand Down
2 changes: 2 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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},
Expand Down
53 changes: 53 additions & 0 deletions src/devices/OTOD_json.h
Original file line number Diff line number Diff line change
@@ -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"
}
}
})"""";*/
9 changes: 9 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down Expand Up @@ -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[]{
Expand Down Expand Up @@ -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]
Expand Down
Loading