From 03159a79e7d0e392e284f2a73c03e4b2dec87614 Mon Sep 17 00:00:00 2001 From: DigiH Date: Wed, 13 Dec 2023 13:25:16 +0100 Subject: [PATCH] ClearGrass/Qingping Barometer Pro CGP23W --- docs/devices/CGP23W.md | 12 +++++++++ src/decoder.h | 1 + src/devices.h | 2 ++ src/devices/CGP23W_json.h | 57 +++++++++++++++++++++++++++++++++++++++ tests/BLE/test_ble.cpp | 3 +++ 5 files changed, 75 insertions(+) create mode 100644 docs/devices/CGP23W.md create mode 100644 src/devices/CGP23W_json.h diff --git a/docs/devices/CGP23W.md b/docs/devices/CGP23W.md new file mode 100644 index 00000000..7a810afc --- /dev/null +++ b/docs/devices/CGP23W.md @@ -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| diff --git a/src/decoder.h b/src/decoder.h index 6ce18dd9..65a76651 100644 --- a/src/decoder.h +++ b/src/decoder.h @@ -50,6 +50,7 @@ class TheengsDecoder { LYWSD02, LYWSDCGQ, CGP1W, + CGP23W, CGG1_STOCK, CGG1_ATC1441, CGG1_PVVX, diff --git a/src/devices.h b/src/devices.h index 6d68fea3..fd55cbf6 100644 --- a/src/devices.h +++ b/src/devices.h @@ -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" @@ -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}, diff --git a/src/devices/CGP23W_json.h b/src/devices/CGP23W_json.h new file mode 100644 index 00000000..56a88bc3 --- /dev/null +++ b/src/devices/CGP23W_json.h @@ -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" + } + } +})"""";*/ diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp index 1d7bd0c5..0975972b 100644 --- a/tests/BLE/test_ble.cpp +++ b/tests/BLE/test_ble.cpp @@ -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[] = { @@ -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[]{ @@ -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]