From ae3ac31dafe78abecc9ddad21aa439731382d8a2 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 9 Dec 2024 13:24:52 -0300 Subject: [PATCH 01/15] feat(matter): adds new temperature sensor matter endpoint --- CMakeLists.txt | 2 + .../MatterTemperatureSensor.ino | 93 ++++++++++++++++ .../examples/MatterTemperatureSensor/ci.json | 7 ++ libraries/Matter/keywords.txt | 6 ++ libraries/Matter/src/Matter.h | 2 + .../MatterTemperatureSensor.cpp | 100 ++++++++++++++++++ .../MatterEndpoints/MatterTemperatureSensor.h | 63 +++++++++++ 7 files changed, 273 insertions(+) create mode 100644 libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino create mode 100644 libraries/Matter/examples/MatterTemperatureSensor/ci.json create mode 100644 libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp create mode 100644 libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h diff --git a/CMakeLists.txt b/CMakeLists.txt index e4991d558d8..07803fec5b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -175,6 +175,7 @@ set(ARDUINO_LIBRARY_Matter_SRCS libraries/Matter/src/MatterEndpoints/MatterColorLight.cpp libraries/Matter/src/MatterEndpoints/MatterEnhancedColorLight.cpp libraries/Matter/src/MatterEndpoints/MatterFan.cpp + libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp libraries/Matter/src/Matter.cpp) set(ARDUINO_LIBRARY_PPP_SRCS @@ -401,3 +402,4 @@ endif() if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_WiFiProv) maybe_add_component(espressif__network_provisioning) endif() + diff --git a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino new file mode 100644 index 00000000000..cbc4384c414 --- /dev/null +++ b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino @@ -0,0 +1,93 @@ +// Copyright 2024 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* + * This example is the smallest code that will create a Matter Device which can be + * commissioned and controlled from a Matter Environment APP. + * It controls a GPIO that could be attached to a LED for visualization. + * Additionally the ESP32 will send debug messages indicating the Matter activity. + * Turning DEBUG Level ON may be useful to following Matter Accessory and Controller messages. + */ + +// Matter Manager +#include +#include + +// List of Matter Endpoints for this Node +// Celcius Temperature Sensor Endpoint - at least one per node +MatterTemperatureSensor CelciusTempSensor; + +// WiFi is manually set and started +const char *ssid = "your-ssid"; // Change this to your WiFi SSID +const char *password = "your-password"; // Change this to your WiFi password + +// Simulate a temperature sensor - add you prefered library code here +float getTemperature() { + static float CelciusTempHWSensor = -10.0; + + // it will increase from -10C to 10C in 0.5C steps to simulate a temperature sensor + CelciusTempHWSensor = CelciusTempHWSensor + 0.5; + if (CelciusTempHWSensor > 10) { + CelciusTempHWSensor = -10; + } + + return CelciusTempHWSensor; +} + +void setup() { + Serial.begin(115200); + + // Manually connect to WiFi + WiFi.begin(ssid, password); + // Wait for connection + while (WiFi.status() != WL_CONNECTED) { + delay(500); + Serial.print("."); + } + Serial.println(); + + // set initial temperature sensor measurement + // Simulated Sensor - it shall print -25C first and then move to the -10C to 10C range + CelciusTempSensor.begin(-25.00); + + // Matter beginning - Last step, after all EndPoints are initialized + Matter.begin(); + + // Check Matter Accessory Commissioning state, which may change during execution of loop() + if (!Matter.isDeviceCommissioned()) { + Serial.println(""); + Serial.println("Matter Node is not commissioned yet."); + Serial.println("Initiate the device discovery in your Matter environment."); + Serial.println("Commission it to your Matter hub with the manual pairing code or QR code"); + Serial.printf("Manual pairing code: %s\r\n", Matter.getManualPairingCode().c_str()); + Serial.printf("QR code URL: %s\r\n", Matter.getOnboardingQRCodeUrl().c_str()); + // waits for Matter Temperature Sensor Commissioning. + uint32_t timeCount = 0; + while (!Matter.isDeviceCommissioned()) { + delay(100); + if ((timeCount++ % 50) == 0) { // 50*100ms = 5 sec + Serial.println("Matter Node not commissioned yet. Waiting for commissioning."); + } + } + Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use."); + } +} + +void loop() { + Serial.printf("Current Temperature is %.02fC\r\n", (float)CelciusTempSensor); + // update the temperature sensor value every 5 seconds + // Matter phone APP shall display the change in temperature + delay(5000); + CelciusTempSensor = getTemperature(); +} diff --git a/libraries/Matter/examples/MatterTemperatureSensor/ci.json b/libraries/Matter/examples/MatterTemperatureSensor/ci.json new file mode 100644 index 00000000000..556a8a9ee6b --- /dev/null +++ b/libraries/Matter/examples/MatterTemperatureSensor/ci.json @@ -0,0 +1,7 @@ +{ + "fqbn_append": "PartitionScheme=huge_app", + "requires": [ + "CONFIG_SOC_WIFI_SUPPORTED=y", + "CONFIG_ESP_MATTER_ENABLE_DATA_MODEL=y" + ] +} diff --git a/libraries/Matter/keywords.txt b/libraries/Matter/keywords.txt index 4668054d12e..57f646a673e 100644 --- a/libraries/Matter/keywords.txt +++ b/libraries/Matter/keywords.txt @@ -18,6 +18,7 @@ MatterEndPoint KEYWORD1 MatterFan KEYWORD1 FanMode_t KEYWORD1 FanModeSequence_t KEYWORD1 +MatterTemperatureSensor KEYWORD1 ####################################### # Methods and Functions (KEYWORD2) @@ -62,6 +63,10 @@ setMode KEYWORD2 getMode KEYWORD2 onChangeMode KEYWORD2 onChangeSpeedPercent KEYWORD2 +setRawTemperature KEYWORD2 +getRawTemperature KEYWORD2 +setTemperatureCelsius KEYWORD2 +getTemperatureCelsius KEYWORD2 ####################################### # Constants (LITERAL1) @@ -88,3 +93,4 @@ FAN_MODE_SEQ_OFF_LOW_MED_HIGH_AUTO LITERAL1 FAN_MODE_SEQ_OFF_LOW_HIGH_AUTO LITERAL1 FAN_MODE_SEQ_OFF_HIGH_AUTO LITERAL1 FAN_MODE_SEQ_OFF_HIGH LITERAL1 + diff --git a/libraries/Matter/src/Matter.h b/libraries/Matter/src/Matter.h index 06edf32288f..1b35d876705 100644 --- a/libraries/Matter/src/Matter.h +++ b/libraries/Matter/src/Matter.h @@ -26,6 +26,7 @@ #include #include #include +#include using namespace esp_matter; @@ -58,6 +59,7 @@ class ArduinoMatter { friend class MatterColorLight; friend class MatterEnhancedColorLight; friend class MatterFan; + friend class MatterTemperatureSensor; protected: static void _init(); diff --git a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp new file mode 100644 index 00000000000..fbe06ed66f0 --- /dev/null +++ b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp @@ -0,0 +1,100 @@ +// Copyright 2024 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#include +#ifdef CONFIG_ESP_MATTER_ENABLE_DATA_MODEL + +#include +#include +#include + +using namespace esp_matter; +using namespace esp_matter::endpoint; +using namespace chip::app::Clusters; + +bool MatterTemperatureSensor::attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val) { + bool ret = true; + if (!started) { + log_e("Matter Temperature Sensor device has not begun."); + return false; + } + + log_d("Temperature Sensor Attr update callback: endpoint: %u, cluster: %u, attribute: %u, val: %u", endpoint_id, cluster_id, attribute_id, val->val.u32); + return ret; +} + +MatterTemperatureSensor::MatterTemperatureSensor() {} + +MatterTemperatureSensor::~MatterTemperatureSensor() { + end(); +} + +bool MatterTemperatureSensor::begin(int16_t _rawTemperature) { + ArduinoMatter::_init(); + + temperature_sensor::config_t temperature_sensor_config; + temperature_sensor_config.temperature_measurement.measured_value = _rawTemperature; + temperature_sensor_config.temperature_measurement.min_measured_value = nullptr; + temperature_sensor_config.temperature_measurement.max_measured_value = nullptr; + + // endpoint handles can be used to add/modify clusters. + endpoint_t *endpoint = temperature_sensor::create(node::get(), &temperature_sensor_config, ENDPOINT_FLAG_NONE, (void *)this); + if (endpoint == nullptr) { + log_e("Failed to create Temperature Sensor endpoint"); + return false; + } + rawTemperature = _rawTemperature; + setEndPointId(endpoint::get_id(endpoint)); + log_i("Temperature Sensor created with endpoint_id %d", getEndPointId()); + started = true; + return true; +} + +void MatterTemperatureSensor::end() { + started = false; +} + +bool MatterTemperatureSensor::setRawTemperature(int16_t _rawTemperature) { + if (!started) { + log_e("Matter Temperature Sensor device has not begun."); + return false; + } + + // avoid processing the a "no-change" + if (rawTemperature == _rawTemperature) { + return true; + } + + esp_matter_attr_val_t temperatureVal = esp_matter_invalid(NULL); + + if (!getAttributeVal(TemperatureMeasurement::Id, TemperatureMeasurement::Attributes::MeasuredValue::Id, &temperatureVal)) { + log_e("Failed to get Temperature Sensor Attribute."); + return false; + } + if (temperatureVal.val.i16 != _rawTemperature) { + temperatureVal.val.i16 = _rawTemperature; + bool ret; + ret = updateAttributeVal(TemperatureMeasurement::Id, TemperatureMeasurement::Attributes::MeasuredValue::Id, &temperatureVal); + if (!ret) { + log_e("Failed to update Fan Speed Percent Attribute."); + return false; + } + rawTemperature = _rawTemperature; + } + log_v("Temperature Sensor set to %.02f Celcius Degrees", (float)_rawTemperature / 100.00); + + return true; +} + +#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */ diff --git a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h new file mode 100644 index 00000000000..ecba0f6f889 --- /dev/null +++ b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h @@ -0,0 +1,63 @@ +// Copyright 2024 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once +#include +#ifdef CONFIG_ESP_MATTER_ENABLE_DATA_MODEL + +#include +#include + +class MatterTemperatureSensor : public MatterEndPoint { +public: + MatterTemperatureSensor(); + ~MatterTemperatureSensor(); + // default initial raw temperature + virtual bool begin(int16_t _rawTemperature = 0); + bool begin(double temperatureCelcius) { + int16_t rawValue = static_cast(temperatureCelcius * 100.0f); + return begin(rawValue); + } + // this will just stop processing Temperature Sensor Matter events + void end(); + + // set the reported raw temperature + bool setRawTemperature(int16_t _rawTemperature); + bool setTemperatureCelsius(double temperatureCelcius) { + int16_t rawValue = static_cast(temperatureCelcius * 100.0f); + return setRawTemperature(rawValue); + } + int16_t getRawTemperature() { // returns the reported raw temperature + return rawTemperature; + } + double getTemperatureCelsius() { // returns the reported temperature in Celcius + return (double)rawTemperature / 100.0; + } + void operator=(double temperatureCelcius) { // sets the reported temperature in Celcius{ + int16_t rawValue = static_cast(temperatureCelcius * 100.0f); + setRawTemperature(rawValue); + } + operator double() { // returns the reported temperature in Celcius + return (double) getTemperatureCelsius(); + } + + // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. + bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); + // User Callback for whenever the Light state is changed by the Matter Controller + +protected: + bool started = false; + int16_t rawTemperature = 0; // default initial reported temperature +}; +#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */ From cbf154820e49b0d26aaa7590551a90699f364d2e Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 9 Dec 2024 13:39:47 -0300 Subject: [PATCH 02/15] feat(matter): commentaries review and fixes --- .../examples/MatterTemperatureSensor/MatterTemperatureSensor.ino | 1 - 1 file changed, 1 deletion(-) diff --git a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino index cbc4384c414..ee792599eba 100644 --- a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino +++ b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino @@ -15,7 +15,6 @@ /* * This example is the smallest code that will create a Matter Device which can be * commissioned and controlled from a Matter Environment APP. - * It controls a GPIO that could be attached to a LED for visualization. * Additionally the ESP32 will send debug messages indicating the Matter activity. * Turning DEBUG Level ON may be useful to following Matter Accessory and Controller messages. */ From 413006089b9906fa188b09c3813a7651ea04258d Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 9 Dec 2024 13:40:08 -0300 Subject: [PATCH 03/15] feat(matter): commentaries review and fixes --- .../MatterTemperatureSensor/MatterTemperatureSensor.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino index ee792599eba..2eab9f7d55c 100644 --- a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino +++ b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino @@ -24,7 +24,8 @@ #include // List of Matter Endpoints for this Node -// Celcius Temperature Sensor Endpoint - at least one per node +// Celcius Temperature Sensor Endpoint + MatterTemperatureSensor CelciusTempSensor; // WiFi is manually set and started From 543c7f4a08bc961cf90ac54b2409625d33584385 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 9 Dec 2024 13:40:29 -0300 Subject: [PATCH 04/15] feat(matter): commentaries review and fixes --- .../MatterTemperatureSensor/MatterTemperatureSensor.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino index 2eab9f7d55c..1739bb3e1c2 100644 --- a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino +++ b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino @@ -32,7 +32,8 @@ MatterTemperatureSensor CelciusTempSensor; const char *ssid = "your-ssid"; // Change this to your WiFi SSID const char *password = "your-password"; // Change this to your WiFi password -// Simulate a temperature sensor - add you prefered library code here +// Simulate a temperature sensor - add your prefered temperature sensor library code here + float getTemperature() { static float CelciusTempHWSensor = -10.0; From 214efe7d88ad2bd90b92aacd15645b0d08d4520f Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 9 Dec 2024 13:40:41 -0300 Subject: [PATCH 05/15] feat(matter): commentaries review and fixes --- .../MatterTemperatureSensor/MatterTemperatureSensor.ino | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino index 1739bb3e1c2..e4c87ea74df 100644 --- a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino +++ b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino @@ -88,7 +88,8 @@ void setup() { void loop() { Serial.printf("Current Temperature is %.02fC\r\n", (float)CelciusTempSensor); // update the temperature sensor value every 5 seconds - // Matter phone APP shall display the change in temperature + // Matter phone APP shall display the temperature change + delay(5000); CelciusTempSensor = getTemperature(); } From 336d99eb7bbc080e67a39160c106930930642a2d Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 9 Dec 2024 13:41:00 -0300 Subject: [PATCH 06/15] feat(matter): commentaries review and fixes --- libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h index ecba0f6f889..9181c121fe8 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h +++ b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h @@ -44,7 +44,7 @@ class MatterTemperatureSensor : public MatterEndPoint { double getTemperatureCelsius() { // returns the reported temperature in Celcius return (double)rawTemperature / 100.0; } - void operator=(double temperatureCelcius) { // sets the reported temperature in Celcius{ + void operator=(double temperatureCelcius) { // sets the reported temperature in Celcius int16_t rawValue = static_cast(temperatureCelcius * 100.0f); setRawTemperature(rawValue); } From ff79cacdeb766e04984c70a8b12c4cdf198bb353 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 9 Dec 2024 13:43:08 -0300 Subject: [PATCH 07/15] feat(matter): commentaries review and fixes --- .../examples/MatterTemperatureSensor/MatterTemperatureSensor.ino | 1 + 1 file changed, 1 insertion(+) diff --git a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino index e4c87ea74df..78bf43e135f 100644 --- a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino +++ b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino @@ -26,6 +26,7 @@ // List of Matter Endpoints for this Node // Celcius Temperature Sensor Endpoint + MatterTemperatureSensor CelciusTempSensor; // WiFi is manually set and started From b8c43cc5907070a27b43e673754871e00e0538ef Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 9 Dec 2024 13:58:05 -0300 Subject: [PATCH 08/15] feat(matter): general commentaries and code review --- .../MatterTemperatureSensor.ino | 10 +++------- .../MatterEndpoints/MatterTemperatureSensor.cpp | 3 +-- .../MatterEndpoints/MatterTemperatureSensor.h | 16 +++++++++------- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino index 78bf43e135f..ca5292060cc 100644 --- a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino +++ b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino @@ -13,7 +13,7 @@ // limitations under the License. /* - * This example is the smallest code that will create a Matter Device which can be + * This example is an example code that will create a Matter Device which can be * commissioned and controlled from a Matter Environment APP. * Additionally the ESP32 will send debug messages indicating the Matter activity. * Turning DEBUG Level ON may be useful to following Matter Accessory and Controller messages. @@ -25,8 +25,6 @@ // List of Matter Endpoints for this Node // Celcius Temperature Sensor Endpoint - - MatterTemperatureSensor CelciusTempSensor; // WiFi is manually set and started @@ -34,7 +32,6 @@ const char *ssid = "your-ssid"; // Change this to your WiFi SSID const char *password = "your-password"; // Change this to your WiFi password // Simulate a temperature sensor - add your prefered temperature sensor library code here - float getTemperature() { static float CelciusTempHWSensor = -10.0; @@ -60,7 +57,7 @@ void setup() { Serial.println(); // set initial temperature sensor measurement - // Simulated Sensor - it shall print -25C first and then move to the -10C to 10C range + // Simulated Sensor - it shall initially print -25C and then move to the -10C to 10C range CelciusTempSensor.begin(-25.00); // Matter beginning - Last step, after all EndPoints are initialized @@ -89,8 +86,7 @@ void setup() { void loop() { Serial.printf("Current Temperature is %.02fC\r\n", (float)CelciusTempSensor); // update the temperature sensor value every 5 seconds - // Matter phone APP shall display the temperature change - + // Matter APP shall display the updated temperature delay(5000); CelciusTempSensor = getTemperature(); } diff --git a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp index fbe06ed66f0..979cc320557 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp +++ b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp @@ -16,7 +16,6 @@ #ifdef CONFIG_ESP_MATTER_ENABLE_DATA_MODEL #include -#include #include using namespace esp_matter; @@ -48,7 +47,7 @@ bool MatterTemperatureSensor::begin(int16_t _rawTemperature) { temperature_sensor_config.temperature_measurement.min_measured_value = nullptr; temperature_sensor_config.temperature_measurement.max_measured_value = nullptr; - // endpoint handles can be used to add/modify clusters. + // endpoint handles can be used to add/modify clusters endpoint_t *endpoint = temperature_sensor::create(node::get(), &temperature_sensor_config, ENDPOINT_FLAG_NONE, (void *)this); if (endpoint == nullptr) { log_e("Failed to create Temperature Sensor endpoint"); diff --git a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h index 9181c121fe8..a4f954afa88 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h +++ b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h @@ -23,13 +23,13 @@ class MatterTemperatureSensor : public MatterEndPoint { public: MatterTemperatureSensor(); ~MatterTemperatureSensor(); - // default initial raw temperature + // begin Matter Temperature Sensor endpoint virtual bool begin(int16_t _rawTemperature = 0); bool begin(double temperatureCelcius) { int16_t rawValue = static_cast(temperatureCelcius * 100.0f); return begin(rawValue); } - // this will just stop processing Temperature Sensor Matter events + // this will stop processing Temperature Sensor Matter events void end(); // set the reported raw temperature @@ -38,23 +38,25 @@ class MatterTemperatureSensor : public MatterEndPoint { int16_t rawValue = static_cast(temperatureCelcius * 100.0f); return setRawTemperature(rawValue); } - int16_t getRawTemperature() { // returns the reported raw temperature + // returns the reported raw temperature (in 1/100th of a degree) + int16_t getRawTemperature() { return rawTemperature; } - double getTemperatureCelsius() { // returns the reported temperature in Celcius + // returns the reported temperature in Celcius + double getTemperatureCelsius() { return (double)rawTemperature / 100.0; } - void operator=(double temperatureCelcius) { // sets the reported temperature in Celcius + // sets the reported temperature in Celcius + void operator=(double temperatureCelcius) { int16_t rawValue = static_cast(temperatureCelcius * 100.0f); setRawTemperature(rawValue); } - operator double() { // returns the reported temperature in Celcius + operator double() { return (double) getTemperatureCelsius(); } // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val); - // User Callback for whenever the Light state is changed by the Matter Controller protected: bool started = false; From 1f3b13be1d6df8a61a1fc79a7fafe9cfde0be33f Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 9 Dec 2024 14:01:18 -0300 Subject: [PATCH 09/15] feat(matter): keeping arduino style for local variables (lower case) --- .../MatterTemperatureSensor.ino | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino index ca5292060cc..0683806fed2 100644 --- a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino +++ b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino @@ -33,15 +33,15 @@ const char *password = "your-password"; // Change this to your WiFi password // Simulate a temperature sensor - add your prefered temperature sensor library code here float getTemperature() { - static float CelciusTempHWSensor = -10.0; + static float celciusTempHWSensor = -10.0; // it will increase from -10C to 10C in 0.5C steps to simulate a temperature sensor - CelciusTempHWSensor = CelciusTempHWSensor + 0.5; - if (CelciusTempHWSensor > 10) { - CelciusTempHWSensor = -10; + celciusTempHWSensor = celciusTempHWSensor + 0.5; + if (celciusTempHWSensor > 10) { + celciusTempHWSensor = -10; } - return CelciusTempHWSensor; + return celciusTempHWSensor; } void setup() { From 8c09c185783a4462f2efe72b39b6eada3c1bd618 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 9 Dec 2024 16:00:15 -0300 Subject: [PATCH 10/15] feat(matter): applies a generic temperature unit to the implementation and example --- .../MatterTemperatureSensor.ino | 26 +++++++------ .../MatterEndpoints/MatterTemperatureSensor.h | 38 +++++++++---------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino index 0683806fed2..f3f761d2b84 100644 --- a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino +++ b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino @@ -24,24 +24,26 @@ #include // List of Matter Endpoints for this Node -// Celcius Temperature Sensor Endpoint -MatterTemperatureSensor CelciusTempSensor; +// Matter Temperature Sensor Endpoint +MatterTemperatureSensor SimulatedTemperatureSensor; // WiFi is manually set and started const char *ssid = "your-ssid"; // Change this to your WiFi SSID const char *password = "your-password"; // Change this to your WiFi password // Simulate a temperature sensor - add your prefered temperature sensor library code here -float getTemperature() { - static float celciusTempHWSensor = -10.0; +float getSimulatedTemperature() { + // The Endpoint implementation keeps an int16_t as internal value information, + // which stores data in 1/100th of any temperature unit + static float simulatedTempHWSensor = -10.0; // it will increase from -10C to 10C in 0.5C steps to simulate a temperature sensor - celciusTempHWSensor = celciusTempHWSensor + 0.5; - if (celciusTempHWSensor > 10) { - celciusTempHWSensor = -10; + simulatedTempHWSensor = simulatedTempHWSensor + 0.5; + if (simulatedTempHWSensor > 10) { + simulatedTempHWSensor = -10; } - return celciusTempHWSensor; + return simulatedTempHWSensor; } void setup() { @@ -57,8 +59,8 @@ void setup() { Serial.println(); // set initial temperature sensor measurement - // Simulated Sensor - it shall initially print -25C and then move to the -10C to 10C range - CelciusTempSensor.begin(-25.00); + // Simulated Sensor - it shall initially print -25 degrees and then move to the -10 to 10 range + SimulatedTemperatureSensor.begin(-25.00); // Matter beginning - Last step, after all EndPoints are initialized Matter.begin(); @@ -84,9 +86,9 @@ void setup() { } void loop() { - Serial.printf("Current Temperature is %.02fC\r\n", (float)CelciusTempSensor); + Serial.printf("Current Temperature is %.02f \r\n", SimulatedTemperatureSensor.getTemperature()); // update the temperature sensor value every 5 seconds // Matter APP shall display the updated temperature delay(5000); - CelciusTempSensor = getTemperature(); + SimulatedTemperatureSensor.setTemperature(getSimulatedTemperature()); } diff --git a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h index a4f954afa88..fdef13f2425 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h +++ b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h @@ -23,36 +23,30 @@ class MatterTemperatureSensor : public MatterEndPoint { public: MatterTemperatureSensor(); ~MatterTemperatureSensor(); - // begin Matter Temperature Sensor endpoint - virtual bool begin(int16_t _rawTemperature = 0); - bool begin(double temperatureCelcius) { - int16_t rawValue = static_cast(temperatureCelcius * 100.0f); - return begin(rawValue); + // begin Matter Temperature Sensor endpoint with initial float temperature + bool begin(double temperature) { + return setTemperature(temperature); } // this will stop processing Temperature Sensor Matter events void end(); // set the reported raw temperature - bool setRawTemperature(int16_t _rawTemperature); - bool setTemperatureCelsius(double temperatureCelcius) { - int16_t rawValue = static_cast(temperatureCelcius * 100.0f); + bool setTemperature(double temperature) { + // stores up to 1/100th of a degree precision + int16_t rawValue = static_cast(temperature * 100.0f); return setRawTemperature(rawValue); } - // returns the reported raw temperature (in 1/100th of a degree) - int16_t getRawTemperature() { - return rawTemperature; - } - // returns the reported temperature in Celcius - double getTemperatureCelsius() { + // returns the reported float temperature with 1/100th of a degree precision + double getTemperature() { return (double)rawTemperature / 100.0; } - // sets the reported temperature in Celcius - void operator=(double temperatureCelcius) { - int16_t rawValue = static_cast(temperatureCelcius * 100.0f); - setRawTemperature(rawValue); + // double conversion operator + void operator=(double temperature) { + setTemperature(temperature); } + // double conversion operator operator double() { - return (double) getTemperatureCelsius(); + return (double) getTemperature(); } // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. @@ -60,6 +54,10 @@ class MatterTemperatureSensor : public MatterEndPoint { protected: bool started = false; - int16_t rawTemperature = 0; // default initial reported temperature + // implementation keeps temperature in 1/100th of a degree, any temperature unit + int16_t rawTemperature = 0; + // internal function to set the raw temperature value (Matter Cluster) + bool setRawTemperature(int16_t _rawTemperature); + bool begin(int16_t _rawTemperature); }; #endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */ From 11ba0c40e42c01e305b1ff586debcc77b8234191 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 9 Dec 2024 17:49:25 -0300 Subject: [PATCH 11/15] fix(matter): fixed problem with begin(float) implementation --- libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h index fdef13f2425..dff62065ec0 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h +++ b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h @@ -25,7 +25,7 @@ class MatterTemperatureSensor : public MatterEndPoint { ~MatterTemperatureSensor(); // begin Matter Temperature Sensor endpoint with initial float temperature bool begin(double temperature) { - return setTemperature(temperature); + return begin(static_cast(temperature * 100.0f)); } // this will stop processing Temperature Sensor Matter events void end(); From 291b6fb48213aed4a55f30b271c2ea2bc7a67315 Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 9 Dec 2024 17:50:27 -0300 Subject: [PATCH 12/15] fix(matter): fixed begin(float) initiallization --- libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h index dff62065ec0..2b77d702ca2 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h +++ b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h @@ -24,7 +24,7 @@ class MatterTemperatureSensor : public MatterEndPoint { MatterTemperatureSensor(); ~MatterTemperatureSensor(); // begin Matter Temperature Sensor endpoint with initial float temperature - bool begin(double temperature) { + bool begin(double temperature = 0.00) { return begin(static_cast(temperature * 100.0f)); } // this will stop processing Temperature Sensor Matter events From a9c783bac684eedaff765cde31f9a5a91c97280d Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 9 Dec 2024 18:18:53 -0300 Subject: [PATCH 13/15] feat(matter): updated matter temperature keywords with new api --- libraries/Matter/keywords.txt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/libraries/Matter/keywords.txt b/libraries/Matter/keywords.txt index 57f646a673e..9ba58ea9f8a 100644 --- a/libraries/Matter/keywords.txt +++ b/libraries/Matter/keywords.txt @@ -63,10 +63,8 @@ setMode KEYWORD2 getMode KEYWORD2 onChangeMode KEYWORD2 onChangeSpeedPercent KEYWORD2 -setRawTemperature KEYWORD2 -getRawTemperature KEYWORD2 -setTemperatureCelsius KEYWORD2 -getTemperatureCelsius KEYWORD2 +setTemperature KEYWORD2 +getTemperature KEYWORD2 ####################################### # Constants (LITERAL1) From d8587834497f309fd1325d6601c8e84b2377410c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci-lite[bot]" <117423508+pre-commit-ci-lite[bot]@users.noreply.github.com> Date: Mon, 9 Dec 2024 22:10:58 +0000 Subject: [PATCH 14/15] ci(pre-commit): Apply automatic fixes --- CMakeLists.txt | 1 - .../MatterTemperatureSensor.ino | 188 +++++++++--------- libraries/Matter/keywords.txt | 1 - .../MatterEndpoints/MatterTemperatureSensor.h | 2 +- 4 files changed, 95 insertions(+), 97 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 07803fec5b8..eba1a3fd824 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -402,4 +402,3 @@ endif() if(NOT CONFIG_ARDUINO_SELECTIVE_COMPILATION OR CONFIG_ARDUINO_SELECTIVE_WiFiProv) maybe_add_component(espressif__network_provisioning) endif() - diff --git a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino index f3f761d2b84..2e00a7cbb6c 100644 --- a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino +++ b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino @@ -1,94 +1,94 @@ -// Copyright 2024 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -/* - * This example is an example code that will create a Matter Device which can be - * commissioned and controlled from a Matter Environment APP. - * Additionally the ESP32 will send debug messages indicating the Matter activity. - * Turning DEBUG Level ON may be useful to following Matter Accessory and Controller messages. - */ - -// Matter Manager -#include -#include - -// List of Matter Endpoints for this Node -// Matter Temperature Sensor Endpoint -MatterTemperatureSensor SimulatedTemperatureSensor; - -// WiFi is manually set and started -const char *ssid = "your-ssid"; // Change this to your WiFi SSID -const char *password = "your-password"; // Change this to your WiFi password - -// Simulate a temperature sensor - add your prefered temperature sensor library code here -float getSimulatedTemperature() { - // The Endpoint implementation keeps an int16_t as internal value information, - // which stores data in 1/100th of any temperature unit - static float simulatedTempHWSensor = -10.0; - - // it will increase from -10C to 10C in 0.5C steps to simulate a temperature sensor - simulatedTempHWSensor = simulatedTempHWSensor + 0.5; - if (simulatedTempHWSensor > 10) { - simulatedTempHWSensor = -10; - } - - return simulatedTempHWSensor; -} - -void setup() { - Serial.begin(115200); - - // Manually connect to WiFi - WiFi.begin(ssid, password); - // Wait for connection - while (WiFi.status() != WL_CONNECTED) { - delay(500); - Serial.print("."); - } - Serial.println(); - - // set initial temperature sensor measurement - // Simulated Sensor - it shall initially print -25 degrees and then move to the -10 to 10 range - SimulatedTemperatureSensor.begin(-25.00); - - // Matter beginning - Last step, after all EndPoints are initialized - Matter.begin(); - - // Check Matter Accessory Commissioning state, which may change during execution of loop() - if (!Matter.isDeviceCommissioned()) { - Serial.println(""); - Serial.println("Matter Node is not commissioned yet."); - Serial.println("Initiate the device discovery in your Matter environment."); - Serial.println("Commission it to your Matter hub with the manual pairing code or QR code"); - Serial.printf("Manual pairing code: %s\r\n", Matter.getManualPairingCode().c_str()); - Serial.printf("QR code URL: %s\r\n", Matter.getOnboardingQRCodeUrl().c_str()); - // waits for Matter Temperature Sensor Commissioning. - uint32_t timeCount = 0; - while (!Matter.isDeviceCommissioned()) { - delay(100); - if ((timeCount++ % 50) == 0) { // 50*100ms = 5 sec - Serial.println("Matter Node not commissioned yet. Waiting for commissioning."); - } - } - Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use."); - } -} - -void loop() { - Serial.printf("Current Temperature is %.02f \r\n", SimulatedTemperatureSensor.getTemperature()); - // update the temperature sensor value every 5 seconds - // Matter APP shall display the updated temperature - delay(5000); - SimulatedTemperatureSensor.setTemperature(getSimulatedTemperature()); -} +// Copyright 2024 Espressif Systems (Shanghai) PTE LTD +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at + +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +/* + * This example is an example code that will create a Matter Device which can be + * commissioned and controlled from a Matter Environment APP. + * Additionally the ESP32 will send debug messages indicating the Matter activity. + * Turning DEBUG Level ON may be useful to following Matter Accessory and Controller messages. + */ + +// Matter Manager +#include +#include + +// List of Matter Endpoints for this Node +// Matter Temperature Sensor Endpoint +MatterTemperatureSensor SimulatedTemperatureSensor; + +// WiFi is manually set and started +const char *ssid = "your-ssid"; // Change this to your WiFi SSID +const char *password = "your-password"; // Change this to your WiFi password + +// Simulate a temperature sensor - add your prefered temperature sensor library code here +float getSimulatedTemperature() { + // The Endpoint implementation keeps an int16_t as internal value information, + // which stores data in 1/100th of any temperature unit + static float simulatedTempHWSensor = -10.0; + + // it will increase from -10C to 10C in 0.5C steps to simulate a temperature sensor + simulatedTempHWSensor = simulatedTempHWSensor + 0.5; + if (simulatedTempHWSensor > 10) { + simulatedTempHWSensor = -10; + } + + return simulatedTempHWSensor; +} + +void setup() { + Serial.begin(115200); + + // Manually connect to WiFi + WiFi.begin(ssid, password); + // Wait for connection + while (WiFi.status() != WL_CONNECTED) { + delay(500); + Serial.print("."); + } + Serial.println(); + + // set initial temperature sensor measurement + // Simulated Sensor - it shall initially print -25 degrees and then move to the -10 to 10 range + SimulatedTemperatureSensor.begin(-25.00); + + // Matter beginning - Last step, after all EndPoints are initialized + Matter.begin(); + + // Check Matter Accessory Commissioning state, which may change during execution of loop() + if (!Matter.isDeviceCommissioned()) { + Serial.println(""); + Serial.println("Matter Node is not commissioned yet."); + Serial.println("Initiate the device discovery in your Matter environment."); + Serial.println("Commission it to your Matter hub with the manual pairing code or QR code"); + Serial.printf("Manual pairing code: %s\r\n", Matter.getManualPairingCode().c_str()); + Serial.printf("QR code URL: %s\r\n", Matter.getOnboardingQRCodeUrl().c_str()); + // waits for Matter Temperature Sensor Commissioning. + uint32_t timeCount = 0; + while (!Matter.isDeviceCommissioned()) { + delay(100); + if ((timeCount++ % 50) == 0) { // 50*100ms = 5 sec + Serial.println("Matter Node not commissioned yet. Waiting for commissioning."); + } + } + Serial.println("Matter Node is commissioned and connected to Wi-Fi. Ready for use."); + } +} + +void loop() { + Serial.printf("Current Temperature is %.02f \r\n", SimulatedTemperatureSensor.getTemperature()); + // update the temperature sensor value every 5 seconds + // Matter APP shall display the updated temperature + delay(5000); + SimulatedTemperatureSensor.setTemperature(getSimulatedTemperature()); +} diff --git a/libraries/Matter/keywords.txt b/libraries/Matter/keywords.txt index 9ba58ea9f8a..60ffc546bd6 100644 --- a/libraries/Matter/keywords.txt +++ b/libraries/Matter/keywords.txt @@ -91,4 +91,3 @@ FAN_MODE_SEQ_OFF_LOW_MED_HIGH_AUTO LITERAL1 FAN_MODE_SEQ_OFF_LOW_HIGH_AUTO LITERAL1 FAN_MODE_SEQ_OFF_HIGH_AUTO LITERAL1 FAN_MODE_SEQ_OFF_HIGH LITERAL1 - diff --git a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h index 2b77d702ca2..826abac9a2a 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h +++ b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.h @@ -46,7 +46,7 @@ class MatterTemperatureSensor : public MatterEndPoint { } // double conversion operator operator double() { - return (double) getTemperature(); + return (double)getTemperature(); } // this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. From dbcdf6ce2b5e36470ddcd30744a9eca8fad7274d Mon Sep 17 00:00:00 2001 From: Rodrigo Garcia Date: Mon, 9 Dec 2024 19:18:56 -0300 Subject: [PATCH 15/15] fix(matter): fixed code spell ci errors in matter temperature sensor --- .../MatterTemperatureSensor/MatterTemperatureSensor.ino | 2 +- .../Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino index 2e00a7cbb6c..216406d6082 100644 --- a/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino +++ b/libraries/Matter/examples/MatterTemperatureSensor/MatterTemperatureSensor.ino @@ -31,7 +31,7 @@ MatterTemperatureSensor SimulatedTemperatureSensor; const char *ssid = "your-ssid"; // Change this to your WiFi SSID const char *password = "your-password"; // Change this to your WiFi password -// Simulate a temperature sensor - add your prefered temperature sensor library code here +// Simulate a temperature sensor - add your preferred temperature sensor library code here float getSimulatedTemperature() { // The Endpoint implementation keeps an int16_t as internal value information, // which stores data in 1/100th of any temperature unit diff --git a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp index 979cc320557..4a43650f924 100644 --- a/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp +++ b/libraries/Matter/src/MatterEndpoints/MatterTemperatureSensor.cpp @@ -91,7 +91,7 @@ bool MatterTemperatureSensor::setRawTemperature(int16_t _rawTemperature) { } rawTemperature = _rawTemperature; } - log_v("Temperature Sensor set to %.02f Celcius Degrees", (float)_rawTemperature / 100.00); + log_v("Temperature Sensor set to %.02f Degrees", (float)_rawTemperature / 100.00); return true; }