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 Outdoor Meter to manufacturerdata only #482

Closed
wants to merge 1 commit into from
Closed
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
5 changes: 3 additions & 2 deletions src/devices/SBOT_json.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include "common_props.h"

const char* _SBOT_json = "{\"brand\":\"SwitchBot\",\"model\":\"Outdoor Meter\",\"model_id\":\"W340001X\",\"tag\":\"0102\",\"condition\":[\"servicedata\",\"=\",6,\"index\",0,\"77\",\"&\",\"uuid\",\"index\",0,\"fd3d\",\"&\",\"manufacturerdata\",\"=\",28],\"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]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"&\",127]},\"mac\":{\"decoder\":[\"mac_from_hex_data\",\"manufacturerdata\",4]}}}";
const char* _SBOT_json = "{\"brand\":\"SwitchBot\",\"model\":\"Outdoor Meter\",\"model_id\":\"W340001X\",\"tag\":\"0102\",\"condition\":[\"manufacturerdata\",\"index\",18,\"03\",\"|\",\"manufacturerdata\",\"index\",18,\"0b\",\"|\",\"manufacturerdata\",\"index\",18,\"0f\",\"&\",\"manufacturerdata\",\"=\",28,\"index\",0,\"6909\"],\"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]},\"batt\":{\"condition\":[\"servicedata\",0,\"77\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"&\",127]},\"mac\":{\"decoder\":[\"mac_from_hex_data\",\"manufacturerdata\",4]}}}";
/*R""""(
{
"brand":"SwitchBot",
"model":"Outdoor Meter",
"model_id":"W340001X",
"tag":"0102",
"condition":["servicedata", "=", 6, "index", 0, "77", "&", "uuid", "index", 0, "fd3d", "&", "manufacturerdata", "=", 28],
"condition":["manufacturerdata", "index", 18, "03", "|", "manufacturerdata", "index", 18, "0b", "|", "manufacturerdata", "index", 18, "0f", "&", "manufacturerdata", "=", 28, "index", 0, "6909"],
"properties":{
".cal":{
"decoder":["value_from_hex_data", "manufacturerdata", 21, 1, false, false],
Expand All @@ -28,6 +28,7 @@ const char* _SBOT_json = "{\"brand\":\"SwitchBot\",\"model\":\"Outdoor Meter\",\
"post_proc":["&", 127]
},
"batt":{
"condition":["servicedata", 0, "77"],
"decoder":["value_from_hex_data", "servicedata", 4, 2, false, false],
"post_proc":["&", 127]
},
Expand Down
12 changes: 12 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ 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\":\"SwitchBot\",\"model\":\"Outdoor Meter\",\"model_id\":\"W340001X\",\"type\":\"THB\",\"acts\":true,\"tempc\":25.5,\"tempf\":77.9,\"hum\":50,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"SwitchBot\",\"model\":\"Outdoor Meter\",\"model_id\":\"W340001X\",\"type\":\"THB\",\"acts\":true,\"tempc\":26.3,\"tempf\":79.34,\"hum\":80,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"SwitchBot\",\"model\":\"Outdoor Meter\",\"model_id\":\"W340001X\",\"type\":\"THB\",\"acts\":true,\"tempc\":-15.9,\"tempf\":3.38,\"hum\":42,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"SwitchBot\",\"model\":\"Outdoor Meter\",\"model_id\":\"W340001X\",\"type\":\"THB\",\"acts\":true,\"tempc\":20,\"tempf\":68,\"hum\":68,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
};

const char* expected_name_uuid_mfgsvcdata[] = {
Expand Down Expand Up @@ -532,6 +536,10 @@ const char* test_mfgdata[][3] = {
{"Apple", "iPad", "4c0010020304"},
{"Apple", "iPad", "4c0010020704"},
{"Apple", "iPad", "4c0010050b1c93fbf5"},
{"SwitchBot Outdoor Meter MFGDATA only", "Outdoor Meter", "6909aabbccddeeff8b0305993200"},
{"SwitchBot Outdoor Meter MFGDATA only", "Outdoor Meter", "6909aabbccddeeff940b039a5000"},
{"SwitchBot Outdoor Meter MFGDATA only", "Outdoor Meter", "6909aabbccddeeffe30f090f2a00"},
{"SwitchBot Outdoor Meter MFGDATA only", "Outdoor Meter", "6909aabbccddeeff020300944400"},
};

TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
Expand Down Expand Up @@ -657,6 +665,10 @@ 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::SBOT,
TheengsDecoder::BLE_ID_NUM::SBOT,
TheengsDecoder::BLE_ID_NUM::SBOT,
TheengsDecoder::BLE_ID_NUM::SBOT,
};

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