Skip to content

Commit

Permalink
[nrf fromtee] [nrfconnect] Fixed window covering bug in updating clus…
Browse files Browse the repository at this point in the history
…ter attributes (project-chip#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]>
(cherry picked from commit a3fdd05)
  • Loading branch information
kkasperczyk-no authored and Damian-Nordic committed Jun 6, 2022
1 parent 55b65c0 commit fc6a52c
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 6 deletions.
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 @@ -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
Expand Down

0 comments on commit fc6a52c

Please sign in to comment.