Skip to content

Commit a3fdd05

Browse files
[nrfconnect] Fixed window covering bug in updating cluster 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]>
1 parent ebc8c17 commit a3fdd05

File tree

8 files changed

+42
-11
lines changed

8 files changed

+42
-11
lines changed

examples/window-app/common/window-app.matter

+1-1
Original file line numberDiff line numberDiff line change
@@ -1900,7 +1900,7 @@ endpoint 1 {
19001900
persist attribute installedClosedLimitLift default = 0xFFFF;
19011901
persist attribute installedOpenLimitTilt;
19021902
persist attribute installedClosedLimitTilt default = 0xFFFF;
1903-
persist attribute mode default = 0x14;
1903+
persist attribute mode;
19041904
ram attribute safetyStatus;
19051905
ram attribute featureMap default = 0x0017;
19061906
ram attribute clusterRevision default = 5;

examples/window-app/common/window-app.zap

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"featureLevel": 70,
2+
"featureLevel": 71,
33
"creator": "zap",
44
"keyValuePairs": [
55
{
@@ -8844,7 +8844,7 @@
88448844
"storageOption": "NVM",
88458845
"singleton": 0,
88468846
"bounded": 0,
8847-
"defaultValue": "0x14",
8847+
"defaultValue": "0x0",
88488848
"reportable": 1,
88498849
"minInterval": 0,
88508850
"maxInterval": 65344,
@@ -10518,5 +10518,6 @@
1051810518
"endpointVersion": 1,
1051910519
"deviceIdentifier": 514
1052010520
}
10521-
]
10521+
],
10522+
"log": []
1052210523
}

examples/window-app/nrfconnect/main/WindowCovering.cpp

+19
Original file line numberDiff line numberDiff line change
@@ -322,3 +322,22 @@ uint8_t WindowCovering::PositionToBrightness(uint16_t aPosition, MoveType aMoveT
322322

323323
return Percent100thsToValue(pwmLimits, aPosition);
324324
}
325+
326+
void WindowCovering::SchedulePostAttributeChange(chip::EndpointId aEndpoint, chip::AttributeId aAttributeId)
327+
{
328+
AttributeUpdateData * data = chip::Platform::New<AttributeUpdateData>();
329+
VerifyOrReturn(data != nullptr);
330+
331+
data->mEndpoint = aEndpoint;
332+
data->mAttributeId = aAttributeId;
333+
334+
chip::DeviceLayer::PlatformMgr().ScheduleWork(DoPostAttributeChange, reinterpret_cast<intptr_t>(data));
335+
}
336+
337+
void WindowCovering::DoPostAttributeChange(intptr_t aArg)
338+
{
339+
AttributeUpdateData * data = reinterpret_cast<AttributeUpdateData *>(aArg);
340+
VerifyOrReturn(data != nullptr);
341+
342+
PostAttributeChange(data->mEndpoint, data->mAttributeId);
343+
}

examples/window-app/nrfconnect/main/ZclCallbacks.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,5 @@ void MatterWindowCoveringClusterServerAttributeChangedCallback(const app::Concre
7575
break;
7676
};
7777
}
78+
WindowCovering::Instance().SchedulePostAttributeChange(attributePath.mEndpointId, attributePath.mAttributeId);
7879
}

examples/window-app/nrfconnect/main/include/WindowCovering.h

+8
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ class WindowCovering
3636
NONE
3737
};
3838

39+
struct AttributeUpdateData
40+
{
41+
chip::EndpointId mEndpoint;
42+
chip::AttributeId mAttributeId;
43+
};
44+
3945
WindowCovering();
4046
static WindowCovering & Instance()
4147
{
@@ -49,6 +55,7 @@ class WindowCovering
4955
MoveType GetMoveType() { return mCurrentUIMoveType; }
5056
void PositionLEDUpdate(MoveType aMoveType);
5157

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

5461
private:
@@ -63,6 +70,7 @@ class WindowCovering
6370
static void DriveCurrentLiftPosition(intptr_t);
6471
static void DriveCurrentTiltPosition(intptr_t);
6572
static void MoveTimerTimeoutCallback(k_timer * aTimer);
73+
static void DoPostAttributeChange(intptr_t aArg);
6674

6775
MoveType mCurrentUIMoveType;
6876
LEDWidget mLiftLED;

src/app/clusters/window-covering-server/window-covering-server.cpp

-6
Original file line numberDiff line numberDiff line change
@@ -587,12 +587,6 @@ EmberEventControl * ConfigureFakeMotionEventControl(EndpointId endpoint)
587587
return controller;
588588
}
589589

590-
/**
591-
* @brief PostAttributeChange is called when an Attribute is modified
592-
*
593-
* @param[in] endpoint
594-
* @param[in] attributeId
595-
*/
596590
void PostAttributeChange(chip::EndpointId endpoint, chip::AttributeId attributeId)
597591
{
598592
// all-cluster-app: simulation for the CI testing

src/app/clusters/window-covering-server/window-covering-server.h

+8
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,14 @@ void TiltPositionSet(chip::EndpointId endpoint, NPercent100ths position);
139139

140140
EmberAfStatus GetMotionLockStatus(chip::EndpointId endpoint);
141141

142+
/**
143+
* @brief PostAttributeChange is called when an Attribute is modified
144+
*
145+
* @param[in] endpoint
146+
* @param[in] attributeId
147+
*/
148+
void PostAttributeChange(chip::EndpointId endpoint, chip::AttributeId attributeId);
149+
142150
} // namespace WindowCovering
143151
} // namespace Clusters
144152
} // namespace app

zzz_generated/window-app/zap-generated/endpoint_config.h

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)