Skip to content

Commit

Permalink
WindowCovering: Add Identify cluster support to the EFR32 demo (#12087)
Browse files Browse the repository at this point in the history
* WC: Add Winking identify

* WindowCovering: Add: Identify Cluster in ZAP config

* Dev: Add winking on the LED Status for identification

* Rename Identify attribute to CamelCase

* ZAP : Update zzz generated

* WC: Move include

* Restyled by clang-format

* Restyled by clang-format

Co-authored-by: Restyled.io <commits@restyled.io>
  • Loading branch information
2 people authored and pull[bot] committed Nov 22, 2021
1 parent 3bc5675 commit 1238008
Show file tree
Hide file tree
Showing 10 changed files with 194 additions and 15 deletions.
3 changes: 3 additions & 0 deletions examples/window-app/common/include/WindowApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ class WindowApp
ProvisionedStateChanged,
ConnectivityStateChanged,
BLEConnectionsChanged,
WinkOff,
WinkOn,
};

struct Event
Expand Down Expand Up @@ -136,6 +138,7 @@ class WindowApp
bool isThreadProvisioned = false;
bool isThreadEnabled = false;
bool haveBLEConnections = false;
bool isWinking = false;
};

Cover & GetCover();
Expand Down
44 changes: 44 additions & 0 deletions examples/window-app/common/src/WindowApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <AppConfig.h>
#include <WindowApp.h>
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/clusters/identify-server/identify-server.h>
#include <app/clusters/window-covering-server/window-covering-server.h>
#include <app/server/Server.h>
#include <app/util/af.h>
Expand All @@ -29,6 +30,49 @@ using namespace ::chip::Credentials;
using namespace ::chip::DeviceLayer;
using namespace chip::app::Clusters::WindowCovering;

inline void OnTriggerEffectCompleted(chip::System::Layer * systemLayer, void * appState)
{
WindowApp::Instance().PostEvent(WindowApp::EventId::WinkOff);
}

void OnTriggerEffect(Identify * identify)
{
EmberAfIdentifyEffectIdentifier sIdentifyEffect = identify->mCurrentEffectIdentifier;

ChipLogProgress(Zcl, "IDENTFY OnTriggerEffect");

if (identify->mCurrentEffectIdentifier == EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE)
{
ChipLogProgress(Zcl, "IDENTIFY_EFFECT_IDENTIFIER_CHANNEL_CHANGE - Not supported, use effect varriant %d",
identify->mEffectVariant);
sIdentifyEffect = static_cast<EmberAfIdentifyEffectIdentifier>(identify->mEffectVariant);
}

switch (sIdentifyEffect)
{
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BLINK:
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_BREATHE:
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_OKAY:
WindowApp::Instance().PostEvent(WindowApp::EventId::WinkOn);
(void) chip::DeviceLayer::SystemLayer().StartTimer(chip::System::Clock::Seconds16(5), OnTriggerEffectCompleted, identify);
break;
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_FINISH_EFFECT:
case EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT:
(void) chip::DeviceLayer::SystemLayer().CancelTimer(OnTriggerEffectCompleted, identify);
break;
default:
ChipLogProgress(Zcl, "No identifier effect");
}
}

Identify gIdentify = {
chip::EndpointId{ 1 },
[](Identify *) { ChipLogProgress(Zcl, "onIdentifyStart"); },
[](Identify *) { ChipLogProgress(Zcl, "onIdentifyStop"); },
EMBER_ZCL_IDENTIFY_IDENTIFY_TYPE_VISIBLE_LED,
OnTriggerEffect,
};

void WindowApp::Timer::Timeout()
{
mIsActive = false;
Expand Down
11 changes: 10 additions & 1 deletion examples/window-app/common/src/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,16 @@ using namespace ::chip::app::Clusters::WindowCovering;
void MatterPostAttributeChangeCallback(const app::ConcreteAttributePath & attributePath, uint8_t mask, uint8_t type, uint16_t size,
uint8_t * value)
{
if (attributePath.mClusterId == Id)
if (attributePath.mClusterId == app::Clusters::Identify::Id)
{
ChipLogProgress(Zcl, "Identify cluster ID: " ChipLogFormatMEI " Type: %" PRIu8 " Value: %" PRIu16 ", length %" PRIu16,
ChipLogValueMEI(attributePath.mAttributeId), type, *value, size);
}
else if (attributePath.mClusterId == Id)
{
ChipLogProgress(Zcl, "Window cluster ID: " ChipLogFormatMEI, ChipLogValueMEI(attributePath.mClusterId));
}
else
{
ChipLogProgress(Zcl, "Unknown cluster ID: " ChipLogFormatMEI, ChipLogValueMEI(attributePath.mClusterId));
}
Expand Down
33 changes: 28 additions & 5 deletions examples/window-app/common/window-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -3426,15 +3426,23 @@
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 1
"outgoing": 0
},
{
"name": "IdentifyQuery",
"code": 1,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 1
"outgoing": 0
},
{
"name": "TriggerEffect",
"code": 64,
"mfgCode": null,
"source": "client",
"incoming": 1,
"outgoing": 0
}
],
"attributes": [
Expand All @@ -3461,20 +3469,20 @@
"mfgCode": null,
"define": "IDENTIFY_CLUSTER",
"side": "server",
"enabled": 0,
"enabled": 1,
"commands": [
{
"name": "IdentifyQueryResponse",
"code": 0,
"mfgCode": null,
"source": "server",
"incoming": 1,
"incoming": 0,
"outgoing": 1
}
],
"attributes": [
{
"name": "identify time",
"name": "IdentifyTime",
"code": 0,
"mfgCode": null,
"side": "server",
Expand All @@ -3488,6 +3496,21 @@
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "IdentifyType",
"code": 1,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x0",
"reportable": 0,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ClusterRevision",
"code": 65533,
Expand Down
12 changes: 11 additions & 1 deletion examples/window-app/efr32/src/WindowAppImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,12 @@ void WindowAppImpl::DispatchEvent(const WindowApp::Event & event)
UpdateLEDs();
UpdateLCD();
break;

case EventId::WinkOn:
case EventId::WinkOff:
mState.isWinking = (EventId::WinkOn == event.mId);
UpdateLEDs();
break;
case EventId::ConnectivityStateChanged:
case EventId::BLEConnectionsChanged:
UpdateLEDs();
Expand Down Expand Up @@ -298,7 +304,11 @@ void WindowAppImpl::UpdateLEDs()
}
else
{
if (mState.isThreadProvisioned && mState.isThreadEnabled)
if (mState.isWinking)
{
mStatusLED.Blink(200, 200);
}
else if (mState.isThreadProvisioned && mState.isThreadEnabled)
{
mStatusLED.Blink(950, 50);
}
Expand Down
60 changes: 60 additions & 0 deletions zzz_generated/window-app/zap-generated/IMClusterCommandHandler.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions zzz_generated/window-app/zap-generated/callback-stub.cpp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 23 additions & 8 deletions zzz_generated/window-app/zap-generated/endpoint_config.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1238008

Please sign in to comment.