Skip to content

Commit

Permalink
[nrfconnect] Fixed window covering bug in updating cluster attributes (
Browse files Browse the repository at this point in the history
…#18752)

* [nrfconnect] Fixed window covering bug in updating cluster attributes

Nrfconnect window covering example doesn't update window covering
cluster attributes properly.

* Moved PostAttributeChange method from window-covering-server.cpp
to header.
* Called PostAttributeChange method in nrfconnect implementation
of MatterWindowCoveringClusterServerAttributeChangedCallback
* Changed mode default value from 0x14 to 0.

* [nrfconnect] window-app: do not block in chip attribute changed callback.

Signed-off-by: Marcin Kajor <[email protected]>

Co-authored-by: Marcin Kajor <[email protected]>
  • Loading branch information
kkasperczyk-no and markaj-nordic authored May 25, 2022
1 parent ebc8c17 commit a3fdd05
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 11 deletions.
2 changes: 1 addition & 1 deletion examples/window-app/common/window-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -1900,7 +1900,7 @@ endpoint 1 {
persist attribute installedClosedLimitLift default = 0xFFFF;
persist attribute installedOpenLimitTilt;
persist attribute installedClosedLimitTilt default = 0xFFFF;
persist attribute mode default = 0x14;
persist attribute mode;
ram attribute safetyStatus;
ram attribute featureMap default = 0x0017;
ram attribute clusterRevision default = 5;
Expand Down
7 changes: 4 additions & 3 deletions examples/window-app/common/window-app.zap
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"featureLevel": 70,
"featureLevel": 71,
"creator": "zap",
"keyValuePairs": [
{
Expand Down Expand Up @@ -8844,7 +8844,7 @@
"storageOption": "NVM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x14",
"defaultValue": "0x0",
"reportable": 1,
"minInterval": 0,
"maxInterval": 65344,
Expand Down Expand Up @@ -10518,5 +10518,6 @@
"endpointVersion": 1,
"deviceIdentifier": 514
}
]
],
"log": []
}
19 changes: 19 additions & 0 deletions examples/window-app/nrfconnect/main/WindowCovering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -322,3 +322,22 @@ uint8_t WindowCovering::PositionToBrightness(uint16_t aPosition, MoveType aMoveT

return Percent100thsToValue(pwmLimits, aPosition);
}

void WindowCovering::SchedulePostAttributeChange(chip::EndpointId aEndpoint, chip::AttributeId aAttributeId)
{
AttributeUpdateData * data = chip::Platform::New<AttributeUpdateData>();
VerifyOrReturn(data != nullptr);

data->mEndpoint = aEndpoint;
data->mAttributeId = aAttributeId;

chip::DeviceLayer::PlatformMgr().ScheduleWork(DoPostAttributeChange, reinterpret_cast<intptr_t>(data));
}

void WindowCovering::DoPostAttributeChange(intptr_t aArg)
{
AttributeUpdateData * data = reinterpret_cast<AttributeUpdateData *>(aArg);
VerifyOrReturn(data != nullptr);

PostAttributeChange(data->mEndpoint, data->mAttributeId);
}
1 change: 1 addition & 0 deletions examples/window-app/nrfconnect/main/ZclCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,5 @@ void MatterWindowCoveringClusterServerAttributeChangedCallback(const app::Concre
break;
};
}
WindowCovering::Instance().SchedulePostAttributeChange(attributePath.mEndpointId, attributePath.mAttributeId);
}
8 changes: 8 additions & 0 deletions examples/window-app/nrfconnect/main/include/WindowCovering.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ class WindowCovering
NONE
};

struct AttributeUpdateData
{
chip::EndpointId mEndpoint;
chip::AttributeId mAttributeId;
};

WindowCovering();
static WindowCovering & Instance()
{
Expand All @@ -49,6 +55,7 @@ class WindowCovering
MoveType GetMoveType() { return mCurrentUIMoveType; }
void PositionLEDUpdate(MoveType aMoveType);

static void SchedulePostAttributeChange(chip::EndpointId aEndpoint, chip::AttributeId aAttributeId);
static constexpr chip::EndpointId Endpoint() { return 1; };

private:
Expand All @@ -63,6 +70,7 @@ class WindowCovering
static void DriveCurrentLiftPosition(intptr_t);
static void DriveCurrentTiltPosition(intptr_t);
static void MoveTimerTimeoutCallback(k_timer * aTimer);
static void DoPostAttributeChange(intptr_t aArg);

MoveType mCurrentUIMoveType;
LEDWidget mLiftLED;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -587,12 +587,6 @@ EmberEventControl * ConfigureFakeMotionEventControl(EndpointId endpoint)
return controller;
}

/**
* @brief PostAttributeChange is called when an Attribute is modified
*
* @param[in] endpoint
* @param[in] attributeId
*/
void PostAttributeChange(chip::EndpointId endpoint, chip::AttributeId attributeId)
{
// all-cluster-app: simulation for the CI testing
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,14 @@ void TiltPositionSet(chip::EndpointId endpoint, NPercent100ths position);

EmberAfStatus GetMotionLockStatus(chip::EndpointId endpoint);

/**
* @brief PostAttributeChange is called when an Attribute is modified
*
* @param[in] endpoint
* @param[in] attributeId
*/
void PostAttributeChange(chip::EndpointId endpoint, chip::AttributeId attributeId);

} // namespace WindowCovering
} // namespace Clusters
} // namespace app
Expand Down
2 changes: 1 addition & 1 deletion 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.

0 comments on commit a3fdd05

Please sign in to comment.