Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions docs/devices/UT363BT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# UNI-T UT363 BT Anemometer

|Model Id|[UT363BT](https://github.com/theengs/decoder/blob/development/src/devices/UT363BT_json.h)|
|-|-|
|Brand|UNI-T|
|Model|UT363 BT Anemometer|
|Short Description|Wind speed anemometer|
|Communication|BLE broadcast|
|Frequency|2.4Ghz|
|Power Source|3 AAA|
|Exchanged Data|wind speed|
|Encrypted|No|
9 changes: 6 additions & 3 deletions docs/participate/adding-decoders.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ Each device should also have an encoded **tag** property to, at the minimum, def
</thead>
<tbody>
<tr>
<td rowspan=22>Byte[0]</td>
<td rowspan=22>Device Type > "type":</td>
<td rowspan=23>Byte[0]</td>
<td rowspan=23>Device Type > "type":</td>
<td rowspan=1>0 - Reserved</td>
</tr>
<tr>
Expand Down Expand Up @@ -112,7 +112,10 @@ Each device should also have an encoded **tag** property to, at the minimum, def
<td rowspan=1>18 - AUDIO - audio devices</td>
</tr>
<tr>
<td rowspan=1>19-253 - Reserved</td>
<td rowspan=1>19 - WIND - wind speed anemometers</td>
</tr>
<tr>
<td rowspan=1>20-253 - Reserved</td>
</tr>
<tr>
<td rowspan=1>254 - RMAC - known random MAC address devices</td>
Expand Down
11 changes: 10 additions & 1 deletion src/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -585,6 +585,9 @@ int TheengsDecoder::decodeBLEJson(JsonObject& jsondata) {
case 18:
doc["type"] = "AUDIO"; // Button
break;
case 19:
doc["type"] = "WIND"; // Button
break;
case 254:
doc["type"] = "RMAC"; // random MAC address devices
break;
Expand Down Expand Up @@ -936,8 +939,14 @@ int TheengsDecoder::decodeBLEJson(JsonObject& jsondata) {
ascii += ch;
}

// DEBUG_PRINT("PROP: %s\n", prop.as<JsonObject>();

if (ascii != "") {
jsondata[sanitizeJsonKey(kv.key().c_str())] = ascii;
if (prop.containsKey("is_double")) {
jsondata[sanitizeJsonKey(kv.key().c_str())] = std::stod(ascii);
} else {
jsondata[sanitizeJsonKey(kv.key().c_str())] = ascii;
}
}

success = i_main;
Expand Down
1 change: 1 addition & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class TheengsDecoder {
APPLE_CONT,
APPLE_CONTAT,
SERVICE_DATA,
UT363BT,
SE_RHT,
SE_TEMP,
SE_TPROBE,
Expand Down
2 changes: 2 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@
#include "devices/iBeacon_json.h"
#include "devices/APPLE_json.h"
#include "devices/ServiceData_json.h"
#include "devices/UT363BT_json.h"
#include "devices/SE_RHT_json.h"
#include "devices/SE_TEMP_json.h"
#include "devices/SE_TPROBE_json.h"
Expand Down Expand Up @@ -240,6 +241,7 @@ const char* _devices[][2] = {
{_APPLE_json, _APPLE_json_props},
{_APPLE_json_at, _APPLE_json_props},
{_ServiceData_json, _ServiceData_json_props},
{_UT363BT_json, _UT363BT_json_props},
{_SE_RHT_json, _SE_RHT_json_props},
{_SE_TEMP_json, _SE_TEMP_json_props},
{_SE_TPROBE_json, _SE_TPROBE_json_props},
Expand Down
26 changes: 26 additions & 0 deletions src/devices/UT363BT_json.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const char* _UT363BT_json = "{\"brand\":\"UNI-T\",\"model\":\"UT363 BT Anemometer\",\"model_id\":\"UT363BT\",\"tag\":\"1301\",\"condition\":[\"manufacturerdata\",\"=\",38,\"index\",22,\"4d2f53\",\"&\",\"manufacturerdata\",\"=\",38,\"index\",0,\"aabb\"],\"properties\":{\"windspeed\":{\"decoder\":[\"ascii_from_hex_data\",\"manufacturerdata\",10,12],\"is_double\":1}}}";
/*R""""(
{
"brand":"UNI-T",
"model":"UT363 BT Anemometer",
"model_id":"UT363BT",
"tag":"1301",
"condition":["manufacturerdata", "=", 38, "index", 22, "4d2f53", "&", "manufacturerdata", "=", 38, "index", 0, "aabb"],
"properties":{
"windspeed":{
"decoder":["ascii_from_hex_data", "manufacturerdata", 10, 12],
"is_double": 1
}
}
})"""";*/

const char* _UT363BT_json_props = "{\"properties\":{\"windspeed\":{\"unit\":\"m/s\",\"name\":\"wind_speed\"}}}";
/*R""""(
{
"properties":{
"windspeed":{
"unit":"m/s",
"name":"wind_speed"
}
}
})"""";*/
9 changes: 9 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,9 @@ 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\":-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,\"accx\":0,\"accy\":0,\"accz\":0.0078125,\"flag_reed\":false,\"flag_tilt\":false,\"flag_fall\":false,\"flag_impact_x\":true,\"flag_impact_y\":true,\"flag_impact_z\":false,\"uptime\":5703825,\"batt\":95}",
"{\"brand\":\"MikroTik\",\"model\":\"TG-BT5-IN/-OUT\",\"model_id\":\"TG-BT5\",\"type\":\"ACEL\",\"track\":true,\"tempc\":25.62890625,\"tempf\":78.13203125,\"accx\":-0.00390625,\"accy\":-0.0078125,\"accz\":0,\"flag_reed\":true,\"flag_tilt\":false,\"flag_fall\":false,\"flag_impact_x\":true,\"flag_impact_y\":false,\"flag_impact_z\":true,\"uptime\":744,\"batt\":100}",
"{\"brand\":\"UNI-T\",\"model\":\"UT363 BT Anemometer\",\"model_id\":\"UT363BT\",\"type\":\"WIND\",\"cidc\":false,\"windspeed\":6.58}",
"{\"brand\":\"UNI-T\",\"model\":\"UT363 BT Anemometer\",\"model_id\":\"UT363BT\",\"type\":\"WIND\",\"cidc\":false,\"windspeed\":4.3}",
"{\"brand\":\"UNI-T\",\"model\":\"UT363 BT Anemometer\",\"model_id\":\"UT363BT\",\"type\":\"WIND\",\"cidc\":false,\"windspeed\":1.52}",
};

const char* expected_name_uuid_mfgsvcdata[] = {
Expand Down Expand Up @@ -718,6 +721,9 @@ const char* test_mfgdata[][3] = {
{"H5108", "GV51082A7E", "01000101814a78040000"},
{"Mikrotik", "TG-BT5-IN/-OUT", "4f090100cea6000000000200a01c91085700185f"},
{"Mikrotik", "TG-BT5-IN/-OUT", "4f0901009e11fffffeff0000a119e802000029e4"},
{"UNI-T", "UT363 BT", "aabb1005372020362e35384d2f533430800475"},
{"UNI-T", "UT363 BT", "aabb1005372020342e33304d2f533430800476"},
{"UNI-T", "UT363 BT", "aabb1005372020312e35324d2f533430800472"},
};

TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
Expand Down Expand Up @@ -892,6 +898,9 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
TheengsDecoder::BLE_ID_NUM::H5102,
TheengsDecoder::BLE_ID_NUM::TGBT5,
TheengsDecoder::BLE_ID_NUM::TGBT5,
TheengsDecoder::BLE_ID_NUM::UT363BT,
TheengsDecoder::BLE_ID_NUM::UT363BT,
TheengsDecoder::BLE_ID_NUM::UT363BT,
};

// uuid test input [test name] [device name] [uuid] [manufacturer data] [service data]
Expand Down
Loading