Skip to content

Commit

Permalink
e.volve scale initial
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiH committed Jan 26, 2024
1 parent e1f3fdc commit 2f70e74
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/participate/adding-decoders.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ Valid operations are:
- ">" shift right
- "!" Not (invert), useful for bool types
- "&" Logical And the values
- "^" Logical XOR the values
- "min" the minimum allowed value
- "max" the maximum allowed value

Expand Down
5 changes: 5 additions & 0 deletions src/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,11 @@ int TheengsDecoder::decodeBLEJson(JsonObject& jsondata) {
temp_val = val & post_proc[i + 1].as<unsigned int>();
break;
}
case '^': {
long long val = (long long)temp_val;
temp_val = val ^ post_proc[i + 1].as<unsigned int>();
break;
}
}
} else if (strncmp(post_proc[i].as<const char*>(), "max", 3) == 0) {
if (temp_val > post_proc[i + 1].as<double>()) {
Expand Down
1 change: 1 addition & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class TheengsDecoder {
XMTZC04HMLB,
XMTZC05HMKG,
XMTZC05HMLB,
EVOLVE,
TPMS,
KKM_K6P,
KKM_K9,
Expand Down
2 changes: 2 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#include "devices/XMTZC04HMLB_json.h"
#include "devices/XMTZC05HMKG_json.h"
#include "devices/XMTZC05HMLB_json.h"
#include "devices/EVOLVE_json.h"
#include "devices/Mokobeacon_json.h"
#include "devices/RDL52832_json.h"
#include "devices/RuuviTag_RAWv1_json.h"
Expand Down Expand Up @@ -138,6 +139,7 @@ const char* _devices[][2] = {
{_XMTZC04HMLB_json, _XMTZC04HMLB_json_props},
{_XMTZC05HMKG_json, _XMTZC05HMKG_json_props},
{_XMTZC05HMLB_json, _XMTZC05HMLB_json_props},
{_EVOLVE_json, _EVOLVE_json_props},
{_TPMS_json, _TPMS_json_props},
{_KKM_K6P_json, _KKM_K6P_json_props},
{_KKM_K9_json, _KKM_K9_json_props},
Expand Down
26 changes: 26 additions & 0 deletions src/devices/EVOLVE_json.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const char* _EVOLVE_json = "{\"brand\":\"e.volve\",\"model\":\"Scale\",\"model_id\":\"EVOLVE\",\"tag\":\"0501\",\"condition\":[\"manufacturerdata\",\"=\",28,\"index\",0,\"aca0\",\"&\",\"manufacturerdata\",\"index\",17,\"02\"],\"properties\":{\"weight\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",18,6,false,false],\"post_proc\":[\"^\",2924704,\"/\",1000]}}}";
/*R""""(
{
"brand":"e.volve",
"model":"Scale",
"model_id":"EVOLVE",
"tag":"0501",
"condition":["manufacturerdata", "=", 28, "index", 0, "aca0" , "&", "manufacturerdata", "index", 17, "02"],
"properties":{
"weight":{
"decoder":["value_from_hex_data", "manufacturerdata", 18, 6, false, false],
"post_proc":["^", 2924704, "/", 1000]
}
}
})"""";*/

const char* _EVOLVE_json_props = "{\"properties\":{\"weight\":{\"unit\":\"kg\",\"name\":\"weight\"}}}";
/*R""""(
{
"properties":{
"weight":{
"unit":"kg",
"name":"weight"
}
}
})"""";*/
3 changes: 3 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ const char* expected_mfg[] = {
"{\"brand\":\"Apple\",\"model\":\"Apple iPhone/iPad\",\"model_id\":\"APPLEDEVICE\",\"type\":\"TRACK\",\"track\":true,\"prmac\":true,\"unlocked\":false}",
"{\"brand\":\"Apple\",\"model\":\"Apple iPhone/iPad\",\"model_id\":\"APPLEDEVICE\",\"type\":\"TRACK\",\"track\":true,\"prmac\":true,\"unlocked\":false}",
"{\"brand\":\"Apple\",\"model\":\"Apple iPhone/iPad\",\"model_id\":\"APPLEDEVICE\",\"type\":\"TRACK\",\"track\":true,\"prmac\":true,\"unlocked\":true}",
"{\"brand\":\"e.volve\",\"model\":\"Scale\",\"model_id\":\"EVOLVE\",\"type\":\"SCALE\",\"cidc\":false,\"weight\":69.874}",
};

const char* expected_name_uuid_mfgsvcdata[] = {
Expand Down Expand Up @@ -534,6 +535,7 @@ const char* test_mfgdata[][3] = {
{"Apple", "iPad", "4c0010020304"},
{"Apple", "iPad", "4c0010020704"},
{"Apple", "iPad", "4c0010050b1c93fbf5"},
{"Evolve", "Scale", "aca0ce9c695f91a1202db0520db4"},
};

TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
Expand Down Expand Up @@ -659,6 +661,7 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
TheengsDecoder::BLE_ID_NUM::APPLEDEVICE,
TheengsDecoder::BLE_ID_NUM::APPLEDEVICE,
TheengsDecoder::BLE_ID_NUM::APPLEDEVICE,
TheengsDecoder::BLE_ID_NUM::EVOLVE,
};

// uuid test input [test name] [device name] [uuid] [manufacturer data] [service data]
Expand Down

0 comments on commit 2f70e74

Please sign in to comment.