Merge pull request #10732 from SuGlider/matter_while_serial
feat(matter): General Review - remove while(!serial) ipv6(enable) and fixes some commentaries in the code
This commit is contained in:
commit
30e55fc4b7
37 changed files with 153 additions and 185 deletions
|
|
@ -21,6 +21,10 @@
|
|||
// Color Light Endpoint
|
||||
MatterColorLight ColorLight;
|
||||
|
||||
// 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
|
||||
|
||||
// it will keep last OnOff & HSV Color state stored, using Preferences
|
||||
Preferences matterPref;
|
||||
const char *onOffPrefKey = "OnOff";
|
||||
|
|
@ -43,10 +47,6 @@ bool button_state = false; // false = released | true = pres
|
|||
const uint32_t debouceTime = 250; // button debouncing time (ms)
|
||||
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
|
||||
|
||||
// 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
|
||||
|
||||
// Set the RGB LED Light based on the current state of the Color Light
|
||||
bool setLightState(bool state, espHsvColor_t colorHSV) {
|
||||
|
||||
|
|
@ -76,15 +76,10 @@ void setup() {
|
|||
pinMode(ledPin, OUTPUT);
|
||||
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
delay(100);
|
||||
}
|
||||
|
||||
// We start by connecting to a WiFi network
|
||||
Serial.print("Connecting to ");
|
||||
Serial.println(ssid);
|
||||
// enable IPv6
|
||||
WiFi.enableIPv6(true);
|
||||
// Manually connect to WiFi
|
||||
WiFi.begin(ssid, password);
|
||||
// Wait for connection
|
||||
|
|
|
|||
|
|
@ -26,15 +26,10 @@ const char *password = "your-password"; // Change this to your WiFi password
|
|||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
delay(100);
|
||||
}
|
||||
|
||||
// We start by connecting to a WiFi network
|
||||
Serial.print("Connecting to ");
|
||||
Serial.println(ssid);
|
||||
// enable IPv6
|
||||
WiFi.enableIPv6(true);
|
||||
// Manually connect to WiFi
|
||||
WiFi.begin(ssid, password);
|
||||
// Wait for connection
|
||||
|
|
|
|||
|
|
@ -55,15 +55,10 @@ void setup() {
|
|||
pinMode(buttonPin, INPUT_PULLUP);
|
||||
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
delay(100);
|
||||
}
|
||||
|
||||
// We start by connecting to a WiFi network
|
||||
Serial.print("Connecting to ");
|
||||
Serial.println(ssid);
|
||||
// enable IPv6
|
||||
WiFi.enableIPv6(true);
|
||||
// Manually connect to WiFi
|
||||
WiFi.begin(ssid, password);
|
||||
// Wait for connection
|
||||
|
|
|
|||
|
|
@ -36,6 +36,10 @@
|
|||
// Matter Contact Sensor Endpoint
|
||||
MatterContactSensor ContactSensor;
|
||||
|
||||
// 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
|
||||
|
||||
// LED will be used to indicate the Contact Sensor state
|
||||
// set your board RGB LED pin here
|
||||
#ifdef RGB_BUILTIN
|
||||
|
|
@ -48,10 +52,6 @@ const uint8_t ledPin = 2; // Set your pin here if your board has not defined LE
|
|||
// set your board USER BUTTON pin here - decommissioning and Manual Contact Sensor toggle button
|
||||
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
|
||||
|
||||
// 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
|
||||
|
||||
// Button control
|
||||
uint32_t button_time_stamp = 0; // debouncing control
|
||||
bool button_state = false; // false = released | true = pressed
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@
|
|||
// Dimmable Light Endpoint
|
||||
MatterDimmableLight DimmableLight;
|
||||
|
||||
// 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
|
||||
|
||||
// it will keep last OnOff & Brightness state stored, using Preferences
|
||||
Preferences matterPref;
|
||||
const char *onOffPrefKey = "OnOff";
|
||||
|
|
@ -43,10 +47,6 @@ bool button_state = false; // false = released | true = pres
|
|||
const uint32_t debouceTime = 250; // button debouncing time (ms)
|
||||
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
|
||||
|
||||
// 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
|
||||
|
||||
// Set the RGB LED Light based on the current state of the Dimmable Light
|
||||
bool setLightState(bool state, uint8_t brightness) {
|
||||
if (state) {
|
||||
|
|
@ -72,15 +72,10 @@ void setup() {
|
|||
pinMode(ledPin, OUTPUT);
|
||||
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
delay(100);
|
||||
}
|
||||
|
||||
// We start by connecting to a WiFi network
|
||||
Serial.print("Connecting to ");
|
||||
Serial.println(ssid);
|
||||
// enable IPv6
|
||||
WiFi.enableIPv6(true);
|
||||
// Manually connect to WiFi
|
||||
WiFi.begin(ssid, password);
|
||||
// Wait for connection
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@
|
|||
// Color Light Endpoint
|
||||
MatterEnhancedColorLight EnhancedColorLight;
|
||||
|
||||
// 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
|
||||
|
||||
// It will use HSV color to control all Matter Attribute Changes
|
||||
HsvColor_t currentHSVColor = {0, 0, 0};
|
||||
|
||||
|
|
@ -46,10 +50,6 @@ bool button_state = false; // false = released | true = pres
|
|||
const uint32_t debouceTime = 250; // button debouncing time (ms)
|
||||
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
|
||||
|
||||
// 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
|
||||
|
||||
// Set the RGB LED Light based on the current state of the Enhanced Color Light
|
||||
bool setLightState(bool state, espHsvColor_t colorHSV, uint8_t brighteness, uint16_t temperature_Mireds) {
|
||||
|
||||
|
|
@ -80,15 +80,10 @@ void setup() {
|
|||
pinMode(ledPin, OUTPUT);
|
||||
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
delay(100);
|
||||
}
|
||||
|
||||
// We start by connecting to a WiFi network
|
||||
Serial.print("Connecting to ");
|
||||
Serial.println(ssid);
|
||||
// enable IPv6
|
||||
WiFi.enableIPv6(true);
|
||||
// Manually connect to WiFi
|
||||
WiFi.begin(ssid, password);
|
||||
// Wait for connection
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@
|
|||
// Fan Endpoint - On/Off control + Speed Percent Control + Fan Modes
|
||||
MatterFan Fan;
|
||||
|
||||
// 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
|
||||
|
||||
// set your board USER BUTTON pin here - used for toggling On/Off and decommission the Matter Node
|
||||
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
|
||||
|
||||
|
|
@ -41,10 +45,6 @@ const uint8_t dcMotorPin = 2; // Set your pin here if your board has not define
|
|||
#warning "Do not forget to set the RGB LED pin"
|
||||
#endif
|
||||
|
||||
// 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
|
||||
|
||||
void fanDCMotorDrive(bool fanState, uint8_t speedPercent) {
|
||||
// drive the Fan DC motor
|
||||
if (fanState == false) {
|
||||
|
|
@ -71,15 +71,10 @@ void setup() {
|
|||
pinMode(dcMotorPin, OUTPUT);
|
||||
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
delay(100);
|
||||
}
|
||||
|
||||
// We start by connecting to a WiFi network
|
||||
Serial.print("Connecting to ");
|
||||
Serial.println(ssid);
|
||||
// enable IPv6
|
||||
WiFi.enableIPv6(true);
|
||||
// Manually connect to WiFi
|
||||
WiFi.begin(ssid, password);
|
||||
// Wait for connection
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@
|
|||
// Matter Humidity Sensor Endpoint
|
||||
MatterHumiditySensor SimulatedHumiditySensor;
|
||||
|
||||
// set your board USER BUTTON pin here - decommissioning button
|
||||
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
|
||||
|
||||
// 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
|
||||
|
||||
// set your board USER BUTTON pin here - decommissioning button
|
||||
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
|
||||
|
||||
// Button control - decommision the Matter Node
|
||||
uint32_t button_time_stamp = 0; // debouncing control
|
||||
bool button_state = false; // false = released | true = pressed
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@
|
|||
// Single On/Off Light Endpoint - at least one per node
|
||||
MatterOnOffLight OnOffLight;
|
||||
|
||||
// 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
|
||||
|
||||
// Light GPIO that can be controlled by Matter APP
|
||||
#ifdef LED_BUILTIN
|
||||
const uint8_t ledPin = LED_BUILTIN;
|
||||
|
|
@ -44,23 +48,18 @@ bool button_state = false; // false = released | true = pres
|
|||
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
|
||||
|
||||
// Matter Protocol Endpoint (On/OFF Light) Callback
|
||||
bool matterCB(bool state) {
|
||||
bool onOffLightCallback(bool state) {
|
||||
digitalWrite(ledPin, state ? HIGH : LOW);
|
||||
// This callback must return the success state to Matter core
|
||||
return true;
|
||||
}
|
||||
|
||||
// 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
|
||||
|
||||
void setup() {
|
||||
// Initialize the USER BUTTON (Boot button) that will be used to decommission the Matter Node
|
||||
pinMode(buttonPin, INPUT_PULLUP);
|
||||
// Initialize the LED GPIO
|
||||
pinMode(ledPin, OUTPUT);
|
||||
|
||||
WiFi.enableIPv6(true);
|
||||
// Manually connect to WiFi
|
||||
WiFi.begin(ssid, password);
|
||||
// Wait for connection
|
||||
|
|
@ -72,7 +71,7 @@ void setup() {
|
|||
OnOffLight.begin();
|
||||
|
||||
// Associate a callback to the Matter Controller
|
||||
OnOffLight.onChange(matterCB);
|
||||
OnOffLight.onChange(onOffLightCallback);
|
||||
|
||||
// Matter beginning - Last step, after all EndPoints are initialized
|
||||
Matter.begin();
|
||||
|
|
|
|||
|
|
@ -34,13 +34,13 @@
|
|||
// Matter Occupancy Sensor Endpoint
|
||||
MatterOccupancySensor OccupancySensor;
|
||||
|
||||
// set your board USER BUTTON pin here - decommissioning only
|
||||
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
|
||||
|
||||
// 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
|
||||
|
||||
// set your board USER BUTTON pin here - decommissioning only
|
||||
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
|
||||
|
||||
// Button control
|
||||
uint32_t button_time_stamp = 0; // debouncing control
|
||||
bool button_state = false; // false = released | true = pressed
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@
|
|||
#include <WiFi.h>
|
||||
#include <Preferences.h>
|
||||
|
||||
// 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
|
||||
|
||||
// List of Matter Endpoints for this Node
|
||||
// On/Off Light Endpoint
|
||||
MatterOnOffLight OnOffLight;
|
||||
|
|
@ -42,10 +46,6 @@ bool button_state = false; // false = released | true = pres
|
|||
const uint32_t debouceTime = 250; // button debouncing time (ms)
|
||||
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
|
||||
|
||||
// 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
|
||||
|
||||
// Matter Protocol Endpoint Callback
|
||||
bool setLightOnOff(bool state) {
|
||||
Serial.printf("User Callback :: New Light State = %s\r\n", state ? "ON" : "OFF");
|
||||
|
|
@ -67,15 +67,10 @@ void setup() {
|
|||
pinMode(ledPin, OUTPUT);
|
||||
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
delay(100);
|
||||
}
|
||||
|
||||
// We start by connecting to a WiFi network
|
||||
Serial.print("Connecting to ");
|
||||
Serial.println(ssid);
|
||||
// enable IPv6
|
||||
WiFi.enableIPv6(true);
|
||||
// Manually connect to WiFi
|
||||
WiFi.begin(ssid, password);
|
||||
// Wait for connection
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@
|
|||
// On/Off Plugin Endpoint
|
||||
MatterOnOffPlugin OnOffPlugin;
|
||||
|
||||
// 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
|
||||
|
||||
// it will keep last OnOff state stored, using Preferences
|
||||
Preferences matterPref;
|
||||
const char *onOffPrefKey = "OnOff";
|
||||
|
|
@ -41,10 +45,6 @@ uint32_t button_time_stamp = 0; // debouncing control
|
|||
bool button_state = false; // false = released | true = pressed
|
||||
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
|
||||
|
||||
// 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
|
||||
|
||||
// Matter Protocol Endpoint Callback
|
||||
bool setPluginOnOff(bool state) {
|
||||
Serial.printf("User Callback :: New Plugin State = %s\r\n", state ? "ON" : "OFF");
|
||||
|
|
|
|||
|
|
@ -27,13 +27,13 @@
|
|||
// Matter Pressure Sensor Endpoint
|
||||
MatterPressureSensor SimulatedPressureSensor;
|
||||
|
||||
// set your board USER BUTTON pin here - decommissioning button
|
||||
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
|
||||
|
||||
// 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
|
||||
|
||||
// set your board USER BUTTON pin here - decommissioning button
|
||||
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
|
||||
|
||||
// Button control - decommision the Matter Node
|
||||
uint32_t button_time_stamp = 0; // debouncing control
|
||||
bool button_state = false; // false = released | true = pressed
|
||||
|
|
|
|||
|
|
@ -20,6 +20,10 @@
|
|||
// Generic Switch Endpoint - works as a smart button with a single click
|
||||
MatterGenericSwitch SmartButton;
|
||||
|
||||
// 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
|
||||
|
||||
// set your board USER BUTTON pin here
|
||||
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
|
||||
|
||||
|
|
@ -29,24 +33,16 @@ bool button_state = false; // false = released | true = pres
|
|||
const uint32_t debouceTime = 250; // button debouncing time (ms)
|
||||
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
|
||||
|
||||
// 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
|
||||
|
||||
void setup() {
|
||||
// Initialize the USER BUTTON (Boot button) GPIO that will act as a smart button or to decommission the Matter Node
|
||||
pinMode(buttonPin, INPUT_PULLUP);
|
||||
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
delay(100);
|
||||
}
|
||||
|
||||
// We start by connecting to a WiFi network
|
||||
Serial.print("Connecting to ");
|
||||
Serial.println(ssid);
|
||||
// enable IPv6
|
||||
WiFi.enableIPv6(true);
|
||||
|
||||
// Manually connect to WiFi
|
||||
WiFi.begin(ssid, password);
|
||||
// Wait for connection
|
||||
|
|
|
|||
|
|
@ -21,6 +21,10 @@
|
|||
// Color Temperature CW/WW Light Endpoint
|
||||
MatterColorTemperatureLight CW_WW_Light;
|
||||
|
||||
// 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
|
||||
|
||||
// it will keep last OnOff & Brightness state stored, using Preferences
|
||||
Preferences matterPref;
|
||||
const char *onOffPrefKey = "OnOff";
|
||||
|
|
@ -44,10 +48,6 @@ bool button_state = false; // false = released | true = pres
|
|||
const uint32_t debouceTime = 250; // button debouncing time (ms)
|
||||
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
|
||||
|
||||
// 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
|
||||
|
||||
// Set the RGB LED Light based on the current state of the Color Temperature Light
|
||||
bool setLightState(bool state, uint8_t brightness, uint16_t temperature_Mireds) {
|
||||
|
||||
|
|
@ -83,15 +83,10 @@ void setup() {
|
|||
pinMode(ledPin, OUTPUT);
|
||||
|
||||
Serial.begin(115200);
|
||||
while (!Serial) {
|
||||
delay(100);
|
||||
}
|
||||
|
||||
// We start by connecting to a WiFi network
|
||||
Serial.print("Connecting to ");
|
||||
Serial.println(ssid);
|
||||
// enable IPv6
|
||||
WiFi.enableIPv6(true);
|
||||
// Manually connect to WiFi
|
||||
WiFi.begin(ssid, password);
|
||||
// Wait for connection
|
||||
|
|
|
|||
|
|
@ -27,6 +27,10 @@
|
|||
// 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
|
||||
|
||||
// set your board USER BUTTON pin here - decommissioning button
|
||||
const uint8_t buttonPin = BOOT_PIN; // Set your pin here. Using BOOT Button.
|
||||
|
||||
|
|
@ -35,10 +39,6 @@ uint32_t button_time_stamp = 0; // debouncing control
|
|||
bool button_state = false; // false = released | true = pressed
|
||||
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
|
||||
|
||||
// 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 preferred temperature sensor library code here
|
||||
float getSimulatedTemperature() {
|
||||
// The Endpoint implementation keeps an int16_t as internal value information,
|
||||
|
|
|
|||
|
|
@ -206,7 +206,7 @@ bool MatterColorLight::setOnOff(bool newState) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (onOffState == newState) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -256,7 +256,7 @@ bool MatterColorLight::setColorHSV(espHsvColor_t _hsvColor) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (colorHSV.h == _hsvColor.h && colorHSV.s == _hsvColor.s && colorHSV.v == _hsvColor.v) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,16 +37,6 @@ public:
|
|||
bool setColorHSV(espHsvColor_t hsvColor); // returns true if successful
|
||||
espHsvColor_t getColorHSV(); // returns current HSV Color
|
||||
|
||||
// used to update the state of the light using the current Matter Light internal state
|
||||
// It is necessary to set a user callback function using onChange() to handle the physical light state
|
||||
void updateAccessory();
|
||||
|
||||
operator bool(); // returns current on/off light state
|
||||
void operator=(bool state); // turns light on or off
|
||||
|
||||
// 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 On/Off state is changed by the Matter Controller
|
||||
using EndPointOnOffCB = std::function<bool(bool)>;
|
||||
void onChangeOnOff(EndPointOnOffCB onChangeCB) {
|
||||
|
|
@ -64,6 +54,16 @@ public:
|
|||
_onChangeCB = onChangeCB;
|
||||
}
|
||||
|
||||
// used to update the state of the light using the current Matter Light internal state
|
||||
// It is necessary to set a user callback function using onChange() to handle the physical light state
|
||||
void updateAccessory();
|
||||
|
||||
operator bool(); // returns current on/off light state
|
||||
void operator=(bool state); // turns light on or off
|
||||
|
||||
// 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);
|
||||
|
||||
protected:
|
||||
bool started = false;
|
||||
bool onOffState = false; // default initial state is off, but it can be changed by begin(bool)
|
||||
|
|
|
|||
|
|
@ -138,7 +138,7 @@ bool MatterColorTemperatureLight::setOnOff(bool newState) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (onOffState == newState) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -179,7 +179,7 @@ bool MatterColorTemperatureLight::setBrightness(uint8_t newBrightness) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (brightnessLevel == newBrightness) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -210,7 +210,7 @@ bool MatterColorTemperatureLight::setColorTemperature(uint16_t newTemperature) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (colorTemperatureLevel == newTemperature) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,16 +42,6 @@ public:
|
|||
bool setColorTemperature(uint16_t newTemperature); // returns true if successful
|
||||
uint16_t getColorTemperature(); // returns current temperature
|
||||
|
||||
// used to update the state of the light using the current Matter Light internal state
|
||||
// It is necessary to set a user callback function using onChange() to handle the physical light state
|
||||
void updateAccessory();
|
||||
|
||||
operator bool(); // returns current on/off light state
|
||||
void operator=(bool state); // turns light on or off
|
||||
|
||||
// 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 On/Off state is changed by the Matter Controller
|
||||
using EndPointOnOffCB = std::function<bool(bool)>;
|
||||
void onChangeOnOff(EndPointOnOffCB onChangeCB) {
|
||||
|
|
@ -76,6 +66,16 @@ public:
|
|||
_onChangeCB = onChangeCB;
|
||||
}
|
||||
|
||||
// used to update the state of the light using the current Matter Light internal state
|
||||
// It is necessary to set a user callback function using onChange() to handle the physical light state
|
||||
void updateAccessory();
|
||||
|
||||
operator bool(); // returns current on/off light state
|
||||
void operator=(bool state); // turns light on or off
|
||||
|
||||
// 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);
|
||||
|
||||
protected:
|
||||
bool started = false;
|
||||
bool onOffState = false; // default initial state is off, but it can be changed by begin(bool)
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ bool MatterContactSensor::setContact(bool _contactState) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (contactState == _contactState) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ bool MatterDimmableLight::setOnOff(bool newState) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (onOffState == newState) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -155,7 +155,7 @@ bool MatterDimmableLight::setBrightness(uint8_t newBrightness) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (brightnessLevel == newBrightness) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,19 +37,12 @@ public:
|
|||
bool setBrightness(uint8_t newBrightness); // returns true if successful
|
||||
uint8_t getBrightness(); // returns current brightness
|
||||
|
||||
// used to update the state of the light using the current Matter Light internal state
|
||||
// It is necessary to set a user callback function using onChange() to handle the physical light state
|
||||
void updateAccessory();
|
||||
|
||||
operator bool(); // returns current on/off light state
|
||||
void operator=(bool state); // turns light on or off
|
||||
// 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 On/Off state is changed by the Matter Controller
|
||||
using EndPointOnOffCB = std::function<bool(bool)>;
|
||||
void onChangeOnOff(EndPointOnOffCB onChangeCB) {
|
||||
_onChangeOnOffCB = onChangeCB;
|
||||
}
|
||||
|
||||
// User Callback for whenever the Light brightness value [0..255] is changed by the Matter Controller
|
||||
using EndPointBrightnessCB = std::function<bool(uint8_t)>;
|
||||
void onChangeBrightness(EndPointBrightnessCB onChangeCB) {
|
||||
|
|
@ -62,6 +55,15 @@ public:
|
|||
_onChangeCB = onChangeCB;
|
||||
}
|
||||
|
||||
// used to update the state of the light using the current Matter Light internal state
|
||||
// It is necessary to set a user callback function using onChange() to handle the physical light state
|
||||
void updateAccessory();
|
||||
|
||||
operator bool(); // returns current on/off light state
|
||||
void operator=(bool state); // turns light on or off
|
||||
// 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);
|
||||
|
||||
protected:
|
||||
bool started = false;
|
||||
bool onOffState = false; // default initial state is off, but it can be changed by begin(bool)
|
||||
|
|
|
|||
|
|
@ -226,7 +226,7 @@ bool MatterEnhancedColorLight::setOnOff(bool newState) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (onOffState == newState) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -267,7 +267,7 @@ bool MatterEnhancedColorLight::setBrightness(uint8_t newBrightness) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (brightnessLevel == newBrightness) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -298,7 +298,7 @@ bool MatterEnhancedColorLight::setColorTemperature(uint16_t newTemperature) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (colorTemperatureLevel == newTemperature) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -338,7 +338,7 @@ bool MatterEnhancedColorLight::setColorHSV(espHsvColor_t _hsvColor) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (colorHSV.h == _hsvColor.h && colorHSV.s == _hsvColor.s && colorHSV.v == _hsvColor.v) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,16 +47,6 @@ public:
|
|||
bool setColorHSV(espHsvColor_t hsvColor); // returns true if successful
|
||||
espHsvColor_t getColorHSV(); // returns current HSV Color
|
||||
|
||||
// used to update the state of the light using the current Matter Light internal state
|
||||
// It is necessary to set a user callback function using onChange() to handle the physical light state
|
||||
void updateAccessory();
|
||||
|
||||
operator bool(); // returns current on/off light state
|
||||
void operator=(bool state); // turns light on or off
|
||||
|
||||
// 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 On/Off state is changed by the Matter Controller
|
||||
using EndPointOnOffCB = std::function<bool(bool)>;
|
||||
void onChangeOnOff(EndPointOnOffCB onChangeCB) {
|
||||
|
|
@ -87,6 +77,16 @@ public:
|
|||
_onChangeCB = onChangeCB;
|
||||
}
|
||||
|
||||
// used to update the state of the light using the current Matter Light internal state
|
||||
// It is necessary to set a user callback function using onChange() to handle the physical light state
|
||||
void updateAccessory();
|
||||
|
||||
operator bool(); // returns current on/off light state
|
||||
void operator=(bool state); // turns light on or off
|
||||
|
||||
// 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);
|
||||
|
||||
protected:
|
||||
bool started = false;
|
||||
bool onOffState = false; // default initial state is off, but it can be changed by begin(bool)
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ bool MatterFan::setMode(FanMode_t newMode, bool performUpdate) {
|
|||
log_w("Matter Fan device has not begun.");
|
||||
return false;
|
||||
}
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (currentFanMode == newMode) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -159,7 +159,7 @@ bool MatterFan::setSpeedPercent(uint8_t newPercent, bool performUpdate) {
|
|||
log_w("Matter Fan device has not begun.");
|
||||
return false;
|
||||
}
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (currentPercent == newPercent) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -193,7 +193,7 @@ bool MatterFan::setOnOff(bool newState, bool performUpdate) {
|
|||
log_w("Matter Fan device has not begun.");
|
||||
return false;
|
||||
}
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (getOnOff() == newState) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,13 +98,6 @@ public:
|
|||
operator uint8_t() {
|
||||
return getSpeedPercent();
|
||||
}
|
||||
// sets Fan speed percent
|
||||
void operator=(uint8_t speedPercent) {
|
||||
setSpeedPercent(speedPercent);
|
||||
}
|
||||
|
||||
// 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 Fan Mode (state) is changed by the Matter Controller
|
||||
using EndPointModeCB = std::function<bool(FanMode_t)>;
|
||||
|
|
@ -124,6 +117,14 @@ public:
|
|||
_onChangeCB = onChangeCB;
|
||||
}
|
||||
|
||||
// sets Fan speed percent
|
||||
void operator=(uint8_t speedPercent) {
|
||||
setSpeedPercent(speedPercent);
|
||||
}
|
||||
|
||||
// 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);
|
||||
|
||||
protected:
|
||||
bool started = false;
|
||||
uint8_t validFanModes = 0; // bitmap for valid Fan Modes - index of fanModeSequence[]
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ bool MatterHumiditySensor::setRawHumidity(uint16_t _rawHumidity) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (rawHumidity == _rawHumidity) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -98,7 +98,7 @@ bool MatterHumiditySensor::setRawHumidity(uint16_t _rawHumidity) {
|
|||
bool ret;
|
||||
ret = updateAttributeVal(RelativeHumidityMeasurement::Id, RelativeHumidityMeasurement::Attributes::MeasuredValue::Id, &humidityVal);
|
||||
if (!ret) {
|
||||
log_e("Failed to update Fan Speed Percent Attribute.");
|
||||
log_e("Failed to update Humidity Sensor Attribute.");
|
||||
return false;
|
||||
}
|
||||
rawHumidity = _rawHumidity;
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ bool MatterOccupancySensor::setOccupancy(bool _occupancyState) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (occupancyState == _occupancyState) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ bool MatterOnOffLight::setOnOff(bool newState) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (onOffState == newState) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,22 +30,26 @@ public:
|
|||
bool getOnOff(); // returns current light state
|
||||
bool toggle(); // returns true if successful
|
||||
|
||||
// User Callback for whenever the Light state is changed by the Matter Controller
|
||||
using EndPointCB = std::function<bool(bool)>;
|
||||
void onChange(EndPointCB onChangeCB) {
|
||||
_onChangeCB = onChangeCB;
|
||||
}
|
||||
|
||||
// User Callback for whenever the Light On/Off state is changed by the Matter Controller
|
||||
void onChangeOnOff(EndPointCB onChangeCB) {
|
||||
_onChangeOnOffCB = onChangeCB;
|
||||
}
|
||||
|
||||
// used to update the state of the light using the current Matter Light internal state
|
||||
// It is necessary to set a user callback function using onChange() to handle the physical light state
|
||||
void updateAccessory();
|
||||
|
||||
operator bool(); // returns current light state
|
||||
void operator=(bool state); // turns light on or off
|
||||
|
||||
// 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
|
||||
using EndPointCB = std::function<bool(bool)>;
|
||||
void onChange(EndPointCB onChangeCB) {
|
||||
_onChangeCB = onChangeCB;
|
||||
}
|
||||
void onChangeOnOff(EndPointCB onChangeCB) {
|
||||
_onChangeOnOffCB = onChangeCB;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool started = false;
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ bool MatterOnOffPlugin::setOnOff(bool newState) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (onOffState == newState) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,22 +30,26 @@ public:
|
|||
bool getOnOff(); // returns current plugin state
|
||||
bool toggle(); // returns true if successful
|
||||
|
||||
// User Callback for whenever the Plugin state is changed by the Matter Controller
|
||||
using EndPointCB = std::function<bool(bool)>;
|
||||
void onChange(EndPointCB onChangeCB) {
|
||||
_onChangeCB = onChangeCB;
|
||||
}
|
||||
|
||||
// User Callback for whenever the On/Off state is changed by the Matter Controller
|
||||
void onChangeOnOff(EndPointCB onChangeCB) {
|
||||
_onChangeOnOffCB = onChangeCB;
|
||||
}
|
||||
|
||||
// used to update the state of the plugin using the current Matter Plugin internal state
|
||||
// It is necessary to set a user callback function using onChange() to handle the physical plugin state
|
||||
void updateAccessory();
|
||||
|
||||
operator bool(); // returns current plugin state
|
||||
void operator=(bool state); // turns plugin on or off
|
||||
|
||||
// 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 Plugin state is changed by the Matter Controller
|
||||
using EndPointCB = std::function<bool(bool)>;
|
||||
void onChange(EndPointCB onChangeCB) {
|
||||
_onChangeCB = onChangeCB;
|
||||
}
|
||||
void onChangeOnOff(EndPointCB onChangeCB) {
|
||||
_onChangeOnOffCB = onChangeCB;
|
||||
}
|
||||
|
||||
protected:
|
||||
bool started = false;
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ bool MatterPressureSensor::setRawPressure(int16_t _rawPressure) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (rawPressure == _rawPressure) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ public:
|
|||
double getPressure() {
|
||||
return (double)rawPressure;
|
||||
}
|
||||
|
||||
// double conversion operator
|
||||
void operator=(double pressure) {
|
||||
setPressure(pressure);
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ bool MatterTemperatureSensor::setRawTemperature(int16_t _rawTemperature) {
|
|||
return false;
|
||||
}
|
||||
|
||||
// avoid processing the a "no-change"
|
||||
// avoid processing if there was no change
|
||||
if (rawTemperature == _rawTemperature) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -86,7 +86,7 @@ bool MatterTemperatureSensor::setRawTemperature(int16_t _rawTemperature) {
|
|||
bool ret;
|
||||
ret = updateAttributeVal(TemperatureMeasurement::Id, TemperatureMeasurement::Attributes::MeasuredValue::Id, &temperatureVal);
|
||||
if (!ret) {
|
||||
log_e("Failed to update Fan Speed Percent Attribute.");
|
||||
log_e("Failed to update Temperature Sensor Attribute.");
|
||||
return false;
|
||||
}
|
||||
rawTemperature = _rawTemperature;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ public:
|
|||
double getTemperature() {
|
||||
return (double)rawTemperature / 100.0;
|
||||
}
|
||||
|
||||
// double conversion operator
|
||||
void operator=(double temperature) {
|
||||
setTemperature(temperature);
|
||||
|
|
|
|||
Loading…
Reference in a new issue