diff --git a/examples/window-app/nrfconnect/main/WindowCovering.cpp b/examples/window-app/nrfconnect/main/WindowCovering.cpp index 4da326ed16f0b4..f1667045390384 100644 --- a/examples/window-app/nrfconnect/main/WindowCovering.cpp +++ b/examples/window-app/nrfconnect/main/WindowCovering.cpp @@ -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(); + VerifyOrReturn(data != nullptr); + + data->mEndpoint = aEndpoint; + data->mAttributeId = aAttributeId; + + chip::DeviceLayer::PlatformMgr().ScheduleWork(DoPostAttributeChange, reinterpret_cast(data)); +} + +void WindowCovering::DoPostAttributeChange(intptr_t aArg) +{ + AttributeUpdateData * data = reinterpret_cast(aArg); + VerifyOrReturn(data != nullptr); + + PostAttributeChange(data->mEndpoint, data->mAttributeId); +} diff --git a/examples/window-app/nrfconnect/main/ZclCallbacks.cpp b/examples/window-app/nrfconnect/main/ZclCallbacks.cpp index f05dbdec8a9a19..f8407af3ffb07c 100644 --- a/examples/window-app/nrfconnect/main/ZclCallbacks.cpp +++ b/examples/window-app/nrfconnect/main/ZclCallbacks.cpp @@ -75,4 +75,5 @@ void MatterWindowCoveringClusterServerAttributeChangedCallback(const app::Concre break; }; } + WindowCovering::Instance().SchedulePostAttributeChange(attributePath.mEndpointId, attributePath.mAttributeId); } diff --git a/examples/window-app/nrfconnect/main/include/WindowCovering.h b/examples/window-app/nrfconnect/main/include/WindowCovering.h index 9d4d17b548d089..2b5b6ef792d9fd 100644 --- a/examples/window-app/nrfconnect/main/include/WindowCovering.h +++ b/examples/window-app/nrfconnect/main/include/WindowCovering.h @@ -36,6 +36,12 @@ class WindowCovering NONE }; + struct AttributeUpdateData + { + chip::EndpointId mEndpoint; + chip::AttributeId mAttributeId; + }; + WindowCovering(); static WindowCovering & Instance() { @@ -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: @@ -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; diff --git a/src/app/clusters/window-covering-server/window-covering-server.cpp b/src/app/clusters/window-covering-server/window-covering-server.cpp index a4d5d4b7a92f78..79660c45cd4f5f 100644 --- a/src/app/clusters/window-covering-server/window-covering-server.cpp +++ b/src/app/clusters/window-covering-server/window-covering-server.cpp @@ -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 diff --git a/src/app/clusters/window-covering-server/window-covering-server.h b/src/app/clusters/window-covering-server/window-covering-server.h index cf785b61aa19e0..1ef0506ce2ad10 100644 --- a/src/app/clusters/window-covering-server/window-covering-server.h +++ b/src/app/clusters/window-covering-server/window-covering-server.h @@ -137,6 +137,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