Skip to content

Commit 6b553bc

Browse files
heisenbergersDigiH
andauthored
Added decoder for BPARASITEV2, open source moisture sensor by rbaron (#668)
* Added decoder for BPARASITEV2, open source moisture sensor by rbaron * Added tests for b-parasite v2 * Edited for typo * Update BPARASITEV2_json.h * Update test_ble.cpp --------- Co-authored-by: DigiH <17110652+DigiH@users.noreply.github.com>
1 parent 0853a3c commit 6b553bc

4 files changed

Lines changed: 82 additions & 0 deletions

File tree

src/decoder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ class TheengsDecoder {
128128
HHCCPOT002,
129129
HOBOMX2001,
130130
BPARASITE,
131+
BPARASITEV2,
131132
BWBSDOO,
132133
BM2,
133134
BM6,

src/devices.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@
103103
#include "devices/BM3IN1_json.h"
104104
#include "devices/BM4IN1_json.h"
105105
#include "devices/BPARASITE_json.h"
106+
#include "devices/BPARASITEV2_json.h"
106107
#include "devices/BWBSDOO_json.h"
107108
#include "devices/BM2_json.h"
108109
#include "devices/BM6_json.h"
@@ -223,6 +224,7 @@ const char* _devices[][2] = {
223224
{_HHCCPOT002_json, _HHCCPOT002_json_props},
224225
{_HOBOMX2001_json, _HOBOMX2001_json_props},
225226
{_BPARASITE_json, _BPARASITE_json_props},
227+
{_BPARASITEV2_json, _BPARASITEV2_json_props},
226228
{_BWBSDOO_json, _BWBSDOO_json_props},
227229
{_BM2_json, _BM2_json_props},
228230
{_BM6_json, _BM6_json_props},

src/devices/BPARASITEV2_json.h

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
const char* _BPARASITEV2_json = "{\"brand\":\"rbaron\",\"model\":\"b-parasite\",\"model_id\":\"BPv2.0\",\"tag\":\"0902\",\"condition\":[\"name\",\"contain\",\"prst\",\"uuid\",\"contain\",\"fcd2\"],\"properties\":{\"tempc\":{\"condition\":[\"servicedata\",6,\"02\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",8,4,true,true],\"post_proc\":[\"/\",100]},\"hum\":{\"condition\":[\"servicedata\",26,\"2e\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",28,2,false,false]},\"moi\":{\"condition\":[\"servicedata\",30,\"2f\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",32,2,false,false]},\"lux\":{\"condition\":[\"servicedata\",12,\"05\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",14,6,true,false],\"post_proc\":[\"/\",100]},\"batt\":{\"condition\":[\"servicedata\",2,\"01\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",4,2,true,false]},\"volt\":{\"condition\":[\"servicedata\",20,\"0c\"],\"decoder\":[\"value_from_hex_data\",\"servicedata\",22,4,true,false],\"post_proc\":[\"/\",1000]}}}";
2+
3+
/* R""""(
4+
{
5+
"brand":"rbaron",
6+
"model":"b-parasite",
7+
"model_id":"BPv2.0",
8+
"tag":"0902",
9+
"condition":["name", "contain", "prst", "uuid", "contain", "fcd2"],
10+
"properties":{
11+
"tempc":{
12+
"condition":["servicedata", 6, "02"],
13+
"decoder":["value_from_hex_data", "servicedata", 8, 4, true, true],
14+
"post_proc":["/", 100]
15+
},
16+
"hum":{
17+
"condition":["servicedata", 26, "2e"],
18+
"decoder":["value_from_hex_data", "servicedata", 28, 2, false, false]
19+
},
20+
"moi":{
21+
"condition":["servicedata", 30, "2f"],
22+
"decoder":["value_from_hex_data", "servicedata", 32, 2, false, false]
23+
},
24+
"lux":{
25+
"condition": ["servicedata", 12, "05"],
26+
"decoder":["value_from_hex_data", "servicedata", 14, 6, true, false],
27+
"post_proc":["/", 100]
28+
},
29+
"batt":{
30+
"condition":["servicedata", 2, "01"],
31+
"decoder":["value_from_hex_data", "servicedata", 4, 2, true, false]
32+
},
33+
"volt":{
34+
"condition": ["servicedata", 20, "0c"],
35+
"decoder":["value_from_hex_data", "servicedata", 22, 4, true, false],
36+
"post_proc":["/", 1000]
37+
}
38+
}
39+
})"""";*/
40+
41+
const char* _BPARASITEV2_json_props = "{\"properties\":{\"tempc\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"hum\":{\"unit\":\"%\",\"name\":\"humidity\"},\"moi\":{\"unit\":\"%\",\"name\":\"moisture\"},\"lux\":{\"unit\":\"lx\",\"name\":\"illuminance\"},\"batt\":{\"unit\":\"%\",\"name\":\"battery\"},\"volt\":{\"unit\":\"V\",\"name\":\"voltage\"}}}";
42+
/*R""""(
43+
{
44+
"properties":{
45+
"tempc":{
46+
"unit":"°C",
47+
"name":"temperature"
48+
},
49+
"hum":{
50+
"unit":"%",
51+
"name":"humidity"
52+
},
53+
"moi":{
54+
"unit":"%",
55+
"name":"moisture"
56+
},
57+
"lux":{
58+
"unit":"lx",
59+
"name":"illuminance"
60+
},
61+
"batt":{
62+
"unit":"%",
63+
"name":"battery"
64+
},
65+
"volt":{
66+
"unit":"V",
67+
"name":"voltage"
68+
}
69+
}
70+
})"""";*/

tests/BLE/test_ble.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -378,6 +378,9 @@ const char* expected_uuid_name_svcdata[] = {
378378
"{\"brand\":\"Xiaomi\",\"model\":\"TH Sensor\",\"model_id\":\"LYWSD03MMC/MJWSD05MMC_PVVX_BTHOME\",\"type\":\"THB\",\"acts\":true,\"packet_2\":129,\"volt\":3.034,\"power\":1,\"open\":1}",
379379
"{\"brand\":\"Xiaomi\",\"model\":\"TH Sensor\",\"model_id\":\"LYWSD03MMC/MJWSD05MMC_PVVX_BTHOME_ENCR\",\"type\":\"THB\",\"acts\":true,\"encr\":2,\"cipher\":\"be07860de133b342\",\"ctr\":\"23020000\",\"mic\":\"50dea27d\"}",
380380
"{\"brand\":\"Xiaomi\",\"model\":\"TH Sensor\",\"model_id\":\"LYWSD03MMC/MJWSD05MMC_PVVX_BTHOME_ENCR\",\"type\":\"THB\",\"acts\":true,\"encr\":2,\"cipher\":\"613c80e969f052\",\"ctr\":\"a9000000\",\"mic\":\"77b39384\"}",
381+
"{\"brand\":\"rbaron\",\"model\":\"b-parasite\",\"model_id\":\"BPv2.0\",\"type\":\"PLANT\",\"acts\":true,\"tempc\":26.55,\"tempf\":79.79,\"hum\":51,\"moi\":0,\"lux\":0,\"batt\":100,\"volt\":3.016}",
382+
"{\"brand\":\"rbaron\",\"model\":\"b-parasite\",\"model_id\":\"BPv2.0\",\"type\":\"PLANT\",\"acts\":true,\"tempc\":27.68,\"tempf\":81.824,\"hum\":73,\"moi\":66,\"lux\":0,\"batt\":100,\"volt\":3.016}",
383+
"{\"brand\":\"rbaron\",\"model\":\"b-parasite\",\"model_id\":\"BPv2.0\",\"type\":\"PLANT\",\"acts\":true,\"tempc\":30.36,\"tempf\":86.648,\"hum\":85,\"moi\":74,\"lux\":8392,\"batt\":100,\"volt\":3.005}",
381384
};
382385

383386
const char* expected_uuid[] = {
@@ -1214,6 +1217,9 @@ const char* test_uuid_name_svcdata[][4] = {
12141217
{"LYWSD03MMC_PVVX_BTHOME_2", "0xfcd2", "ATC_112233", "4000810cda0b10011101"},
12151218
{"LYWSD03MMC_PVVX_BTHOME_1_ENCR", "0xfcd2", "ATC_77B4FC", "41be07860de133b3422302000050dea27d"}, // MAC Address A4:C1:38:77:B4:FC - AES Key 00112233445566778899001122334455
12161219
{"LYWSD03MMC_PVVX_BTHOME_2_ENCR", "0xfcd2", "ATC_77B4FC", "41613c80e969f052a900000077b39384"}, // MAC Address A4:C1:38:77:B4:FC - AES Key 00112233445566778899001122334455
1220+
{"bParasiteV2", "0xfcd2", "prst", "400164025f0a050000000cc80b2e332f00"},
1221+
{"bParasiteV2", "0xfcd2", "prst", "40016402d00a050000000cc80b2e492f42"},
1222+
{"bParasiteV2", "0xfcd2", "prst", "40016402dc0b0520ce0c0cbd0b2e552f4a"},
12171223
};
12181224

12191225
TheengsDecoder::BLE_ID_NUM test_uuid_name_svcdata_id_num[]{
@@ -1314,6 +1320,9 @@ TheengsDecoder::BLE_ID_NUM test_uuid_name_svcdata_id_num[]{
13141320
TheengsDecoder::BLE_ID_NUM::LYWSD03MMC_PVVX_BTHOME,
13151321
TheengsDecoder::BLE_ID_NUM::LYWSD03MMC_PVVX_BTHOME_1_ENCR,
13161322
TheengsDecoder::BLE_ID_NUM::LYWSD03MMC_PVVX_BTHOME_2_ENCR,
1323+
TheengsDecoder::BLE_ID_NUM::BPARASITEV2,
1324+
TheengsDecoder::BLE_ID_NUM::BPARASITEV2,
1325+
TheengsDecoder::BLE_ID_NUM::BPARASITEV2,
13171326
};
13181327

13191328
// uuid test input [test name] [uuid] [data source] [data]

0 commit comments

Comments
 (0)