diff --git a/src/ArduinoCloudThing.h b/src/ArduinoCloudThing.h index 1837038..8af0130 100644 --- a/src/ArduinoCloudThing.h +++ b/src/ArduinoCloudThing.h @@ -34,7 +34,7 @@ #include "types/automation/CloudColoredLight.h" #include "types/automation/CloudContactSensor.h" -#include "types/automation/CloudDimmeredLight.h" +#include "types/automation/CloudDimmedLight.h" #include "types/automation/CloudLight.h" #include "types/automation/CloudMotionSensor.h" #include "types/automation/CloudSmartPlug.h" diff --git a/src/types/automation/CloudDimmeredLight.h b/src/types/automation/CloudDimmedLight.h similarity index 78% rename from src/types/automation/CloudDimmeredLight.h rename to src/types/automation/CloudDimmedLight.h index 1ea5429..9dbfe12 100644 --- a/src/types/automation/CloudDimmeredLight.h +++ b/src/types/automation/CloudDimmedLight.h @@ -15,8 +15,8 @@ // a commercial license, send an email to license@arduino.cc. // -#ifndef CLOUDDIMMEREDLIGHT_H_ -#define CLOUDDIMMEREDLIGHT_H_ +#ifndef CLOUDDIMMEDLIGHT_H_ +#define CLOUDDIMMEDLIGHT_H_ /****************************************************************************** INCLUDE @@ -29,49 +29,49 @@ /****************************************************************************** CLASS DECLARATION ******************************************************************************/ -class DimmeredLight { +class DimmedLight { public: bool swi; float bri; - DimmeredLight(bool swi, float bri): swi(swi), bri(bri) { + DimmedLight(bool swi, float bri): swi(swi), bri(bri) { } - bool operator==(DimmeredLight & aLight) { + bool operator==(DimmedLight & aLight) { return aLight.swi == swi && aLight.bri == bri; } - bool operator!=(DimmeredLight & aLight) { + bool operator!=(DimmedLight & aLight) { return !(operator==(aLight)); } }; -class CloudDimmeredLight : public ArduinoCloudProperty { +class CloudDimmedLight : public ArduinoCloudProperty { private: - DimmeredLight _value, - _cloud_value; + DimmedLight _value, + _cloud_value; public: - CloudDimmeredLight() : _value(false, 0), _cloud_value(false, 0) {} - CloudDimmeredLight(bool swi, float brightness) : _value(swi, brightness), _cloud_value(swi, brightness) {} + CloudDimmedLight() : _value(false, 0), _cloud_value(false, 0) {} + CloudDimmedLight(bool swi, float brightness) : _value(swi, brightness), _cloud_value(swi, brightness) {} virtual bool isDifferentFromCloud() { return _value != _cloud_value; } - CloudDimmeredLight& operator=(DimmeredLight aLight) { + CloudDimmedLight& operator=(DimmedLight aLight) { _value.swi = aLight.swi; _value.bri = aLight.bri; updateLocalTimestamp(); return *this; } - DimmeredLight getCloudValue() { + DimmedLight getCloudValue() { return _cloud_value; } - DimmeredLight getValue() { + DimmedLight getValue() { return _value; } @@ -118,4 +118,4 @@ class CloudDimmeredLight : public ArduinoCloudProperty { } }; -#endif /* CLOUDDIMMEREDLIGHT_H_ */ \ No newline at end of file +#endif /* CLOUDDIMMEDLIGHT_H_ */ \ No newline at end of file diff --git a/test/src/test_decode.cpp b/test/src/test_decode.cpp index e694cdb..c3aa4df 100644 --- a/test/src/test_decode.cpp +++ b/test/src/test_decode.cpp @@ -16,7 +16,7 @@ #include "types/CloudWrapperString.h" #include "types/automation/CloudColoredLight.h" #include "types/automation/CloudContactSensor.h" -#include "types/automation/CloudDimmeredLight.h" +#include "types/automation/CloudDimmedLight.h" #include "types/automation/CloudLight.h" #include "types/automation/CloudMotionSensor.h" #include "types/automation/CloudSmartPlug.h" @@ -191,12 +191,12 @@ SCENARIO("Arduino Cloud Properties are decoded", "[ArduinoCloudThing::decode]") /************************************************************************************/ - WHEN("A DimmeredLight property is changed via CBOR message") { + WHEN("A DimmedLight property is changed via CBOR message") { GIVEN("CloudProtocol::V2") { ArduinoCloudThing thing; thing.begin(); - CloudDimmeredLight light_test = CloudDimmeredLight(false, 0.0); + CloudDimmedLight light_test = CloudDimmedLight(false, 0.0); thing.addPropertyReal(light_test, "test", Permission::ReadWrite); @@ -204,8 +204,8 @@ SCENARIO("Arduino Cloud Properties are decoded", "[ArduinoCloudThing::decode]") uint8_t const payload[] = {0x82, 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}; thing.decode(payload, sizeof(payload) / sizeof(uint8_t)); - DimmeredLight light_compare = DimmeredLight(true, 2.0); - DimmeredLight value_light_test = light_test.getValue(); + DimmedLight light_compare = DimmedLight(true, 2.0); + DimmedLight value_light_test = light_test.getValue(); bool verify = (value_light_test == light_compare); REQUIRE(verify); REQUIRE(value_light_test.swi == light_compare.swi); diff --git a/test/src/test_encode.cpp b/test/src/test_encode.cpp index 9a915de..fe4b996 100644 --- a/test/src/test_encode.cpp +++ b/test/src/test_encode.cpp @@ -149,13 +149,13 @@ SCENARIO("Arduino Cloud Properties are encoded", "[ArduinoCloudThing::encode]") /************************************************************************************/ - WHEN("A 'DimmeredLight' property is added") { + WHEN("A 'DimmedLight' property is added") { GIVEN("CloudProtocol::V2") { ArduinoCloudThing thing; thing.begin(); encode(thing); - CloudDimmeredLight color_test = CloudDimmeredLight(true, 2.0); + CloudDimmedLight color_test = CloudDimmedLight(true, 2.0); thing.addPropertyReal(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}] = 83 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*/