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

SwitchBot Meter (Plus) manufacturerdata & name only decoder #519

Merged
merged 1 commit into from
Feb 20, 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
1 change: 1 addition & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ class TheengsDecoder {
SBCU,
SBMS,
SBMT,
SBMT_M,
SBOT,
SBS1,
SHT4X,
Expand Down
1 change: 1 addition & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ const char* _devices[][2] = {
{_SBCU_json, _SBCU_json_props},
{_SBMS_json, _SBMS_json_props},
{_SBMT_json, _SBMT_json_props},
{_SBMT_json_M, _SBMT_json_props},
{_SBOT_json, _SBOT_json_props},
{_SBS1_json, _SBS1_json_props},
{_SHT4X_json, _SHT4X_json_props},
Expand Down
35 changes: 34 additions & 1 deletion src/devices/SBMT_json.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,37 @@ const char* _SBMT_json = "{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"
}
})"""";*/

const char* _SBMT_json_props = _common_BTH_props;
const char* _SBMT_json_M = "{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"model_id\":\"THX1/W230150X\",\"tag\":\"0100\",\"condition\":[\"name\",\"index\",0,\"WoSensorTH\",\"&\",\"manufacturerdata\",\"=\",26],\"properties\":{\".cal\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",21,1,false,false],\"post_proc\":[\"/\",10]},\"tempc\":{\"condition\":[\"manufacturerdata\",22,\"bit\",3,0],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",22,2,true,false],\"post_proc\":[\"+\",\".cal\",\"*\",-1]},\"_tempc\":{\"condition\":[\"manufacturerdata\",22,\"bit\",3,1],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",22,2,true,false],\"post_proc\":[\"+\",\".cal\",\"-\",128]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",24,2,false,false],\"post_proc\":[\"&\",127]},\"mac\":{\"decoder\":[\"mac_from_hex_data\",\"manufacturerdata\",4]}}}";
/*R""""(
{
"brand":"SwitchBot",
"model":"Meter (Plus)",
"model_id":"THX1/W230150X",
"tag":"0100",
"condition":["name", "index", 0, "WoSensorTH", "&", "manufacturerdata", "=", 26],
"properties":{
".cal":{
"decoder":["value_from_hex_data", "manufacturerdata", 21, 1, false, false],
"post_proc":["/", 10]
},
"tempc":{
"condition":["manufacturerdata", 22, "bit", 3, 0],
"decoder":["value_from_hex_data", "manufacturerdata", 22, 2, true, false],
"post_proc":["+", ".cal", "*", -1]
},
"_tempc":{
"condition":["manufacturerdata", 22, "bit", 3, 1],
"decoder":["value_from_hex_data", "manufacturerdata", 22, 2, true, false],
"post_proc":["+", ".cal", "-", 128]
},
"hum":{
"decoder":["value_from_hex_data", "manufacturerdata", 24, 2, false, false],
"post_proc":["&", 127]
},
"mac":{
"decoder":["mac_from_hex_data", "manufacturerdata", 4]
}
}
})"""";*/

const char* _SBMT_json_props = _common_BTHM_props;
9 changes: 9 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ const char* expected_mfg[] = {
"{\"brand\":\"Theengs\",\"model\":\"iBeacon Tracker\",\"model_id\":\"TheengsIB02\",\"type\":\"TRACK\",\"cidc\":false,\"track\":true,\"prmac\":true,\"device\":\"Theengs iBeacon Tracker\"}",
"{\"brand\":\"Mobvoi\",\"model\":\"TicWatch GTH (Pro)\",\"model_id\":\"TICWATCHGTH\",\"type\":\"TRACK\",\"cidc\":false,\"acts\":true,\"track\":true,\"device\":\"TicWatch GTH (Pro) Tracker\"}",
"{\"brand\":\"XOSS\",\"model\":\"X2 Heart Rate Sensor\",\"model_id\":\"XOSSX2\",\"type\":\"BODY\",\"cidc\":false,\"bpm\":63,\"batt\":97}",
"{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"model_id\":\"THX1/W230150X\",\"type\":\"THB\",\"tempc\":22.9,\"tempf\":73.22,\"hum\":47,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"model_id\":\"THX1/W230150X\",\"type\":\"THB\",\"tempc\":23,\"tempf\":73.4,\"hum\":50,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"SwitchBot\",\"model\":\"Meter (Plus)\",\"model_id\":\"THX1/W230150X\",\"type\":\"THB\",\"tempc\":22.8,\"tempf\":73.04,\"hum\":91,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
};

const char* expected_name_uuid_mfgsvcdata[] = {
Expand Down Expand Up @@ -547,6 +550,9 @@ const char* test_mfgdata[][3] = {
{"Theengs", "iBeacon Tracker", "4c000215546865656e67732d69426561636f6e32f644000064"},
{"Mobvoi", "TicWatch GTH Pro", "0000aabbccddeeff"},
{"XOSS", "X2", "04ff0161063f"},
{"SwitchBot Meter ManData", "WoSensorTHP", "6909aabbccddeeff4a0109962f"},
{"SwitchBot Meter ManData", "WoSensorTHP", "6909aabbccddeeff4801009732"},
{"SwitchBot Meter ManData", "WoSensorTHP", "6909aabbccddeeff3e0908965b"},
};

TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
Expand Down Expand Up @@ -676,6 +682,9 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
TheengsDecoder::BLE_ID_NUM::TheengsIB02,
TheengsDecoder::BLE_ID_NUM::TICWATCHGTH,
TheengsDecoder::BLE_ID_NUM::XOSSX2,
TheengsDecoder::BLE_ID_NUM::SBMT_M,
TheengsDecoder::BLE_ID_NUM::SBMT_M,
TheengsDecoder::BLE_ID_NUM::SBMT_M,
};

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