Skip to content

Commit

Permalink
Integrate Terms and Conditions Acknowledgements in Commissioning Process
Browse files Browse the repository at this point in the history
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.

1. **Initial setup**

    ```bash
    mkdir -p $HOME/workspace
    git -C $HOME/workspace clone https://github.com/project-chip/zap.git --depth 1
    git -C $HOME/workspace clone [email protected]:swan-amazon/connectedhomeip.git -b feature/enhanced-setup-flow --depth 1
    git -C $HOME/workspace/connectedhomeip submodule update --init --recursive --depth 1
    ```

2. **Zap regen**

    ```bash
    ./scripts/tools/zap/zap_bootstrap.sh
    python3 ./scripts/tools/zap_regen_all.py
    python3 ./scripts/tools/zap_convert_all.py
    ```

3. **Build the Application**: Configure and build the `chip-all-clusters-app`
   with Bluetooth and WiFi disabled to simulate an on-network only commissioning
   environment.

    ```bash
    gn gen --check --fail-on-unused-args --export-compile-commands --root=/workspace/connectedhomeip/examples/all-clusters-app/linux --args="chip_tc_required_acknowledgements=1 chip_tc_required_acknowledgements_version=1 chip_config_network_layer_ble=false chip_enable_wifi=false is_debug=true" /workspace/connectedhomeip/out/linux-x64-all-clusters-no-ble-no-wifi
    ninja -C out/linux-x64-all-clusters-no-ble-no-wifi
    ```

4. **Build the `chip-tool`**: Configure and compile the `chip-tool`, which is
   used to commission and control the `chip-all-clusters-app`.

    ```bash
    gn gen --check --fail-on-unused-args --export-compile-commands --root=/workspace/connectedhomeip/examples/chip-tool /workspace/connectedhomeip/out/linux-x64-chip-tool
    ninja -C out/linux-x64-chip-tool
    ```

5. **Run the Test Application**: Execute the application, specifying a local
   Key-Value Store file and enabling trace decoding.

    ```bash
    rm -f /tmp/chip_* /tmp/kvs.bin && /workspace/connectedhomeip/out/linux-x64-all-clusters-no-ble-no-wifi/chip-all-clusters-app --KVS=/tmp/kvs.bin --trace_decode 1
    ```

6. **Commissioning Test Application**: Commission the test application with
   `chip-tool`

    ```bash
    /workspace/connectedhomeip/out/linux-x64-chip-tool/chip-tool pairing code 1 34970112332 --trace_decode 1 --tc-acknowledgements 1 --tc-acknowledgements-version 1
    /workspace/connectedhomeip/out/linux-x64-chip-tool/chip-tool onoff off 1 1
    ```

7. **Probe Test Application**:

    ```bash
    /workspace/connectedhomeip/out/linux-x64-chip-tool/chip-tool generalcommissioning read-by-id 5 1 0
    /workspace/connectedhomeip/out/linux-x64-chip-tool/chip-tool generalcommissioning read-by-id 6 1 0
    /workspace/connectedhomeip/out/linux-x64-chip-tool/chip-tool generalcommissioning read-by-id 7 1 0
    /workspace/connectedhomeip/out/linux-x64-chip-tool/chip-tool generalcommissioning set-tcacknowledgements 1 1 1 0
    ```

wip

fix
  • Loading branch information
swan-amazon committed Jun 10, 2024
1 parent 4790af5 commit 5380776
Show file tree
Hide file tree
Showing 25 changed files with 1,280 additions and 115 deletions.
21 changes: 20 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
"expressions": "native",
"sourceMap": {
"${workspaceFolder}/examples/all-clusters-app/": "${workspaceFolder}/examples/all-clusters-app/",
"${workspaceFolder}/examples/all-clusters-app/linux/third_party/connectedhomeip/": "${workspaceFolder}/"
"${workspaceFolder}/examples/all-clusters-app/third_party/connectedhomeip/src/": "${workspaceFolder}/src/",
"${workspaceFolder}/examples/all-clusters-app/third_party/connectedhomeip/": "${workspaceFolder}/"
},
"relativePathBase": "${workspaceFolder}",
"breakpointMode": "path",
Expand Down Expand Up @@ -69,6 +70,24 @@
"terminal": "console",
"stopOnEntry": false
},
{
"name": "LLDB Debugger: Unit Test",
"type": "lldb", // [vadimcn/codelldb](https://github.com/vadimcn/codelldb)
"request": "launch",
"expressions": "native",
"sourceMap": {},
"relativePathBase": "${workspaceFolder}",
"breakpointMode": "path",
"sourceLanguages": ["cpp"],
"reverseDebugging": true,
"program": "/workspace/connectedhomeip/out/unified/linux_x64_clang/tests/TestDefaultTermsAndConditionsProvider",
"args": [],
"cwd": "/workspace/connectedhomeip/out/unified",
"env": {},
"stdio": [null, null, null],
"terminal": "console",
"stopOnEntry": false
},
{
"name": "Attach to running process",
"type": "lldb",
Expand Down
10 changes: 10 additions & 0 deletions config/standalone/CHIPProjectConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,16 @@
#define CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING "1.0"
#endif

// ----------------------- Terms and Conditions -----------------------

#ifndef CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS
#define CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS 0
#endif

#ifndef CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION
#define CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION 0
#endif

//
// Default of 8 ECs is not sufficient for some of the unit tests
// that try to validate multiple simultaneous interactions.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2171,6 +2171,22 @@
"source": "server",
"isIncoming": 0,
"isEnabled": 1
},
{
"name": "SetTCAcknowledgements",
"code": 6,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "SetTCAcknowledgementsResponse",
"code": 7,
"mfgCode": null,
"source": "server",
"isIncoming": 0,
"isEnabled": 1
}
],
"attributes": [
Expand Down Expand Up @@ -2254,6 +2270,70 @@
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "TCAcceptedVersion",
"code": 5,
"mfgCode": null,
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "TCMinRequiredVersion",
"code": 6,
"mfgCode": null,
"side": "server",
"type": "int16u",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "1",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "TCAcknowledgements",
"code": 7,
"mfgCode": null,
"side": "server",
"type": "bitmap16",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0x0000",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "TCAcknowledgementsRequired",
"code": 8,
"mfgCode": null,
"side": "server",
"type": "boolean",
"included": 1,
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "true",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "GeneratedCommandList",
"code": 65528,
Expand Down Expand Up @@ -2328,7 +2408,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "0",
"defaultValue": "1",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@

#pragma once


#define CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS 1

#define CHIP_CONFIG_TC_REQUIRED_ACKNOWLEDGEMENTS_VERSION 1

// include the CHIPProjectConfig from config/standalone
#include <CHIPProjectConfig.h>

Expand Down
1 change: 0 additions & 1 deletion examples/chip-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,6 @@ static_library("chip-tool-utils") {
"${chip_root}/examples/common/tracing:commandline",
"${chip_root}/src/app/icd/client:handler",
"${chip_root}/src/app/icd/client:manager",
"${chip_root}/src/app/server",
"${chip_root}/src/app/tests/suites/commands/interaction_model",
"${chip_root}/src/controller/data_model",
"${chip_root}/src/credentials:file_attestation_trust_store",
Expand Down
13 changes: 12 additions & 1 deletion examples/chip-tool/commands/pairing/PairingCommand.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2020-2024 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -118,6 +118,17 @@ CommissioningParameters PairingCommand::GetCommissioningParameters()
params.SetCountryCode(CharSpan::fromCharString(mCountryCode.Value()));
}

// mTCAcknowledgements and mTCAcknowledgementVersion are options, but related. When one is missing, default the value to 0, to
// increase the test tools ability to test the applications.
if (mTCAcknowledgements.HasValue() || mTCAcknowledgementVersion.HasValue())
{
TermsAndConditionsAcknowledgement termsAndConditionsAcknowledgement = {
.acceptedTermsAndConditions = mTCAcknowledgements.ValueOr(0),
.acceptedTermsAndConditionsVersion = mTCAcknowledgementVersion.ValueOr(0),
};
params.SetTermsAndConditionsAcknowledgement(termsAndConditionsAcknowledgement);
}

// mTimeZoneList is an optional argument managed by TypedComplexArgument mComplex_TimeZones.
// Since optional Complex arguments are not currently supported via the <chip::Optional> class,
// we will use mTimeZoneList.data() value to determine if the argument was provided.
Expand Down
12 changes: 11 additions & 1 deletion examples/chip-tool/commands/pairing/PairingCommand.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020 Project CHIP Authors
* Copyright (c) 2020-2024 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -182,6 +182,14 @@ class PairingCommand : public CHIPCommand,
AddArgument("dst-offset", &mComplex_DSTOffsets,
"DSTOffset list to use when setting Time Synchronization cluster's DSTOffset attribute",
Argument::kOptional);

AddArgument("tc-acknowledgements", 0, UINT16_MAX, &mTCAcknowledgements,
"Terms and Conditions acknowledgements to use to set the General Commissioning cluster's TC "
"Acknowledgements bit-field");

AddArgument("tc-acknowledgements-version", 0, UINT16_MAX, &mTCAcknowledgementVersion,
"Terms and Conditions acknowledgement version to use to set the General Commissioning cluster's TC "
"Acknowledgement version");
}

AddArgument("timeout", 0, UINT16_MAX, &mTimeout);
Expand Down Expand Up @@ -233,6 +241,8 @@ class PairingCommand : public CHIPCommand,
chip::Optional<bool> mBypassAttestationVerifier;
chip::Optional<std::vector<uint32_t>> mCASEAuthTags;
chip::Optional<char *> mCountryCode;
chip::Optional<uint16_t> mTCAcknowledgements;
chip::Optional<uint16_t> mTCAcknowledgementVersion;
chip::Optional<bool> mSkipICDRegistration;
chip::Optional<NodeId> mICDCheckInNodeId;
chip::Optional<chip::ByteSpan> mICDSymmetricKey;
Expand Down
1 change: 1 addition & 0 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,7 @@ static_library("interaction-model") {
"${chip_root}/src/lib/address_resolve",
"${chip_root}/src/lib/support",
"${chip_root}/src/lib/support:static-support",
"${chip_root}/src/messaging:messaging",
"${chip_root}/src/protocols/interaction_model",
"${chip_root}/src/protocols/secure_channel",
"${chip_root}/src/system",
Expand Down
Loading

0 comments on commit 5380776

Please sign in to comment.