From adfc649aa3d3e2f5e9035db5947f9746ef887ee7 Mon Sep 17 00:00:00 2001 From: pennam Date: Fri, 21 Oct 2022 12:43:52 +0200 Subject: [PATCH 1/2] CloudDimmedLight: Remove fake variables from cbor message - Is not possible to associate a color widget to a CloudDimmedLight variable --- src/property/types/automation/CloudDimmedLight.h | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/property/types/automation/CloudDimmedLight.h b/src/property/types/automation/CloudDimmedLight.h index 8e0c0b39f..5da30821b 100644 --- a/src/property/types/automation/CloudDimmedLight.h +++ b/src/property/types/automation/CloudDimmedLight.h @@ -100,16 +100,7 @@ class CloudDimmedLight : public Property { virtual CborError appendAttributesToCloud(CborEncoder *encoder) { CHECK_CBOR_MULTI(appendAttribute(_value.swi, "swi", encoder)); - // To allow visualization through color widget - // Start - float hue = 0; - float sat = 0; - CHECK_CBOR_MULTI(appendAttribute(hue, "hue", encoder)); - CHECK_CBOR_MULTI(appendAttribute(sat, "sat", encoder)); CHECK_CBOR_MULTI(appendAttribute(_value.bri, "bri", encoder)); - // should be only: - // appendAttribute(_value.bri); - // end return CborNoError; } From 078f62fe1fdf6cf0379c1d3335aefd3b24686883 Mon Sep 17 00:00:00 2001 From: pennam Date: Mon, 24 Oct 2022 13:58:44 +0200 Subject: [PATCH 2/2] Fix encoding test for DimmedLight property --- extras/test/src/test_encode.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extras/test/src/test_encode.cpp b/extras/test/src/test_encode.cpp index 4c702cffc..ecb3c54ee 100644 --- a/extras/test/src/test_encode.cpp +++ b/extras/test/src/test_encode.cpp @@ -196,8 +196,8 @@ SCENARIO("Arduino Cloud Properties are encoded", "[ArduinoCloudThing::encode-1]" CloudDimmedLight color_test = CloudDimmedLight(true, 2.0); addPropertyToContainer(property_container, color_test, "test", Permission::ReadWrite); - /* [{0: "test:swi", 4: true},{0: "test:hue", 2: 0.0},{0: "test:sat", 2: 0.0},{0: "test:bri", 2: 2.0}] = 9F A2 00 68 74 65 73 74 3A 73 77 69 04 F5 A2 00 68 74 65 73 74 3A 68 75 65 02 FA 00 00 00 00 A2 00 68 74 65 73 74 3A 73 61 74 02 FA 00 00 00 00 A2 00 68 74 65 73 74 3A 62 72 69 02 FA 40 00 00 00 FF*/ - std::vector const expected = {0x9F, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x73, 0x77, 0x69, 0x04, 0xF5, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x68, 0x75, 0x65, 0x02, 0xFA, 0x00, 0x00, 0x00, 0x00, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x73, 0x61, 0x74, 0x02, 0xFA, 0x00, 0x00, 0x00, 0x00, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x62, 0x72, 0x69, 0x02, 0xFA, 0x40, 0x00, 0x00, 0x00, 0xFF }; + /* [{0: "test:swi", 4: true},{0: "test:bri", 2: 2.0}] = 9F A2 00 68 74 65 73 74 3A 73 77 69 04 F5 A2 00 68 74 65 73 74 3A 62 72 69 02 FA 40 00 00 00 FF*/ + std::vector const expected = {0x9F, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x73, 0x77, 0x69, 0x04, 0xF5, 0xA2, 0x00, 0x68, 0x74, 0x65, 0x73, 0x74, 0x3A, 0x62, 0x72, 0x69, 0x02, 0xFA, 0x40, 0x00, 0x00, 0x00, 0xFF }; std::vector const actual = cbor::encode(property_container); REQUIRE(actual == expected); }