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

Delegate implementation for Valve Configuration and control cluster. Tested with watervalve CHEF device. #37088

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

Conversation

sxb427
Copy link

@sxb427 sxb427 commented Jan 16, 2025

Adds a delegate implementation for valve configuration and control cluster intended to be used by chef devices using this cluster. Summary of changes -

  • External Read / Write callbacks for RemainingTime attribute which has only external storage option available.
  • Command handlers :
    • HandleOpenValve: Returns the same level passed as input.
    • HandleCloseValve: NOP for now. TBD if currentState should be set to kClosed in server or delegate.
    • HandleRemainingDurationTick: NOP.
  • Attribute modifications for watervalve device (ZAP):
    • DefaultOpenDuration default value to 100: Valve will remain in kOpen state after Open command is sent, for DefaultOpenDuration seconds.
    • Featuremap default value to 2: Enable kLevel feature for device.

Testing with watervalve

# Commission
./chip-tool pairing code 0x20 MT:Y.K90AFN00KA0648G00

# Read Current state (should be 0: kClosed)
./chip-tool valveconfigurationandcontrol read current-state 0x20 1 | grep "CurrentState"

# Send Open command with level = 50%. This will start a timer from 100 and continuously update RemainingDuration.
./chip-tool valveconfigurationandcontrol command-by-id 0 '{"0x1": 50}' 0x20 1
./chip-tool valveconfigurationandcontrol read remaining-duration 0x20 1 | grep "RemainingDuration"

# CurrentLevel should be set to 50 and, currentState to kOpen: 1
./chip-tool valveconfigurationandcontrol read current-level 0x20 1 | grep "CurrentLevel"
./chip-tool valveconfigurationandcontrol read current-state 0x20 1 | grep "CurrentState"

# Send close command. CurrentState changes to 2: kTransitioning
./chip-tool valveconfigurationandcontrol command-by-id 1 '{}' 0x20 1
./chip-tool valveconfigurationandcontrol read current-state 0x20 1 | grep "CurrentState"

Copy link

Review changes with  SemanticDiff

@CLAassistant
Copy link

CLAassistant commented Jan 16, 2025

CLA assistant check
All committers have signed the CLA.

}
if (duration.IsNull())
{
std::memset(buffer, '\0', maxReadLength);
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 correct? The null value for a uint32_t is via https://github.com/project-chip/connectedhomeip/blob/master/src/app/util/odd-sized-integers.h#L149 and generally 0xFFFFFFFF I believe.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please run a test to validate.

Copy link
Author

Choose a reason for hiding this comment

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

Internally, the attribute is store as an optional, which allows NULL values. However, the API only accepts raw bytes. So inspired from here, it seems 0xFF... interpreted as NULL is a known convention that the caller and callee can agree upon. So I've implemented it that way:

  • If callee receives a write request of 0xFFF.., it simply sets the attr to NULL.
  • If call receives a read request when the current attr. value is NULL, it simply returns 0xFFF..

…urationNull

* When reading remaining time, max numeric value for the given size (0xFFF...) is interpreted as NULL.
Copy link

github-actions bot commented Jan 17, 2025

PR #37088: Size comparison from f9c7a8d to 4aa5e8a

Full report (7 builds for cc13x4_26x4, cc32xx, stm32)
platform target config section f9c7a8d 4aa5e8a change % change
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 839628 839628 0 0.0
RAM 123536 123536 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 825064 825064 0 0.0
RAM 125416 125416 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 772072 772072 0 0.0
RAM 113900 113900 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 756252 756252 0 0.0
RAM 114100 114100 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 539693 539693 0 0.0
RAM 205288 205288 0 0.0
lock CC3235SF_LAUNCHXL FLASH 573765 573765 0 0.0
RAM 205424 205424 0 0.0
stm32 light STM32WB5MM-DK FLASH 484448 484448 0 0.0
RAM 144752 144752 0 0.0

Copy link

github-actions bot commented Jan 17, 2025

PR #37088: Size comparison from 292665e to 65b22c1

Full report (71 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
platform target config section 292665e 65b22c1 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1093164 1093164 0 0.0
RAM 103354 103354 0 0.0
bl702 lighting-app bl702+eth FLASH 651226 651226 0 0.0
RAM 25361 25361 0 0.0
bl702+wifi FLASH 829150 829150 0 0.0
RAM 14101 14101 0 0.0
bl706+mfd+rpc+littlefs FLASH 1056180 1056180 0 0.0
RAM 23957 23957 0 0.0
bl702l contact-sensor-app bl702l+mfd+littlefs FLASH 889204 889204 0 0.0
RAM 18632 18632 0 0.0
lighting-app bl702l+mfd+littlefs FLASH 972164 972164 0 0.0
RAM 16480 16480 0 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 838436 838436 0 0.0
RAM 123536 123536 0 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 823784 823784 0 0.0
RAM 125416 125416 0 0.0
pump-app LP_EM_CC1354P10_6 FLASH 771104 771104 0 0.0
RAM 113900 113900 0 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 755300 755300 0 0.0
RAM 114100 114100 0 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 538781 538781 0 0.0
RAM 205288 205288 0 0.0
lock CC3235SF_LAUNCHXL FLASH 572629 572629 0 0.0
RAM 205424 205424 0 0.0
cyw30739 light CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 679881 679881 0 0.0
RAM 78596 78596 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 699733 699733 0 0.0
RAM 81236 81236 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 699733 699733 0 0.0
RAM 81236 81236 0 0.0
CYW930739M2EVB-02 unknown 2040 2040 0 0.0
FLASH 656669 656669 0 0.0
RAM 73664 73664 0 0.0
light-switch CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 616289 616289 0 0.0
RAM 71588 71588 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 635925 635925 0 0.0
RAM 74132 74132 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 635925 635925 0 0.0
RAM 74132 74132 0 0.0
lock CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 635753 635753 0 0.0
RAM 74588 74588 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 655469 655469 0 0.0
RAM 77132 77132 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 655469 655469 0 0.0
RAM 77132 77132 0 0.0
thermostat CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 612301 612301 0 0.0
RAM 68684 68684 0 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 632161 632161 0 0.0
RAM 71316 71316 0 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 632161 632161 0 0.0
RAM 71316 71316 0 0.0
efr32 lock-app BRD4187C FLASH 935112 935112 0 0.0
RAM 160004 160004 0 0.0
BRD4338a FLASH 730804 730796 -8 -0.0
RAM 234844 234844 0 0.0
window-app BRD4187C FLASH 1030456 1030456 0 0.0
RAM 128112 128112 0 0.0
esp32 all-clusters-app c3devkit DRAM 95192 95192 0 0.0
FLASH 1538592 1538652 60 0.0
IRAM 82552 82552 0 0.0
m5stack DRAM 116172 116172 0 0.0
FLASH 1545810 1545862 52 0.0
IRAM 117039 117039 0 0.0
linux air-purifier-app debug unknown 4752 4752 0 0.0
FLASH 2710271 2710271 0 0.0
RAM 133096 133096 0 0.0
all-clusters-app debug unknown 5560 5560 0 0.0
FLASH 5976336 5976610 274 0.0
RAM 531880 531880 0 0.0
all-clusters-minimal-app debug unknown 5456 5456 0 0.0
FLASH 5324354 5324354 0 0.0
RAM 242992 242992 0 0.0
bridge-app debug unknown 5472 5472 0 0.0
FLASH 4682582 4682582 0 0.0
RAM 221744 221744 0 0.0
chip-tool debug unknown 5984 5984 0 0.0
FLASH 13045234 13045234 0 0.0
RAM 596634 596634 0 0.0
chip-tool-ipv6only arm64 unknown 21816 21816 0 0.0
FLASH 11125744 11125744 0 0.0
RAM 648168 648168 0 0.0
fabric-admin debug unknown 5808 5808 0 0.0
FLASH 11392209 11392209 0 0.0
RAM 596978 596978 0 0.0
fabric-bridge-app debug unknown 4728 4728 0 0.0
FLASH 4507632 4507632 0 0.0
RAM 208880 208880 0 0.0
fabric-sync debug unknown 4968 4968 0 0.0
FLASH 5610437 5610437 0 0.0
RAM 483656 483656 0 0.0
lighting-app debug+rpc+ui unknown 6136 6136 0 0.0
FLASH 5617905 5617905 0 0.0
RAM 232008 232008 0 0.0
lock-app debug unknown 5408 5408 0 0.0
FLASH 4731538 4731538 0 0.0
RAM 207976 207976 0 0.0
ota-provider-app debug unknown 4768 4768 0 0.0
FLASH 4361240 4361240 0 0.0
RAM 201696 201696 0 0.0
ota-requestor-app debug unknown 4720 4720 0 0.0
FLASH 4498914 4498914 0 0.0
RAM 206280 206280 0 0.0
shell debug unknown 4248 4248 0 0.0
FLASH 3006717 3006989 272 0.0
RAM 160736 160736 0 0.0
thermostat-no-ble arm64 unknown 9568 9568 0 0.0
FLASH 4102184 4102184 0 0.0
RAM 246224 246224 0 0.0
tv-app debug unknown 5736 5736 0 0.0
FLASH 5950597 5950597 0 0.0
RAM 607088 607088 0 0.0
tv-casting-app debug unknown 5312 5312 0 0.0
FLASH 11273069 11273069 0 0.0
RAM 711064 711064 0 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 914768 914824 56 0.0
RAM 143172 143172 0 0.0
nrf7002dk_nrf5340_cpuapp FLASH 890116 890116 0 0.0
RAM 141359 141359 0 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 849488 849488 0 0.0
RAM 142084 142084 0 0.0
nxp contact k32w0+release FLASH 584504 584504 0 0.0
RAM 70952 70952 0 0.0
mcxw71+release FLASH 600024 600024 0 0.0
RAM 63168 63168 0 0.0
light k32w0+release FLASH 611188 611188 0 0.0
RAM 70344 70344 0 0.0
k32w1+release FLASH 685736 685736 0 0.0
RAM 48760 48760 0 0.0
lock mcxw71+release FLASH 761800 761800 0 0.0
RAM 70796 70796 0 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1648060 1648076 16 0.0
RAM 211624 211624 0 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1554628 1554628 0 0.0
RAM 208440 208440 0 0.0
light cy8ckit_062s2_43012 FLASH 1470172 1470172 0 0.0
RAM 200408 200408 0 0.0
lock cy8ckit_062s2_43012 FLASH 1467884 1467884 0 0.0
RAM 224760 224760 0 0.0
qpg lighting-app qpg6105+debug FLASH 662552 662552 0 0.0
RAM 105296 105296 0 0.0
lock-app qpg6105+debug FLASH 620268 620268 0 0.0
RAM 99748 99748 0 0.0
stm32 light STM32WB5MM-DK FLASH 483240 483240 0 0.0
RAM 144752 144752 0 0.0
telink bridge-app tlsr9258a FLASH 682276 682276 0 0.0
RAM 91088 91088 0 0.0
contact-sensor-app tlsr9528a_retention FLASH 622566 622566 0 0.0
RAM 31488 31488 0 0.0
light-app-ota-compress-lzma-shell-factory-data tl3218x FLASH 771344 771344 0 0.0
RAM 49348 49348 0 0.0
light-app-ota-shell-factory-data tl7218x FLASH 775948 775948 0 0.0
RAM 99652 99652 0 0.0
light-switch-app-ota-compress-lzma-shell-factory-data tlsr9528a FLASH 709794 709794 0 0.0
RAM 73384 73384 0 0.0
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 626894 626894 0 0.0
RAM 142020 142020 0 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 812958 812958 0 0.0
RAM 99564 99564 0 0.0
tizen all-clusters-app arm unknown 5132 5132 0 0.0
FLASH 1755280 1755400 120 0.0
RAM 93672 93672 0 0.0
chip-tool-ubsan arm unknown 11044 11044 0 0.0
FLASH 18216638 18216638 0 0.0
RAM 7958464 7958464 0 0.0

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