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

[DRAFT/EXAMPLE] Cleaner interface split for ServerClusterInterface #37791

Closed

Conversation

andy31415
Copy link
Contributor

@andy31415 andy31415 commented Feb 26, 2025

This is a more "clean interface" version of #37541:

  • ServerClusterInterface does not have any intrusiveness in it
  • Registry is now tied to the codegendatamodelprovider

This uses slightly more RAM since the linked list is not intrusive: uses heap instead of BSS and 4 bytes extra per cluster. However this may be ok since small devices will have less than 20 clusters.

Testing

Covered by unit tests. Test coverage for new code is 100%:

image

image

Copy link

Review changes with  SemanticDiff

@andy31415
Copy link
Contributor Author

/gemini summary

@andy31415
Copy link
Contributor Author

/gemini review

Copy link

Summary of Changes

This pull request aims to improve the interface for ServerClusterInterface by making it less intrusive and tying the registry to the codegen data model provider. This approach uses slightly more RAM due to the non-intrusive linked list, but this is considered acceptable since small devices will have a limited number of clusters. The changes include adding a new error code, updating the build coverage script, modifying build configurations, renaming the Invoke method to InvokeCommand in the Provider class and related usages, introducing a DefaultServerCluster class, and adding a test suite for server clusters.

Highlights

  • Interface Cleanup: The ServerClusterInterface is made less intrusive, enhancing modularity.
  • Registry Association: The registry is now tied to the codegenDataModelProvider, streamlining data model management.
  • Memory Usage: There's a slight increase in RAM usage, which is considered acceptable for the target devices.
  • New DefaultServerCluster: A new DefaultServerCluster class is introduced, providing a default implementation for server clusters.
  • Invoke Rename: The Invoke method in the Provider class is renamed to InvokeCommand for clarity.

Changelog

Click here to see the changelog
  • docs/ids_and_codes/ERROR_CODES.md
    • Added a new error code CHIP_ERROR_IN_USE.
  • scripts/build_coverage.sh
    • Added --ignore-errors inconsistent to lcov commands to handle inconsistent coverage data.
  • src/BUILD.gn
    • Reordered and added test directories to tests list.
    • Conditionally included codegen/tests based on OS and platform to avoid duplicate symbols and compilation issues.
  • src/app/InteractionModelEngine.cpp
    • Renamed GetDataModelProvider()->Invoke to GetDataModelProvider()->InvokeCommand.
  • src/app/data-model-provider/Provider.h
    • Renamed virtual method Invoke to InvokeCommand.
  • src/app/data-model-provider/tests/TestActionReturnStatus.cpp
    • Reordered includes for better readability.
  • src/app/server-cluster/BUILD.gn
    • Added a new source_set for server-cluster with necessary dependencies.
  • src/app/server-cluster/DefaultServerCluster.cpp
    • Created a new class DefaultServerCluster with default implementations for attribute and command handling.
  • src/app/server-cluster/DefaultServerCluster.h
    • Created a header file for DefaultServerCluster.
  • src/app/server-cluster/ServerClusterInterface.h
    • Created a header file for ServerClusterInterface.
  • src/app/server-cluster/tests/BUILD.gn
    • Added a chip_test_suite for server cluster interface tests.
  • src/app/server-cluster/tests/TestDefaultServerCluster.cpp
    • Created a test suite for DefaultServerCluster.
  • src/app/tests/TestCommandInteraction.cpp
    • Renamed Invoke to InvokeCommand in TestCommandInteractionModel.
  • src/app/tests/test-interaction-model-api.cpp
    • Renamed Invoke to InvokeCommand in TestImCustomDataModel.
  • src/app/tests/test-interaction-model-api.h
    • Renamed Invoke to InvokeCommand in TestImCustomDataModel.
  • src/controller/tests/data_model/DataModelFixtures.cpp
    • Renamed Invoke to InvokeCommand in CustomDataModel.
  • src/controller/tests/data_model/DataModelFixtures.h
    • Renamed Invoke to InvokeCommand in CustomDataModel.
  • src/data-model-providers/codegen/BUILD.gn
    • Added a new source_set for registry.
  • src/data-model-providers/codegen/CodegenDataModelProvider.cpp
    • Renamed Invoke to InvokeCommand in CodegenDataModelProvider.
  • src/data-model-providers/codegen/CodegenDataModelProvider.h
    • Renamed Invoke to InvokeCommand in CodegenDataModelProvider.
  • src/data-model-providers/codegen/ServerClusterInterfaceRegistry.cpp
    • Created a new class ServerClusterInterfaceRegistry to manage server cluster interfaces.
  • src/data-model-providers/codegen/ServerClusterInterfaceRegistry.h
    • Created a header file for ServerClusterInterfaceRegistry.
  • src/data-model-providers/codegen/model.gni
    • Added dependencies for server-cluster and registry.
  • src/data-model-providers/codegen/tests/BUILD.gn
    • Added a test suite for ServerClusterInterfaceRegistry.
  • src/data-model-providers/codegen/tests/TestCodegenModelViaMocks.cpp
    • Renamed Invoke to InvokeCommand in tests.
  • src/data-model-providers/codegen/tests/TestServerClusterInterfaceRegistry.cpp
    • Created a test suite for ServerClusterInterfaceRegistry.
  • src/lib/core/CHIPError.cpp
    • Added a description for CHIP_ERROR_IN_USE.
  • src/lib/core/CHIPError.h
    • Added a new error code CHIP_ERROR_IN_USE.

Activity

  • semanticdiff-com[bot] provided a link to review changes with SemanticDiff.
  • andy31415 requested a summary from gemini.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a cleaner interface split for ServerClusterInterface. The changes look good overall, but I have a few suggestions for improvement, particularly around consistency and documentation.

Summary of Findings

  • Method Naming Consistency: The renaming of Invoke to InvokeCommand should be consistently applied across all relevant interfaces and implementations to avoid confusion.
  • Code Coverage: Ensure adequate unit tests are added or updated to cover the new DefaultServerCluster class and its functionalities.
  • Error Code Documentation: Provide a clear explanation of when the new CHIP_ERROR_IN_USE error code should be used.

Assessment

The pull request introduces a cleaner interface split for ServerClusterInterface, aiming to reduce intrusiveness and improve modularity. The changes include renaming a method, adding a new error code, and introducing a DefaultServerCluster class. While the changes seem well-structured, there are a few areas that could benefit from further clarification or refinement. I recommend addressing the comments before merging, and users should have others review and approve this code before merging.

@andy31415 andy31415 dismissed gemini-code-assist[bot]’s stale review February 26, 2025 16:21

Unsure about the comments: asks for coverage and coverage is quite good. The only addressable one may be the better details on error code meaning.

Copy link

github-actions bot commented Feb 26, 2025

PR #37791: Size comparison from a8e2ae5 to ae9ddf7

Full report (73 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
platform target config section a8e2ae5 ae9ddf7 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1096884 1096884 0 0.0
RAM 94842 94842 0 0.0
bl702 lighting-app bl702+eth FLASH 651862 651862 0 0.0
RAM 33509 33509 0 0.0
bl702+wifi FLASH 829134 829134 0 0.0
RAM 22233 22233 0 0.0
bl706+mfd+rpc+littlefs FLASH 1061530 1061530 0 0.0
RAM 32157 32157 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 892374 892374 0 0.0
RAM 26896 26896 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 975270 975270 0 0.0
RAM 24644 24644 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 817152 817152 0 0.0
RAM 120272 120272 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 826072 826072 0 0.0
RAM 125368 125368 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 772948 772948 0 0.0
RAM 113740 113740 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 757232 757232 0 0.0
RAM 113948 113948 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 540638 540638 0 0.0
RAM 205128 205128 0 0.0
lock CC3235SF_LAUNCHXL FLASH 574786 574786 0 0.0
RAM 205376 205376 0 0.0
cyw30739 light CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 656565 656565 0 0.0
RAM 75324 75324 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 676425 676417 -8 -0.0
RAM 77964 77964 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 676425 676417 -8 -0.0
RAM 77964 77964 0 0.0
CYW930739M2EVB-02 unknown 2040 2040 0 0.0
FLASH 633349 633357 8 0.0
RAM 70392 70392 0 0.0
light-switch CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 616429 616429 0 0.0
RAM 71532 71532 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 636065 636065 0 0.0
RAM 74076 74076 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 636065 636065 0 0.0
RAM 74076 74076 0 0.0
lock CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 635925 635925 0 0.0
RAM 74540 74540 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 655649 655649 0 0.0
RAM 77084 77084 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 655649 655649 0 0.0
RAM 77084 77084 0 0.0
thermostat CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 612273 612273 0 0.0
RAM 68628 68628 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 632133 632133 0 0.0
RAM 71268 71268 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 632133 632133 0 0.0
RAM 71268 71268 0 0.0
efr32 lock-app BRD4187C FLASH 939664 939664 0 0.0
RAM 159920 159920 0 0.0
BRD4338a FLASH 732648 732648 0 0.0
RAM 234828 234828 0 0.0
window-app BRD4187C FLASH 1032096 1032096 0 0.0
RAM 128024 128024 0 0.0
esp32 all-clusters-app c3devkit DRAM 98656 98656 0 0.0
FLASH 1589230 1589230 0 0.0
IRAM 83820 83820 0 0.0
m5stack DRAM 117436 117436 0 0.0
FLASH 1556110 1556110 0 0.0
IRAM 117039 117039 0 0.0
linux air-purifier-app debug unknown 4728 4728 0 0.0
FLASH 2650031 2650047 16 0.0
RAM 111088 111088 0 0.0
all-clusters-app debug unknown 5536 5536 0 0.0
FLASH 5961772 5961788 16 0.0
RAM 514832 514832 0 0.0
all-clusters-minimal-app debug unknown 5432 5432 0 0.0
FLASH 5296484 5296500 16 0.0
RAM 221272 221272 0 0.0
bridge-app debug unknown 5448 5448 0 0.0
FLASH 4648832 4648880 48 0.0
RAM 200144 200144 0 0.0
camera-app debug unknown 5432 5432 0 0.0
FLASH 4671992 4671976 -16 -0.0
RAM 194592 194592 0 0.0
chip-tool debug unknown 6096 6096 0 0.0
FLASH 13302487 13302535 48 0.0
RAM 603392 603392 0 0.0
chip-tool-ipv6only arm64 unknown 21976 21976 0 0.0
FLASH 11495528 11495544 16 0.0
RAM 656112 656112 0 0.0
fabric-admin debug unknown 5784 5784 0 0.0
FLASH 11567249 11567297 48 0.0
RAM 603176 603176 0 0.0
fabric-bridge-app debug unknown 4696 4696 0 0.0
FLASH 4452430 4452446 16 0.0
RAM 187016 187016 0 0.0
fabric-sync debug unknown 4952 4952 0 0.0
FLASH 5569381 5569429 48 0.0
RAM 470400 470400 0 0.0
lighting-app debug+rpc+ui unknown 6160 6160 0 0.0
FLASH 5515665 5515681 16 0.0
RAM 203952 203952 0 0.0
lock-app debug unknown 5400 5400 0 0.0
FLASH 4688680 4688696 16 0.0
RAM 191144 191144 0 0.0
ota-provider-app debug unknown 4736 4736 0 0.0
FLASH 4310860 4310876 16 0.0
RAM 179832 179832 0 0.0
ota-requestor-app debug unknown 4688 4688 0 0.0
FLASH 4441212 4441260 48 0.0
RAM 184320 184320 0 0.0
shell debug unknown 4216 4216 0 0.0
FLASH 2978956 2979004 48 0.0
RAM 144344 144344 0 0.0
thermostat-no-ble arm64 unknown 9448 9448 0 0.0
FLASH 4138536 4138552 16 0.0
RAM 229016 229016 0 0.0
tv-app debug unknown 5728 5728 0 0.0
FLASH 5908261 5908277 16 0.0
RAM 593832 593832 0 0.0
tv-casting-app debug unknown 5304 5304 0 0.0
FLASH 11472973 11472989 16 0.0
RAM 718656 718656 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 911752 911752 0 0.0
RAM 142859 142859 0 0.0
nrf7002dk_nrf5340_cpuapp FLASH 902608 902608 0 0.0
RAM 125195 125195 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 850420 850420 0 0.0
RAM 141271 141271 0 0.0
nxp contact k32w0+release FLASH 585400 585400 0 0.0
RAM 70876 70876 0 0.0
mcxw71+release FLASH 600840 600840 0 0.0
RAM 63096 63096 0 0.0
light k32w0+release FLASH 611340 611340 0 0.0
RAM 70164 70164 0 0.0
k32w1+release FLASH 685824 685824 0 0.0
RAM 48584 48584 0 0.0
lock mcxw71+release FLASH 749680 749680 0 0.0
RAM 67500 67500 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1655676 1655676 0 0.0
RAM 212264 212264 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1562372 1562372 0 0.0
RAM 208560 208560 0 0.0
light cy8ckit_062s2_43012 FLASH 1441172 1441172 0 0.0
RAM 197296 197296 0 0.0
lock cy8ckit_062s2_43012 FLASH 1470060 1470060 0 0.0
RAM 224960 224960 0 0.0
qpg lighting-app qpg6105+debug FLASH 662316 662316 0 0.0
RAM 105116 105116 0 0.0
lock-app qpg6105+debug FLASH 620432 620432 0 0.0
RAM 99664 99664 0 0.0
stm32 light STM32WB5MM-DK FLASH 459832 459832 0 0.0
RAM 141472 141472 0 0.0
telink bridge-app tl7218x FLASH 669192 669192 0 0.0
RAM 90752 90752 0 0.0
contact-sensor-app tlsr9528a_retention FLASH 622078 622078 0 0.0
RAM 31488 31488 0 0.0
light-app-ota-shell-factory-data tl3218x FLASH 745386 745386 0 0.0
RAM 40396 40396 0 0.0
tl7218x FLASH 753948 753948 0 0.0
RAM 97540 97540 0 0.0
light-switch-app-ota-compress-lzma-factory-data tl7218x_retention FLASH 681018 681018 0 0.0
RAM 52192 52192 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 709580 709580 0 0.0
RAM 73400 73400 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 600760 600760 0 0.0
RAM 138812 138812 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 788988 788988 0 0.0
RAM 96388 96388 0 0.0
tizen all-clusters-app arm unknown 5116 5116 0 0.0
FLASH 1766128 1766156 28 0.0
RAM 93844 93844 0 0.0
chip-tool-ubsan arm unknown 11492 11492 0 0.0
FLASH 18983950 18983978 28 0.0
RAM 8306328 8306328 0 0.0

@andy31415
Copy link
Contributor Author

Closing: this was merged back into #37541

@andy31415 andy31415 closed this Feb 27, 2025
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.

1 participant