Skip to content

Commit

Permalink
[nrfconnect] Added handling Identify TriggerEffect command
Browse files Browse the repository at this point in the history
All-clusters-app for nrfconnect doesn't support handling
TriggerEffect command, despite it is enabled in the .zap
configuration.

Added method that handles TriggerEffect callback.
  • Loading branch information
kkasperczyk-no committed Jun 13, 2022
1 parent c1e1d01 commit 33bd9c0
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
39 changes: 39 additions & 0 deletions examples/all-clusters-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
#include <app-common/zap-generated/cluster-id.h>
#include <app/clusters/identify-server/identify-server.h>
#include <app/util/attribute-storage.h>

#include <credentials/DeviceAttestationCredsProvider.h>
Expand Down Expand Up @@ -63,6 +64,16 @@ k_timer sFunctionTimer;

chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider;

constexpr EndpointId kIdentifyEndpointId = 1;

Identify sIdentify = {
chip::EndpointId{ kIdentifyEndpointId },
[](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStart"); },
[](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStop"); },
EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_NONE,
OnIdentifyTriggerEffect,
};

} // namespace

constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE;
Expand All @@ -82,6 +93,34 @@ constexpr uint32_t kOff_ms{ 950 };
} // namespace StatusLed
} // namespace LedConsts

namespace {

void OnIdentifyTriggerEffect(Identify * identify)
{
ChipLogProgress(Zcl, "OnIdentifyTriggerEffect");
switch (identify->mCurrentEffectIdentifier)
{
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK:
ChipLogProgress(Zcl, "Effect: EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK");
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE:
ChipLogProgress(Zcl, "Effect: EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE");
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY:
ChipLogProgress(Zcl, "Effect: EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY");
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE:
ChipLogProgress(Zcl, "Effect: EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE");
break;
default:
ChipLogProgress(Zcl, "Effect: No identifier effect");
break;
}
return;
}

}; // namespace

CHIP_ERROR AppTask::Init()
{
// Initialize CHIP stack
Expand Down
43 changes: 43 additions & 0 deletions examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include <app-common/zap-generated/attribute-id.h>
#include <app-common/zap-generated/attribute-type.h>
#include <app-common/zap-generated/cluster-id.h>
#include <app/clusters/identify-server/identify-server.h>
#include <app/util/attribute-storage.h>

#include <credentials/DeviceAttestationCredsProvider.h>
Expand All @@ -53,10 +54,24 @@ using namespace ::chip::DeviceLayer;
LOG_MODULE_DECLARE(app, CONFIG_MATTER_LOG_LEVEL);
K_MSGQ_DEFINE(sAppEventQueue, sizeof(AppEvent), APP_EVENT_QUEUE_SIZE, alignof(AppEvent));

namespace {

static LEDWidget sStatusLED;
static UnusedLedsWrapper<3> sUnusedLeds{ { DK_LED2, DK_LED3, DK_LED4 } };
static k_timer sFunctionTimer;

constexpr EndpointId kIdentifyEndpointId = 1;

Identify sIdentify = {
chip::EndpointId{ kIdentifyEndpointId },
[](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStart"); },
[](Identify *) { ChipLogProgress(Zcl, "OnIdentifyStop"); },
EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_NONE,
OnIdentifyTriggerEffect,
};

} // namespace

constexpr EndpointId kNetworkCommissioningEndpointSecondary = 0xFFFE;

namespace LedConsts {
Expand All @@ -74,6 +89,34 @@ constexpr uint32_t kOff_ms{ 950 };
} // namespace StatusLed
} // namespace LedConsts

namespace {

void OnIdentifyTriggerEffect(Identify * identify)
{
ChipLogProgress(Zcl, "OnIdentifyTriggerEffect");
switch (identify->mCurrentEffectIdentifier)
{
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK:
ChipLogProgress(Zcl, "Effect: EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK");
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE:
ChipLogProgress(Zcl, "Effect: EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE");
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY:
ChipLogProgress(Zcl, "Effect: EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY");
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE:
ChipLogProgress(Zcl, "Effect: EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE");
break;
default:
ChipLogProgress(Zcl, "Effect: No identifier effect");
break;
}
return;
}

}; // namespace

CHIP_ERROR AppTask::Init()
{
// Initialize CHIP stack
Expand Down

0 comments on commit 33bd9c0

Please sign in to comment.