You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sld601-matter-application-development/matter-application-cluster-logic.md
+18-13Lines changed: 18 additions & 13 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,7 +42,7 @@ Enable the On/Off cluster (0x0006) as both a Server and a Client. This should ad
42
42
43
43
By configuring both a client and server for the On/Off cluster, the device should be able to transmit On/Off commands and store On/Off attributes. For this guide, we will mainly focus on the attribute storing and manipulation.
44
44
45
-
Save the .zap file. The tool will automatically generate the necessary code files for your application, reflecting the new cluster configuration. For more information, reference [ZCL Advanced Platform (ZAP) Tool for Matter](https://docs.silabs.com/matter/2.3.1/matter-references/matter-zap).
45
+
Save the .zap file. The tool will automatically generate the necessary code files for your application, reflecting the new cluster configuration. For more information, reference [ZCL Advanced Platform (ZAP) Tool for Matter](https://docs.silabs.com/matter/latest/matter-references/matter-zap).
46
46
47
47
48
48
## Step 3: Analyze the Auto-generated Code
@@ -58,28 +58,30 @@ You will also notice that following the cluster enablement, a corresponding comp
58
58
59
59
## Step 4: Add Application Logic
60
60
61
-
Locate your projects src/AppTask.cpp file. This file acts as the central hub for application-specific logic, initialization, and event processing in a Matter application on Silicon Labs platforms. We will begin by creating two helper functions, one that starts a one-shot timer to expire in 10 seconds and invokes a handler, **OnOffTmrExpiryHandler**.
61
+
Locate your projects src/AppTask.cpp file. This file acts as the central hub for application-specific logic, initialization, and event processing in a Matter application on Silicon Labs platforms. We will begin by creating two helper functions, one that starts a one-shot timer to expire in 10 seconds and the handler function, **OnOffTmrExpiryHandler**.
This function will have to be defined in AppTask.h as well.
99
+
This function will have to be defined in AppTask.h as well as part of the AppTask class.
98
100
99
-
Now locate the MatterPostAttributeChangeCallback() function in the src/ZclCallbacks.cpp file. This function is called by the application framework after it changes an attribute value.
100
-
Modify it as below:
101
+
Now locate the MatterPostAttributeChangeCallback() function in the src/ZclCallbacks.cpp file. This function is called by the application framework after it changes an attribute value. Since we are modifying OnOff attribute in the OnOffTmrExpiryHandler(), this callback will be used to re-initiate the timer such that the attribute is continuously being toggled. To do this, the AppTask::OnOffAttributeWriteStartTimer() can be called. OnOffAttributeWriteStartTimer() is part of the AppTask context. In order to implement this function in the we must first get the AppTask instance with AppTask::GetAppTask(). To do this, modify the MatterPostAttributeChangeCallback() as shown below:
Make sure to #include "AppTask.h" at the top of ZclCallbacks.cpp to call the AppTask:: function.
118
+
Make sure to #include "AppTask.h" at the top of ZclCallbacks.cpp to call the AppTask::GetAppTask() function. For more information on the AppTask, reference AppTask.h.
118
119
119
-
The last step is to add a call to OnOffTmrStart() at the end of the AppTask::AppInit() function to start the attribute write sequence.
120
+
The last step is to add a call to OnOffTmrStart() at the end of the AppTask::AppInit() function to start the attribute write sequence. Below is the code flow:
121
+
122
+

123
+
124
+
In the flow chart above, OnOffAttributeWriteStartTimer() calls OnOffTmrStart() to restart the timer.
0 commit comments