Skip to content

Commit

Permalink
Mikrotik TG-BT5-IN/-OUT Decoder
Browse files Browse the repository at this point in the history
Mikrotik TG-BT5-IN/-OUT initial Decoder
  • Loading branch information
DigiH committed Dec 7, 2024
1 parent 979a076 commit 1678be0
Show file tree
Hide file tree
Showing 5 changed files with 82 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/devices/Mikrotik.md
Original file line number Diff line number Diff line change
@@ -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|✅|
1 change: 1 addition & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ class TheengsDecoder {
NODONNIU,
MOKOBEACON,
MOKOBEACONXPRO,
TGBT5,
INODEEM,
RUUVITAG_RAWV1,
RUUVITAG_RAWV2,
Expand Down
2 changes: 2 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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},
Expand Down
45 changes: 45 additions & 0 deletions src/devices/Mikrotik_json.h
Original file line number Diff line number Diff line change
@@ -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,\"*\",100,\">\",0,\"/\",100]},\"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, "*", 100, ">", 0, "/", 100]
},
"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"
}
}
})"""";*/
21 changes: 21 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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.62,\"tempf\":83.516,\"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.62,\"tempf\":78.116,\"uptime\":744,\"batt\":100}",
};

const char* expected_name_uuid_mfgsvcdata[] = {
Expand Down Expand Up @@ -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[]{
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 1678be0

Please sign in to comment.