diff --git a/src/decoder.h b/src/decoder.h index 985ae3fa..eb225f5e 100644 --- a/src/decoder.h +++ b/src/decoder.h @@ -99,6 +99,7 @@ class TheengsDecoder { SBCU, SBMS, SBMT, + SBMT_M, SBOT, SBS1, SHT4X, diff --git a/src/devices.h b/src/devices.h index 8ba2d704..2d331d4f 100644 --- a/src/devices.h +++ b/src/devices.h @@ -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}, diff --git a/src/devices/SBMT_json.h b/src/devices/SBMT_json.h index 440375f4..7c318878 100644 --- a/src/devices/SBMT_json.h +++ b/src/devices/SBMT_json.h @@ -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; diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp index 41d442fb..9f5789e8 100644 --- a/tests/BLE/test_ble.cpp +++ b/tests/BLE/test_ble.cpp @@ -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[] = { @@ -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[]{ @@ -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]