From aea4dd947ec6fa2b1fb777d0c882ede4113b8ecd Mon Sep 17 00:00:00 2001 From: Balazs Bacskay Date: Sun, 13 Feb 2022 08:22:58 +0100 Subject: [PATCH 1/2] Add decoding battery info to CGG1 v1 --- src/devices/CGG1_json.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/devices/CGG1_json.h b/src/devices/CGG1_json.h index 13cfcc56..4dc1cb6f 100644 --- a/src/devices/CGG1_json.h +++ b/src/devices/CGG1_json.h @@ -1,6 +1,6 @@ #include "common_props.h" -const char* _CGG1_json_v1 = "{\"brand\":\"Xiaomi\",\"model\":\"CG_round_v1\",\"model_id\":\"CGG1\",\"condition\":[\"servicedata\",\"index\",0,\"0807\",\"|\",\"servicedata\",\"index\",0,\"8816\"],\"properties\":{\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",20,4,true],\"post_proc\":[\"/\",10]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",24,4,true,false],\"post_proc\":[\"/\",10]}}}"; +const char* _CGG1_json_v1 = "{\"brand\":\"Xiaomi\",\"model\":\"CG_round_v1\",\"model_id\":\"CGG1\",\"condition\":[\"servicedata\",\"index\",0,\"0807\",\"|\",\"servicedata\",\"index\",0,\"8816\"],\"properties\":{\"tempc\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",20,4,true],\"post_proc\":[\"/\",10]},\"hum\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\",24,4,true,false],\"post_proc\":[\"/\",10]},\"batt\":{\"decoder\":[\"value_from_hex_data\",\"servicedata\", 32, 2, true, false]}}}"; /* R""""( { "brand":"Xiaomi", @@ -15,6 +15,9 @@ const char* _CGG1_json_v1 = "{\"brand\":\"Xiaomi\",\"model\":\"CG_round_v1\",\"m "hum":{ "decoder":["value_from_hex_data", "servicedata", 24, 4, true, false], "post_proc":["/", 10] + }, + "batt":{ + "decoder":["value_from_hex_data", "servicedata", 32, 2, false, false] } } })"""";*/ From 14402d5a3073d24f6dc2443bbb01f83924045246 Mon Sep 17 00:00:00 2001 From: Balazs Bacskay Date: Sun, 13 Feb 2022 10:41:08 +0100 Subject: [PATCH 2/2] Update test for CGG1 v1 battery decoding --- tests/BLE/test_ble.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/BLE/test_ble.cpp b/tests/BLE/test_ble.cpp index 16469806..10132f07 100644 --- a/tests/BLE/test_ble.cpp +++ b/tests/BLE/test_ble.cpp @@ -19,9 +19,9 @@ const char* expected_servicedata[] = { "{\"brand\":\"Xiaomi\",\"model\":\"CG_THP\",\"model_id\":\"CGP1W\",\"tempc\":25.2,\"tempf\":77.36,\"hum\":58.6,\"pres\":100.86}", "{\"brand\":\"Xiaomi\",\"model\":\"CG_round_v2\",\"model_id\":\"CGG1\",\"tempc\":27.4,\"tempf\":81.32}", "{\"brand\":\"Xiaomi\",\"model\":\"CG_round_v2\",\"model_id\":\"CGG1\",\"tempc\":27.2,\"tempf\":80.96,\"hum\":63.8}", - "{\"brand\":\"Xiaomi\",\"model\":\"CG_round_v1\",\"model_id\":\"CGG1\",\"tempc\":27.4,\"tempf\":81.32,\"hum\":62.6}", - "{\"brand\":\"Xiaomi\",\"model\":\"CG_round_v1\",\"model_id\":\"CGG1\",\"tempc\":23.5,\"tempf\":74.3,\"hum\":28.3}", - "{\"brand\":\"Xiaomi\",\"model\":\"CG_round_v1\",\"model_id\":\"CGG1\",\"tempc\":24.4,\"tempf\":75.92,\"hum\":31.5}", + "{\"brand\":\"Xiaomi\",\"model\":\"CG_round_v1\",\"model_id\":\"CGG1\",\"tempc\":27.4,\"tempf\":81.32,\"hum\":62.6,\"batt\":13}", + "{\"brand\":\"Xiaomi\",\"model\":\"CG_round_v1\",\"model_id\":\"CGG1\",\"tempc\":23.5,\"tempf\":74.3,\"hum\":28.3,\"batt\":100}", + "{\"brand\":\"Xiaomi\",\"model\":\"CG_round_v1\",\"model_id\":\"CGG1\",\"tempc\":24.4,\"tempf\":75.92,\"hum\":31.5,\"batt\":100}", "{\"brand\":\"Xiaomi\",\"model\":\"CG_alarm_clock\",\"model_id\":\"CGD1\",\"tempc\":26.6,\"tempf\":79.88,\"hum\":63.9}", "{\"brand\":\"Xiaomi\",\"model\":\"CG_alarm_clock\",\"model_id\":\"CGD1\",\"tempc\":26.9,\"tempf\":80.42,\"hum\":67}", "{\"brand\":\"Xiaomi\",\"model\":\"CG_alarm_clock\",\"model_id\":\"CGD1\",\"tempc\":27,\"tempf\":80.6,\"hum\":65.7}",