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

Make global attributes be part of IM instead of part of DataModel::Provider #37345

Open
wants to merge 15 commits into
base: master
Choose a base branch
from

Conversation

andy31415
Copy link
Contributor

@andy31415 andy31415 commented Jan 31, 2025

Since this part is already in metadata, this makes code cleaner and easier to maintain (and easier to write providers).

Fixes #36486

Testing

Unit tests were updated.
Since PR #37338 merged, the changes in TestReadInteraction should be reasonable readable in what got added (generally the global list attributes).

@andy31415 andy31415 requested a review from a team as a code owner January 31, 2025 18:57
Copy link

Review changes with  SemanticDiff


for (auto entry : buffer)
{
if (!addedExtraGlobals && entry.attributeId > lastGlobalId)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am somewhat unclear why we sort these...this was taken from the existing implementation, but it does seem to make the code more complex. Is the spec requiring sorting?

Copy link
Contributor

Choose a reason for hiding this comment

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

Spec does not require sorting. ember attribute metadata is sorted.

When implementing attributes not in metadata we kept the "act as if they are still in metadata" behavior. But yes, we can probably nix this part and just put these things at the end, always.

Copy link

PR #37345: Size comparison from 435583e to f56ae26

Full report (1 build for stm32)
platform target config section 435583e f56ae26 change % change
stm32 light STM32WB5MM-DK FLASH 482600 482656 56 0.0
RAM 144672 144672 0 0.0

Copy link

github-actions bot commented Jan 31, 2025

PR #37345: Size comparison from 435583e to 94b4cf5

Full report (3 builds for cc32xx, stm32)
platform target config section 435583e 94b4cf5 change % change
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 538445 538477 32 0.0
RAM 205192 205192 0 0.0
lock CC3235SF_LAUNCHXL FLASH 572309 572333 24 0.0
RAM 205344 205344 0 0.0
stm32 light STM32WB5MM-DK FLASH 482600 482656 56 0.0
RAM 144672 144672 0 0.0

Copy link

github-actions bot commented Jan 31, 2025

PR #37345: Size comparison from 435583e to 1fe7070

Full report (72 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
platform target config section 435583e 1fe7070 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1093546 1093578 32 0.0
RAM 103298 103298 0 0.0
bl702 lighting-app bl702+eth FLASH 650158 650194 36 0.0
RAM 25265 25265 0 0.0
bl702+wifi FLASH 828066 828102 36 0.0
RAM 13981 13981 0 0.0
bl706+mfd+rpc+littlefs FLASH 1056626 1056406 -220 -0.0
RAM 23861 23861 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 888060 888096 36 0.0
RAM 18504 18504 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 971046 971082 36 0.0
RAM 16368 16368 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 838000 838064 64 0.0
RAM 123464 123464 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 823420 823484 64 0.0
RAM 125344 125344 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 770644 770716 72 0.0
RAM 113804 113804 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 754888 754976 88 0.0
RAM 114012 114012 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 538445 538477 32 0.0
RAM 205192 205192 0 0.0
lock CC3235SF_LAUNCHXL FLASH 572309 572333 24 0.0
RAM 205344 205344 0 0.0
cyw30739 light CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 679409 679433 24 0.0
RAM 78532 78532 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 699261 699285 24 0.0
RAM 81172 81172 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 699261 699285 24 0.0
RAM 81172 81172 0 0.0
CYW930739M2EVB-02 unknown 2040 2040 0 0.0
FLASH 656189 656221 32 0.0
RAM 73600 73600 0 0.0
light-switch CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 615793 615825 32 0.0
RAM 71516 71516 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 635421 635461 40 0.0
RAM 74060 74060 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 635421 635461 40 0.0
RAM 74060 74060 0 0.0
lock CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 635273 635297 24 0.0
RAM 74524 74524 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 654981 655005 24 0.0
RAM 77068 77068 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 654981 655005 24 0.0
RAM 77068 77068 0 0.0
thermostat CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 611709 611725 16 0.0
RAM 68612 68612 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 631569 631585 16 0.0
RAM 71252 71252 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 631569 631585 16 0.0
RAM 71252 71252 0 0.0
efr32 lock-app BRD4187C FLASH 936200 936256 56 0.0
RAM 159872 159872 0 0.0
BRD4338a FLASH 729900 729796 -104 -0.0
RAM 234700 234700 0 0.0
window-app BRD4187C FLASH 1029256 1029160 -96 -0.0
RAM 127976 127976 0 0.0
esp32 all-clusters-app c3devkit DRAM 97296 97296 0 0.0
FLASH 1577036 1576960 -76 -0.0
IRAM 83820 83820 0 0.0
m5stack DRAM 116092 116084 -8 -0.0
FLASH 1544978 1545142 164 0.0
IRAM 117039 117039 0 0.0
linux air-purifier-app debug unknown 4760 4760 0 0.0
FLASH 2708941 2707889 -1052 -0.0
RAM 132816 132688 -128 -0.1
all-clusters-app debug unknown 5568 5568 0 0.0
FLASH 5974964 5973914 -1050 -0.0
RAM 531632 531504 -128 -0.0
all-clusters-minimal-app debug unknown 5464 5464 0 0.0
FLASH 5323650 5322662 -988 -0.0
RAM 242744 242616 -128 -0.1
bridge-app debug unknown 5480 5480 0 0.0
FLASH 4681838 4680820 -1018 -0.0
RAM 221480 221352 -128 -0.1
chip-tool debug unknown 6120 6120 0 0.0
FLASH 13096150 13095340 -810 -0.0
RAM 596770 596578 -192 -0.0
chip-tool-ipv6only arm64 unknown 21848 21816 -32 -0.1
FLASH 11162144 11161184 -960 -0.0
RAM 648496 648304 -192 -0.0
fabric-admin debug unknown 5808 5808 0 0.0
FLASH 11388197 11387419 -778 -0.0
RAM 596554 596362 -192 -0.0
fabric-bridge-app debug unknown 4736 4736 0 0.0
FLASH 4506436 4505386 -1050 -0.0
RAM 208664 208536 -128 -0.1
fabric-sync debug unknown 4976 4976 0 0.0
FLASH 5612821 5611829 -992 -0.0
RAM 483536 483408 -128 -0.0
lighting-app debug+rpc+ui unknown 6144 6144 0 0.0
FLASH 5624593 5623585 -1008 -0.0
RAM 231760 231632 -128 -0.1
lock-app debug unknown 5416 5416 0 0.0
FLASH 4730952 4729932 -1020 -0.0
RAM 207728 207600 -128 -0.1
ota-provider-app debug unknown 4776 4776 0 0.0
FLASH 4359496 4358478 -1018 -0.0
RAM 201368 201240 -128 -0.1
ota-requestor-app debug unknown 4728 4728 0 0.0
FLASH 4496968 4495980 -988 -0.0
RAM 205952 205824 -128 -0.1
shell debug unknown 4256 4256 0 0.0
FLASH 3004861 3004061 -800 -0.0
RAM 160504 160376 -128 -0.1
thermostat-no-ble arm64 unknown 9536 9512 -24 -0.3
FLASH 4098736 4097656 -1080 -0.0
RAM 246144 246016 -128 -0.1
tv-app debug unknown 5744 5744 0 0.0
FLASH 5952405 5951397 -1008 -0.0
RAM 606936 606808 -128 -0.0
tv-casting-app debug unknown 5320 5320 0 0.0
FLASH 11269757 11268589 -1168 -0.0
RAM 710896 710736 -160 -0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 906972 907008 36 0.0
RAM 142395 142395 0 0.0
nrf7002dk_nrf5340_cpuapp FLASH 901532 901656 124 0.0
RAM 124739 124739 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 845696 845756 60 0.0
RAM 141323 141323 0 0.0
nxp contact k32w0+release FLASH 584288 584416 128 0.0
RAM 70860 70860 0 0.0
mcxw71+release FLASH 599632 599776 144 0.0
RAM 63080 63080 0 0.0
light k32w0+release FLASH 610732 610820 88 0.0
RAM 70252 70252 0 0.0
k32w1+release FLASH 685192 685248 56 0.0
RAM 48664 48664 0 0.0
lock mcxw71+release FLASH 748664 748744 80 0.0
RAM 67476 67476 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1646372 1646228 -144 -0.0
RAM 211560 211560 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1553148 1553060 -88 -0.0
RAM 208376 208376 0 0.0
light cy8ckit_062s2_43012 FLASH 1468828 1468724 -104 -0.0
RAM 200352 200352 0 0.0
lock cy8ckit_062s2_43012 FLASH 1466860 1466756 -104 -0.0
RAM 224688 224688 0 0.0
qpg lighting-app qpg6105+debug FLASH 661984 662056 72 0.0
RAM 105204 105204 0 0.0
lock-app qpg6105+debug FLASH 619788 619828 40 0.0
RAM 99648 99648 0 0.0
stm32 light STM32WB5MM-DK FLASH 482600 482656 56 0.0
RAM 144672 144672 0 0.0
telink bridge-app tl7218x FLASH 664748 664838 90 0.0
RAM 90812 90812 0 0.0
contact-sensor-app tlsr9528a_retention FLASH 621506 621596 90 0.0
RAM 31484 31484 0 0.0
light-app-ota-shell-factory-data tl3218x FLASH 770258 770348 90 0.0
RAM 43552 43552 0 0.0
tl7218x FLASH 778790 778880 90 0.0
RAM 98688 98688 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 680124 680214 90 0.0
RAM 52176 52176 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 708678 708768 90 0.0
RAM 73384 73384 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 625592 625682 90 0.0
RAM 142016 142016 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 812974 813066 92 0.0
RAM 99560 99560 0 0.0
tizen all-clusters-app arm unknown 5116 5104 -12 -0.2
FLASH 1751892 1750876 -1016 -0.1
RAM 93524 93460 -64 -0.1
chip-tool-ubsan arm unknown 11408 11392 -16 -0.1
FLASH 18696094 18692366 -3728 -0.0
RAM 8183744 8181456 -2288 -0.0

@mergify mergify bot added the conflict label Jan 31, 2025
@mergify mergify bot removed the conflict label Jan 31, 2025
Copy link

github-actions bot commented Jan 31, 2025

PR #37345: Size comparison from 26341b4 to 058fcf2

Full report (72 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
platform target config section 26341b4 058fcf2 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1093546 1093578 32 0.0
RAM 103298 103298 0 0.0
bl702 lighting-app bl702+eth FLASH 650158 649938 -220 -0.0
RAM 25265 25265 0 0.0
bl702+wifi FLASH 828066 828102 36 0.0
RAM 13981 13981 0 0.0
bl706+mfd+rpc+littlefs FLASH 1056626 1056406 -220 -0.0
RAM 23861 23861 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 888060 888096 36 0.0
RAM 18504 18504 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 971046 971082 36 0.0
RAM 16368 16368 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 838000 838064 64 0.0
RAM 123464 123464 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 823420 823484 64 0.0
RAM 125344 125344 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 770644 770700 56 0.0
RAM 113804 113804 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 754888 754976 88 0.0
RAM 114012 114012 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 538445 538477 32 0.0
RAM 205192 205192 0 0.0
lock CC3235SF_LAUNCHXL FLASH 572309 572333 24 0.0
RAM 205344 205344 0 0.0
cyw30739 light CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 679409 679433 24 0.0
RAM 78532 78532 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 699261 699285 24 0.0
RAM 81172 81172 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 699261 699285 24 0.0
RAM 81172 81172 0 0.0
CYW930739M2EVB-02 unknown 2040 2040 0 0.0
FLASH 656189 656221 32 0.0
RAM 73600 73600 0 0.0
light-switch CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 615793 615825 32 0.0
RAM 71516 71516 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 635421 635461 40 0.0
RAM 74060 74060 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 635421 635461 40 0.0
RAM 74060 74060 0 0.0
lock CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 635273 635297 24 0.0
RAM 74524 74524 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 654981 655005 24 0.0
RAM 77068 77068 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 654981 655005 24 0.0
RAM 77068 77068 0 0.0
thermostat CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 611709 611725 16 0.0
RAM 68612 68612 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 631569 631585 16 0.0
RAM 71252 71252 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 631569 631585 16 0.0
RAM 71252 71252 0 0.0
efr32 lock-app BRD4187C FLASH 936200 936256 56 0.0
RAM 159872 159872 0 0.0
BRD4338a FLASH 729900 729748 -152 -0.0
RAM 234700 234700 0 0.0
window-app BRD4187C FLASH 1029256 1029096 -160 -0.0
RAM 127976 127976 0 0.0
esp32 all-clusters-app c3devkit DRAM 97296 97296 0 0.0
FLASH 1577036 1576942 -94 -0.0
IRAM 83820 83820 0 0.0
m5stack DRAM 116092 116084 -8 -0.0
FLASH 1544978 1545134 156 0.0
IRAM 117039 117039 0 0.0
linux air-purifier-app debug unknown 4760 4760 0 0.0
FLASH 2708941 2707917 -1024 -0.0
RAM 132816 132688 -128 -0.1
all-clusters-app debug unknown 5568 5568 0 0.0
FLASH 5974964 5973942 -1022 -0.0
RAM 531632 531504 -128 -0.0
all-clusters-minimal-app debug unknown 5464 5464 0 0.0
FLASH 5323650 5322690 -960 -0.0
RAM 242744 242616 -128 -0.1
bridge-app debug unknown 5480 5480 0 0.0
FLASH 4681838 4680848 -990 -0.0
RAM 221480 221352 -128 -0.1
chip-tool debug unknown 6120 6120 0 0.0
FLASH 13096150 13095368 -782 -0.0
RAM 596770 596578 -192 -0.0
chip-tool-ipv6only arm64 unknown 21848 21816 -32 -0.1
FLASH 11162144 11161232 -912 -0.0
RAM 648496 648304 -192 -0.0
fabric-admin debug unknown 5808 5808 0 0.0
FLASH 11388197 11387415 -782 -0.0
RAM 596554 596362 -192 -0.0
fabric-bridge-app debug unknown 4736 4736 0 0.0
FLASH 4506436 4505414 -1022 -0.0
RAM 208664 208536 -128 -0.1
fabric-sync debug unknown 4976 4976 0 0.0
FLASH 5612821 5611861 -960 -0.0
RAM 483536 483408 -128 -0.0
lighting-app debug+rpc+ui unknown 6144 6144 0 0.0
FLASH 5624593 5623601 -992 -0.0
RAM 231760 231632 -128 -0.1
lock-app debug unknown 5416 5416 0 0.0
FLASH 4730952 4729960 -992 -0.0
RAM 207728 207600 -128 -0.1
ota-provider-app debug unknown 4776 4776 0 0.0
FLASH 4359496 4358506 -990 -0.0
RAM 201368 201240 -128 -0.1
ota-requestor-app debug unknown 4728 4728 0 0.0
FLASH 4496968 4496008 -960 -0.0
RAM 205952 205824 -128 -0.1
shell debug unknown 4256 4256 0 0.0
FLASH 3004861 3004045 -816 -0.0
RAM 160504 160376 -128 -0.1
thermostat-no-ble arm64 unknown 9536 9512 -24 -0.3
FLASH 4098736 4097720 -1016 -0.0
RAM 246144 246016 -128 -0.1
tv-app debug unknown 5744 5744 0 0.0
FLASH 5952405 5951397 -1008 -0.0
RAM 606936 606808 -128 -0.0
tv-casting-app debug unknown 5320 5320 0 0.0
FLASH 11269757 11268605 -1152 -0.0
RAM 710896 710736 -160 -0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 906972 907012 40 0.0
RAM 142395 142395 0 0.0
nrf7002dk_nrf5340_cpuapp FLASH 901532 901656 124 0.0
RAM 124739 124739 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 845696 845760 64 0.0
RAM 141323 141323 0 0.0
nxp contact k32w0+release FLASH 584288 584416 128 0.0
RAM 70860 70860 0 0.0
mcxw71+release FLASH 599632 599776 144 0.0
RAM 63080 63080 0 0.0
light k32w0+release FLASH 610732 610820 88 0.0
RAM 70252 70252 0 0.0
k32w1+release FLASH 685192 685248 56 0.0
RAM 48664 48664 0 0.0
lock mcxw71+release FLASH 748664 748744 80 0.0
RAM 67476 67476 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1646372 1646180 -192 -0.0
RAM 211560 211560 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1553148 1553012 -136 -0.0
RAM 208376 208376 0 0.0
light cy8ckit_062s2_43012 FLASH 1468828 1468676 -152 -0.0
RAM 200352 200352 0 0.0
lock cy8ckit_062s2_43012 FLASH 1466860 1466708 -152 -0.0
RAM 224688 224688 0 0.0
qpg lighting-app qpg6105+debug FLASH 661984 662056 72 0.0
RAM 105204 105204 0 0.0
lock-app qpg6105+debug FLASH 619788 619828 40 0.0
RAM 99648 99648 0 0.0
stm32 light STM32WB5MM-DK FLASH 482600 482664 64 0.0
RAM 144672 144672 0 0.0
telink bridge-app tl7218x FLASH 664748 664842 94 0.0
RAM 90812 90812 0 0.0
contact-sensor-app tlsr9528a_retention FLASH 621506 621600 94 0.0
RAM 31484 31484 0 0.0
light-app-ota-shell-factory-data tl3218x FLASH 770258 770352 94 0.0
RAM 43552 43552 0 0.0
tl7218x FLASH 778790 778884 94 0.0
RAM 98688 98688 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 680124 680218 94 0.0
RAM 52176 52176 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 708678 708772 94 0.0
RAM 73384 73384 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 625592 625686 94 0.0
RAM 142016 142016 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 812974 813070 96 0.0
RAM 99560 99560 0 0.0
tizen all-clusters-app arm unknown 5116 5104 -12 -0.2
FLASH 1751892 1750836 -1056 -0.1
RAM 93524 93460 -64 -0.1
chip-tool-ubsan arm unknown 11408 11392 -16 -0.1
FLASH 18696094 18692334 -3760 -0.0
RAM 8183744 8181456 -2288 -0.0

// if we get here, the path was NOT valid
if (err == CHIP_ERROR_NOT_FOUND)
{
return DataModel::ValidateClusterPath(provider, path, Status::Failure);
Copy link
Contributor

Choose a reason for hiding this comment

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

Worth commenting that the Status::Failure is arbitrary, because in practice we clearly failed on the endpoint-or-cluster level above?

@@ -80,6 +80,13 @@ class EndpointFinder
ReadOnlyBuffer<EndpointEntry> mEndpoints;
};

/// Validates that the cluster identified by `path` exists within the given provider.
/// If the endpoint exists but does not have the cluster identified by the path, will return Status::UnsupportedCluster.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// If the endpoint exists but does not have the cluster identified by the path, will return Status::UnsupportedCluster.
/// If the endpoint does not exist, will return Status::UnsupportedEndpoint.
/// If the endpoint exists but does not have the cluster identified by the path, will return Status::UnsupportedCluster.

/// Validates that the cluster identified by `path` exists within the given provider.
/// If the endpoint exists but does not have the cluster identified by the path, will return Status::UnsupportedCluster.
///
/// otherwise, it will return successStatus.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// otherwise, it will return successStatus.
/// Otherwise, will return successStatus.

@@ -37,6 +37,7 @@
#include <lib/support/CodeUtils.h>
#include <optional>
#include <protocols/interaction_model/StatusCode.h>
#include <regex.h>
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 regex.h needed? That seems very odd.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

auto-include (probably by a typo) ... will fix

else
{

Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change

@@ -177,8 +178,15 @@ DataModel::ActionReturnStatus RetrieveClusterData(DataModel::Provider * dataMode
{
status = *access_status;
}
else if (IsSupportedGlobalAttributeNotInMetadata(readRequest.path.mAttributeId))
{
// Global attributes are NOT directly handled by datamodel providers, instead
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
// Global attributes are NOT directly handled by datamodel providers, instead
// Global attributes are NOT directly handled by data model providers, instead

@@ -116,27 +114,13 @@ DataModel::ActionReturnStatus CodegenDataModelProvider::ReadAttribute(const Data
}

// Read via AAI
std::optional<CHIP_ERROR> aai_result;
if (const EmberAfCluster ** cluster = std::get_if<const EmberAfCluster *>(&metadata))
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the "what is the right error if we have no metadata" thing FindAttributeMetadata does still relevant here? Or is that all handled by callers now?

Also, the comments above this method no longer match the actual method behavior. Those should have been adjusted in previous PRs, but we should at least do it now.

const EmberAfAttributeMetadata * attributeMetadata = std::get<const EmberAfAttributeMetadata *>(metadata);
// We can only get a status or metadata.
Copy link
Contributor

Choose a reason for hiding this comment

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

What guarantees that? What if someone in fact does a read for a global attribute on the provider?

@@ -102,6 +103,10 @@ DataModel::ActionReturnStatus CodegenDataModelProvider::WriteAttribute(const Dat
// and tests and implementation
//
// Open issue that needs fixing: https://github.com/project-chip/connectedhomeip/issues/33735

// First check things that are not even in metadata. These are read.only.
VerifyOrReturnValue(!IsSupportedGlobalAttributeNotInMetadata(request.path.mAttributeId), Status::UnsupportedWrite);
Copy link
Contributor

Choose a reason for hiding this comment

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

This does not match spec, if it's actually the status that will get returned, for cases when the cluster does not exist.

So either the cluster existence check is done before we ever get here (?) or we have no test coverage for this case.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, one last important thing: Where are the changes to the Provider.h documentation that explain that providers do not handle global attributes not in metadata and callers have to do that themselves?

@@ -82,6 +82,27 @@ std::optional<EndpointEntry> EndpointFinder::Find(EndpointId endpointId)
return std::nullopt;
}

Protocols::InteractionModel::Status ValidateClusterPath(ProviderMetadataTree * provider, const ConcreteClusterPath & path,
Copy link
Contributor

Choose a reason for hiding this comment

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

This seems to duplicate ValidateClusterPath in EmberMetadata.... Is it worth commoning those up somehow?

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.

Have global attribute handling part if InteractionModel (or reporting/Engine.cpp)
4 participants