Skip to content
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
4 changes: 2 additions & 2 deletions docs/devices/SBMP.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
|-|-|
|Brand|SwitchBot|
|Model|Meter Pro (CO2)|
|Short Description|Thermo-Hygrometer and CO2 Monitor|
|Short Description|Thermo-Hygrometer with optional CO2 Monitor|
|Communication|BLE broadcast|
|Frequency|2.4Ghz|
|Power Source|2 AA|
|Exchanged Data|temperature, humidity, carbon dioxide, battery|
|Exchanged Data|temperature, humidity, battery, carbon dioxide (CO2 version only)|
|Encrypted|No|
13 changes: 7 additions & 6 deletions src/devices/SBMP_json.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
#include "common_props.h"

const char* _SBMP_json = "{\"brand\":\"SwitchBot\",\"model\":\"Meter Pro (CO2)\",\"model_id\":\"W490001X\",\"tag\":\"0f02\",\"condition\":[\"uuid\",\"index\",0,\"fd3d\",\"&\",\"servicedata\",\"=\",6,\"index\",0,\"35\",\"&\",\"manufacturerdata\",\"=\",36,\"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]},\"co2\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",30,4,false,false]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"&\",127]},\"mac\":{\"decoder\":[\"mac_from_hex_data\",\"manufacturerdata\",4]}}}";
const char* _SBMP_json = "{\"brand\":\"SwitchBot\",\"model\":\"Meter Pro (CO2)\",\"model_id\":\"W490001X\",\"tag\":\"0202\",\"condition\":[\"servicedata\",\"=\",6,\"index\",0,\"35\",\"|\",\"servicedata\",\"=\",6,\"index\",0,\"34\",\"&\",\"uuid\",\"index\",0,\"fd3d\",\"&\",\"manufacturerdata\",\">=\",30,\"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\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":[\"&\",127]},\"mac\":{\"decoder\":[\"mac_from_hex_data\",\"manufacturerdata\",4]},\"co2\":{\"condition\":[\"manufacturerdata\",\"=\",36],\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",30,4,false,false]}}}";
/*R""""(
{
"brand":"SwitchBot",
"model":"Meter Pro (CO2)",
"model_id":"W490001X",
"tag":"0f02",
"condition":["uuid", "index", 0, "fd3d", "&", "servicedata", "=", 6, "index", 0, "35", "&", "manufacturerdata", "=", 36, "index", 0, "6909"],
"tag":"0202",
"condition":["servicedata", "=", 6, "index", 0, "35", "|", "servicedata", "=", 6, "index", 0, "34", "&", "uuid", "index", 0, "fd3d", "&", "manufacturerdata", ">=", 30, "index", 0, "6909"],
"properties":{
".cal":{
"decoder":["value_from_hex_data", "manufacturerdata", 21, 1, false, false],
Expand All @@ -27,15 +27,16 @@ const char* _SBMP_json = "{\"brand\":\"SwitchBot\",\"model\":\"Meter Pro (CO2)\"
"decoder":["value_from_hex_data", "manufacturerdata", 24, 2, false, false],
"post_proc":["&", 127]
},
"co2":{
"decoder":["value_from_hex_data", "manufacturerdata", 30, 4, false, false]
},
"batt":{
"decoder":["value_from_hex_data", "servicedata", 4, 2, false, false],
"post_proc":["&", 127]
},
"mac":{
"decoder":["mac_from_hex_data", "manufacturerdata", 4]
},
"co2":{
"condition":["manufacturerdata", "=", 36],
"decoder":["value_from_hex_data", "manufacturerdata", 30, 4, false, false]
}
}
})"""";*/
Expand Down
9 changes: 6 additions & 3 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,9 +273,10 @@ const char* expected_name_uuid_mfgsvcdata[] = {
"{\"brand\":\"SwitchBot\",\"model\":\"Blind Tilt\",\"model_id\":\"W270160X\",\"type\":\"WCVR\",\"acts\":true,\"ctrl\":true,\"open\":70,\"direction\":\"up\",\"motion\":false,\"calibrated\":true,\"lightlevel\":2,\"batt\":100,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"SwitchBot\",\"model\":\"Blind Tilt\",\"model_id\":\"W270160X\",\"type\":\"WCVR\",\"acts\":true,\"ctrl\":true,\"open\":50,\"direction\":\"up\",\"motion\":false,\"calibrated\":true,\"lightlevel\":2,\"batt\":100,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
"{\"brand\":\"nut\",\"model\":\"Smart Tracker\",\"model_id\":\"NUT\",\"type\":\"TRACK\",\"cidc\":false,\"acts\":true,\"track\":true,\"device\":\"nut Tracker\"}",
"{\"brand\":\"SwitchBot\",\"model\":\"Meter Pro (CO2)\",\"model_id\":\"W490001X\",\"type\":\"AIR\",\"acts\":true,\"tempc\":22.8,\"tempf\":73.04,\"hum\":40,\"co2\":893,\"batt\":100,\"mac\":\"B0:E9:FE:DD:EE:FF\"}",
"{\"brand\":\"nut\",\"model\":\"Smart Tracker\",\"model_id\":\"NUT\",\"type\":\"TRACK\",\"cidc\":false,\"acts\":true,\"track\":true,\"device\":\"nut Tracker\"}",
"{\"brand\":\"HolyIoT\",\"model\":\"Beacon\",\"model_id\":\"HOLYIOT\",\"type\":\"TRACK\",\"cidc\":false,\"track\":true,\"batt\":100,\"device\":\"HolyIoT Beacon Tracker\"}",
"{\"brand\":\"SwitchBot\",\"model\":\"Meter Pro (CO2)\",\"model_id\":\"W490001X\",\"type\":\"THBX\",\"acts\":true,\"tempc\":22.8,\"tempf\":73.04,\"hum\":40,\"co2\":893,\"batt\":100,\"mac\":\"B0:E9:FE:DD:EE:FF\"}",
"{\"brand\":\"SwitchBot\",\"model\":\"Meter Pro (CO2)\",\"model_id\":\"W490001X\",\"type\":\"THBX\",\"acts\":true,\"tempc\":21.8,\"tempf\":71.24,\"hum\":61,\"batt\":100,\"mac\":\"B0:E9:FE:9A:01:66\"}",
};

const char* expected_name_mac_uuid_mfgsvcdata[] = {
Expand Down Expand Up @@ -1099,9 +1100,10 @@ const char* test_name_uuid_mfgsvcdata[][5] = {
{"Switchbot_BlindTilt NEW", "WoBlindTilt", "0xfd3d", "6909aabbccddeeff2427412184", "780064"},
{"Switchbot_BlindTilt NEW", "WoBlindTilt", "0xfd3d", "6909aabbccddeeff39274b4184", "780064"},
{"Nut","nut","0x180a","12345678",""},
{"SwitchBot Meter Pro (CO2)", "Outdoor Meter", "0xfd3d", "6909b0e9feddeeff0ce40896280004037d00", "350064"},
{"Nut","nut","0x180a","","aabbccddeeff"},
{"Holyiot", "Holy-IOT", "0x5242", "4c000215cde0598cbc284b89b3786039a1da9efc271b000ec9", "4164aabbccddeeff0405040000"},
{"SwitchBot Meter Pro (CO2)", "Meter Pro CO2", "0xfd3d", "6909b0e9feddeeff0ce40896280004037d00", "350064"},
{"SwitchBot Meter Pro (NO CO2)", "Meter Pro", "0xfd3d", "6909b0e9fe9a0166886408953d001a", "340064"},
};

TheengsDecoder::BLE_ID_NUM test_name_uuid_mfgsvcdata_id_num[]{
Expand Down Expand Up @@ -1131,9 +1133,10 @@ TheengsDecoder::BLE_ID_NUM test_name_uuid_mfgsvcdata_id_num[]{
TheengsDecoder::BLE_ID_NUM::SBBT,
TheengsDecoder::BLE_ID_NUM::SBBT,
TheengsDecoder::BLE_ID_NUM::NUT,
TheengsDecoder::BLE_ID_NUM::SBMP,
TheengsDecoder::BLE_ID_NUM::NUT,
TheengsDecoder::BLE_ID_NUM::HOLYIOT,
TheengsDecoder::BLE_ID_NUM::SBMP,
TheengsDecoder::BLE_ID_NUM::SBMP,
};

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