Skip to content

Commit

Permalink
ClearGrass/Qingping Barometer Pro CGP23W (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
DigiH authored Dec 13, 2023
1 parent ea92bf6 commit d14b963
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/devices/CGP23W.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# ClearGrass/Qingping Barometer Pro CGP23W

|Model Id|[CGP1W](https://github.com/theengs/decoder/blob/development/src/devices/CGP1W_json.h)|
|-|-|
|Brand|ClearGrass/Qingping|
|Model|Barometer Pro|
|Short Description|Rechargeable temperature, humidity and atmospheric pressure sensor|
|Communication|BLE broadcast|
|Frequency|2.4Ghz|
|Power Source|Internal battery/USB-C|
|Exchanged Data|temperature, humidity, atmospheric pressure, battery|
|Encrypted|No|
1 change: 1 addition & 0 deletions src/decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ class TheengsDecoder {
LYWSD02,
LYWSDCGQ,
CGP1W,
CGP23W,
CGG1_STOCK,
CGG1_ATC1441,
CGG1_PVVX,
Expand Down
2 changes: 2 additions & 0 deletions src/devices.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "devices/CGDN1_json.h"
#include "devices/CGH1_json.h"
#include "devices/CGP1W_json.h"
#include "devices/CGP23W_json.h"
#include "devices/CGPR1_json.h"
#include "devices/GAEN_json.h"
#include "devices/H5055_json.h"
Expand Down Expand Up @@ -112,6 +113,7 @@ const char* _devices[][2] = {
{_LYWSD02_json, _LYWSD02_json_props},
{_LYWSDCGQ_json, _LYWSDCGQ_json_props},
{_CGP1W_json, _CGP1W_json_props},
{_CGP23W_json, _CGP23W_json_props},
{_CGG1_json_STOCK, _CGG1_json_props},
{_CGG1_json_ATC1441, _CGG1_json_props},
{_CGG1_json_PVVX, _CGG1_json_props},
Expand Down
57 changes: 57 additions & 0 deletions src/devices/CGP23W_json.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
const char* _CGP23W_json = "{\"brand\":\"ClearGrass/Qingping\",\"model\":\"Barometer Pro\",\"model_id\":\"CGP23W\",\"tag\":\"02\",\"condition\":[\"servicedata\",\"=\",42,\"index\",2,\"18\",\"&\",\"uuid\",\"index\",0,\"fdcd\"],\"properties\":{\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",20,4,true,true],\"post_proc\":[\"/\",10]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",24,4,true,false],\"post_proc\":[\"/\",10]},\"pres\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",38,4,true,false],\"post_proc\":[\"/\",10]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",32,2,false,false],\"post_proc\":[\"&\",127]},\"mac\":{\"decoder\":[\"revmac_from_hex_data\",\"servicedata\",4]}}}";
/*R""""(
{
"brand":"ClearGrass/Qingping",
"model":"Barometer Pro",
"model_id":"CGP23W",
"tag":"02",
"condition":["servicedata", "=", 42, "index", 2, "18", "&", "uuid", "index", 0, "fdcd"],
"properties":{
"tempc":{
"decoder":["value_from_hex_data", "servicedata", 20, 4, true, true],
"post_proc":["/", 10]
},
"hum":{
"decoder":["value_from_hex_data", "servicedata", 24, 4, true, false],
"post_proc":["/", 10]
},
"pres":{
"decoder":["value_from_hex_data", "servicedata", 38, 4, true, false],
"post_proc":["/", 10]
},
"batt":{
"decoder":["value_from_hex_data", "servicedata", 32, 2, false, false],
"post_proc":["&", 127]
},
"mac":{
"decoder":["revmac_from_hex_data", "servicedata", 4]
}
}
})"""";*/

const char* _CGP23W_json_props = "{\"properties\":{\"pres\":{\"unit\":\"hPa\",\"name\":\"pressure\"},\"tempc\":{\"unit\":\"°C\",\"name\":\"temperature\"},\"hum\":{\"unit\":\"%\",\"name\":\"humidity\"},\"batt\":{\"unit\":\"%\",\"name\":\"battery\"},\"mac\":{\"unit\":\"string\",\"name\":\"MAC address\"}}}";
/*R""""(
{
"properties":{
"pres":{
"unit":"hPa",
"name":"pressure"
},
"tempc":{
"unit":"°C",
"name":"temperature"
},
"hum":{
"unit":"%",
"name":"humidity"
},
"batt":{
"unit":"%",
"name":"battery"
},
"mac":{
"unit":"string",
"name":"MAC address"
}
}
})"""";*/
3 changes: 3 additions & 0 deletions tests/BLE/test_ble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ const char* expected_uuid[] = {
"{\"brand\":\"KKM\",\"model\":\"Tracking K9\",\"model_id\":\"K9\",\"type\":\"ACEL\",\"track\":true,\"tempc\":-11.79,\"tempf\":10.778,\"hum\":43.84,\"volt\":3.672,\"accx\":15,\"accy\":-15,\"accz\":1015}",
"{\"brand\":\"KKM\",\"model\":\"Tracking K9\",\"model_id\":\"K9\",\"type\":\"ACEL\",\"track\":true,\"tempc\":-10.9,\"tempf\":12.38,\"hum\":74.86,\"volt\":3.675,\"accx\":-62,\"accy\":0,\"accz\":1046}",
"{\"brand\":\"SwitchBot\",\"model\":\"Bot\",\"model_id\":\"X1\",\"type\":\"ACTR\",\"acts\":true,\"mode\":\"onestate\",\"state\":\"on\",\"batt\":71}",
"{\"brand\":\"ClearGrass/Qingping\",\"model\":\"Barometer Pro\",\"model_id\":\"CGP23W\",\"type\":\"THBX\",\"tempc\":23.2,\"tempf\":73.76,\"hum\":47.6,\"pres\":1007.4,\"batt\":94,\"mac\":\"AA:BB:CC:DD:EE:FF\"}",
};

const char* expected_mac_mfg[] = {
Expand Down Expand Up @@ -883,6 +884,7 @@ const char* test_uuid[][4] = {
{"KKM K9", "0xfeaa", "servicedata", "21010f0e58f4362bd8000ffff103f7"},
{"KKM K9", "0xfeaa", "servicedata", "21010f0e5bf51b4addffc200000416"},
{"Switchbot_S1", "0xfd3d", "servicedata", "48004700"},
{"ClearGrass Barometer Pro", "0xfdcd", "servicedata", "8818ffeeddccbbaa0104e800dc0102015e07025a27"},
};

TheengsDecoder::BLE_ID_NUM test_uuid_id_num[]{
Expand Down Expand Up @@ -1002,6 +1004,7 @@ TheengsDecoder::BLE_ID_NUM test_uuid_id_num[]{
TheengsDecoder::BLE_ID_NUM::KKM_K9,
TheengsDecoder::BLE_ID_NUM::KKM_K9,
TheengsDecoder::BLE_ID_NUM::SBS1,
TheengsDecoder::BLE_ID_NUM::CGP23W,
};

// MAC manufacturer data test input [test name] [mac] [data]
Expand Down

0 comments on commit d14b963

Please sign in to comment.