36
36
#include < app-common/zap-generated/attribute-id.h>
37
37
#include < app-common/zap-generated/cluster-id.h>
38
38
#include < app/Command.h>
39
+ #include < app/clusters/identify-server/identify-server.h>
39
40
#include < app/server/Dnssd.h>
40
41
#include < app/util/basic-types.h>
41
42
#include < app/util/util.h>
@@ -49,9 +50,48 @@ using namespace ::chip::Inet;
49
50
using namespace ::chip::System;
50
51
using namespace ::chip::DeviceLayer;
51
52
52
- uint32_t identifyTimerCount;
53
53
constexpr uint32_t kIdentifyTimerDelayMS = 250 ;
54
54
55
+ void OnIdentifyTriggerEffect (Identify * identify)
56
+ {
57
+ switch (identify->mCurrentEffectIdentifier )
58
+ {
59
+ case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK:
60
+ statusLED1.Blink (kIdentifyTimerDelayMS * 2 );
61
+ ChipLogProgress (Zcl, " EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK" );
62
+ break ;
63
+ case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE:
64
+ ChipLogProgress (Zcl, " EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE" );
65
+ break ;
66
+ case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY:
67
+ ChipLogProgress (Zcl, " EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY" );
68
+ break ;
69
+ case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE:
70
+ ChipLogProgress (Zcl, " EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE" );
71
+ break ;
72
+ default :
73
+ ChipLogProgress (Zcl, " No identifier effect" );
74
+ break ;
75
+ }
76
+ return ;
77
+ }
78
+
79
+ Identify gIdentify0 = {
80
+ chip::EndpointId{ 0 },
81
+ [](Identify *) { ChipLogProgress (Zcl, " onIdentifyStart" ); },
82
+ [](Identify *) { ChipLogProgress (Zcl, " onIdentifyStop" ); },
83
+ EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED,
84
+ OnIdentifyTriggerEffect,
85
+ };
86
+
87
+ Identify gIdentify1 = {
88
+ chip::EndpointId{ 1 },
89
+ [](Identify *) { ChipLogProgress (Zcl, " onIdentifyStart" ); },
90
+ [](Identify *) { ChipLogProgress (Zcl, " onIdentifyStop" ); },
91
+ EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED,
92
+ OnIdentifyTriggerEffect,
93
+ };
94
+
55
95
void DeviceCallbacks::DeviceEventCallback (const ChipDeviceEvent * event, intptr_t arg)
56
96
{
57
97
switch (event->Type )
@@ -108,10 +148,6 @@ void DeviceCallbacks::PostAttributeChangeCallback(EndpointId endpointId, Cluster
108
148
OnOnOffPostAttributeChangeCallback (endpointId, attributeId, value);
109
149
break ;
110
150
111
- case ZCL_IDENTIFY_CLUSTER_ID:
112
- OnIdentifyPostAttributeChangeCallback (endpointId, attributeId, value);
113
- break ;
114
-
115
151
case ZCL_LEVEL_CONTROL_CLUSTER_ID:
116
152
OnLevelControlAttributeChangeCallback (endpointId, attributeId, value);
117
153
break ;
@@ -218,37 +254,6 @@ void DeviceCallbacks::OnColorControlAttributeChangeCallback(EndpointId endpointI
218
254
}
219
255
#endif
220
256
221
- void IdentifyTimerHandler (Layer * systemLayer, void * appState)
222
- {
223
- statusLED1.Animate ();
224
-
225
- if (identifyTimerCount)
226
- {
227
- systemLayer->StartTimer (Clock::Milliseconds32 (kIdentifyTimerDelayMS ), IdentifyTimerHandler, appState);
228
- // Decrement the timer count.
229
- identifyTimerCount--;
230
- }
231
- }
232
-
233
- void DeviceCallbacks::OnIdentifyPostAttributeChangeCallback (EndpointId endpointId, AttributeId attributeId, uint8_t * value)
234
- {
235
- VerifyOrExit (attributeId == ZCL_IDENTIFY_TIME_ATTRIBUTE_ID, ESP_LOGI (TAG, " Unhandled Attribute ID: '0x%04x" , attributeId));
236
- VerifyOrExit (endpointId == 1 , ESP_LOGE (TAG, " Unexpected EndPoint ID: `0x%02x'" , endpointId));
237
-
238
- statusLED1.Blink (kIdentifyTimerDelayMS * 2 );
239
-
240
- // timerCount represents the number of callback executions before we stop the timer.
241
- // value is expressed in seconds and the timer is fired every 250ms, so just multiply value by 4.
242
- // Also, we want timerCount to be odd number, so the ligth state ends in the same state it starts.
243
- identifyTimerCount = (*value) * 4 ;
244
-
245
- DeviceLayer::SystemLayer ().CancelTimer (IdentifyTimerHandler, this );
246
- DeviceLayer::SystemLayer ().StartTimer (Clock::Milliseconds32 (kIdentifyTimerDelayMS ), IdentifyTimerHandler, this );
247
-
248
- exit :
249
- return ;
250
- }
251
-
252
257
bool emberAfBasicClusterMfgSpecificPingCallback (chip::app::Command * commandObj)
253
258
{
254
259
emberAfSendDefaultResponse (emberAfCurrentCommand (), EMBER_ZCL_STATUS_SUCCESS);
0 commit comments