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

Feature/enhanced setup flow feature #34065

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

Conversation

swan-amazon
Copy link
Contributor

Integrate Terms and Conditions Acknowledgements in Commissioning Process

Fixes #34064

  1. Add support for setting Terms and Conditions acknowledgements

    • Added functionality to set Terms and Conditions acknowledgements and
      acknowledgment version in the General Commissioning cluster.
    • Implemented corresponding commands and responses to handle
      acknowledgements.
  2. Enhance setup flow handling

    • Refactored the setup flow handling to accommodate setting Terms and
      Conditions acknowledgements.
    • Updated the commissioning stages to include configuring Terms and
      Conditions acknowledgements.
  3. Handle setting Terms and Conditions acknowledgements

    • Implemented setting Terms and Conditions acknowledgements in the
      commissioning process.
    • Implemented proper handling of command responses and error checking.
  4. Zap regen

    python3 ./scripts/tools/zap_regen_all.py

@swan-amazon swan-amazon force-pushed the feature/enhanced-setup-flow-feature branch from 66ddf83 to d9e1799 Compare October 16, 2024 21:32
Copy link

github-actions bot commented Oct 16, 2024

PR #34065: Size comparison from 1000d7e to d9e1799

Full report (82 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
platform target config section 1000d7e d9e1799 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1349986 1350520 534 0.0
RAM 104120 104144 24 0.0
bl702 lighting-app bl702+eth FLASH 647742 648022 280 0.0
RAM 25233 25241 8 0.0
bl702+wifi FLASH 825228 825508 280 0.0
RAM 13965 13973 8 0.1
bl706+mfd+rpc+littlefs FLASH 1054154 1054178 24 0.0
RAM 23821 23821 0 0.0
bl702l lighting-app bl702l+mfd+littlefs FLASH 974998 975022 24 0.0
RAM 16468 16476 8 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 829564 829632 68 0.0
RAM 123452 123468 16 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 814872 814940 68 0.0
RAM 125332 125356 24 0.0
pump-app LP_EM_CC1354P10_6 FLASH 761420 761548 128 0.0
RAM 113824 113856 32 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 745664 745800 136 0.0
RAM 114016 114032 16 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 617202 617422 220 0.0
RAM 205908 205932 24 0.0
lock CC3235SF_LAUNCHXL FLASH 657258 657478 220 0.0
RAM 206060 206076 16 0.0
cyw30739 light CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 678549 678701 152 0.0
RAM 78668 78684 16 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 698393 698545 152 0.0
RAM 81300 81324 24 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 698393 698545 152 0.0
RAM 81300 81324 24 0.0
CYW930739M2EVB-02 unknown 2040 2040 0 0.0
FLASH 655329 655481 152 0.0
RAM 73736 73752 16 0.0
light-switch CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 614845 615093 248 0.0
RAM 71628 71660 32 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 634473 634729 256 0.0
RAM 74180 74204 24 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 634473 634729 256 0.0
RAM 74180 74204 24 0.0
lock CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 634165 634413 248 0.0
RAM 74676 74700 24 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 653873 654129 256 0.0
RAM 77228 77244 16 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 653873 654129 256 0.0
RAM 77228 77244 16 0.0
thermostat CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 609477 609733 256 0.0
RAM 68764 68780 16 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 629337 629593 256 0.0
RAM 71396 71420 24 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 629337 629593 256 0.0
RAM 71396 71420 24 0.0
efr32 lock-app BRD4187C FLASH 925216 925336 120 0.0
RAM 159708 159732 24 0.0
BRD4338a FLASH 741384 741576 192 0.0
RAM 231008 231028 20 0.0
window-app BRD4187C FLASH 1018172 1018388 216 0.0
RAM 128052 128076 24 0.0
esp32 all-clusters-app c3devkit DRAM 95248 95280 32 0.0
FLASH 1539936 1540096 160 0.0
IRAM 82538 82538 0 0.0
m5stack DRAM 116192 116216 24 0.0
FLASH 1550134 1550290 156 0.0
IRAM 117039 117039 0 0.0
linux air-purifier-app debug unknown 4688 4688 0 0.0
FLASH 2781089 2781571 482 0.0
RAM 129520 129648 128 0.1
all-clusters-app debug unknown 5528 5528 0 0.0
FLASH 6092068 6092550 482 0.0
RAM 524128 524256 128 0.0
all-clusters-minimal-app debug unknown 5424 5424 0 0.0
FLASH 5422820 5423334 514 0.0
RAM 242416 242544 128 0.1
bridge-app debug unknown 5408 5408 0 0.0
FLASH 4751720 4752202 482 0.0
RAM 218384 218512 128 0.1
chip-tool debug unknown 5960 5960 0 0.0
FLASH 13161544 13161544 0 0.0
RAM 584562 584562 0 0.0
chip-tool-ipv6only arm64 unknown 21408 21408 0 0.0
FLASH 11720160 11720160 0 0.0
RAM 635480 635480 0 0.0
fabric-admin debug unknown 5792 5792 0 0.0
FLASH 11377139 11377139 0 0.0
RAM 584218 584218 0 0.0
fabric-bridge-app debug unknown 4632 4632 0 0.0
FLASH 4575352 4575868 516 0.0
RAM 205048 205144 96 0.0
lighting-app debug+rpc+ui unknown 6056 6056 0 0.0
FLASH 5693713 5694225 512 0.0
RAM 228488 228616 128 0.1
lock-app debug unknown 5344 5344 0 0.0
FLASH 4801296 4801810 514 0.0
RAM 204472 204600 128 0.1
ota-provider-app debug unknown 4720 4720 0 0.0
FLASH 4430678 4431162 484 0.0
RAM 198192 198288 96 0.0
ota-requestor-app debug unknown 4656 4656 0 0.0
FLASH 4569444 4569928 484 0.0
RAM 202760 202856 96 0.0
shell debug unknown 4216 4216 0 0.0
FLASH 3115549 3116029 480 0.0
RAM 160496 160624 128 0.1
thermostat-no-ble arm64 unknown 9448 9464 16 0.2
FLASH 4319696 4320208 512 0.0
RAM 242888 243032 144 0.1
tv-app debug unknown 5624 5624 0 0.0
FLASH 6031557 6032069 512 0.0
RAM 596416 596576 160 0.0
tv-casting-app debug unknown 5208 5208 0 0.0
FLASH 11367389 11367965 576 0.0
RAM 675936 676080 144 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 915512 915716 204 0.0
RAM 143359 143412 53 0.0
nrf7002dk_nrf5340_cpuapp FLASH 886016 886076 60 0.0
RAM 141498 141551 53 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 848932 849132 200 0.0
RAM 142261 142314 53 0.0
nxp contact k32w0+release FLASH 582248 582264 16 0.0
RAM 70952 70968 16 0.0
k32w1+release FLASH 597136 597264 128 0.0
RAM 63184 63208 24 0.0
mcxw71+release FLASH 596896 597024 128 0.0
RAM 63184 63208 24 0.0
light k32w0+release FLASH 618764 618828 64 0.0
RAM 70416 70432 16 0.0
k32w1+release FLASH 683112 683264 152 0.0
RAM 48816 48824 8 0.0
mcxw71+release FLASH 683128 683280 152 0.0
RAM 48816 48824 8 0.0
lock k32w1+release FLASH 705480 705616 136 0.0
RAM 67324 67356 32 0.0
mcxw71+release FLASH 705504 705624 120 0.0
RAM 67324 67356 32 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1647556 1647740 184 0.0
RAM 212408 212432 24 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1553620 1553804 184 0.0
RAM 209208 209240 32 0.0
light cy8ckit_062s2_43012 FLASH 1467956 1468156 200 0.0
RAM 201200 201216 16 0.0
lock cy8ckit_062s2_43012 FLASH 1464932 1465116 184 0.0
RAM 225560 225576 16 0.0
qpg lighting-app qpg6105+debug FLASH 660560 660784 224 0.0
RAM 105396 105420 24 0.0
lock-app qpg6105+debug FLASH 618580 618748 168 0.0
RAM 99864 99888 24 0.0
stm32 light STM32WB5MM-DK FLASH 481896 482112 216 0.0
RAM 144844 144868 24 0.0
telink air-quality-sensor-app tlsr9528a_retention FLASH 620998 621234 236 0.0
RAM 50648 50708 60 0.1
all-clusters-app tlsr9118bdk40d FLASH 689376 689622 246 0.0
RAM 149488 149548 60 0.0
all-clusters-minimal-app tlsr9528a FLASH 782368 782614 246 0.0
RAM 111440 111500 60 0.1
bridge-app tlsr9258a FLASH 681098 681344 246 0.0
RAM 91304 91364 60 0.1
contact-sensor-app tlsr9528a_retention FLASH 620762 620998 236 0.0
RAM 50600 50660 60 0.1
light-switch-app-ota-shell-factory-data tlsr9528a FLASH 708716 708966 250 0.0
RAM 73940 74000 60 0.1
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 625712 625946 234 0.0
RAM 144468 144528 60 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 811720 811966 246 0.0
RAM 99100 99160 60 0.1
lock-app-dfu tlsr9528a FLASH 656668 656918 250 0.0
RAM 66660 66720 60 0.1
ota-requestor-app tlsr9258a FLASH 697076 697322 246 0.0
RAM 90896 90956 60 0.1
pump-app-usb tlsr9518adk80d FLASH 634400 634650 250 0.0
RAM 55476 55536 60 0.1
pump-controller-app tlsr9518adk80d FLASH 611598 611848 250 0.0
RAM 52720 52780 60 0.1
shell tlsr9518adk80d FLASH 467872 467872 0 0.0
RAM 68168 68168 0 0.0
smoke_co_alarm-app tlsr9528a_retention FLASH 627912 628148 236 0.0
RAM 52320 52380 60 0.1
temperature-measurement-app-mars-ota tlsr9518adk80d FLASH 653730 653980 250 0.0
RAM 56268 56328 60 0.1
thermostat tlsr9518adk80d FLASH 638340 638590 250 0.0
RAM 53112 53172 60 0.1
window-covering tlsr9118bdk40d FLASH 524456 524698 242 0.0
RAM 97444 97504 60 0.1
tizen all-clusters-app arm unknown 4912 4920 8 0.2
FLASH 1729220 1729628 408 0.0
RAM 90180 90228 48 0.1
chip-tool-ubsan arm unknown 10792 10792 0 0.0
FLASH 18327198 18327198 0 0.0
RAM 7969512 7969512 0 0.0

src/app/BUILD.gn Outdated Show resolved Hide resolved
This commit introduces the initial logic for handling Terms and
Conditions (TC) acknowledgements in the General Commissioning cluster.
The logic includes support for setting and checking TC acknowledgements
and versions during the commissioning process.

Changes include:
- Handling TC acknowledgements and TC acknowledgement version in the
  pairing command.
- Logic to read TC attributes and check TC acceptance in the General
  Commissioning server.
- Introduction of classes to manage TC acceptance logic.
- Initialization and use of TC providers in the server setup.
- Addition of a new commissioning stage for TC acknowledgements in the
  commissioning flow.

The feature logic is currently disabled and will be enabled in an
example in a subsequent commit.
Copy link

github-actions bot commented Oct 17, 2024

PR #34065: Size comparison from 5fe4409 to a7ea749

Full report (79 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, linux, nrfconnect, nxp, psoc6, qpg, stm32, telink, tizen)
platform target config section 5fe4409 a7ea749 change % change
bl602 lighting-app bl602+mfd+littlefs+rpc FLASH 1349986 1350520 534 0.0
RAM 104120 104144 24 0.0
bl702 lighting-app bl702+eth FLASH 647742 648022 280 0.0
RAM 25233 25241 8 0.0
bl702+wifi FLASH 825228 825508 280 0.0
RAM 13965 13973 8 0.1
bl706+mfd+rpc+littlefs FLASH 1054154 1054178 24 0.0
RAM 23821 23821 0 0.0
bl702l lighting-app bl702l+mfd+littlefs FLASH 974998 975022 24 0.0
RAM 16468 16476 8 0.0
cc13x4_26x4 lighting-app LP_EM_CC1354P10_6 FLASH 829564 829632 68 0.0
RAM 123452 123468 16 0.0
lock-ftd LP_EM_CC1354P10_6 FLASH 814872 814940 68 0.0
RAM 125332 125356 24 0.0
pump-app LP_EM_CC1354P10_6 FLASH 761420 761548 128 0.0
RAM 113824 113856 32 0.0
pump-controller-app LP_EM_CC1354P10_6 FLASH 745664 745800 136 0.0
RAM 114016 114032 16 0.0
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 617202 617422 220 0.0
RAM 205908 205932 24 0.0
lock CC3235SF_LAUNCHXL FLASH 657258 657478 220 0.0
RAM 206060 206076 16 0.0
cyw30739 light CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 678549 678701 152 0.0
RAM 78668 78684 16 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 698393 698545 152 0.0
RAM 81300 81324 24 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 698393 698545 152 0.0
RAM 81300 81324 24 0.0
CYW930739M2EVB-02 unknown 2040 2040 0 0.0
FLASH 655329 655481 152 0.0
RAM 73736 73752 16 0.0
light-switch CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 614845 615093 248 0.0
RAM 71628 71660 32 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 634473 634729 256 0.0
RAM 74180 74204 24 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 634473 634729 256 0.0
RAM 74180 74204 24 0.0
lock CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 634165 634413 248 0.0
RAM 74676 74700 24 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 653873 654129 256 0.0
RAM 77228 77244 16 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 653873 654129 256 0.0
RAM 77228 77244 16 0.0
thermostat CYW30739B2-P5-EVK-01 unknown 2040 2040 0 0.0
FLASH 609477 609733 256 0.0
RAM 68764 68780 16 0.0
CYW30739B2-P5-EVK-02 unknown 2040 2040 0 0.0
FLASH 629337 629593 256 0.0
RAM 71396 71420 24 0.0
CYW30739B2-P5-EVK-03 unknown 2040 2040 0 0.0
FLASH 629337 629593 256 0.0
RAM 71396 71420 24 0.0
efr32 lock-app BRD4187C FLASH 925216 925336 120 0.0
RAM 159708 159732 24 0.0
BRD4338a FLASH 741384 741576 192 0.0
RAM 231008 231028 20 0.0
window-app BRD4187C FLASH 1018172 1018388 216 0.0
RAM 128052 128076 24 0.0
esp32 all-clusters-app c3devkit DRAM 95256 95288 32 0.0
FLASH 1539878 1540038 160 0.0
IRAM 82538 82538 0 0.0
m5stack DRAM 116192 116216 24 0.0
FLASH 1550070 1550242 172 0.0
IRAM 117039 117039 0 0.0
linux air-purifier-app debug unknown 4688 4688 0 0.0
FLASH 2781147 2781629 482 0.0
RAM 129520 129648 128 0.1
all-clusters-app debug unknown 5528 5528 0 0.0
FLASH 6092126 6092608 482 0.0
RAM 524000 524128 128 0.0
all-clusters-minimal-app debug unknown 5424 5424 0 0.0
FLASH 5422878 5423392 514 0.0
RAM 242416 242544 128 0.1
bridge-app debug unknown 5408 5408 0 0.0
FLASH 4751808 4752290 482 0.0
RAM 218384 218512 128 0.1
chip-tool debug unknown 5960 5960 0 0.0
FLASH 13161588 13161588 0 0.0
RAM 584562 584562 0 0.0
chip-tool-ipv6only arm64 unknown 21408 21408 0 0.0
FLASH 11720208 11720208 0 0.0
RAM 635488 635488 0 0.0
fabric-admin debug unknown 5792 5792 0 0.0
FLASH 11383761 11383761 0 0.0
RAM 584650 584650 0 0.0
fabric-bridge-app debug unknown 4632 4632 0 0.0
FLASH 4578204 4578720 516 0.0
RAM 205336 205432 96 0.0
lighting-app debug+rpc+ui unknown 6056 6056 0 0.0
FLASH 5693761 5694273 512 0.0
RAM 228488 228616 128 0.1
lock-app debug unknown 5344 5344 0 0.0
FLASH 4801354 4801868 514 0.0
RAM 204472 204600 128 0.1
ota-provider-app debug unknown 4720 4720 0 0.0
FLASH 4430736 4431220 484 0.0
RAM 198192 198288 96 0.0
ota-requestor-app debug unknown 4656 4656 0 0.0
FLASH 4569502 4569986 484 0.0
RAM 202760 202856 96 0.0
shell debug unknown 4216 4216 0 0.0
FLASH 3115597 3116077 480 0.0
RAM 160368 160496 128 0.1
thermostat-no-ble arm64 unknown 9448 9464 16 0.2
FLASH 4319760 4320272 512 0.0
RAM 242896 243040 144 0.1
tv-app debug unknown 5624 5624 0 0.0
FLASH 6031653 6032165 512 0.0
RAM 596416 596576 160 0.0
tv-casting-app debug unknown 5208 5208 0 0.0
FLASH 11367421 11367997 576 0.0
RAM 675936 676080 144 0.0
nrfconnect all-clusters-app nrf52840dk_nrf52840 FLASH 915452 915656 204 0.0
RAM 143357 143410 53 0.0
nrf7002dk_nrf5340_cpuapp FLASH 885956 886016 60 0.0
RAM 141496 141549 53 0.0
all-clusters-minimal-app nrf52840dk_nrf52840 FLASH 848944 849144 200 0.0
RAM 142265 142318 53 0.0
nxp contact k32w0+release FLASH 582312 582328 16 0.0
RAM 70948 70964 16 0.0
mcxw71+release FLASH 596896 597024 128 0.0
RAM 63184 63208 24 0.0
light k32w0+release FLASH 618884 618948 64 0.0
RAM 70412 70428 16 0.0
k32w1+release FLASH 683112 683264 152 0.0
RAM 48816 48824 8 0.0
lock mcxw71+release FLASH 705504 705624 120 0.0
RAM 67324 67356 32 0.0
psoc6 all-clusters cy8ckit_062s2_43012 FLASH 1647500 1647684 184 0.0
RAM 212408 212432 24 0.0
all-clusters-minimal cy8ckit_062s2_43012 FLASH 1553620 1553820 200 0.0
RAM 209208 209240 32 0.0
light cy8ckit_062s2_43012 FLASH 1467956 1468156 200 0.0
RAM 201200 201216 16 0.0
lock cy8ckit_062s2_43012 FLASH 1464932 1465116 184 0.0
RAM 225560 225576 16 0.0
qpg lighting-app qpg6105+debug FLASH 660560 660784 224 0.0
RAM 105396 105420 24 0.0
lock-app qpg6105+debug FLASH 618580 618748 168 0.0
RAM 99864 99888 24 0.0
stm32 light STM32WB5MM-DK FLASH 481896 482112 216 0.0
RAM 144844 144868 24 0.0
telink air-quality-sensor-app tlsr9528a_retention FLASH 620998 621234 236 0.0
RAM 50648 50708 60 0.1
all-clusters-app tlsr9118bdk40d FLASH 689390 689636 246 0.0
RAM 149492 149552 60 0.0
all-clusters-minimal-app tlsr9528a FLASH 782382 782628 246 0.0
RAM 111440 111500 60 0.1
bridge-app tlsr9258a FLASH 681112 681358 246 0.0
RAM 91304 91364 60 0.1
contact-sensor-app tlsr9528a_retention FLASH 620762 620998 236 0.0
RAM 50600 50660 60 0.1
light-switch-app-ota-shell-factory-data tlsr9528a FLASH 708716 708966 250 0.0
RAM 73940 74000 60 0.1
lighting-app-ota-factory-data tlsr9118bdk40d FLASH 625712 625946 234 0.0
RAM 144468 144528 60 0.0
lighting-app-ota-rpc-factory-data-4mb tlsr9518adk80d FLASH 811720 811966 246 0.0
RAM 99100 99160 60 0.1
lock-app-dfu tlsr9528a FLASH 656668 656918 250 0.0
RAM 66660 66720 60 0.1
ota-requestor-app tlsr9258a FLASH 697090 697336 246 0.0
RAM 90896 90956 60 0.1
pump-app-usb tlsr9518adk80d FLASH 634400 634650 250 0.0
RAM 55476 55536 60 0.1
pump-controller-app tlsr9518adk80d FLASH 611598 611848 250 0.0
RAM 52720 52780 60 0.1
shell tlsr9518adk80d FLASH 467872 467872 0 0.0
RAM 68168 68168 0 0.0
smoke_co_alarm-app tlsr9528a_retention FLASH 627912 628148 236 0.0
RAM 52320 52380 60 0.1
temperature-measurement-app-mars-ota tlsr9518adk80d FLASH 653730 653980 250 0.0
RAM 56268 56328 60 0.1
thermostat tlsr9518adk80d FLASH 638340 638590 250 0.0
RAM 53112 53172 60 0.1
window-covering tlsr9118bdk40d FLASH 524456 524698 242 0.0
RAM 97444 97504 60 0.1
tizen all-clusters-app arm unknown 4912 4920 8 0.2
FLASH 1729236 1729652 416 0.0
RAM 90108 90156 48 0.1
chip-tool-ubsan arm unknown 10792 10792 0 0.0
FLASH 18327198 18327198 0 0.0
RAM 7969512 7969512 0 0.0

Comment on lines 125 to 135
if (nullptr == termsAndConditionsProvider)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}

err = termsAndConditionsProvider->GetRequirements(outTermsAndConditions);
if (CHIP_NO_ERROR != err)
{
return CHIP_ERROR_INTERNAL;
}

Copy link
Contributor

Choose a reason for hiding this comment

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

For these returns on conditions not met or err != CHIP_NO_ERROR, we use VerifyOrReturnError(cond, error) and ReturnErrorOnFailure(err)

It would make the overall vertical space in here much tighter.

Comment on lines 121 to 137
TermsAndConditionsProvider * const termsAndConditionsProvider = Server::GetInstance().GetTermsAndConditionsProvider();
Optional<TermsAndConditions> outTermsAndConditions;
CHIP_ERROR err;

if (nullptr == termsAndConditionsProvider)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}

err = termsAndConditionsProvider->GetRequirements(outTermsAndConditions);
if (CHIP_NO_ERROR != err)
{
return CHIP_ERROR_INTERNAL;
}

return !outTermsAndConditions.HasValue() ? aEncoder.Encode(static_cast<uint16_t>(0))
: aEncoder.Encode(outTermsAndConditions.Value().version);
Copy link
Contributor

Choose a reason for hiding this comment

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

Example:

Suggested change
TermsAndConditionsProvider * const termsAndConditionsProvider = Server::GetInstance().GetTermsAndConditionsProvider();
Optional<TermsAndConditions> outTermsAndConditions;
CHIP_ERROR err;
if (nullptr == termsAndConditionsProvider)
{
return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}
err = termsAndConditionsProvider->GetRequirements(outTermsAndConditions);
if (CHIP_NO_ERROR != err)
{
return CHIP_ERROR_INTERNAL;
}
return !outTermsAndConditions.HasValue() ? aEncoder.Encode(static_cast<uint16_t>(0))
: aEncoder.Encode(outTermsAndConditions.Value().version);
TermsAndConditionsProvider * const termsAndConditionsProvider = Server::GetInstance().GetTermsAndConditionsProvider();
VerifyOrReturnError(nullptr != termsAndConditionsProvider, CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE);
Optional<TermsAndConditions> outTermsAndConditions;
ReturnErrorOnFailure(termsAndConditionsProvider->GetRequirements(outTermsAndConditions));
return !outTermsAndConditions.HasValue() ? aEncoder.Encode(static_cast<uint16_t>(0))
: aEncoder.Encode(outTermsAndConditions.Value().version);

The re-writing of errors to CHIP_ERROR_INTERNAL is frowned-upon because the underlying error under the hood will be lost to upstream logging, and furthermore, so errors properly lead to different IM StatusCode for some cases.

}
else
{
CheckSuccess(termsAndConditionsProvider->CommitAcceptance(), Failure);
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 allowed to be called (and immediately committed) outside failsafe?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Outside of the failsafe context, I believe we should be able to accept updated terms and conditions. I thought the intention of failsafe context was to establish a failsafe context where you could change things and they are not committed until the failsafe is closed or commissioning complete. I don't believe we made any statements that this command may only be received while in the failsafe context.

Copy link
Contributor

Choose a reason for hiding this comment

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

Every command of General Commissioning cluster can only be handled during fail-same. But overall, it's odd whenever there is any state that can be reverted by fail-safe under some situations, but not others.

Comment on lines +29 to +36
#define VerifyNoErrorOrReturnValue(expr, code, ...) VerifyOrReturnValue(CHIP_NO_ERROR == expr, code, ##__VA_ARGS__)
#define VerifyNoErrorOrReturnInternal(expr, ...) VerifyNoErrorOrReturnValue(expr, CHIP_ERROR_INTERNAL, ##__VA_ARGS__)
#define VerifyOrReturnInvalidArgument(expr, ...) VerifyOrReturnValue(expr, CHIP_ERROR_INVALID_ARGUMENT, ##__VA_ARGS__)
#define VerifyOrReturnUninitialized(expr, ...) VerifyOrReturnValue(expr, CHIP_ERROR_UNINITIALIZED, ##__VA_ARGS__)
#define VerifyOrReturnInternal(expr, ...) VerifyOrReturnValue(expr, CHIP_ERROR_INTERNAL, ##__VA_ARGS__)
#define VerifyNotNullOrReturnInvalidArgument(expr, ...) \
VerifyOrReturnValue(nullptr != expr, CHIP_ERROR_INVALID_ARGUMENT, ##__VA_ARGS__)
#define VerifyNotNullOrReturnUninitialized(expr, ...) VerifyOrReturnValue(nullptr != expr, CHIP_ERROR_UNINITIALIZED, ##__VA_ARGS__)
Copy link
Contributor

Choose a reason for hiding this comment

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

Why all these different ones rather than following the usual patterns?

8 * sizeof(uint16_t); // Extra space for rollback compatibility
} // namespace

CHIP_ERROR chip::app::DefaultTermsAndConditionsStorageDelegate::Init(PersistentStorageDelegate * const inPersistentStorageDelegate)
Copy link
Contributor

Choose a reason for hiding this comment

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

the * const here and many other places is superfluous.

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 had ChatGPT write this up... I can remove them, but they do provide some purpose, but if the codebase avoids it, I can remove them.


The value of marking a pointer as const to prevent reassignment is mostly contextual and subjective, depending on factors like coding standards, project size, and developer preferences. Let's explore its potential value in terms of code safety and clarity:

Value of the const Safeguard

  1. Preventing Accidental Reassignment:

    • If your function doesn’t intend to reassign the pointer, marking it const can prevent potential errors or bugs. While it’s uncommon to accidentally reassign a pointer, this safeguard ensures that such mistakes (whether by you or others maintaining the code) can’t happen.
    • Example: If the function signature makes it clear that the pointer shouldn’t change, the const makes it explicit, and the compiler will catch any unintentional reassignment attempts. In large codebases, or when refactoring, this can help avoid subtle issues.
  2. Intentionality and Code Self-Documentation:

    • Using const clarifies the function’s contract. It signals to anyone reading or maintaining the code that the function will not modify the pointer itself, reinforcing the idea that the pointer is only used to access the object it points to, and its address is fixed inside the function.
    • Code readability: Some developers find that adding const improves readability by making the contract of the function more explicit: "This function guarantees it won’t reassign the pointer."
  3. Consistency Across a Codebase:

    • In projects where const correctness is emphasized, consistently applying const to pointers and references can enforce a mindset of immutability, leading to fewer bugs, especially in larger teams or systems with complex pointer manipulation.
    • Code standards: In some codebases (particularly in critical systems, embedded systems, or safety-critical applications), strict const correctness is a common practice to ensure immutability where appropriate.
  4. Compiler Optimizations:

    • In some cases, marking pointers const might enable the compiler to perform certain optimizations, although this is more relevant when using const on the object the pointer points to, rather than the pointer itself. Nonetheless, using const consistently can lead to subtle performance improvements.

Is the Safeguard Always Valuable?

While these benefits exist, the actual value of marking the pointer const in a specific function can vary:

  • For small functions or simple codebases, this safeguard might not be crucial. It might even be seen as unnecessary verbosity if it’s obvious from the function’s implementation that the pointer won’t be reassigned.

  • For large or complex codebases where multiple developers interact with the code, or where functions are long and intricate, the const qualifier can be more valuable as it contributes to readability and avoids unintended side effects.

Code Clarity in Practice

  • Minimal clarity improvement: In simple functions, marking the pointer as const may provide minimal clarity because it’s already clear from context that the pointer won't be reassigned.
  • Enhanced clarity in larger functions: In larger or more complex functions, where the pointer is used in multiple places, adding const can act as a reminder that the pointer shouldn’t be modified.

Conclusion: How Valuable Is It?

  • In smaller or less critical functions: The value might be negligible, as it doesn’t fundamentally change behavior.
  • In larger or more complex functions, or in codebases that emphasize immutability and safety: It adds clarity and helps prevent potential bugs. In such cases, the const safeguard can be useful, even if only to communicate intent clearly to other developers.

Whether this safeguard adds value depends on your team's coding practices and the complexity of your system. If you prioritize strict immutability and preventing subtle bugs, using const is beneficial. If simplicity and brevity are more important in your specific context, it may seem superfluous.

Copy link
Contributor

Choose a reason for hiding this comment

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

Whether this safeguard adds value depends on your team's coding practices and the complexity of your system

const int * == int const * --> this the common understanding in practice of single-const either side. Our codebase strongly prefers the const at the start.

VerifyNoErrorOrReturnInternal(tlvReader.ExitContainer(tlvContainer));

// Only v1 serialization format is supported
VerifyOrReturnInternal(kSerializationVersion == serializationVersion);
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not tolerate v > 1? Will this clean-up as intended if this ever hits, or will the caller exit elsewhere and we will get in a messed-up place which can't go on?

Comment on lines +273 to +274
ChipLogError(AppServer, "Failed storage delegate Delete(): %" CHIP_ERROR_FORMAT, err.Format());
return CHIP_ERROR_INTERNAL;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggest nor returning an error here, as the client can't do anything with it.

@@ -222,6 +222,8 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams)

mReportScheduler = initParams.reportScheduler;

mTermsAndConditionsProvider = initParams.termsAndConditionsProvider;
Copy link
Contributor

@tcarmelveilleux tcarmelveilleux Oct 22, 2024

Choose a reason for hiding this comment

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

This should be conditional T&Cs enabled, otherwise we have to pay for some provider flash space even if not used.

Comment on lines +316 to +328
#if CHIP_CONFIG_TC_REQUIRED
static app::DefaultTermsAndConditionsProvider sDefaultTermsAndConditionsProviderInstance;
static app::DefaultTermsAndConditionsStorageDelegate sDefaultTermsAndConditionsStorageDelegateInstance;

Optional<app::TermsAndConditions> termsAndConditions = Optional<app::TermsAndConditions>((app::TermsAndConditions){
.value = CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS,
.version = CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION,
});

ReturnErrorOnFailure(sDefaultTermsAndConditionsStorageDelegateInstance.Init(this->persistentStorageDelegate));
ReturnErrorOnFailure(sDefaultTermsAndConditionsProviderInstance.Init(&sDefaultTermsAndConditionsStorageDelegateInstance,
termsAndConditions));
this->termsAndConditionsProvider = &sDefaultTermsAndConditionsProviderInstance;
Copy link
Contributor

Choose a reason for hiding this comment

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

This means that in this case (which most products will inherit blindly) will use the CHIP_CONFIG_XXX per-firmware version. Would recommend not doing any magic init of this here, and making every user of T&C provider setup explicit init of the T&C when needed.


SessionHandle handle = commandObj->GetExchangeContext()->GetSessionHandle();

// Ensure it's a valid CASE session
Copy link
Contributor

Choose a reason for hiding this comment

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

Per (now updated) spec, this check happens after the terms and conditions check, so this is not matching the spec.

if (handle->GetSessionType() != Session::SessionType::kSecure ||
handle->AsSecureSession()->GetSecureSessionType() != SecureSession::Type::kCASE ||
!failSafe.MatchesFabricIndex(commandObj->GetAccessingFabricIndex()))
response.errorCode = CheckTermsAndConditionsAcknowledgements(termsAndConditionsProvider);
Copy link
Contributor

Choose a reason for hiding this comment

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

So that can return one of three values: NotMet, NotReceived, NotAccepted. The spec allows NotReceived and NotMet here; it does not have any provisions for NotAccepted.

Is NotAccepted not a possible return value in this situation? If so that should probably be documented here with an explanation of why not.

If it's a possible return value, this does not match the spec.

}
else

if (failSafe.UpdateTermsAndConditionsHasBeenInvoked())
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see anything in the spec that says that terms and conditions bits are rolled back by fail-safe expiration, or indeed any interaction between fail-safe and terms and conditions bits. Where is this coming from?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's fix the spec. It was the intent that there would be fail-safe handling during commissioning fail-safe, AND it's implemented. I would be OK letting it stay like this until the spec is updated, assuming it's already the assumption.

Copy link

Choose a reason for hiding this comment

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

Comment on lines +571 to +572
// Clear terms and conditions acceptance on failsafe timer expiration
termsAndConditionsProvider->RevertAcceptance();
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not in the spec. Where is this coming from?

Copy link
Contributor

Choose a reason for hiding this comment

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

See my comment above.

Copy link

Choose a reason for hiding this comment

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


VerifyNotNullOrReturnUninitialized(mStorageDelegate);

tlvWriter.Init(buffer, sizeof(buffer));
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
tlvWriter.Init(buffer, sizeof(buffer));
tlvWriter.Init(buffer);


uint32_t lengthWritten = tlvWriter.GetLengthWritten();
VerifyOrReturnInternal(CanCastTo<uint16_t>(lengthWritten));
VerifyOrReturnInternal(lengthWritten <= kEstimatedTlvBufferSize);
Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, if this is false you already had a buffer overrun and smashed your stack and probably can't trust anything.... So not sure what this check is really getting you.

* @param[in] inStorageDelegate Storage delegate dependency.
*/
CHIP_ERROR Init(TermsAndConditionsStorageDelegate * const inStorageDelegate,
const chip::Optional<chip::app::TermsAndConditions> & inRequiredTermsAndConditions);
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
const chip::Optional<chip::app::TermsAndConditions> & inRequiredTermsAndConditions);
const Optional<TermsAndConditions> & inRequiredTermsAndConditions);


bool setTermsAndConditionsCallRequiredBeforeCommissioningCompleteSuccess =
termsAndConditionsState != TermsAndConditionsState::OK;
return aEncoder.Encode(setTermsAndConditionsCallRequiredBeforeCommissioningCompleteSuccess);

Choose a reason for hiding this comment

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

I understand the value read from this attribute change according to the user's status of acceptance.
However, it seems that there is no implementation to report the value when this attribute is subscribed.

return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
}

return aEncoder.EncodeNull();

Choose a reason for hiding this comment

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

Is this feature currently under development?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

[Feature] Implement Enhanced Setup Flow for core platform