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

Amphiro/Oras/Hansa Faucet decoder #544

Merged
merged 1 commit into from
Apr 25, 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/ORAS.md
Original file line number Diff line number Diff line change
@@ -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|
1 change: 1 addition & 0 deletions docs/participate/adding-decoders.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
1 change: 1 addition & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class TheengsDecoder {
ABTEMP,
AMPHIRO,
ORALB_BT,
ORAS,
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 @@ -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"
Expand Down Expand Up @@ -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},
Expand Down
33 changes: 33 additions & 0 deletions src/devices/Oras_json.h
Original file line number Diff line number Diff line change
@@ -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"
}
}
})"""";*/
6 changes: 6 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down Expand Up @@ -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[]{
Expand Down Expand Up @@ -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]
Expand Down
Loading