| |
| |
| #include "AppEvent.h" |
| #include "AppTask.h" |
| #include <app/clusters/identify-server/identify-server.h> |
| |
| using namespace ::chip::app; |
| using namespace ::chip::DeviceLayer; |
| |
| Clusters::Identify::EffectIdentifierEnum sIdentifyEffect = Clusters::Identify::EffectIdentifierEnum::kStopEffect; |
| |
| /********************************************************** |
| * Identify Callbacks |
| *********************************************************/ |
| |
| namespace { |
| void OnTriggerIdentifyEffectCompleted(chip::System::Layer * systemLayer, void * appState) |
| { |
| sIdentifyEffect = Clusters::Identify::EffectIdentifierEnum::kStopEffect; |
| } |
| } // namespace |
| |
| void OnTriggerIdentifyEffect(Identify * identify) |
| { |
| sIdentifyEffect = identify->mCurrentEffectIdentifier; |
| |
| if (identify->mEffectVariant != Clusters::Identify::EffectVariantEnum::kDefault) |
| { |
| ChipLogDetail(AppServer, "Identify Effect Variant unsupported. Using default"); |
| } |
| |
| switch (sIdentifyEffect) |
| { |
| case Clusters::Identify::EffectIdentifierEnum::kBlink: |
| case Clusters::Identify::EffectIdentifierEnum::kBreathe: |
| case Clusters::Identify::EffectIdentifierEnum::kOkay: |
| case Clusters::Identify::EffectIdentifierEnum::kChannelChange: |
| SystemLayer().ScheduleLambda([identify] { |
| (void) chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(5), OnTriggerIdentifyEffectCompleted, |
| identify); |
| }); |
| break; |
| case Clusters::Identify::EffectIdentifierEnum::kFinishEffect: |
| SystemLayer().ScheduleLambda([identify] { |
| (void) chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerIdentifyEffectCompleted, identify); |
| (void) chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(1), OnTriggerIdentifyEffectCompleted, |
| identify); |
| }); |
| break; |
| case Clusters::Identify::EffectIdentifierEnum::kStopEffect: |
| SystemLayer().ScheduleLambda( |
| [identify] { (void) chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerIdentifyEffectCompleted, identify); }); |
| sIdentifyEffect = Clusters::Identify::EffectIdentifierEnum::kStopEffect; |
| break; |
| default: |
| ChipLogProgress(Zcl, "No identifier effect"); |
| } |
| } |
| |
| Identify gIdentify = { |
| chip::EndpointId{ 1 }, |
| [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); }, |
| [](Identify *) { ChipLogProgress(Zcl, "onIdentifyStop"); }, |
| Clusters::Identify::IdentifyTypeEnum::kVisibleIndicator, |
| OnTriggerIdentifyEffect, |
| }; |