Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fan Control]Circular callback fix #36406

Conversation

lpbeliveau-silabs
Copy link
Contributor

Proposed fix to circumvent the circular callback when a percentage change happens with a max speed value below 100.

Basically, currently, with a max speed of 10, what happens is:
Attribute write PercentSetting 25
PercentSetting Change to 25 Callback
SpeedSetting Change 3 Callback
PercentSetting Change 30 Callback.

Added AttributeAccessInterface and used it in All-cluster app.

Copy link

Review changes with  SemanticDiff

@lpbeliveau-silabs lpbeliveau-silabs changed the title [Fan Control]Circular callback fix (#85) [Fan Control]Circular callback fix Nov 6, 2024
@lpbeliveau-silabs lpbeliveau-silabs force-pushed the bugfix/circular_callback_fan_control branch from 0a34a55 to 1453f46 Compare November 6, 2024 21:07
Copy link

github-actions bot commented Nov 6, 2024

PR #36406: Size comparison from 2af51b0 to 1453f46

Full report (68 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
platform target config section 2af51b0 1453f46 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1351454 1351454 0 0.0
RAM 104080 104080 0 0.0
bl702 lighting-app bl702+eth FLASH 649058 649058 0 0.0
RAM 25321 25321 0 0.0
bl702+wifi FLASH 826638 826638 0 0.0
RAM 14053 14053 0 0.0
bl706+mfd+rpc+littlefs FLASH 1056298 1056298 0 0.0
RAM 23901 23901 0 0.0
bl702l lighting-app bl702l+mfd+littlefs FLASH 976464 976464 0 0.0
RAM 16556 16556 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 837924 837924 0 0.0
RAM 123628 123628 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 823696 823696 0 0.0
RAM 125516 125516 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 770436 770436 0 0.0
RAM 113984 113984 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 754640 754640 0 0.0
RAM 114192 114192 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 627382 625814 -1568 -0.2
RAM 205780 205780 0 0.0
lock CC3235SF_LAUNCHXL FLASH 667126 667126 0 0.0
RAM 205932 205932 0 0.0
cyw30739 light CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 679585 679585 0 0.0
RAM 78684 78684 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 699437 699437 0 0.0
RAM 81324 81324 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 699437 699437 0 0.0
RAM 81324 81324 0 0.0
CYW930739M2EVB-02 unknown 2040 2040 0 0.0
FLASH 656373 656373 0 0.0
RAM 73752 73752 0 0.0
light-switch CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 616289 616289 0 0.0
RAM 71644 71644 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 635917 635917 0 0.0
RAM 74188 74188 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 635917 635917 0 0.0
RAM 74188 74188 0 0.0
lock CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 635753 635753 0 0.0
RAM 74692 74692 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 655469 655469 0 0.0
RAM 77236 77236 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 655469 655469 0 0.0
RAM 77236 77236 0 0.0
thermostat CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 611157 611157 0 0.0
RAM 68772 68772 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 631009 631009 0 0.0
RAM 71412 71412 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 631009 631009 0 0.0
RAM 71412 71412 0 0.0
efr32 lock-app BRD4187C FLASH 928556 928556 0 0.0
RAM 160164 160164 0 0.0
BRD4338a FLASH 743448 743448 0 0.0
RAM 233288 233288 0 0.0
window-app BRD4187C FLASH 1018584 1018584 0 0.0
RAM 128260 128260 0 0.0
esp32 all-clusters-app c3devkit DRAM 95328 95328 0 0.0
FLASH 1539912 1540378 466 0.0
IRAM 82542 82542 0 0.0
m5stack DRAM 116256 116256 0 0.0
FLASH 1549102 1549510 408 0.0
IRAM 117039 117039 0 0.0
linux air-purifier-app debug unknown 4688 4688 0 0.0
FLASH 2698549 2698203 -346 -0.0
RAM 129616 129616 0 0.0
all-clusters-app debug unknown 5528 5528 0 0.0
FLASH 5990696 5992814 2118 0.0
RAM 523872 523936 64 0.0
all-clusters-minimal-app debug unknown 5424 5424 0 0.0
FLASH 5328004 5327658 -346 -0.0
RAM 242448 242448 0 0.0
bridge-app debug unknown 5408 5408 0 0.0
FLASH 4670416 4670416 0 0.0
RAM 218384 218384 0 0.0
chip-tool debug unknown 5960 5960 0 0.0
FLASH 12871656 12871656 0 0.0
RAM 584466 584466 0 0.0
chip-tool-ipv6only arm64 unknown 21400 21400 0 0.0
FLASH 11001840 11001840 0 0.0
RAM 635368 635368 0 0.0
fabric-admin debug unknown 5792 5792 0 0.0
FLASH 11278901 11278901 0 0.0
RAM 584922 584922 0 0.0
fabric-bridge-app debug unknown 4632 4632 0 0.0
FLASH 4497280 4497280 0 0.0
RAM 205368 205368 0 0.0
fabric-sync debug unknown 4856 4856 0 0.0
FLASH 5303941 5303941 0 0.0
RAM 466864 466864 0 0.0
lighting-app debug+rpc+ui unknown 6056 6056 0 0.0
FLASH 5609185 5609185 0 0.0
RAM 228520 228520 0 0.0
lock-app debug unknown 5344 5344 0 0.0
FLASH 4719890 4719890 0 0.0
RAM 204520 204520 0 0.0
ota-provider-app debug unknown 4720 4720 0 0.0
FLASH 4345322 4345322 0 0.0
RAM 198240 198240 0 0.0
ota-requestor-app debug unknown 4656 4656 0 0.0
FLASH 4483724 4483724 0 0.0
RAM 202808 202808 0 0.0
shell debug unknown 4216 4216 0 0.0
FLASH 3013773 3011469 -2304 -0.1
RAM 160336 160336 0 0.0
thermostat-no-ble arm64 unknown 9440 9440 0 0.0
FLASH 4089072 4089072 0 0.0
RAM 242904 242904 0 0.0
tv-app debug unknown 5624 5624 0 0.0
FLASH 5942037 5942037 0 0.0
RAM 596304 596304 0 0.0
tv-casting-app debug unknown 5208 5208 0 0.0
FLASH 11078813 11078813 0 0.0
RAM 694536 694536 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 915000 915448 448 0.0
RAM 143281 143281 0 0.0
nrf7002dk_nrf5340_cpuapp FLASH 887560 887828 268 0.0
RAM 141468 141468 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 849064 847576 -1488 -0.2
RAM 142189 142189 0 0.0
nxp contact k32w0+release FLASH 584112 584112 0 0.0
RAM 71044 71044 0 0.0
mcxw71+release FLASH 598656 598656 0 0.0
RAM 63144 63144 0 0.0
light k32w0+release FLASH 611156 611156 0 0.0
RAM 70436 70436 0 0.0
k32w1+release FLASH 684952 684952 0 0.0
RAM 48776 48776 0 0.0
lock mcxw71+release FLASH 748488 748488 0 0.0
RAM 67300 67300 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1642828 1643332 504 0.0
RAM 212056 212056 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1550356 1550100 -256 -0.0
RAM 208856 208856 0 0.0
light cy8ckit_062s2_43012 FLASH 1466956 1466956 0 0.0
RAM 200840 200840 0 0.0
lock cy8ckit_062s2_43012 FLASH 1464684 1464684 0 0.0
RAM 225200 225200 0 0.0
qpg lighting-app qpg6105+debug FLASH 662240 662240 0 0.0
RAM 105380 105380 0 0.0
lock-app qpg6105+debug FLASH 620196 620196 0 0.0
RAM 99832 99832 0 0.0
stm32 light STM32WB5MM-DK FLASH 483056 483056 0 0.0
RAM 144844 144844 0 0.0
telink bridge-app tlsr9258a FLASH 684318 684318 0 0.0
RAM 91528 91528 0 0.0
contact-sensor-app tlsr9528a_retention FLASH 622362 622362 0 0.0
RAM 50464 50464 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 710292 710292 0 0.0
RAM 73804 73804 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 628478 628478 0 0.0
RAM 145384 145384 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 814302 814302 0 0.0
RAM 100004 100004 0 0.0
tizen all-clusters-app arm unknown 4932 4936 4 0.1
FLASH 1721588 1722676 1088 0.1
RAM 90608 90640 32 0.0
chip-tool-ubsan arm unknown 10820 10820 0 0.0
FLASH 18006430 18006430 0 0.0
RAM 7857244 7857244 0 0.0

@lpbeliveau-silabs lpbeliveau-silabs force-pushed the bugfix/circular_callback_fan_control branch from 7caabc8 to e0a0c8b Compare November 7, 2024 14:33
Copy link

github-actions bot commented Nov 7, 2024

PR #36406: Size comparison from 9961bb8 to e0a0c8b

Full report (68 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
platform target config section 9961bb8 e0a0c8b change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1349836 1349836 0 0.0
RAM 104080 104080 0 0.0
bl702 lighting-app bl702+eth FLASH 649336 649336 0 0.0
RAM 25321 25321 0 0.0
bl702+wifi FLASH 826660 826660 0 0.0
RAM 14053 14053 0 0.0
bl706+mfd+rpc+littlefs FLASH 1054864 1054864 0 0.0
RAM 23893 23893 0 0.0
bl702l lighting-app bl702l+mfd+littlefs FLASH 976486 976486 0 0.0
RAM 16556 16556 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 837948 837948 0 0.0
RAM 123628 123628 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 823736 823736 0 0.0
RAM 125516 125516 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 770476 770476 0 0.0
RAM 113984 113984 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 754680 754680 0 0.0
RAM 114192 114192 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 627446 625878 -1568 -0.2
RAM 205780 205780 0 0.0
lock CC3235SF_LAUNCHXL FLASH 667190 667190 0 0.0
RAM 205932 205932 0 0.0
cyw30739 light CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 679617 679617 0 0.0
RAM 78684 78684 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 699461 699461 0 0.0
RAM 81324 81324 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 699461 699461 0 0.0
RAM 81324 81324 0 0.0
CYW930739M2EVB-02 unknown 2040 2040 0 0.0
FLASH 656405 656405 0 0.0
RAM 73752 73752 0 0.0
light-switch CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 616345 616345 0 0.0
RAM 71644 71644 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 635973 635973 0 0.0
RAM 74188 74188 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 635973 635973 0 0.0
RAM 74188 74188 0 0.0
lock CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 635801 635801 0 0.0
RAM 74692 74692 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 655509 655509 0 0.0
RAM 77236 77236 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 655509 655509 0 0.0
RAM 77236 77236 0 0.0
thermostat CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 611197 611197 0 0.0
RAM 68772 68772 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 631049 631049 0 0.0
RAM 71412 71412 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 631049 631049 0 0.0
RAM 71412 71412 0 0.0
efr32 lock-app BRD4187C FLASH 927508 927508 0 0.0
RAM 160160 160160 0 0.0
BRD4338a FLASH 743576 743576 0 0.0
RAM 233288 233288 0 0.0
window-app BRD4187C FLASH 1018616 1018616 0 0.0
RAM 128260 128260 0 0.0
esp32 all-clusters-app c3devkit DRAM 95328 95328 0 0.0
FLASH 1539952 1540398 446 0.0
IRAM 82542 82542 0 0.0
m5stack DRAM 116256 116256 0 0.0
FLASH 1549122 1549534 412 0.0
IRAM 117039 117039 0 0.0
linux air-purifier-app debug unknown 4688 4688 0 0.0
FLASH 2698659 2698449 -210 -0.0
RAM 129616 129616 0 0.0
all-clusters-app debug unknown 5528 5528 0 0.0
FLASH 5990636 5992744 2108 0.0
RAM 523872 523936 64 0.0
all-clusters-minimal-app debug unknown 5424 5424 0 0.0
FLASH 5328114 5327786 -328 -0.0
RAM 242448 242448 0 0.0
bridge-app debug unknown 5408 5408 0 0.0
FLASH 4670524 4670524 0 0.0
RAM 218384 218384 0 0.0
chip-tool debug unknown 5960 5960 0 0.0
FLASH 12871764 12871764 0 0.0
RAM 584466 584466 0 0.0
chip-tool-ipv6only arm64 unknown 21400 21400 0 0.0
FLASH 11002032 11002032 0 0.0
RAM 635368 635368 0 0.0
fabric-admin debug unknown 5784 5784 0 0.0
FLASH 11276847 11276847 0 0.0
RAM 584890 584890 0 0.0
fabric-bridge-app debug unknown 4664 4664 0 0.0
FLASH 4494792 4494792 0 0.0
RAM 205368 205368 0 0.0
fabric-sync debug unknown 4856 4856 0 0.0
FLASH 5304053 5304053 0 0.0
RAM 466864 466864 0 0.0
lighting-app debug+rpc+ui unknown 6072 6072 0 0.0
FLASH 5607025 5607025 0 0.0
RAM 228520 228520 0 0.0
lock-app debug unknown 5344 5344 0 0.0
FLASH 4719998 4719998 0 0.0
RAM 204520 204520 0 0.0
ota-provider-app debug unknown 4720 4720 0 0.0
FLASH 4345430 4345430 0 0.0
RAM 198240 198240 0 0.0
ota-requestor-app debug unknown 4656 4656 0 0.0
FLASH 4483832 4483832 0 0.0
RAM 202808 202808 0 0.0
shell debug unknown 4216 4216 0 0.0
FLASH 3013709 3011421 -2288 -0.1
RAM 160336 160336 0 0.0
thermostat-no-ble arm64 unknown 9440 9440 0 0.0
FLASH 4089264 4089264 0 0.0
RAM 242904 242904 0 0.0
tv-app debug unknown 5624 5624 0 0.0
FLASH 5942149 5942149 0 0.0
RAM 596304 596304 0 0.0
tv-casting-app debug unknown 5208 5208 0 0.0
FLASH 11078909 11078909 0 0.0
RAM 694536 694536 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 915028 915476 448 0.0
RAM 143281 143281 0 0.0
nrf7002dk_nrf5340_cpuapp FLASH 887560 887816 256 0.0
RAM 141468 141468 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 849108 847616 -1492 -0.2
RAM 142189 142189 0 0.0
nxp contact k32w0+release FLASH 584144 584144 0 0.0
RAM 71044 71044 0 0.0
mcxw71+release FLASH 598688 598688 0 0.0
RAM 63144 63144 0 0.0
light k32w0+release FLASH 611204 611204 0 0.0
RAM 70436 70436 0 0.0
k32w1+release FLASH 685000 685000 0 0.0
RAM 48776 48776 0 0.0
lock mcxw71+release FLASH 748528 748528 0 0.0
RAM 67300 67300 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1642780 1643284 504 0.0
RAM 212056 212056 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1550420 1550148 -272 -0.0
RAM 208856 208856 0 0.0
light cy8ckit_062s2_43012 FLASH 1466924 1466924 0 0.0
RAM 200840 200840 0 0.0
lock cy8ckit_062s2_43012 FLASH 1464748 1464748 0 0.0
RAM 225200 225200 0 0.0
qpg lighting-app qpg6105+debug FLASH 662264 662264 0 0.0
RAM 105380 105380 0 0.0
lock-app qpg6105+debug FLASH 620236 620236 0 0.0
RAM 99832 99832 0 0.0
stm32 light STM32WB5MM-DK FLASH 483088 483088 0 0.0
RAM 144844 144844 0 0.0
telink bridge-app tlsr9258a FLASH 684366 684366 0 0.0
RAM 91528 91528 0 0.0
contact-sensor-app tlsr9528a_retention FLASH 622410 622410 0 0.0
RAM 50464 50464 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 710340 710340 0 0.0
RAM 73804 73804 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 628536 628536 0 0.0
RAM 145384 145384 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 814262 814262 0 0.0
RAM 100004 100004 0 0.0
tizen all-clusters-app arm unknown 4932 4936 4 0.1
FLASH 1721556 1722636 1080 0.1
RAM 90608 90640 32 0.0
chip-tool-ubsan arm unknown 10820 10820 0 0.0
FLASH 1800658 1800658 0 0.0
RAM 7857276 7857276 0 0.0

@mergify mergify bot merged commit 078bc30 into project-chip:master Nov 7, 2024
67 checks passed
VerifyOrReturn(Status::Success == status,
ChipLogError(Zcl, "Failed to get SpeedMax with error: 0x%02x", to_underlying(status)));
// Adjust PercentSetting from a speed value change for SpeedSetting only when the SpeedSetting change was received
// on a write command, not when it was changed by the server or the app logic. This avoids circular logic such as
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no "write command" in Matter. That's Zigbee terminology. Please fix this comment to make sense for Matter.

status = PercentSetting::Set(attributePath.mEndpointId, percentSetting);
VerifyOrReturn(Status::Success == status,
ChipLogError(Zcl, "Failed to set PercentSetting with error: 0x%02x", to_underlying(status)));
// If SpeedSetting is set to 0, the server SHALL set the FanMode attribute value to Off.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why are we doing that both in here and in MatterFanControlClusterServerAttributeChangedCallback? That seems pretty odd to me.

ChipLogError(Zcl, "Failed to get PercentSetting with error: 0x%02x", to_underlying(status)));
CHIP_ERROR FanControlAttributeAccessInterface::Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder)
{
Status status = Status::Success;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this declared here, not where it's actually used?

#include <app/util/af-types.h>

namespace chip {
namespace app {
namespace Clusters {
namespace FanControl {

class FanControlAttributeAccessInterface : public AttributeAccessInterface
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs documentation. The fact that all users of this cluster now need to inherit from this thing, and will get non-spec-compliant behavior unless they do (which is an API break, by the way), is extremely non-obvious.

What should have happened here is that if we need an AttributeAccessInterface registered for proper cluster functionality then the cluster needs to register it. And if we have things the app needs to handle, the cluster should be calling out into the app for those things, via the relevant delegate interface, instead of the app implementing AttributeAccessInterface directly.

@@ -24,6 +24,7 @@
#include <app-common/zap-generated/cluster-objects.h>
#include <app-common/zap-generated/ids/Attributes.h>
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/AttributeAccessInterfaceRegistry.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this used anywhere in this file?

soares-sergio added a commit to soares-sergio/connectedhomeip that referenced this pull request Nov 12, 2024
mergify bot pushed a commit that referenced this pull request Nov 12, 2024
@lpbeliveau-silabs lpbeliveau-silabs deleted the bugfix/circular_callback_fan_control branch December 10, 2024 14:06
yyzhong-g pushed a commit to yyzhong-g/connectedhomeip that referenced this pull request Dec 12, 2024
yyzhong-g pushed a commit to yyzhong-g/connectedhomeip that referenced this pull request Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants