Skip to content

Commit 1645676

Browse files
jmartinez-silabspull[bot]
authored andcommitted
Enable Identify cluster in Lighting-app, Perform actions on EFR32 (#11672)
* Add identify cluster to light app * regen rebase regen * instantiate identify object in lighting app task, Use status led for Identify standard and trigger effects restyle * Add missing file on mbed and telink CMakeList
1 parent 4cff829 commit 1645676

File tree

10 files changed

+192
-13
lines changed

10 files changed

+192
-13
lines changed

examples/lighting-app/efr32/src/AppTask.cpp

+68-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include <app-common/zap-generated/attribute-id.h>
2828
#include <app-common/zap-generated/attribute-type.h>
2929
#include <app-common/zap-generated/cluster-id.h>
30+
#include <app/clusters/identify-server/identify-server.h>
3031
#include <app/server/OnboardingCodesUtil.h>
3132
#include <app/server/Server.h>
3233
#include <app/util/attribute-storage.h>
@@ -75,11 +76,58 @@ bool sIsThreadProvisioned = false;
7576
bool sIsThreadEnabled = false;
7677
bool sHaveBLEConnections = false;
7778

79+
EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT;
80+
7881
uint8_t sAppEventQueueBuffer[APP_EVENT_QUEUE_SIZE * sizeof(AppEvent)];
7982
StaticQueue_t sAppEventQueueStruct;
8083

8184
StackType_t appStack[APP_TASK_STACK_SIZE / sizeof(StackType_t)];
8285
StaticTask_t appTaskStruct;
86+
87+
inline void OnTriggerEffectCompleted(chip::System::Layer * systemLayer, void * appState)
88+
{
89+
sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT;
90+
}
91+
92+
void OnTriggerEffect(Identify * identify)
93+
{
94+
sIdentifyEffect = identify->mCurrentEffectIdentifier;
95+
96+
if (identify->mCurrentEffectIdentifier == EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE)
97+
{
98+
ChipLogProgress(Zcl, "IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE - Not supported, use effect varriant %d",
99+
identify->mEffectVariant);
100+
sIdentifyEffect = static_cast<EmberAfIdentifyEffectIdentifier>(identify->mEffectVariant);
101+
}
102+
103+
switch (sIdentifyEffect)
104+
{
105+
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK:
106+
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE:
107+
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY:
108+
(void) chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(5), OnTriggerEffectCompleted, identify);
109+
break;
110+
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT:
111+
(void) chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerEffectCompleted, identify);
112+
(void) chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(1), OnTriggerEffectCompleted, identify);
113+
break;
114+
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT:
115+
(void) chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerEffectCompleted, identify);
116+
sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT;
117+
break;
118+
default:
119+
ChipLogProgress(Zcl, "No identifier effect");
120+
}
121+
}
122+
123+
Identify gIdentify = {
124+
chip::EndpointId{ 1 },
125+
[](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); },
126+
[](Identify *) { ChipLogProgress(Zcl, "onIdentifyStop"); },
127+
EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED,
128+
OnTriggerEffect,
129+
};
130+
83131
} // namespace
84132

85133
using namespace chip::TLV;
@@ -212,7 +260,26 @@ void AppTask::AppTaskMain(void * pvParameter)
212260
// Otherwise, blink the LED ON for a very short time.
213261
if (sAppTask.mFunction != kFunction_FactoryReset)
214262
{
215-
if (sIsThreadProvisioned && sIsThreadEnabled)
263+
if (gIdentify.mActive)
264+
{
265+
sStatusLED.Blink(250, 250);
266+
}
267+
if (sIdentifyEffect != EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT)
268+
{
269+
if (sIdentifyEffect == EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK)
270+
{
271+
sStatusLED.Blink(50, 50);
272+
}
273+
if (sIdentifyEffect == EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE)
274+
{
275+
sStatusLED.Blink(1000, 1000);
276+
}
277+
if (sIdentifyEffect == EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY)
278+
{
279+
sStatusLED.Blink(300, 700);
280+
}
281+
}
282+
else if (sIsThreadProvisioned && sIsThreadEnabled)
216283
{
217284
sStatusLED.Blink(950, 50);
218285
}

examples/lighting-app/efr32/src/ZclCallbacks.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ void MatterPostAttributeChangeCallback(const chip::app::ConcreteAttributePath &
6767

6868
// WIP Apply attribute change to Light
6969
}
70+
else if (clusterId == Identify::Id)
71+
{
72+
ChipLogProgress(Zcl, "Identify attribute ID: " ChipLogFormatMEI " Type: %" PRIu8 " Value: %" PRIu16 ", length %" PRIu16,
73+
ChipLogValueMEI(attributeId), type, *value, size);
74+
}
7075
}
7176

7277
/** @brief OnOff Cluster Init

examples/lighting-app/lighting-common/lighting-app.zap

+16-1
Original file line numberDiff line numberDiff line change
@@ -3675,7 +3675,7 @@
36753675
"mfgCode": null,
36763676
"define": "IDENTIFY_CLUSTER",
36773677
"side": "server",
3678-
"enabled": 0,
3678+
"enabled": 1,
36793679
"commands": [
36803680
{
36813681
"name": "IdentifyQueryResponse",
@@ -3702,6 +3702,21 @@
37023702
"maxInterval": 65344,
37033703
"reportableChange": 0
37043704
},
3705+
{
3706+
"name": "identify type",
3707+
"code": 1,
3708+
"mfgCode": null,
3709+
"side": "server",
3710+
"included": 1,
3711+
"storageOption": "RAM",
3712+
"singleton": 0,
3713+
"bounded": 0,
3714+
"defaultValue": "0x0",
3715+
"reportable": 0,
3716+
"minInterval": 1,
3717+
"maxInterval": 65534,
3718+
"reportableChange": 0
3719+
},
37053720
{
37063721
"name": "ClusterRevision",
37073722
"code": 65533,

examples/lighting-app/mbed/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ target_sources(${APP_TARGET} PRIVATE
7979
${CHIP_ROOT}/src/app/clusters/basic/basic.cpp
8080
${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp
8181
${CHIP_ROOT}/src/app/clusters/descriptor/descriptor.cpp
82+
${CHIP_ROOT}/src/app/clusters/identify-server/identify-server.cpp
8283
${CHIP_ROOT}/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp
8384
${CHIP_ROOT}/src/app/clusters/ethernet_network_diagnostics_server/ethernet_network_diagnostics_server.cpp
8485
${CHIP_ROOT}/src/app/clusters/thread_network_diagnostics_server/thread_network_diagnostics_server.cpp

examples/lighting-app/telink/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ target_sources(app PRIVATE
7979
${CHIP_ROOT}/src/app/clusters/basic/basic.cpp
8080
${CHIP_ROOT}/src/app/clusters/bindings/bindings.cpp
8181
${CHIP_ROOT}/src/app/clusters/descriptor/descriptor.cpp
82+
${CHIP_ROOT}/src/app/clusters/identify-server/identify-server.cpp
8283
${CHIP_ROOT}/src/app/clusters/diagnostic-logs-server/diagnostic-logs-server.cpp
8384
${CHIP_ROOT}/src/app/clusters/ethernet_network_diagnostics_server/ethernet_network_diagnostics_server.cpp
8485
${CHIP_ROOT}/src/app/clusters/thread_network_diagnostics_server/thread_network_diagnostics_server.cpp

zzz_generated/lighting-app/zap-generated/IMClusterCommandHandler.cpp

+60
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zzz_generated/lighting-app/zap-generated/PluginApplicationCallbacks.h

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

zzz_generated/lighting-app/zap-generated/callback-stub.cpp

+8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)