diff --git a/src/decoder.h b/src/decoder.h index 7e2c8404..34488807 100644 --- a/src/decoder.h +++ b/src/decoder.h @@ -163,6 +163,7 @@ class TheengsDecoder { SBMO_003Z, SBMO_003Z_ENCR, SBHT_003C, + SBHT_003C_ENCR, BLE_ID_MAX }; diff --git a/src/devices.h b/src/devices.h index d035b4d7..313d2836 100644 --- a/src/devices.h +++ b/src/devices.h @@ -117,6 +117,7 @@ #include "devices/SBMO_003Z_json.h" #include "devices/SBMO_003Z_ENCR_json.h" #include "devices/SBHT_003C_json.h" +#include "devices/SBHT_003C_ENCR_json.h" const char* _devices[][2] = { @@ -237,4 +238,5 @@ const char* _devices[][2] = { {_SBMO_003Z_json, _SBMO_003Z_json_props}, {_SBMO_003Z_ENCR_json, _SBMO_003Z_ENCR_json_props}, {_SBHT_003C_json, _SBHT_003C_json_props}, + {_SBHT_003C_ENCR_json, _SBHT_003C_ENCR_json_props}, }; diff --git a/src/devices/SBHT_003C_ENCR_json.h b/src/devices/SBHT_003C_ENCR_json.h new file mode 100644 index 00000000..eec193fc --- /dev/null +++ b/src/devices/SBHT_003C_ENCR_json.h @@ -0,0 +1,62 @@ +const char* _SBHT_003C_ENCR_json = "{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T encrypted\",\"model_id\":\"SBHT-003C_ENCR\",\"tag\":\"010602\",\"condition\":[\"servicedata\",\"=\",36,\"index\",0,\"45\",\"|\",\"servicedata\",\"=\",40,\"index\",0,\"45\",\"&\",\"uuid\",\"index\",0,\"fcd2\",\"&\",\"name\",\"index\",0,\"SBHT-003C\"],\"properties\":{\"cipher\":{\"condition\":[\"servicedata\",\"=\",36],\"decoder\":[\"string_from_hex_data\",\"servicedata\",2,18]},\"_cipher\":{\"condition\":[\"servicedata\",\"=\",40],\"decoder\":[\"string_from_hex_data\",\"servicedata\",2,22]},\"ctr\":{\"condition\":[\"servicedata\",\"=\",36],\"decoder\":[\"string_from_hex_data\",\"servicedata\",20,8]},\"_ctr\":{\"condition\":[\"servicedata\",\"=\",40],\"decoder\":[\"string_from_hex_data\",\"servicedata\",24,8]},\"mic\":{\"condition\":[\"servicedata\",\"=\",36],\"decoder\":[\"string_from_hex_data\",\"servicedata\",28,8]},\"_mic\":{\"condition\":[\"servicedata\",\"=\",40],\"decoder\":[\"string_from_hex_data\",\"servicedata\",32,8]},\"mac\":{\"condition\":[\"manufacturerdata\",\"=\",30],\"decoder\":[\"revmac_from_hex_data\",\"manufacturerdata\",18]}}}"; +/*R""""( +{ + "brand":"Shelly", + "model":"ShellyBLU H&T encrypted", + "model_id":"SBHT-003C_ENCR", + "tag":"010602", + "condition":["servicedata", "=", 36, "index", 0, "45", "|", "servicedata", "=", 40, "index", 0, "45", "&", "uuid", "index", 0, "fcd2", "&", "name", "index", 0, "SBHT-003C"], + "properties":{ + "cipher":{ + "condition":["servicedata", "=", 36], + "decoder":["string_from_hex_data", "servicedata", 2, 18] + }, + "_cipher":{ + "condition":["servicedata", "=", 40], + "decoder":["string_from_hex_data", "servicedata", 2, 22] + }, + "ctr":{ + "condition":["servicedata", "=", 36], + "decoder":["string_from_hex_data", "servicedata", 20, 8] + }, + "_ctr":{ + "condition":["servicedata", "=", 40], + "decoder":["string_from_hex_data", "servicedata", 24, 8] + }, + "mic":{ + "condition":["servicedata", "=", 36], + "decoder":["string_from_hex_data", "servicedata", 28, 8] + }, + "_mic":{ + "condition":["servicedata", "=", 40], + "decoder":["string_from_hex_data", "servicedata", 32, 8] + }, + "mac":{ + "condition":["manufacturerdata", "=", 30], + "decoder":["revmac_from_hex_data", "manufacturerdata", 18] + } + } +})"""";*/ + +const char* _SBHT_003C_ENCR_json_props = "{\"properties\":{\"cipher\":{\"unit\":\"hex\",\"name\":\"ciphertext\"},\"ctr\":{\"unit\":\"hex\",\"name\":\"counter\"},\"mic\":{\"unit\":\"hex\",\"name\":\"message integrity check\"},\"mac\":{\"unit\":\"string\",\"name\":\"MAC address\"}}}"; +/*R""""( +{ + "properties":{ + "cipher":{ + "unit":"hex", + "name":"ciphertext" + }, + "ctr":{ + "unit":"hex", + "name":"counter" + }, + "mic":{ + "unit":"hex", + "name":"message integrity check" + }, + "mac":{ + "unit":"string", + "name":"MAC address" + } + } +})"""";*/ diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp index 57353c2d..58d45bc3 100644 --- a/tests/BLE/test_ble.cpp +++ b/tests/BLE/test_ble.cpp @@ -200,12 +200,13 @@ const char* expected_name_mac_uuid_mfgsvcdata[] = { "{\"brand\":\"Shelly\",\"model\":\"ShellyBLU Motion\",\"model_id\":\"SBMO-003Z\",\"type\":\"CTMO\",\"acts\":true,\"cont\":true,\"packet\":2,\"batt\":100,\"lux\":132,\"motion\":true,\"mac\":\"60:EF:AB:AA:BB:CC\"}", "{\"brand\":\"Shelly\",\"model\":\"ShellyBLU Motion\",\"model_id\":\"SBMO-003Z\",\"type\":\"CTMO\",\"acts\":true,\"cont\":true,\"packet\":5,\"batt\":100,\"lux\":36,\"motion\":false,\"mac\":\"60:EF:AB:AA:BB:CC\"}", "{\"brand\":\"Shelly\",\"model\":\"ShellyBLU Motion encrypted\",\"model_id\":\"SBMO_003Z_ENCR\",\"type\":\"CTMO\",\"acts\":true,\"cont\":true,\"encr\":2,\"cipher\":\"cc08edf25d61cc0f42b6\",\"ctr\":\"00112233\",\"mic\":\"18cd3624\",\"mac\":\"60:EF:AB:AA:BB:CC\"}", - "{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T\",\"model_id\":\"SBHT-003C\",\"type\":\"THB\",\"acts\":true,\"cont\":true,\"packet\":78,\"batt\":100,\"hum\":63,\"tempc\":22.3,\"tempf\":72.14,\"mac\":\"AA:BB:BB:DD:EE:FF\"}", - "{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T\",\"model_id\":\"SBHT-003C\",\"type\":\"THB\",\"acts\":true,\"cont\":true,\"packet\":78,\"batt\":100,\"hum\":63,\"button\":1,\"tempc\":22.3,\"tempf\":72.14,\"mac\":\"AA:BB:BB:DD:EE:FF\"}", + "{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T\",\"model_id\":\"SBHT-003C\",\"type\":\"THB\",\"acts\":true,\"cont\":true,\"packet\":78,\"batt\":100,\"hum\":63,\"tempc\":22.3,\"tempf\":72.14,\"mac\":\"AA:BB:CC:DD:EE:FF\"}", + "{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T\",\"model_id\":\"SBHT-003C\",\"type\":\"THB\",\"acts\":true,\"cont\":true,\"packet\":78,\"batt\":100,\"hum\":63,\"button\":1,\"tempc\":22.3,\"tempf\":72.14,\"mac\":\"AA:BB:CC:DD:EE:FF\"}", "{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T\",\"model_id\":\"SBHT-003C\",\"type\":\"THB\",\"acts\":true,\"cont\":true,\"packet\":174,\"batt\":100,\"hum\":56,\"tempc\":25,\"tempf\":77,\"mac\":\"AA:BB:AA:BB:AA:BB\"}", "{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T\",\"model_id\":\"SBHT-003C\",\"type\":\"THB\",\"acts\":true,\"cont\":true,\"packet\":174,\"batt\":100,\"hum\":56,\"button\":11,\"tempc\":25,\"tempf\":77,\"mac\":\"AA:BB:AA:BB:AA:BB\"}", - - + "{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T encrypted\",\"model_id\":\"SBHT-003C_ENCR\",\"type\":\"THB\",\"acts\":true,\"cont\":true,\"encr\":2,\"cipher\":\"e1a236ace4b4086167\",\"ctr\":\"4bfbd366\",\"mic\":\"8c080c2e\",\"mac\":\"AA:BB:CC:DD:EE:FF\"}", + "{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T encrypted\",\"model_id\":\"SBHT-003C_ENCR\",\"type\":\"THB\",\"acts\":true,\"cont\":true,\"encr\":2,\"cipher\":\"c85de27369ce3f84750015\",\"ctr\":\"aae9d466\",\"mic\":\"b801349b\",\"mac\":\"AA:BB:CC:DD:EE:FF\"}", + "{\"brand\":\"Shelly\",\"model\":\"ShellyBLU H&T encrypted\",\"model_id\":\"SBHT-003C_ENCR\",\"type\":\"THB\",\"acts\":true,\"cont\":true,\"encr\":2,\"cipher\":\"3a25e3518e72c92f6dfef8\",\"ctr\":\"e9e9d466\",\"mic\":\"96b53b8a\",\"mac\":\"AA:BB:CC:DD:EE:FF\"}", }; const char* expected_uuid_name_svcdata[] = { @@ -810,10 +811,13 @@ const char* test_name_mac_uuid_mfgsvcdata[][6] = { {"SBMO-003Z", "60:EF:AB:AA:BB:CC", "SBMO-003Z", "0xfcd2", "a90b0101000b05000accbbaaabef60", "4400020164059033002101"}, {"SBMO-003Z", "60:EF:AB:AA:BB:CC", "SBMO-003Z", "0xfcd2", "a90b0101000b05000accbbaaabef60", "440005016405100e002100"}, {"SBMO-003Z encrypted", "60:EF:AB:AA:BB:CC", "SBMO-003Z", "0xfcd2", "a90b0101000b05000accbbaaabef60", "45cc08edf25d61cc0f42b60011223318cd3624"}, - {"SBHT-003C", "AA:BB:CC:DD:EE:FF", "SBHT-003C", "0xfcd2", "a90b0111000b03000affeeddbbbbaa", "44004e01642e3f45df00"}, - {"SBHT-003C", "AA:BB:CC:DD:EE:FF", "SBHT-003C", "0xfcd2", "a90b0111000b03000affeeddbbbbaa", "44004e01642e3f3a0145df00"}, + {"SBHT-003C", "AA:BB:CC:DD:EE:FF", "SBHT-003C", "0xfcd2", "a90b0111000b03000affeeddccbbaa", "44004e01642e3f45df00"}, + {"SBHT-003C", "AA:BB:CC:DD:EE:FF", "SBHT-003C", "0xfcd2", "a90b0111000b03000affeeddccbbaa", "44004e01642e3f3a0145df00"}, {"SBHT-003C", "AA:BB:AA:BB:AA:BB", "SBHT-003C", "0xfcd2", "a90b0111000b03000abbaabbaabbaa", "4400ae01642e3845fa00"}, {"SBHT-003C", "AA:BB:AA:BB:AA:BB", "SBHT-003C", "0xfcd2", "a90b0111000b03000abbaabbaabbaa", "4400ae01642e383afe45fa00"}, + {"SBHT-003C encrypted", "AA:BB:CC:DD:EE:FF", "SBHT-003C", "0xfcd2", "a90b0111000b03000affeeddccbbaa", "45e1a236ace4b40861674bfbd3668c080c2e"}, + {"SBHT-003C encrypted", "AA:BB:CC:DD:EE:FF", "SBHT-003C", "0xfcd2", "a90b0111000b03000affeeddccbbaa", "45c85de27369ce3f84750015aae9d466b801349b"}, + {"SBHT-003C encrypted", "AA:BB:CC:DD:EE:FF", "SBHT-003C", "0xfcd2", "a90b0111000b03000affeeddccbbaa", "453a25e3518e72c92f6dfef8e9e9d46696b53b8a"}, }; TheengsDecoder::BLE_ID_NUM test_name_mac_uuid_mfgsvcdata_id_num[]{ @@ -829,6 +833,9 @@ TheengsDecoder::BLE_ID_NUM test_name_mac_uuid_mfgsvcdata_id_num[]{ TheengsDecoder::BLE_ID_NUM::SBHT_003C, TheengsDecoder::BLE_ID_NUM::SBHT_003C, TheengsDecoder::BLE_ID_NUM::SBHT_003C, + TheengsDecoder::BLE_ID_NUM::SBHT_003C_ENCR, + TheengsDecoder::BLE_ID_NUM::SBHT_003C_ENCR, + TheengsDecoder::BLE_ID_NUM::SBHT_003C_ENCR, }; // uuid name test input [test name] [uuid] [device name] [service data]