diff --git a/docs/.vuepress/config.js b/docs/.vuepress/config.js index c21a3b7d..7313552e 100644 --- a/docs/.vuepress/config.js +++ b/docs/.vuepress/config.js @@ -58,6 +58,7 @@ module.exports = { 'devices/CGPR1', 'devices/RuuviTag_RAWv1', 'devices/RuuviTag_RAWv2', + 'devices/SBS1', 'devices/TPMS', 'devices/VEGTRUG', 'devices/WS02', diff --git a/docs/devices/SBS1.md b/docs/devices/SBS1.md new file mode 100644 index 00000000..b120a52d --- /dev/null +++ b/docs/devices/SBS1.md @@ -0,0 +1,12 @@ +# SwitchBot S1 + +|Model Id|[SWITCHBOT-S1](https://github.com/theengs/decoder/blob/development/src/devices/SBS1_json.h)| +|-|-| +|Brand|SwitchBot| +|Model|SwitchBot S1| +|Short Description|Switch Button Pusher| +|Communication|BLE broadcast| +|Frequency|2.4Ghz| +|Power source|1 CR2| +|Exchanged data|mode, state, battery| +|Encrypted|No| diff --git a/src/decoder.h b/src/decoder.h index c4797ff9..a7f84fcf 100644 --- a/src/decoder.h +++ b/src/decoder.h @@ -81,6 +81,7 @@ class TheengsDecoder { IBT_2X, RUUVITAG_RAWV1, RUUVITAG_RAWV2, + SBS1, BM_V23, MS_CDP, GAEN, diff --git a/src/devices.h b/src/devices.h index 33f259aa..a7916ce0 100644 --- a/src/devices.h +++ b/src/devices.h @@ -47,6 +47,7 @@ #include "devices/Mokobeacon_json.h" #include "devices/RuuviTag_RAWv1_json.h" #include "devices/RuuviTag_RAWv2_json.h" +#include "devices/SBS1_json.h" #include "devices/TPMS_json.h" #include "devices/VEGTRUG_json.h" #include "devices/WS02_json.h" @@ -94,6 +95,7 @@ const char* _devices[][2] = { {_IBT_2X_json, _IBT_2X_json_props}, {_RuuviTag_RAWv1_json, _RuuviTag_RAWv1_json_props}, {_RuuviTag_RAWv2_json, _RuuviTag_RAWv2_json_props}, + {_SBS1_json, _SBS1_json_props}, {_BM_V23_json, _BM_V23_json_props}, {_MS_CDP_json, _MS_CDP_json_props}, {_GAEN_json, _GAEN_json_props}, diff --git a/src/devices/SBS1_json.h b/src/devices/SBS1_json.h new file mode 100644 index 00000000..25e2900f --- /dev/null +++ b/src/devices/SBS1_json.h @@ -0,0 +1,54 @@ +const char* _SBS1_json = "{\"brand\":\"SwitchBot\",\"model\":\"S1\",\"model_id\":\"SWITCHBOT-S1\",\"condition\":[\"uuid\",\"index\",0,\"0d00\",\"&\",\"servicedata\",\"=\",6,\"index\",0,\"48\"],\"properties\":{\"mode\":{\"condition\":[\"servicedata\",2,\"8\",\"|\",\"servicedata\",2,\"9\",\"|\",\"servicedata\",2,\"c\",\"|\",\"servicedata\",2,\"d\"],\"decoder\":[\"static_value\",\"on/off\"]},\"_mode\":{\"condition\":[\"servicedata\",2,\"0\",\"|\",\"servicedata\",2,\"1\",\"|\",\"servicedata\",2,\"4\",\"|\",\"servicedata\",2,\"5\"],\"decoder\":[\"static_value\",\"onestate\"]},\"state\":{\"condition\":[\"servicedata\",2,\"0\",\"|\",\"servicedata\",2,\"1\",\"|\",\"servicedata\",2,\"8\",\"|\",\"servicedata\",2,\"9\"],\"decoder\":[\"static_value\",\"on\"]},\"_state\":{\"condition\":[\"servicedata\",2,\"4\",\"|\",\"servicedata\",2,\"5\",\"|\",\"servicedata\",2,\"c\",\"|\",\"servicedata\",2,\"d\"],\"decoder\":[\"static_value\",\"off\"]},\"batt\":{\"condition\":[\"servicedata\",4,\"0\",\"|\",\"servicedata\",4,\"1\",\"|\",\"servicedata\",4,\"2\",\"|\",\"servicedata\",4,\"3\",\"|\",\"servicedata\",4,\"4\",\"|\",\"servicedata\",4,\"5\",\"|\",\"servicedata\",4,\"6\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false]},\"_batt\":{\"condition\":[\"servicedata\",4,\"8\",\"|\",\"servicedata\",4,\"9\",\"|\",\"servicedata\",4,\"a\",\"|\",\"servicedata\",4,\"b\",\"|\",\"servicedata\",4,\"c\",\"|\",\"servicedata\",4,\"d\",\"|\",\"servicedata\",4,\"e\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,false,false],\"post_proc\":['-',128]}}}"; +/*R""""( +{ + "brand":"SwitchBot", + "model":"S1", + "model_id":"SWITCHBOT-S1", + "condition":["uuid", "index",0, "0d00","&", "servicedata", "=", 6, "index", 0, "48"], + "properties":{ + "mode":{ + "condition":["servicedata", 2, "8", "|", "servicedata", 2, "9", "|", "servicedata", 2, "c", "|", "servicedata", 2, "d"], + "decoder":["static_value", "on/off"] + }, + "_mode":{ + "condition":["servicedata", 2, "0", "|", "servicedata", 2, "1", "|", "servicedata", 2, "4", "|", "servicedata", 2, "5"], + "decoder":["static_value", "onestate"] + }, + "state":{ + "condition":["servicedata", 2, "0", "|", "servicedata", 2, "1", "|", "servicedata", 2, "8", "|", "servicedata", 2, "9"], + "decoder":["static_value", "on"] + }, + "_state":{ + "condition":["servicedata", 2, "4", "|", "servicedata", 2, "5", "|", "servicedata", 2, "c", "|", "servicedata", 2, "d"], + "decoder":["static_value", "off"] + }, + "batt":{ + "condition":["servicedata", 4, "0", "|", "servicedata", 4, "1", "|", "servicedata", 4, "2", "|", "servicedata", 4, "3", "|", "servicedata", 4, "4", "|", "servicedata", 4, "5", "|", "servicedata", 4, "6"], + "decoder":["value_from_hex_data", "servicedata", 4, 2, false, false] + }, + "_batt":{ + "condition":["servicedata", 4, "8", "|", "servicedata", 4, "9", "|", "servicedata", 4, "a", "|", "servicedata", 4, "b", "|", "servicedata", 4, "c", "|", "servicedata", 4, "d", "|", "servicedata", 4, "e"], + "decoder":["value_from_hex_data", "servicedata", 4, 2, false, false], + "post_proc":['-', 128] + } + } +})"""";*/ + +const char* _SBS1_json_props = "{\"properties\":{\"mode\":{\"unit\":\"string\",\"name\":\"mode\"},\"state\":{\"unit\":\"string\",\"name\":\"state\"},\"batt\":{\"unit\":\"%\",\"name\":\"battery\"}}}"; +/*R""""( +{ + "properties":{ + "mode":{ + "unit":"string", + "name":"mode" + }, + "state":{ + "unit":"string", + "name":"state" + }, + "batt":{ + "unit":"%", + "name":"battery" + } + } +})"""";*/ \ No newline at end of file diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp index f4261df2..92c5424c 100644 --- a/tests/BLE/test_ble.cpp +++ b/tests/BLE/test_ble.cpp @@ -99,6 +99,9 @@ const char* expected_uuid[] = { "{\"brand\":\"Mokosmart\",\"model\":\"Beacon\",\"model_id\":\"Mokobeacon\",\"batt\":100,\"x_axis\":-24576,\"y_axis\":-3841,\"z_axis\":-8189}", "{\"brand\":\"Mokosmart\",\"model\":\"BeaconX Pro\",\"model_id\":\"MBXPRO\",\"tempc\":27.4,\"tempf\":81.32,\"hum\":49.4,\"volt\":3.247}", "{\"brand\":\"GENERIC\",\"model\":\"GAEN\",\"model_id\":\"GAEN\",\"rpi\":\"e7c6d34c71e48baf278bd99be74685bc\",\"aem\":\"a78126ab\"}", + "{\"brand\":\"SwitchBot\",\"model\":\"S1\",\"model_id\":\"SWITCHBOT-S1\",\"mode\":\"on/off\",\"state\":\"off\",\"batt\":91}", + "{\"brand\":\"SwitchBot\",\"model\":\"S1\",\"model_id\":\"SWITCHBOT-S1\",\"mode\":\"on/off\",\"state\":\"on\",\"batt\":76}", + "{\"brand\":\"SwitchBot\",\"model\":\"S1\",\"model_id\":\"SWITCHBOT-S1\",\"mode\":\"onestate\",\"state\":\"on\",\"batt\":91}", }; // Service data test input [test name] [data] @@ -268,6 +271,9 @@ const char* test_uuid[][4] = { {"Mokobeacon", "0xff01", "servicedata", "64000000005085a000f0ffe003"}, {"MokoXPro", "feab", "servicedata", "70000a011201ee0caf03def14635998a"}, {"GAEN", "fd6f", "servicedata", "e7c6d34c71e48baf278bd99be74685bca78126ab"}, + {"Switchbot_S1", "0d00", "servicedata", "48d0db"}, + {"Switchbot_S1", "0d00", "servicedata", "4890cc"}, + {"Switchbot_S1", "0d00", "servicedata", "48005b"}, }; TheengsDecoder::BLE_ID_NUM test_uuid_id_num[]{ @@ -295,6 +301,9 @@ TheengsDecoder::BLE_ID_NUM test_uuid_id_num[]{ TheengsDecoder::BLE_ID_NUM::MOKOBEACON, TheengsDecoder::BLE_ID_NUM::MOKOBEACONXPRO, TheengsDecoder::BLE_ID_NUM::GAEN, + TheengsDecoder::BLE_ID_NUM::SBS1, + TheengsDecoder::BLE_ID_NUM::SBS1, + TheengsDecoder::BLE_ID_NUM::SBS1, }; template