diff --git a/docs/devices/Mikrotik.md b/docs/devices/Mikrotik.md new file mode 100644 index 00000000..b7165d31 --- /dev/null +++ b/docs/devices/Mikrotik.md @@ -0,0 +1,13 @@ +# MikroTik TG-BT5-IN & TG-BT5-OUT + +|Model Id|[TG-BT5](https://github.com/theengs/decoder/blob/development/src/devices/Mikrotik_json.h)| +|-|-| +|Brand|MikroTik| +|Model|TG-BT5-IN/-OUT| +|Short Description|Indoor/Outdoor temperature and acceleration sensor| +|Communication|BLE broadcast| +|Frequency|2.4Ghz| +|Power Source|built-in non-replaceable battery| +|Exchanged Data|temperature, acceleration x/y/z-axis, uptime, battery| +|Encrypted|No - Currently only unencrypted devices are supported| +|Device Tracker|✅| diff --git a/src/decoder.h b/src/decoder.h index 4a71d8ce..3df911d9 100644 --- a/src/decoder.h +++ b/src/decoder.h @@ -92,6 +92,7 @@ class TheengsDecoder { NODONNIU, MOKOBEACON, MOKOBEACONXPRO, + TGBT5, INODEEM, RUUVITAG_RAWV1, RUUVITAG_RAWV2, diff --git a/src/devices.h b/src/devices.h index d28f2c45..39d9ea74 100644 --- a/src/devices.h +++ b/src/devices.h @@ -58,6 +58,7 @@ #include "devices/XMTZC05HMKG_json.h" #include "devices/XMTZC05HMLB_json.h" #include "devices/Mokobeacon_json.h" +#include "devices/Mikrotik_json.h" #include "devices/RDL52832_json.h" #include "devices/RuuviTag_RAWv1_json.h" #include "devices/RuuviTag_RAWv2_json.h" @@ -171,6 +172,7 @@ const char* _devices[][2] = { {_NODONNIU_json, _NODONNIU_json_props}, {_Mokobeacon_json, _Mokobeacon_json_props}, {_MBXPRO_json, _MBXPRO_json_props}, + {_Mikrotik_json, _Mikrotik_json_props}, {_iNodeEM_json, _iNodeEM_json_props}, {_RuuviTag_RAWv1_json, _RuuviTag_RAWv1_json_props}, {_RuuviTag_RAWv2_json, _RuuviTag_RAWv2_json_props}, diff --git a/src/devices/Mikrotik_json.h b/src/devices/Mikrotik_json.h new file mode 100644 index 00000000..fdcd631a --- /dev/null +++ b/src/devices/Mikrotik_json.h @@ -0,0 +1,45 @@ +const char* _Mikrotik_json = "{\"brand\":\"MikroTik\",\"model\":\"TG-BT5-IN/-OUT\",\"model_id\":\"TG-BT5\",\"tag\":\"0708\",\"condition\":[\"manufacturerdata\",\"=\",40,\"index\",0,\"4f0901\"],\"properties\":{\".cal\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",24,2,false,false],\"post_proc\":[\"/\",256,\"*\",1000,\">\",0,\"/\",1000]},\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",26,2,false,true],\"post_proc\":[\"&\",127,\"+\",\".cal\"]},\"uptime\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",28,8,true,false]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",38,2,false,false],\"post_proc\":[\"&\",127]}}}"; +/*R""""( +{ + "brand":"MikroTik", + "model":"TG-BT5-IN/-OUT", + "model_id":"TG-BT5", + "tag":"0708", + "condition":["manufacturerdata", "=", 40, "index", 0, "4f0901"], + "properties":{ + ".cal":{ + "decoder":["value_from_hex_data", "manufacturerdata", 24, 2, false, false], + "post_proc":["/", 256, "*", 1000, ">", 0, "/", 1000] + }, + "tempc":{ + "decoder":["value_from_hex_data", "manufacturerdata", 26, 2, false, true], + "post_proc":["&", 127, "+", ".cal"] + }, + "uptime":{ + "decoder":["value_from_hex_data", "manufacturerdata", 28, 8, true, false] + }, + "batt":{ + "decoder":["value_from_hex_data", "manufacturerdata", 38, 2, false, false], + "post_proc":["&", 127] + } + } +})"""";*/ + +const char* _Mikrotik_json_props = "{\"properties\":{\"tempc\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"uptime\":{\"unit\":\"s\",\"name\":\"duration\"},\"batt\":{\"unit\":\"%\",\"name\":\"battery\"}}}"; +/*R""""( +{ + "properties":{ + "tempc":{ + "unit":"°C", + "name":"temperature" + }, + "uptime":{ + "unit":"s", + "name":"duration" + }, + "batt":{ + "unit":"%", + "name":"battery" + } + } +})"""";*/ diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp index 5399c769..244c698a 100644 --- a/tests/BLE/test_ble.cpp +++ b/tests/BLE/test_ble.cpp @@ -188,6 +188,13 @@ const char* expected_mfg[] = { "{\"brand\":\"Govee\",\"model\":\"Smart Thermo-Hygrometer\",\"model_id\":\"H5100/01/02/04/05/08/74/77\",\"type\":\"THB\",\"cidc\":false,\"acts\":true,\"tempc\":1.7,\"tempf\":35.06,\"batt\":67}", "{\"brand\":\"Govee\",\"model\":\"Smart Thermo-Hygrometer\",\"model_id\":\"H5100/01/02/04/05/08/74/77\",\"type\":\"THB\",\"cidc\":false,\"acts\":true,\"tempc\":-3.6,\"tempf\":25.52,\"batt\":35}", "{\"brand\":\"Govee\",\"model\":\"Smart Thermo-Hygrometer\",\"model_id\":\"H5100/01/02/04/05/08/74/77\",\"type\":\"THB\",\"cidc\":false,\"acts\":true,\"tempc\":-8.4,\"tempf\":16.88,\"batt\":4}", + "{\"brand\":\"MikroTik\",\"model\":\"TG-BT5-IN/-OUT\",\"model_id\":\"TG-BT5\",\"type\":\"ACEL\",\"track\":true,\"tempc\":28.625,\"tempf\":83.525,\"uptime\":5703825,\"batt\":95}", + "{\"brand\":\"MikroTik\",\"model\":\"TG-BT5-IN/-OUT\",\"model_id\":\"TG-BT5\",\"type\":\"ACEL\",\"track\":true,\"tempc\":0,\"tempf\":32,\"uptime\":597,\"batt\":100}", + "{\"brand\":\"MikroTik\",\"model\":\"TG-BT5-IN/-OUT\",\"model_id\":\"TG-BT5\",\"type\":\"ACEL\",\"track\":true,\"tempc\":0,\"tempf\":32,\"uptime\":639,\"batt\":100}", + "{\"brand\":\"MikroTik\",\"model\":\"TG-BT5-IN/-OUT\",\"model_id\":\"TG-BT5\",\"type\":\"ACEL\",\"track\":true,\"tempc\":0,\"tempf\":32,\"uptime\":687,\"batt\":100}", + "{\"brand\":\"MikroTik\",\"model\":\"TG-BT5-IN/-OUT\",\"model_id\":\"TG-BT5\",\"type\":\"ACEL\",\"track\":true,\"tempc\":0,\"tempf\":32,\"uptime\":705,\"batt\":100}", + "{\"brand\":\"MikroTik\",\"model\":\"TG-BT5-IN/-OUT\",\"model_id\":\"TG-BT5\",\"type\":\"ACEL\",\"track\":true,\"tempc\":0,\"tempf\":32,\"uptime\":744,\"batt\":100}", + "{\"brand\":\"MikroTik\",\"model\":\"TG-BT5-IN/-OUT\",\"model_id\":\"TG-BT5\",\"type\":\"ACEL\",\"track\":true,\"tempc\":25.628,\"tempf\":78.1304,\"uptime\":744,\"batt\":100}", }; const char* expected_name_uuid_mfgsvcdata[] = { @@ -709,6 +716,13 @@ const char* test_mfgdata[][3] = { {"H5108", "GV51082A7E", "010001010044c0430000"}, {"H5108", "GV51082A7E", "01000101808ef8230000"}, {"H5108", "GV51082A7E", "01000101814a78040000"}, + {"Mikrotik", "TG-BT5-IN/-OUT", "4f090100cea6000000000200a01c91085700005f"}, + {"Mikrotik", "TG-BT5-IN/-OUT", "4f090100ed2ffffffefffeff0080550200000064"}, + {"Mikrotik", "TG-BT5-IN/-OUT", "4f0901003fbf07000300feff00807f0200000064"}, + {"Mikrotik", "TG-BT5-IN/-OUT", "4f090100497b38008d0348000080af0200000064"}, + {"Mikrotik", "TG-BT5-IN/-OUT", "4f090100de84feffffffffff0080c10200000064"}, + {"Mikrotik", "TG-BT5-IN/-OUT", "4f0901009e11fffffeff00000080e80200000064"}, + {"Mikrotik", "TG-BT5-IN/-OUT", "4f0901009e11fffffeff0000a119e802000000e4"}, }; TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{ @@ -880,6 +894,13 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{ TheengsDecoder::BLE_ID_NUM::H5102, TheengsDecoder::BLE_ID_NUM::H5102, TheengsDecoder::BLE_ID_NUM::H5102, + TheengsDecoder::BLE_ID_NUM::TGBT5, + TheengsDecoder::BLE_ID_NUM::TGBT5, + TheengsDecoder::BLE_ID_NUM::TGBT5, + TheengsDecoder::BLE_ID_NUM::TGBT5, + TheengsDecoder::BLE_ID_NUM::TGBT5, + TheengsDecoder::BLE_ID_NUM::TGBT5, + TheengsDecoder::BLE_ID_NUM::TGBT5, }; // uuid test input [test name] [device name] [uuid] [manufacturer data] [service data]