Skip to content

Commit

Permalink
Add WS08 Thermobeacon (#61)
Browse files Browse the repository at this point in the history
Improve Thermobeacon decoders robustness
  • Loading branch information
1technophile authored Jan 24, 2022
1 parent 7b1ce64 commit 89643ba
Show file tree
Hide file tree
Showing 7 changed files with 63 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/.vuepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ module.exports = {
'devices/TPMS',
'devices/VEGTRUG',
'devices/WS02',
'devices/WS08',
'devices/HHCCJCY01HHCC',
'devices/XMTZC04HM',
'devices/XMTZC05HM',
Expand Down
12 changes: 12 additions & 0 deletions docs/devices/WS08.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# WS08 ThermoBeacon

|Model Id|[WS08](https://github.com/theengs/decoder/blob/development/src/devices/WS08_json.h)|
|-|-|
|Brand|ThermoBeacon|
|Model|WS08|
|Short Description|Beacon, temperature and humidity sensor with LCD and magnet|
|Communication|BLE broadcast|
|Frequency|2.4Ghz|
|Power source|CR2477|
|Exchanged data|temperature, humidity, volt|
|Encrypted|No|
1 change: 1 addition & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class TheengsDecoder {
CGPR1,
IBEACON,
WS02,
WS08,
H5075,
H5072,
H5102,
Expand Down
2 changes: 2 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "devices/TPMS_json.h"
#include "devices/VEGTRUG_json.h"
#include "devices/WS02_json.h"
#include "devices/WS08_json.h"
#include "devices/XMTZC04HM_json.h"
#include "devices/XMTZC05HM_json.h"
#include "devices/iBeacon_json.h"
Expand Down Expand Up @@ -77,6 +78,7 @@ const char* _devices[][2] = {
{_CGPR1_json, _CGPR1_json_props},
{_ibeacon_json, _ibeacon_json_props},
{_WS02_json, _WS02_json_props},
{_WS08_json, _WS08_json_props},
{_H5075_json, _H5075_json_props},
{_H5072_json, _H5072_json_props},
{_H5102_json, _H5102_json_props},
Expand Down
4 changes: 2 additions & 2 deletions src/devices/WS02_json.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
const char* _WS02_json = "{\"brand\":\"ThermoBeacon\",\"model\":\"WS02\",\"model_id\":\"WS02\",\"condition\":[\"manufacturerdata\",\">=\",40,\"contain\",\"100000001a11\"],\"properties\":{\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",24,4,true],\"post_proc\":[\"/\",16]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",28,4,true],\"post_proc\":[\"/\",16]},\"volt\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",20,4,true],\"post_proc\":[\"/\",1000]}}}";
const char* _WS02_json = "{\"brand\":\"ThermoBeacon\",\"model\":\"WS02\",\"model_id\":\"WS02\",\"condition\":[\"manufacturerdata\",\">=\",40,\"index\",0,\"10000000\"],\"properties\":{\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",24,4,true],\"post_proc\":[\"/\",16]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",28,4,true],\"post_proc\":[\"/\",16]},\"volt\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",20,4,true],\"post_proc\":[\"/\",1000]}}}";

/*R""""(
{
"brand":"ThermoBeacon",
"model":"WS02",
"model_id":"WS02",
"condition":["manufacturerdata", ">=", 40, "contain", "100000001a11"],
"condition":["manufacturerdata", ">=", 40, "index", 0, "10000000"],
"properties":{
"tempc":{
"decoder":["value_from_hex_data", "manufacturerdata", 24, 4, true],
Expand Down
42 changes: 42 additions & 0 deletions src/devices/WS08_json.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const char* _WS08_json = "{\"brand\":\"ThermoBeacon\",\"model\":\"WS08\",\"model_id\":\"WS08\",\"condition\":[\"manufacturerdata\",\">=\",40,\"index\",0,\"11000000\"],\"properties\":{\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",24,4,true],\"post_proc\":[\"/\",16]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",28,4,true],\"post_proc\":[\"/\",16]},\"volt\":{\"decoder\":[\"value_from_hex_data\",\"manufacturerdata\",20,4,true],\"post_proc\":[\"/\",1000]}}}";

/*R""""(
{
"brand":"ThermoBeacon",
"model":"WS08",
"model_id":"WS08",
"condition":["manufacturerdata", ">=", 40, "index", 0, "11000000"],
"properties":{
"tempc":{
"decoder":["value_from_hex_data", "manufacturerdata", 24, 4, true],
"post_proc":["/", 16]
},
"hum":{
"decoder":["value_from_hex_data", "manufacturerdata", 28, 4, true],
"post_proc":["/", 16]
},
"volt":{
"decoder":["value_from_hex_data", "manufacturerdata", 20, 4, true],
"post_proc":["/", 1000]
}
}
})"""";*/

const char* _WS08_json_props = "{\"properties\":{\"volt\":{\"unit\":\"V\",\"name\":\"voltage\"},\"tempc\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"hum\":{\"unit\":\"%\",\"name\":\"humidity\"}}}";
/*R""""(
{
"properties":{
"volt":{
"unit":"V",
"name":"voltage"
},
"tempc":{
"unit":"°C",
"name":"temperature"
},
"hum":{
"unit":"%",
"name":"humidity"
}
}
})"""";*/
3 changes: 3 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const char* expected_mfg[] = {
"{\"brand\":\"GENERIC\",\"model\":\"IBEACON\",\"model_id\":\"IBEACON\",\"mfid\":\"4c00\",\"uuid\":\"426c7565436861726d426561636f6e73\",\"major\":3838,\"minor\":4949,\"power\":-59}",
"{\"brand\":\"GENERIC\",\"model\":\"IBEACON\",\"model_id\":\"IBEACON\",\"mfid\":\"4c00\",\"uuid\":\"fda50693a4e24fb1afcfc6eb07647825\",\"major\":1,\"minor\":2,\"battery\":2.6}",
"{\"brand\":\"ThermoBeacon\",\"model\":\"WS02\",\"model_id\":\"WS02\",\"tempc\":31.3125,\"tempf\":88.3625,\"hum\":70.75,\"volt\":3.160}",
"{\"brand\":\"ThermoBeacon\",\"model\":\"WS08\",\"model_id\":\"WS08\",\"tempc\":31.3125,\"tempf\":88.3625,\"hum\":70.75,\"volt\":3.160}",
"{\"brand\":\"Govee\",\"model\":\"Smart Thermo Hygrometer\",\"model_id\":\"H5075\",\"tempc\":26.8,\"tempf\":80.24,\"hum\":52.6,\"batt\":100}",
"{\"brand\":\"Govee\",\"model\":\"Thermo Hygrometer\",\"model_id\":\"H5072\",\"tempc\":27.5,\"tempf\":81.5,\"hum\":53.1,\"batt\":100}",
"{\"brand\":\"Govee\",\"model\":\"Smart Thermo Hygrometer\",\"model_id\":\"H5102\",\"tempc\":21.9,\"tempf\":71.42,\"hum\":40.6,\"batt\":100}",
Expand Down Expand Up @@ -146,6 +147,7 @@ const char* test_mfgdata[][3] = {
{"iBeacon", "BlueCharm_135727", "4c000215426c7565436861726d426561636f6e730efe1355c5"},
{"iBeacon", "NRF51822", "4c000215fda50693a4e24fb1afcfc6eb07647825000100021a"},
{"WS02", "ThermoBeacon", "100000001a110000f770580cf5016c0443090000"},
{"WS08", "ThermoBeacon", "110000001a110000f770580cf5016c0443090000"},
{"H5075", "GVH5075_1234", "88ec000418ee6400"},
{"H5072", "GVH5072_1234", "88ec0004344b6400"},
{"H5102", "GVH5102_1234", "0100010103590e64"},
Expand All @@ -170,6 +172,7 @@ TheengsDecoder::BLE_ID_NUM test_mfgdata_id_num[]{
TheengsDecoder::BLE_ID_NUM::IBEACON,
TheengsDecoder::BLE_ID_NUM::IBEACON,
TheengsDecoder::BLE_ID_NUM::WS02,
TheengsDecoder::BLE_ID_NUM::WS08,
TheengsDecoder::BLE_ID_NUM::H5075,
TheengsDecoder::BLE_ID_NUM::H5072,
TheengsDecoder::BLE_ID_NUM::H5102,
Expand Down

0 comments on commit 89643ba

Please sign in to comment.