feat(matter): moved all identify callback to endpoint.h

This commit is contained in:
Rodrigo Garcia 2024-12-16 10:58:49 -03:00
parent 1dff8bc759
commit 0e22bb4bac
15 changed files with 32 additions and 187 deletions

View file

@ -32,6 +32,10 @@
// Single On/Off Light Endpoint - at least one per node // Single On/Off Light Endpoint - at least one per node
MatterOnOffLight OnOffLight; 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 // Light GPIO that can be controlled by Matter APP
#ifdef LED_BUILTIN #ifdef LED_BUILTIN
const uint8_t ledPin = LED_BUILTIN; const uint8_t ledPin = LED_BUILTIN;
@ -48,15 +52,23 @@ bool button_state = false; // false = released | true = pres
const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission const uint32_t decommissioningTimeout = 5000; // keep the button pressed for 5s, or longer, to decommission
// Matter Protocol Endpoint (On/OFF Light) Callback // Matter Protocol Endpoint (On/OFF Light) Callback
bool matterCB(bool state) { bool onOffLightCallback(bool state) {
digitalWrite(ledPin, state ? HIGH : LOW); digitalWrite(ledPin, state ? HIGH : LOW);
// This callback must return the success state to Matter core // This callback must return the success state to Matter core
return true; return true;
} }
// WiFi is manually set and started bool onIdentifyLightCallback(bool identifyIsActive, uint8_t counter) {
const char *ssid = "your-ssid"; // Change this to your WiFi SSID log_i("Identify Cluster is %s, counter: %d", identifyIsActive ? "Active" : "Inactive", counter);
const char *password = "your-password"; // Change this to your WiFi password if (identifyIsActive) {
// Start Blinking the light
OnOffLight.toggle();
} else {
// Stop Blinking and restore the light to the its last state
OnOffLight.updateAccessory();
}
return true;
}
void setup() { void setup() {
// Initialize the USER BUTTON (Boot button) that will be used to decommission the Matter Node // Initialize the USER BUTTON (Boot button) that will be used to decommission the Matter Node
@ -75,20 +87,10 @@ void setup() {
OnOffLight.begin(); OnOffLight.begin();
// On Identify Callback - Blink the LED // On Identify Callback - Blink the LED
OnOffLight.onIdentify([](bool identifyIsActive, uint8_t counter) { OnOffLight.onIdentify(onIdentifyLightCallback);
log_i("Identify Cluster is %s, counter: %d", identifyIsActive ? "Active" : "Inactive", counter);
if (identifyIsActive) {
// Start Blinking the light
OnOffLight.toggle();
} else {
// Stop Blinking and restore the light to the its last state
OnOffLight.updateAccessory();
}
return true;
});
// Associate a callback to the Matter Controller // Associate a callback to the Matter Controller
OnOffLight.onChange(matterCB); OnOffLight.onChange(onOffLightCallback);
// Matter beginning - Last step, after all EndPoints are initialized // Matter beginning - Last step, after all EndPoints are initialized
Matter.begin(); Matter.begin();

View file

@ -103,8 +103,21 @@ public:
virtual bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val) = 0; virtual bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val) = 0;
// This callback is invoked when clients interact with the Identify Cluster of an specific endpoint. // This callback is invoked when clients interact with the Identify Cluster of an specific endpoint.
virtual bool endpointIdentifyCB(uint16_t endpoint_id, bool identifyIsEnabled, uint8_t identifyCounter) = 0; bool endpointIdentifyCB(uint16_t endpoint_id, bool identifyIsEnabled, uint8_t identifyCounter) {
if (_onEndPointIdentifyCB) {
return _onEndPointIdentifyCB(identifyIsEnabled, identifyCounter);
}
return true;
}
// User callaback for the Identify Cluster functionality
using EndPointIdentifyCB = std::function<bool(bool, uint8_t)>;
void onIdentify(EndPointIdentifyCB onEndPointIdentifyCB) {
_onEndPointIdentifyCB = onEndPointIdentifyCB;
}
protected: protected:
uint16_t endpoint_id = 0; uint16_t endpoint_id = 0;
EndPointIdentifyCB _onEndPointIdentifyCB = NULL;
}; };
#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */ #endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */

View file

@ -46,18 +46,6 @@ public:
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. // 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); bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
// this function is invoked when clients interact with the Identify Cluster of an specific endpoint
bool endpointIdentifyCB(uint16_t endpoint_id, bool identifyIsEnabled, uint8_t identifyCounter) {
if (_onEndPointIdentifyCB) {
return _onEndPointIdentifyCB(identifyIsEnabled, identifyCounter);
}
return true;
}
// User callaback for the Identify Cluster functionality
using EndPointIdentifyCB = std::function<bool(bool, uint8_t)>;
void onIdentify(EndPointIdentifyCB onEndPointIdentifyCB) {
_onEndPointIdentifyCB = onEndPointIdentifyCB;
}
// User Callback for whenever the Light On/Off state is changed by the Matter Controller // User Callback for whenever the Light On/Off state is changed by the Matter Controller
using EndPointOnOffCB = std::function<bool(bool)>; using EndPointOnOffCB = std::function<bool(bool)>;
@ -83,6 +71,5 @@ protected:
EndPointOnOffCB _onChangeOnOffCB = NULL; EndPointOnOffCB _onChangeOnOffCB = NULL;
EndPointRGBColorCB _onChangeColorCB = NULL; EndPointRGBColorCB _onChangeColorCB = NULL;
EndPointCB _onChangeCB = NULL; EndPointCB _onChangeCB = NULL;
EndPointIdentifyCB _onEndPointIdentifyCB = NULL;
}; };
#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */ #endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */

View file

@ -51,18 +51,6 @@ public:
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. // 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); bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
// this function is invoked when clients interact with the Identify Cluster of an specific endpoint
bool endpointIdentifyCB(uint16_t endpoint_id, bool identifyIsEnabled, uint8_t identifyCounter) {
if (_onEndPointIdentifyCB) {
return _onEndPointIdentifyCB(identifyIsEnabled, identifyCounter);
}
return true;
}
// User callaback for the Identify Cluster functionality
using EndPointIdentifyCB = std::function<bool(bool, uint8_t)>;
void onIdentify(EndPointIdentifyCB onEndPointIdentifyCB) {
_onEndPointIdentifyCB = onEndPointIdentifyCB;
}
// User Callback for whenever the Light On/Off state is changed by the Matter Controller // User Callback for whenever the Light On/Off state is changed by the Matter Controller
using EndPointOnOffCB = std::function<bool(bool)>; using EndPointOnOffCB = std::function<bool(bool)>;
@ -97,7 +85,5 @@ protected:
EndPointBrightnessCB _onChangeBrightnessCB = NULL; EndPointBrightnessCB _onChangeBrightnessCB = NULL;
EndPointTemperatureCB _onChangeTemperatureCB = NULL; EndPointTemperatureCB _onChangeTemperatureCB = NULL;
EndPointCB _onChangeCB = NULL; EndPointCB _onChangeCB = NULL;
EndPointIdentifyCB _onEndPointIdentifyCB = NULL;
}; };
#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */ #endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */

View file

@ -46,22 +46,9 @@ public:
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. // 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); bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
// this function is invoked when clients interact with the Identify Cluster of an specific endpoint
bool endpointIdentifyCB(uint16_t endpoint_id, bool identifyIsEnabled, uint8_t identifyCounter) {
if (_onEndPointIdentifyCB) {
return _onEndPointIdentifyCB(identifyIsEnabled, identifyCounter);
}
return true;
}
// User callaback for the Identify Cluster functionality
using EndPointIdentifyCB = std::function<bool(bool, uint8_t)>;
void onIdentify(EndPointIdentifyCB onEndPointIdentifyCB) {
_onEndPointIdentifyCB = onEndPointIdentifyCB;
}
protected: protected:
bool started = false; bool started = false;
bool contactState = false; bool contactState = false;
EndPointIdentifyCB _onEndPointIdentifyCB = NULL;
}; };
#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */ #endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */

View file

@ -46,18 +46,6 @@ public:
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. // 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); bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
// this function is invoked when clients interact with the Identify Cluster of an specific endpoint
bool endpointIdentifyCB(uint16_t endpoint_id, bool identifyIsEnabled, uint8_t identifyCounter) {
if (_onEndPointIdentifyCB) {
return _onEndPointIdentifyCB(identifyIsEnabled, identifyCounter);
}
return true;
}
// User callaback for the Identify Cluster functionality
using EndPointIdentifyCB = std::function<bool(bool, uint8_t)>;
void onIdentify(EndPointIdentifyCB onEndPointIdentifyCB) {
_onEndPointIdentifyCB = onEndPointIdentifyCB;
}
// User Callback for whenever the Light On/Off state is changed by the Matter Controller // User Callback for whenever the Light On/Off state is changed by the Matter Controller
using EndPointOnOffCB = std::function<bool(bool)>; using EndPointOnOffCB = std::function<bool(bool)>;
@ -83,6 +71,5 @@ protected:
EndPointOnOffCB _onChangeOnOffCB = NULL; EndPointOnOffCB _onChangeOnOffCB = NULL;
EndPointBrightnessCB _onChangeBrightnessCB = NULL; EndPointBrightnessCB _onChangeBrightnessCB = NULL;
EndPointCB _onChangeCB = NULL; EndPointCB _onChangeCB = NULL;
EndPointIdentifyCB _onEndPointIdentifyCB = NULL;
}; };
#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */ #endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */

View file

@ -56,18 +56,6 @@ public:
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. // 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); bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
// this function is invoked when clients interact with the Identify Cluster of an specific endpoint
bool endpointIdentifyCB(uint16_t endpoint_id, bool identifyIsEnabled, uint8_t identifyCounter) {
if (_onEndPointIdentifyCB) {
return _onEndPointIdentifyCB(identifyIsEnabled, identifyCounter);
}
return true;
}
// User callaback for the Identify Cluster functionality
using EndPointIdentifyCB = std::function<bool(bool, uint8_t)>;
void onIdentify(EndPointIdentifyCB onEndPointIdentifyCB) {
_onEndPointIdentifyCB = onEndPointIdentifyCB;
}
// User Callback for whenever the Light On/Off state is changed by the Matter Controller // User Callback for whenever the Light On/Off state is changed by the Matter Controller
using EndPointOnOffCB = std::function<bool(bool)>; using EndPointOnOffCB = std::function<bool(bool)>;
@ -110,6 +98,5 @@ protected:
EndPointRGBColorCB _onChangeColorCB = NULL; EndPointRGBColorCB _onChangeColorCB = NULL;
EndPointTemperatureCB _onChangeTemperatureCB = NULL; EndPointTemperatureCB _onChangeTemperatureCB = NULL;
EndPointCB _onChangeCB = NULL; EndPointCB _onChangeCB = NULL;
EndPointIdentifyCB _onEndPointIdentifyCB = NULL;
}; };
#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */ #endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */

View file

@ -105,18 +105,6 @@ public:
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. // 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); bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
// this function is invoked when clients interact with the Identify Cluster of an specific endpoint
bool endpointIdentifyCB(uint16_t endpoint_id, bool identifyIsEnabled, uint8_t identifyCounter) {
if (_onEndPointIdentifyCB) {
return _onEndPointIdentifyCB(identifyIsEnabled, identifyCounter);
}
return true;
}
// User callaback for the Identify Cluster functionality
using EndPointIdentifyCB = std::function<bool(bool, uint8_t)>;
void onIdentify(EndPointIdentifyCB onEndPointIdentifyCB) {
_onEndPointIdentifyCB = onEndPointIdentifyCB;
}
// User Callback for whenever the Fan Mode (state) is changed by the Matter Controller // User Callback for whenever the Fan Mode (state) is changed by the Matter Controller
using EndPointModeCB = std::function<bool(FanMode_t)>; using EndPointModeCB = std::function<bool(FanMode_t)>;
@ -145,7 +133,6 @@ protected:
EndPointModeCB _onChangeModeCB = NULL; EndPointModeCB _onChangeModeCB = NULL;
EndPointSpeedCB _onChangeSpeedCB = NULL; EndPointSpeedCB _onChangeSpeedCB = NULL;
EndPointCB _onChangeCB = NULL; EndPointCB _onChangeCB = NULL;
EndPointIdentifyCB _onEndPointIdentifyCB = NULL;
// bitmap for Fan Sequence Modes (OFF, LOW, MEDIUM, HIGH, AUTO) // bitmap for Fan Sequence Modes (OFF, LOW, MEDIUM, HIGH, AUTO)
static const uint8_t fanSeqModeOff = 0x01; static const uint8_t fanSeqModeOff = 0x01;

View file

@ -32,21 +32,8 @@ public:
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. // 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); bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
// this function is invoked when clients interact with the Identify Cluster of an specific endpoint
bool endpointIdentifyCB(uint16_t endpoint_id, bool identifyIsEnabled, uint8_t identifyCounter) {
if (_onEndPointIdentifyCB) {
return _onEndPointIdentifyCB(identifyIsEnabled, identifyCounter);
}
return true;
}
// User callaback for the Identify Cluster functionality
using EndPointIdentifyCB = std::function<bool(bool, uint8_t)>;
void onIdentify(EndPointIdentifyCB onEndPointIdentifyCB) {
_onEndPointIdentifyCB = onEndPointIdentifyCB;
}
protected: protected:
bool started = false; bool started = false;
EndPointIdentifyCB _onEndPointIdentifyCB = NULL;
}; };
#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */ #endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */

View file

@ -57,18 +57,6 @@ public:
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. // 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); bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
// this function is invoked when clients interact with the Identify Cluster of an specific endpoint
bool endpointIdentifyCB(uint16_t endpoint_id, bool identifyIsEnabled, uint8_t identifyCounter) {
if (_onEndPointIdentifyCB) {
return _onEndPointIdentifyCB(identifyIsEnabled, identifyCounter);
}
return true;
}
// User callaback for the Identify Cluster functionality
using EndPointIdentifyCB = std::function<bool(bool, uint8_t)>;
void onIdentify(EndPointIdentifyCB onEndPointIdentifyCB) {
_onEndPointIdentifyCB = onEndPointIdentifyCB;
}
protected: protected:
bool started = false; bool started = false;
@ -77,6 +65,5 @@ protected:
// internal function to set the raw humidity value (Matter Cluster) // internal function to set the raw humidity value (Matter Cluster)
bool begin(uint16_t _rawHumidity); bool begin(uint16_t _rawHumidity);
bool setRawHumidity(uint16_t _rawHumidity); bool setRawHumidity(uint16_t _rawHumidity);
EndPointIdentifyCB _onEndPointIdentifyCB = NULL;
}; };
#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */ #endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */

View file

@ -57,18 +57,6 @@ public:
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. // 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); bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
// this function is invoked when clients interact with the Identify Cluster of an specific endpoint
bool endpointIdentifyCB(uint16_t endpoint_id, bool identifyIsEnabled, uint8_t identifyCounter) {
if (_onEndPointIdentifyCB) {
return _onEndPointIdentifyCB(identifyIsEnabled, identifyCounter);
}
return true;
}
// User callaback for the Identify Cluster functionality
using EndPointIdentifyCB = std::function<bool(bool, uint8_t)>;
void onIdentify(EndPointIdentifyCB onEndPointIdentifyCB) {
_onEndPointIdentifyCB = onEndPointIdentifyCB;
}
protected: protected:
// bitmap for Occupancy Sensor Types // bitmap for Occupancy Sensor Types
@ -81,6 +69,5 @@ protected:
bool started = false; bool started = false;
bool occupancyState = false; bool occupancyState = false;
EndPointIdentifyCB _onEndPointIdentifyCB = NULL;
}; };
#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */ #endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */

View file

@ -39,18 +39,6 @@ public:
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. // 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); bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
// this function is invoked when clients interact with the Identify Cluster of an specific endpoint
bool endpointIdentifyCB(uint16_t endpoint_id, bool identifyIsEnabled, uint8_t identifyCounter) {
if (_onEndPointIdentifyCB) {
return _onEndPointIdentifyCB(identifyIsEnabled, identifyCounter);
}
return true;
}
// User callaback for the Identify Cluster functionality
using EndPointIdentifyCB = std::function<bool(bool, uint8_t)>;
void onIdentify(EndPointIdentifyCB onEndPointIdentifyCB) {
_onEndPointIdentifyCB = onEndPointIdentifyCB;
}
// User Callback for whenever the Light state is changed by the Matter Controller // User Callback for whenever the Light state is changed by the Matter Controller
using EndPointCB = std::function<bool(bool)>; using EndPointCB = std::function<bool(bool)>;
@ -66,6 +54,5 @@ protected:
bool onOffState = false; // default initial state is off, but it can be changed by begin(bool) bool onOffState = false; // default initial state is off, but it can be changed by begin(bool)
EndPointCB _onChangeCB = NULL; EndPointCB _onChangeCB = NULL;
EndPointCB _onChangeOnOffCB = NULL; EndPointCB _onChangeOnOffCB = NULL;
EndPointIdentifyCB _onEndPointIdentifyCB = NULL;
}; };
#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */ #endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */

View file

@ -39,18 +39,6 @@ public:
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. // 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); bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
// this function is invoked when clients interact with the Identify Cluster of an specific endpoint
bool endpointIdentifyCB(uint16_t endpoint_id, bool identifyIsEnabled, uint8_t identifyCounter) {
if (_onEndPointIdentifyCB) {
return _onEndPointIdentifyCB(identifyIsEnabled, identifyCounter);
}
return true;
}
// User callaback for the Identify Cluster functionality
using EndPointIdentifyCB = std::function<bool(bool, uint8_t)>;
void onIdentify(EndPointIdentifyCB onEndPointIdentifyCB) {
_onEndPointIdentifyCB = onEndPointIdentifyCB;
}
// User Callback for whenever the Plugin state is changed by the Matter Controller // User Callback for whenever the Plugin state is changed by the Matter Controller
using EndPointCB = std::function<bool(bool)>; using EndPointCB = std::function<bool(bool)>;
@ -66,6 +54,5 @@ protected:
bool onOffState = false; // default initial state is off, but it can be changed by begin(bool) bool onOffState = false; // default initial state is off, but it can be changed by begin(bool)
EndPointCB _onChangeCB = NULL; EndPointCB _onChangeCB = NULL;
EndPointCB _onChangeOnOffCB = NULL; EndPointCB _onChangeOnOffCB = NULL;
EndPointIdentifyCB _onEndPointIdentifyCB = NULL;
}; };
#endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */ #endif /* CONFIG_ESP_MATTER_ENABLE_DATA_MODEL */

View file

@ -50,24 +50,11 @@ public:
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. // 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); bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
// this function is invoked when clients interact with the Identify Cluster of an specific endpoint
bool endpointIdentifyCB(uint16_t endpoint_id, bool identifyIsEnabled, uint8_t identifyCounter) {
if (_onEndPointIdentifyCB) {
return _onEndPointIdentifyCB(identifyIsEnabled, identifyCounter);
}
return true;
}
// User callaback for the Identify Cluster functionality
using EndPointIdentifyCB = std::function<bool(bool, uint8_t)>;
void onIdentify(EndPointIdentifyCB onEndPointIdentifyCB) {
_onEndPointIdentifyCB = onEndPointIdentifyCB;
}
protected: protected:
bool started = false; bool started = false;
// implementation keeps pressure in hPa // implementation keeps pressure in hPa
int16_t rawPressure = 0; int16_t rawPressure = 0;
EndPointIdentifyCB _onEndPointIdentifyCB = NULL;
// internal function to set the raw pressure value (Matter Cluster) // internal function to set the raw pressure value (Matter Cluster)
bool setRawPressure(int16_t _rawPressure); bool setRawPressure(int16_t _rawPressure);
bool begin(int16_t _rawPressure); bool begin(int16_t _rawPressure);

View file

@ -51,24 +51,11 @@ public:
// this function is called by Matter internal event processor. It could be overwritten by the application, if necessary. // 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); bool attributeChangeCB(uint16_t endpoint_id, uint32_t cluster_id, uint32_t attribute_id, esp_matter_attr_val_t *val);
// this function is invoked when clients interact with the Identify Cluster of an specific endpoint
bool endpointIdentifyCB(uint16_t endpoint_id, bool identifyIsEnabled, uint8_t identifyCounter) {
if (_onEndPointIdentifyCB) {
return _onEndPointIdentifyCB(identifyIsEnabled, identifyCounter);
}
return true;
}
// User callaback for the Identify Cluster functionality
using EndPointIdentifyCB = std::function<bool(bool, uint8_t)>;
void onIdentify(EndPointIdentifyCB onEndPointIdentifyCB) {
_onEndPointIdentifyCB = onEndPointIdentifyCB;
}
protected: protected:
bool started = false; bool started = false;
// implementation keeps temperature in 1/100th of a degree, any temperature unit // implementation keeps temperature in 1/100th of a degree, any temperature unit
int16_t rawTemperature = 0; int16_t rawTemperature = 0;
EndPointIdentifyCB _onEndPointIdentifyCB = NULL;
// internal function to set the raw temperature value (Matter Cluster) // internal function to set the raw temperature value (Matter Cluster)
bool setRawTemperature(int16_t _rawTemperature); bool setRawTemperature(int16_t _rawTemperature);
bool begin(int16_t _rawTemperature); bool begin(int16_t _rawTemperature);