diff --git a/docs/devices/ORAS.md b/docs/devices/ORAS.md new file mode 100644 index 000000000..2756e86b1 --- /dev/null +++ b/docs/devices/ORAS.md @@ -0,0 +1,12 @@ +# Amphiro/Oras/Hansa Smart Faucet + +|Model Id|[ORAS](https://github.com/theengs/decoder/blob/development/src/devices/Oras_json.h)| +|-|-| +|Brand|Amphiro/Oras/Hansa| +|Model|Smart Faucet| +|Short Description|Bluetooth Faucet| +|Communication|BLE broadcast| +|Frequency|2.4Ghz| +|Power Source|Battery or mains| +|Exchanged Data|serial number, battery| +|Encrypted|No| diff --git a/docs/participate/adding-decoders.md b/docs/participate/adding-decoders.md index 0fa965ffa..171617290 100644 --- a/docs/participate/adding-decoders.md +++ b/docs/participate/adding-decoders.md @@ -282,6 +282,7 @@ The first parameter is the name of the function to call, The available functions - "value_from_hex_data" - converts the hex string value into an `integer` or `double` type. - "bf_value_from_hex_data" - converts the (binary fraction) hex string value into a `double` type. This should be used when the hex data is represented in the format of `XX.XX`. For example: when `0x1a1e` should output 26.30. - "string_from_hex_data" - converts the hex value to a string type. +- "ascii_from_hex_data" - converts the hex value to ASCII text. - "static_value" - sets the value to the static value specified if the condition is met. - "bit_static_value" - sets the value to either one of two given values, depending on the evaluated binary bit. diff --git a/src/decoder.h b/src/decoder.h index 595e10e36..3d662a55c 100644 --- a/src/decoder.h +++ b/src/decoder.h @@ -127,6 +127,7 @@ class TheengsDecoder { ABTEMP, AMPHIRO, ORALB_BT, + ORAS, PH10, XOSSX2, TPTH, diff --git a/src/devices.h b/src/devices.h index f1e2e2fa5..ec9449404 100644 --- a/src/devices.h +++ b/src/devices.h @@ -80,6 +80,7 @@ #include "devices/ABTemp_json.h" #include "devices/Amphiro_json.h" #include "devices/OralB_json.h" +#include "devices/Oras_json.h" #include "devices/PH10_json.h" #include "devices/XOSSX2_json.h" #include "devices/TPTH_json.h" @@ -198,6 +199,7 @@ const char* _devices[][2] = { {_ABTemp_json, _ABTemp_json_props}, {_AMPHIRO_json, _AMPHIRO_json_props}, {_OralB_json, _OralB_json_props}, + {_Oras_json, _Oras_json_props}, {_PH10_json, _PH10_json_props}, {_XOSSX2_json, _XOSSX2_json_props}, {_TPTH_json, _TPTH_json_props}, diff --git a/src/devices/Oras_json.h b/src/devices/Oras_json.h new file mode 100644 index 000000000..bbe9afc6d --- /dev/null +++ b/src/devices/Oras_json.h @@ -0,0 +1,33 @@ +const char* _Oras_json = "{\"brand\":\"Oras\",\"model\":\"Smart faucet\",\"model_id\":\"ORAS\",\"tag\":\"0801\",\"condition\":[\"manufacturerdata\",\"=\",40,\"index\",0,\"3101\"],\"properties\":{\"serial\":{\"decoder\":[\"ascii_from_hex_data\",\"manufacturerdata\",10,20]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",6,2,false,false],\"post_proc\":[\"&\",127]}}}"; +/*R""""( +{ + "brand":"Oras", + "model":"Smart faucet", + "model_id":"ORAS", + "tag":"0801", + "condition":["manufacturerdata", "=", 40, "index", 0, "3101"], + "properties":{ + "serial":{ + "decoder":["ascii_from_hex_data", "manufacturerdata", 10, 20] + }, + "batt":{ + "decoder":["value_from_hex_data", "manufacturerdata", 6, 2, false, false], + "post_proc":["&", 127] + } + } +})"""";*/ + +const char* _Oras_json_props = "{\"properties\":{\"serial\":{\"unit\":\"string\",\"name\":\"serial number\"},\"batt\":{\"unit\":\"%\",\"name\":\"battery\"}}}"; +/*R""""( +{ + "properties":{ + "serial":{ + "unit":"string", + "name":"serial number" + }, + "batt":{ + "unit":"%", + "name":"battery" + } + } +})"""";*/ diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp index 38b3e88bc..186f2a9cb 100644 --- a/tests/BLE/test_ble.cpp +++ b/tests/BLE/test_ble.cpp @@ -154,6 +154,8 @@ const char* expected_mfg[] = { "{\"brand\":\"iTAG\",\"model\":\"Smart Tracker\",\"model_id\":\"ITAG\",\"type\":\"TRACK\",\"cidc\":false,\"acts\":true,\"cont\":true,\"track\":true,\"device\":\"iTAG Tracker\"}", "{\"brand\":\"iTAG\",\"model\":\"Smart Tracker\",\"model_id\":\"ITAG\",\"type\":\"TRACK\",\"cidc\":false,\"acts\":true,\"cont\":true,\"track\":true,\"device\":\"iTAG Tracker\"}", "{\"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}", }; const char* expected_name_uuid_mfgsvcdata[] = { @@ -577,6 +579,8 @@ const char* test_mfgdata[][3] = { {"Tracker iTAG sesardelaisla", "iTAG", "0501aabbccddeeff6602010300"}, {"Tracker iTAG sesardelaisla", "iTAG", "0501ffeeddccbbaa3fa2e2ee00"}, {"Tilt Hydrothermometer", "Tilt", "4c000215a495bb10c5b14b44b5121370f02d74de004403f8c5"}, + {"Oras", "Smart Faucet", "3101006400323131313030373933350020202020"}, + {"Oras", "Smart Faucet", "3101004800546865656e67734142430020202020"}, }; TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{ @@ -714,6 +718,8 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{ TheengsDecoder::BLE_ID_NUM::ITAG, TheengsDecoder::BLE_ID_NUM::ITAG, TheengsDecoder::BLE_ID_NUM::TILT, + TheengsDecoder::BLE_ID_NUM::ORAS, + TheengsDecoder::BLE_ID_NUM::ORAS, }; // uuid test input [test name] [device name] [uuid] [manufacturer data] [service data]