Skip to content

Commit

Permalink
SwitchBot Outdoor Meter (#333)
Browse files Browse the repository at this point in the history
Initial decoder
  • Loading branch information
DigiH authored May 10, 2023
1 parent 7987753 commit 859e85d
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/devices/SBOT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# SwitchBot Outdoor Meter

|Model Id|[W340001X)](https://github.com/theengs/decoder/blob/development/src/devices/SBOT_json.h)|
|-|-|
|Brand|SwitchBot|
|Model|Outdoor Meter|
|Short Description|Indoor/Outdoor Thermometer and Hygrometer|
|Communication|BLE broadcast|
|Frequency|2.4Ghz|
|Power source|2 AAA|
|Exchanged data|temperature, humidity, battery|
|Encrypted|No|
1 change: 1 addition & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ class TheengsDecoder {
SBCU,
SBMS,
SBMT,
SBOT,
SBS1,
SHT4X,
SCD4X,
Expand Down
2 changes: 2 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#include "devices/SBCU_json.h"
#include "devices/SBMS_json.h"
#include "devices/SBMT_json.h"
#include "devices/SBOT_json.h"
#include "devices/SBS1_json.h"
#include "devices/SHT4X_json.h"
#include "devices/SCD4X_json.h"
Expand Down Expand Up @@ -132,6 +133,7 @@ const char* _devices[][2] = {
{_SBCU_json, _SBCU_json_props},
{_SBMS_json, _SBMS_json_props},
{_SBMT_json, _SBMT_json_props},
{_SBOT_json, _SBOT_json_props},
{_SBS1_json, _SBS1_json_props},
{_SHT4X_json, _SHT4X_json_props},
{_SCD4X_json, _SCD4X_json_props},
Expand Down
37 changes: 37 additions & 0 deletions src/devices/SBOT_json.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#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]}}}";
/*R""""(
{
"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]
}
}
})"""";*/

const char* _SBOT_json_props = _common_BTH_props;
6 changes: 6 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ const char* expected_name_uuid_mfgsvcdata[] = {
"{\"brand\":\"Radioland\",\"model\":\"RDL52832\",\"model_id\":\"RDL52832\",\"type\":\"ACEL\",\"acts\":true,\"track\":true,\"mfid\":\"4c00\",\"uuid\":\"fda50693a4e24fb1afcfc6eb07647825\",\"major\":1,\"minor\":2,\"txpower\":-40,\"tempc\":24.2265625,\"tempf\":75.6078125,\"hum\":47.19921875,\"accx\":-0.196133,\"accy\":0.0980665,\"accz\":9.5124505}",
"{\"brand\":\"Radioland\",\"model\":\"RDL52832\",\"model_id\":\"RDL52832\",\"type\":\"ACEL\",\"acts\":true,\"track\":true,\"mfid\":\"4c00\",\"uuid\":\"fda50693a4e24fb1afcfc6eb07647825\",\"major\":1,\"minor\":2,\"txpower\":-40,\"tempc\":25.296875,\"tempf\":77.534375,\"hum\":58.22265625,\"accx\":1.372931,\"accy\":0.8825985,\"accz\":-9.610517}",
"{\"brand\":\"Radioland\",\"model\":\"RDL52832\",\"model_id\":\"RDL52832\",\"type\":\"ACEL\",\"acts\":true,\"track\":true,\"mfid\":\"4c00\",\"uuid\":\"fda50693a4e24fb1afcfc6eb07647825\",\"major\":1,\"minor\":2,\"txpower\":-40,\"tempc\":26.2734375,\"tempf\":79.2921875,\"hum\":61.203125,\"accx\":1.96133,\"accy\":-9.414384,\"accz\":1.4709975}",
"{\"brand\":\"SwitchBot\",\"model\":\"Outdoor Meter\",\"model_id\":\"W340001X\",\"type\":\"THB\",\"acts\":true,\"tempc\":25.5,\"tempf\":77.9,\"hum\":50,\"batt\":100}",
"{\"brand\":\"SwitchBot\",\"model\":\"Outdoor Meter\",\"model_id\":\"W340001X\",\"type\":\"THB\",\"acts\":true,\"tempc\":26.3,\"tempf\":79.34,\"hum\":80,\"batt\":100}",
};

const char* expected_uuid_name_svcdata[] = {
Expand Down Expand Up @@ -536,6 +538,8 @@ const char* test_name_uuid_mfgsvcdata[][5] = {
{"RDL52832", "RDL52832", "0x1803", "4c000215fda50693a4e24fb1afcfc6eb0764782500010002d8", "183a2f33010000020000000100000907"},
{"RDL52832", "RDL52832", "0x1803", "4c000215fda50693a4e24fb1afcfc6eb0764782500010002d8", "194c3a39000001040000000901000908"},
{"RDL52832", "RDL52832", "0x1803", "4c000215fda50693a4e24fb1afcfc6eb0764782500010002d8", "1a463d34000002000100090600000105"},
{"SwitchBot Outdoor Meter", "Outdoor Meter", "0xfd3d", "6909f9666b959cea8b0305993200", "770064"},
{"SwitchBot Outdoor Meter", "Outdoor Meter", "0xfd3d", "6909f9666b959cea940b039a5000", "770064"},
};

TheengsDecoder::BLE_ID_NUM test_name_uuid_mfgsvcdata_id_num[]{
Expand All @@ -545,6 +549,8 @@ TheengsDecoder::BLE_ID_NUM test_name_uuid_mfgsvcdata_id_num[]{
TheengsDecoder::BLE_ID_NUM::RDL52832,
TheengsDecoder::BLE_ID_NUM::RDL52832,
TheengsDecoder::BLE_ID_NUM::RDL52832,
TheengsDecoder::BLE_ID_NUM::SBOT,
TheengsDecoder::BLE_ID_NUM::SBOT,
};

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

0 comments on commit 859e85d

Please sign in to comment.