diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 89f25b2c163142..7601ec0d7495b9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -23,7 +23,10 @@ on: workflow_dispatch: concurrency: - group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == 'pull_request' && github.event.number) || (github.event_name == 'workflow_dispatch' && github.run_number) || github.sha }} + group: + ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name == + 'pull_request' && github.event.number) || (github.event_name == + 'workflow_dispatch' && github.run_number) || github.sha }} cancel-in-progress: true jobs: @@ -43,7 +46,7 @@ jobs: - name: Checkout submodules & Bootstrap uses: ./.github/actions/checkout-submodules-and-bootstrap with: - platform: linux + platform: linux - name: Check for orphaned gn files if: always() @@ -103,7 +106,6 @@ jobs: --known-failure app/reporting/reporting.cpp \ --known-failure app/reporting/tests/MockReportScheduler.cpp \ --known-failure app/reporting/tests/MockReportScheduler.h \ - --known-failure app/TestEventTriggerDelegate.h \ --known-failure app/util/attribute-storage.cpp \ --known-failure app/util/attribute-storage.h \ --known-failure app/util/attribute-storage-detail.h \ @@ -174,7 +176,8 @@ jobs: # git grep exits with 0 if it finds a match, but we want # to fail (exit nonzero) on match. And we want to exclude this file, # to avoid our grep regexp matching itself. - - name: Check for use of PRI*8, which are not supported on some libcs. + - name: + Check for use of PRI*8, which are not supported on some libcs. if: always() run: | git grep -I -n "PRI.8" -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)third_party/lwip/repo/lwip/src/include/lwip/arch.h' && exit 1 || exit 0 @@ -182,7 +185,9 @@ jobs: # git grep exits with 0 if it finds a match, but we want # to fail (exit nonzero) on match. And we want to exclude this file, # to avoid our grep regexp matching itself. - - name: Check for use of PRI*16, which are not supported on some libcs. + - name: + Check for use of PRI*16, which are not supported on some + libcs. if: always() run: | git grep -I -n "PRI.16" -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)third_party/lwip/repo/lwip/src/include/lwip/arch.h' && exit 1 || exit 0 @@ -190,7 +195,9 @@ jobs: # git grep exits with 0 if it finds a match, but we want # to fail (exit nonzero) on match. And we want to exclude this file, # to avoid our grep regexp matching itself. - - name: Check for use of PRI*64, which are not supported on some libcs. + - name: + Check for use of PRI*64, which are not supported on some + libcs. if: always() run: | # TODO: MessageDefHelper should ideally not be excluded here. @@ -230,7 +237,9 @@ jobs: # git grep exits with 0 if it finds a match, but we want # to fail (exit nonzero) on match. And we want to exclude this file, # to avoid our grep regexp matching itself. - - name: Check for use of 0x%u and the like, which lead to misleading output. + - name: + Check for use of 0x%u and the like, which lead to misleading + output. if: always() run: | git grep -I -n '0x%[0-9l.-]*[^0-9lxX".-]' -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0 @@ -238,14 +247,18 @@ jobs: # git grep exits with 0 if it finds a match, but we want # to fail (exit nonzero) on match. And we want to exclude this file, # to avoid our grep regexp matching itself. - - name: Check for use of '"0x" PRIu*' and the like, which lead to misleading output. + - name: + Check for use of '"0x" PRIu*' and the like, which lead to + misleading output. if: always() run: | git grep -I -n '0x%[0-9-]*" *PRI[^xX]' -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0 # git grep exits with 0 if it finds a match, but we want # to fail (exit nonzero) on match. - - name: Check for use of NSLog instead of Matter logging in Matter framework + - name: + Check for use of NSLog instead of Matter logging in Matter + framework if: always() run: | git grep -n 'NSLog(' -- src/darwin/Framework/CHIP && exit 1 || exit 0 @@ -254,7 +267,9 @@ jobs: # to fail (exit nonzero) on match. And we want to exclude this file, # to avoid our grep regexp matching itself, as well as excluding the files # that implement the type-safe accessors - - name: Check for use of 'emberAfReadAttribute' instead of the type-safe getters + - name: + Check for use of 'emberAfReadAttribute' instead of the + type-safe getters if: always() run: | git grep -I -n 'emberAfReadAttribute' -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)src/app/util/attribute-table.h' ':(exclude)zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp' ':(exclude)src/app/zap-templates/templates/app/attributes/Accessors-src.zapt' ':(exclude)src/app/util/attribute-table.cpp' && exit 1 || exit 0 @@ -264,7 +279,9 @@ jobs: # to avoid our grep regexp matching itself, as well as excluding the files # that implement the type-safe accessors, attribute writing from the wire, and some # Pigweed RPC code that seems hard to update. - - name: Check for use of 'emberAfWriteAttribute' instead of the type-safe setters + - name: + Check for use of 'emberAfWriteAttribute' instead of the + type-safe setters if: always() run: | git grep -I -n 'emberAfWriteAttribute' -- './*' ':(exclude).github/workflows/lint.yml' ':(exclude)zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp' ':(exclude)src/app/zap-templates/templates/app/attributes/Accessors-src.zapt' ':(exclude)src/app/util/attribute-table.cpp' ':(exclude)examples/common/pigweed/rpc_services/Attributes.h' ':(exclude)src/app/util/attribute-table.h' ':(exclude)src/app/util/ember-compatibility-functions.cpp' && exit 1 || exit 0 @@ -278,7 +295,9 @@ jobs: # git grep exits with 0 if it finds a match, but we want # to fail (exit nonzero) on match. And we want to exclude this file, # to avoid our grep regexp matching itself. - - name: Check for use of "SuccessOrExit(CHIP_ERROR_*)", which should probably be "SuccessOrExit(err = CHIP_ERROR_*)" + - name: + Check for use of "SuccessOrExit(CHIP_ERROR_*)", which should + probably be "SuccessOrExit(err = CHIP_ERROR_*)" if: always() run: | git grep -I -n 'SuccessOrExit(CHIP_ERROR' -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0 @@ -286,14 +305,19 @@ jobs: # git grep exits with 0 if it finds a match, but we want # to fail (exit nonzero) on match. And we want to exclude this file, # to avoid our grep regexp matching itself. - - name: Check for use of "SuccessOrExit(something-without-assignment(", which should probably be "SuccessOrExit(err = something(" + - name: + Check for use of + "SuccessOrExit(something-without-assignment(", which should + probably be "SuccessOrExit(err = something(" if: always() run: | git grep -I -n 'SuccessOrExit([^=)]*(' -- './*' ':(exclude).github/workflows/lint.yml' && exit 1 || exit 0 # git grep exits with 0 if it finds a match, but we want # to fail (exit nonzero) on match. - - name: Check for use of "using namespace" outside of a class/function in headers. + - name: + Check for use of "using namespace" outside of a class/function + in headers. if: always() run: | # Various platforms have `using namespace chip::Ble` in their BLEManager* headers; just exclude those for now. diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 73158ccb0557fd..d7639273132898 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -508,6 +508,7 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_FAN_3_4.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_FAN_3_5.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-lit-icd-ipv6only-no-ble-no-wifi-tsan-clang-test/lit-icd-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_ICDM_2_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-lit-icd-ipv6only-no-ble-no-wifi-tsan-clang-test/lit-icd-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_ICDManagementCluster.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --hex-arg enableKey:000102030405060708090a0b0c0d0e0f --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_IDM_1_2.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json --enable-key 000102030405060708090a0b0c0d0e0f" --script "src/python_testing/TC_IDM_1_4.py" --script-args "--hex-arg PIXIT.DGGEN.TEST_EVENT_TRIGGER_KEY:000102030405060708090a0b0c0d0e0f --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_PWRTL_2_1.py" --script-args "--storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' diff --git a/examples/chip-tool/commands/common/DeviceScanner.cpp b/examples/chip-tool/commands/common/DeviceScanner.cpp index 35d74bd06c844f..9d3dbca98f8db9 100644 --- a/examples/chip-tool/commands/common/DeviceScanner.cpp +++ b/examples/chip-tool/commands/common/DeviceScanner.cpp @@ -55,7 +55,7 @@ CHIP_ERROR DeviceScanner::Stop() void DeviceScanner::OnNodeDiscovered(const DiscoveredNodeData & nodeData) { - auto & commissionData = nodeData.commissionData; + auto & commissionData = nodeData.nodeData; auto discriminator = commissionData.longDiscriminator; auto vendorId = static_cast(commissionData.vendorId); diff --git a/examples/chip-tool/commands/common/DeviceScanner.h b/examples/chip-tool/commands/common/DeviceScanner.h index 0f29c87175a18e..e8259ffc554897 100644 --- a/examples/chip-tool/commands/common/DeviceScanner.h +++ b/examples/chip-tool/commands/common/DeviceScanner.h @@ -42,7 +42,7 @@ struct DeviceScannerResult chip::Optional mResolutionData; }; -class DeviceScanner : public chip::Dnssd::CommissioningResolveDelegate, +class DeviceScanner : public chip::Dnssd::DiscoverNodeDelegate, public chip::Dnssd::DnssdBrowseDelegate #if CONFIG_NETWORK_LAYER_BLE , @@ -56,7 +56,7 @@ class DeviceScanner : public chip::Dnssd::CommissioningResolveDelegate, CHIP_ERROR Get(uint16_t index, chip::Dnssd::CommonResolutionData & resolutionData); void Log() const; - /////////// CommissioningResolveDelegate Interface ///////// + /////////// DiscoverNodeDelegate Interface ///////// void OnNodeDiscovered(const chip::Dnssd::DiscoveredNodeData & nodeData) override; /////////// DnssdBrowseDelegate Interface ///////// diff --git a/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp b/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp index 37955e821e8b82..9e3026262db97d 100644 --- a/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp +++ b/examples/chip-tool/commands/common/RemoteDataModelLogger.cpp @@ -209,7 +209,7 @@ CHIP_ERROR LogDiscoveredNodeData(const chip::Dnssd::DiscoveredNodeData & nodeDat VerifyOrReturnError(gDelegate != nullptr, CHIP_NO_ERROR); auto & resolutionData = nodeData.resolutionData; - auto & commissionData = nodeData.commissionData; + auto & commissionData = nodeData.nodeData; if (!chip::CanCastTo(resolutionData.numIPs)) { diff --git a/examples/chip-tool/commands/pairing/PairingCommand.cpp b/examples/chip-tool/commands/pairing/PairingCommand.cpp index 0f47e48314b5a4..5ec206c25b7ea0 100644 --- a/examples/chip-tool/commands/pairing/PairingCommand.cpp +++ b/examples/chip-tool/commands/pairing/PairingCommand.cpp @@ -482,7 +482,7 @@ void PairingCommand::OnICDStayActiveComplete(NodeId deviceId, uint32_t promisedA void PairingCommand::OnDiscoveredDevice(const chip::Dnssd::DiscoveredNodeData & nodeData) { // Ignore nodes with closed commissioning window - VerifyOrReturn(nodeData.commissionData.commissioningMode != 0); + VerifyOrReturn(nodeData.nodeData.commissioningMode != 0); auto & resolutionData = nodeData.resolutionData; diff --git a/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn b/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn index 43a9860b5da48a..322c728a063ba7 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn +++ b/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn @@ -112,6 +112,7 @@ k32w0_executable("light_app") { "${chip_root}/examples/common/QRCode", "${chip_root}/examples/lighting-app/nxp/zap/", "${chip_root}/examples/providers:device_info_provider", + "${chip_root}/src/app:test-event-trigger", "${chip_root}/src/lib", "${chip_root}/src/platform:syscalls_stub", "${chip_root}/third_party/mbedtls:mbedtls", diff --git a/examples/lighting-app/silabs/build_for_wifi_args.gni b/examples/lighting-app/silabs/build_for_wifi_args.gni index bbb57ae35a4343..7e33551c30a97c 100644 --- a/examples/lighting-app/silabs/build_for_wifi_args.gni +++ b/examples/lighting-app/silabs/build_for_wifi_args.gni @@ -18,6 +18,9 @@ silabs_sdk_target = get_label_info(":sdk", "label_no_toolchain") chip_enable_openthread = false import("${chip_root}/src/platform/silabs/wifi_args.gni") +# Not needed for the Lighting-app +chip_enable_read_client = false + chip_enable_ota_requestor = true app_data_model = "${chip_root}/examples/lighting-app/silabs/data_model:silabs-lighting" diff --git a/examples/lighting-app/silabs/data_model/lighting-thread-app.matter b/examples/lighting-app/silabs/data_model/lighting-thread-app.matter index 415281989cae5d..60b6480176d518 100644 --- a/examples/lighting-app/silabs/data_model/lighting-thread-app.matter +++ b/examples/lighting-app/silabs/data_model/lighting-thread-app.matter @@ -745,265 +745,6 @@ cluster TimeFormatLocalization = 44 { readonly attribute int16u clusterRevision = 65533; } -/** This cluster is used to describe the configuration and capabilities of a physical power source that provides power to the Node. */ -cluster PowerSource = 47 { - revision 1; // NOTE: Default/not specifically set - - enum BatApprovedChemistryEnum : enum16 { - kUnspecified = 0; - kAlkaline = 1; - kLithiumCarbonFluoride = 2; - kLithiumChromiumOxide = 3; - kLithiumCopperOxide = 4; - kLithiumIronDisulfide = 5; - kLithiumManganeseDioxide = 6; - kLithiumThionylChloride = 7; - kMagnesium = 8; - kMercuryOxide = 9; - kNickelOxyhydride = 10; - kSilverOxide = 11; - kZincAir = 12; - kZincCarbon = 13; - kZincChloride = 14; - kZincManganeseDioxide = 15; - kLeadAcid = 16; - kLithiumCobaltOxide = 17; - kLithiumIon = 18; - kLithiumIonPolymer = 19; - kLithiumIronPhosphate = 20; - kLithiumSulfur = 21; - kLithiumTitanate = 22; - kNickelCadmium = 23; - kNickelHydrogen = 24; - kNickelIron = 25; - kNickelMetalHydride = 26; - kNickelZinc = 27; - kSilverZinc = 28; - kSodiumIon = 29; - kSodiumSulfur = 30; - kZincBromide = 31; - kZincCerium = 32; - } - - enum BatChargeFaultEnum : enum8 { - kUnspecified = 0; - kAmbientTooHot = 1; - kAmbientTooCold = 2; - kBatteryTooHot = 3; - kBatteryTooCold = 4; - kBatteryAbsent = 5; - kBatteryOverVoltage = 6; - kBatteryUnderVoltage = 7; - kChargerOverVoltage = 8; - kChargerUnderVoltage = 9; - kSafetyTimeout = 10; - } - - enum BatChargeLevelEnum : enum8 { - kOK = 0; - kWarning = 1; - kCritical = 2; - } - - enum BatChargeStateEnum : enum8 { - kUnknown = 0; - kIsCharging = 1; - kIsAtFullCharge = 2; - kIsNotCharging = 3; - } - - enum BatCommonDesignationEnum : enum16 { - kUnspecified = 0; - kAAA = 1; - kAA = 2; - kC = 3; - kD = 4; - k4v5 = 5; - k6v0 = 6; - k9v0 = 7; - k12AA = 8; - kAAAA = 9; - kA = 10; - kB = 11; - kF = 12; - kN = 13; - kNo6 = 14; - kSubC = 15; - kA23 = 16; - kA27 = 17; - kBA5800 = 18; - kDuplex = 19; - k4SR44 = 20; - k523 = 21; - k531 = 22; - k15v0 = 23; - k22v5 = 24; - k30v0 = 25; - k45v0 = 26; - k67v5 = 27; - kJ = 28; - kCR123A = 29; - kCR2 = 30; - k2CR5 = 31; - kCRP2 = 32; - kCRV3 = 33; - kSR41 = 34; - kSR43 = 35; - kSR44 = 36; - kSR45 = 37; - kSR48 = 38; - kSR54 = 39; - kSR55 = 40; - kSR57 = 41; - kSR58 = 42; - kSR59 = 43; - kSR60 = 44; - kSR63 = 45; - kSR64 = 46; - kSR65 = 47; - kSR66 = 48; - kSR67 = 49; - kSR68 = 50; - kSR69 = 51; - kSR516 = 52; - kSR731 = 53; - kSR712 = 54; - kLR932 = 55; - kA5 = 56; - kA10 = 57; - kA13 = 58; - kA312 = 59; - kA675 = 60; - kAC41E = 61; - k10180 = 62; - k10280 = 63; - k10440 = 64; - k14250 = 65; - k14430 = 66; - k14500 = 67; - k14650 = 68; - k15270 = 69; - k16340 = 70; - kRCR123A = 71; - k17500 = 72; - k17670 = 73; - k18350 = 74; - k18500 = 75; - k18650 = 76; - k19670 = 77; - k25500 = 78; - k26650 = 79; - k32600 = 80; - } - - enum BatFaultEnum : enum8 { - kUnspecified = 0; - kOverTemp = 1; - kUnderTemp = 2; - } - - enum BatReplaceabilityEnum : enum8 { - kUnspecified = 0; - kNotReplaceable = 1; - kUserReplaceable = 2; - kFactoryReplaceable = 3; - } - - enum PowerSourceStatusEnum : enum8 { - kUnspecified = 0; - kActive = 1; - kStandby = 2; - kUnavailable = 3; - } - - enum WiredCurrentTypeEnum : enum8 { - kAC = 0; - kDC = 1; - } - - enum WiredFaultEnum : enum8 { - kUnspecified = 0; - kOverVoltage = 1; - kUnderVoltage = 2; - } - - bitmap Feature : bitmap32 { - kWired = 0x1; - kBattery = 0x2; - kRechargeable = 0x4; - kReplaceable = 0x8; - } - - struct BatChargeFaultChangeType { - BatChargeFaultEnum current[] = 0; - BatChargeFaultEnum previous[] = 1; - } - - struct BatFaultChangeType { - BatFaultEnum current[] = 0; - BatFaultEnum previous[] = 1; - } - - struct WiredFaultChangeType { - WiredFaultEnum current[] = 0; - WiredFaultEnum previous[] = 1; - } - - info event WiredFaultChange = 0 { - WiredFaultEnum current[] = 0; - WiredFaultEnum previous[] = 1; - } - - info event BatFaultChange = 1 { - BatFaultEnum current[] = 0; - BatFaultEnum previous[] = 1; - } - - info event BatChargeFaultChange = 2 { - BatChargeFaultEnum current[] = 0; - BatChargeFaultEnum previous[] = 1; - } - - readonly attribute PowerSourceStatusEnum status = 0; - readonly attribute int8u order = 1; - readonly attribute char_string<60> description = 2; - readonly attribute optional nullable int32u wiredAssessedInputVoltage = 3; - readonly attribute optional nullable int16u wiredAssessedInputFrequency = 4; - readonly attribute optional WiredCurrentTypeEnum wiredCurrentType = 5; - readonly attribute optional nullable int32u wiredAssessedCurrent = 6; - readonly attribute optional int32u wiredNominalVoltage = 7; - readonly attribute optional int32u wiredMaximumCurrent = 8; - readonly attribute optional boolean wiredPresent = 9; - readonly attribute optional WiredFaultEnum activeWiredFaults[] = 10; - readonly attribute optional nullable int32u batVoltage = 11; - readonly attribute optional nullable int8u batPercentRemaining = 12; - readonly attribute optional nullable int32u batTimeRemaining = 13; - readonly attribute optional BatChargeLevelEnum batChargeLevel = 14; - readonly attribute optional boolean batReplacementNeeded = 15; - readonly attribute optional BatReplaceabilityEnum batReplaceability = 16; - readonly attribute optional boolean batPresent = 17; - readonly attribute optional BatFaultEnum activeBatFaults[] = 18; - readonly attribute optional char_string<60> batReplacementDescription = 19; - readonly attribute optional BatCommonDesignationEnum batCommonDesignation = 20; - readonly attribute optional char_string<20> batANSIDesignation = 21; - readonly attribute optional char_string<20> batIECDesignation = 22; - readonly attribute optional BatApprovedChemistryEnum batApprovedChemistry = 23; - readonly attribute optional int32u batCapacity = 24; - readonly attribute optional int8u batQuantity = 25; - readonly attribute optional BatChargeStateEnum batChargeState = 26; - readonly attribute optional nullable int32u batTimeToFullCharge = 27; - readonly attribute optional boolean batFunctionalWhileCharging = 28; - readonly attribute optional nullable int32u batChargingCurrent = 29; - readonly attribute optional BatChargeFaultEnum activeBatChargeFaults[] = 30; - readonly attribute endpoint_no endpointList[] = 31; - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; -} - /** This cluster is used to manage global aspects of the Commissioning flow. */ cluster GeneralCommissioning = 48 { revision 1; // NOTE: Default/not specifically set @@ -1253,53 +994,6 @@ cluster NetworkCommissioning = 49 { command access(invoke: administer) QueryIdentity(QueryIdentityRequest): QueryIdentityResponse = 9; } -/** The cluster provides commands for retrieving unstructured diagnostic logs from a Node that may be used to aid in diagnostics. */ -cluster DiagnosticLogs = 50 { - revision 1; // NOTE: Default/not specifically set - - enum IntentEnum : enum8 { - kEndUserSupport = 0; - kNetworkDiag = 1; - kCrashLogs = 2; - } - - enum StatusEnum : enum8 { - kSuccess = 0; - kExhausted = 1; - kNoLogs = 2; - kBusy = 3; - kDenied = 4; - } - - enum TransferProtocolEnum : enum8 { - kResponsePayload = 0; - kBDX = 1; - } - - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; - - request struct RetrieveLogsRequestRequest { - IntentEnum intent = 0; - TransferProtocolEnum requestedProtocol = 1; - optional char_string<32> transferFileDesignator = 2; - } - - response struct RetrieveLogsResponse = 1 { - StatusEnum status = 0; - long_octet_string logContent = 1; - optional epoch_us UTCTimeStamp = 2; - optional systime_us timeSinceBoot = 3; - } - - /** Retrieving diagnostic logs from a Node */ - command RetrieveLogsRequest(RetrieveLogsRequestRequest): RetrieveLogsResponse = 0; -} - /** The General Diagnostics Cluster, along with other diagnostics clusters, provide a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ cluster GeneralDiagnostics = 51 { revision 2; @@ -1431,43 +1125,6 @@ cluster GeneralDiagnostics = 51 { command PayloadTestRequest(PayloadTestRequestRequest): PayloadTestResponse = 3; } -/** The Software Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ -cluster SoftwareDiagnostics = 52 { - revision 1; // NOTE: Default/not specifically set - - bitmap Feature : bitmap32 { - kWatermarks = 0x1; - } - - struct ThreadMetricsStruct { - int64u id = 0; - optional char_string<8> name = 1; - optional int32u stackFreeCurrent = 2; - optional int32u stackFreeMinimum = 3; - optional int32u stackSize = 4; - } - - info event SoftwareFault = 0 { - int64u id = 0; - optional char_string name = 1; - optional octet_string faultRecording = 2; - } - - readonly attribute optional ThreadMetricsStruct threadMetrics[] = 0; - readonly attribute optional int64u currentHeapFree = 1; - readonly attribute optional int64u currentHeapUsed = 2; - readonly attribute optional int64u currentHeapHighWatermark = 3; - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; - - /** Reception of this command SHALL reset the values: The StackFreeMinimum field of the ThreadMetrics attribute, CurrentHeapHighWaterMark attribute. */ - command access(invoke: manage) ResetWatermarks(): DefaultSuccess = 0; -} - /** The Thread Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems */ cluster ThreadNetworkDiagnostics = 53 { revision 2; @@ -1888,43 +1545,6 @@ cluster GroupKeyManagement = 63 { fabric command access(invoke: administer) KeySetReadAllIndices(): KeySetReadAllIndicesResponse = 4; } -/** The Fixed Label Cluster provides a feature for the device to tag an endpoint with zero or more read only -labels. */ -cluster FixedLabel = 64 { - revision 1; // NOTE: Default/not specifically set - - struct LabelStruct { - char_string<16> label = 0; - char_string<16> value = 1; - } - - readonly attribute LabelStruct labelList[] = 0; - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; -} - -/** The User Label Cluster provides a feature to tag an endpoint with zero or more labels. */ -cluster UserLabel = 65 { - revision 1; // NOTE: Default/not specifically set - - struct LabelStruct { - char_string<16> label = 0; - char_string<16> value = 1; - } - - attribute access(write: manage) LabelStruct labelList[] = 0; - readonly attribute command_id generatedCommandList[] = 65528; - readonly attribute command_id acceptedCommandList[] = 65529; - readonly attribute event_id eventList[] = 65530; - readonly attribute attrib_id attributeList[] = 65531; - readonly attribute bitmap32 featureMap = 65532; - readonly attribute int16u clusterRevision = 65533; -} - /** Attributes and commands for scene configuration and manipulation. */ provisional cluster ScenesManagement = 98 { revision 1; @@ -2515,13 +2135,6 @@ endpoint 0 { handle command ReorderNetwork; } - server cluster DiagnosticLogs { - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; - - handle command RetrieveLogsRequest; - } - server cluster GeneralDiagnostics { emits event BootReason; callback attribute networkInterfaces; @@ -2541,18 +2154,6 @@ endpoint 0 { handle command TimeSnapshotResponse; } - server cluster SoftwareDiagnostics { - emits event SoftwareFault; - callback attribute threadMetrics; - callback attribute currentHeapFree; - callback attribute currentHeapUsed; - callback attribute currentHeapHighWatermark; - callback attribute featureMap; - ram attribute clusterRevision default = 1; - - handle command ResetWatermarks; - } - server cluster ThreadNetworkDiagnostics { callback attribute channel; callback attribute routingRole; @@ -2673,22 +2274,9 @@ endpoint 0 { handle command KeySetReadAllIndices; handle command KeySetReadAllIndicesResponse; } - - server cluster FixedLabel { - callback attribute labelList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; - } - - server cluster UserLabel { - callback attribute labelList; - ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; - } } endpoint 1 { - device type ma_powersource = 17, version 1; - device type ma_dimmablelight = 257, version 1; + device type ma_extendedcolorlight = 269, version 1; server cluster Identify { @@ -2792,26 +2380,6 @@ endpoint 1 { callback attribute clusterRevision; } - server cluster PowerSource { - ram attribute status default = 0; - ram attribute order default = 0; - ram attribute description default = "USB"; - ram attribute wiredAssessedInputVoltage; - ram attribute wiredAssessedInputFrequency; - ram attribute wiredCurrentType default = 1; - ram attribute wiredAssessedCurrent; - ram attribute wiredNominalVoltage default = 5000; - ram attribute wiredMaximumCurrent default = 1000; - ram attribute wiredPresent default = 1; - callback attribute endpointList; - callback attribute generatedCommandList; - callback attribute acceptedCommandList; - callback attribute eventList; - callback attribute attributeList; - ram attribute featureMap default = 1; - ram attribute clusterRevision default = 2; - } - server cluster ScenesManagement { ram attribute lastConfiguredBy; ram attribute sceneTableSize default = 16; @@ -2860,6 +2428,10 @@ endpoint 1 { ram attribute colorTempPhysicalMaxMireds default = 0xFEFF; ram attribute coupleColorTempToLevelMinMireds; persist attribute startUpColorTemperatureMireds; + callback attribute generatedCommandList; + callback attribute acceptedCommandList; + callback attribute eventList; + callback attribute attributeList; ram attribute featureMap default = 0x1F; ram attribute clusterRevision default = 6; diff --git a/examples/lighting-app/silabs/data_model/lighting-thread-app.zap b/examples/lighting-app/silabs/data_model/lighting-thread-app.zap index b894a2f5a70c00..9e293bcd3032d1 100644 --- a/examples/lighting-app/silabs/data_model/lighting-thread-app.zap +++ b/examples/lighting-app/silabs/data_model/lighting-thread-app.zap @@ -17,6 +17,12 @@ } ], "package": [ + { + "pathRelativity": "relativeToZap", + "path": "../../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", + "version": "chip-v1" + }, { "pathRelativity": "relativeToZap", "path": "../../../../src/app/zap-templates/zcl/zcl.json", @@ -24,12 +30,6 @@ "category": "matter", "version": 1, "description": "Matter SDK ZCL data" - }, - { - "pathRelativity": "relativeToZap", - "path": "../../../../src/app/zap-templates/app-templates.json", - "type": "gen-templates-json", - "version": "chip-v1" } ], "endpointTypes": [ @@ -1494,58 +1494,6 @@ } ] }, - { - "name": "Diagnostic Logs", - "code": 50, - "mfgCode": null, - "define": "DIAGNOSTIC_LOGS_CLUSTER", - "side": "server", - "enabled": 1, - "commands": [ - { - "name": "RetrieveLogsRequest", - "code": 0, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - } - ], - "attributes": [ - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "server", - "type": "bitmap32", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "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": "General Diagnostics", "code": 51, @@ -1767,131 +1715,6 @@ } ] }, - { - "name": "Software Diagnostics", - "code": 52, - "mfgCode": null, - "define": "SOFTWARE_DIAGNOSTICS_CLUSTER", - "side": "server", - "enabled": 1, - "commands": [ - { - "name": "ResetWatermarks", - "code": 0, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - } - ], - "attributes": [ - { - "name": "ThreadMetrics", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "CurrentHeapFree", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "int64u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "CurrentHeapUsed", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "int64u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "CurrentHeapHighWatermark", - "code": 3, - "mfgCode": null, - "side": "server", - "type": "int64u", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "server", - "type": "bitmap32", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - } - ], - "events": [ - { - "name": "SoftwareFault", - "code": 0, - "mfgCode": null, - "side": "server", - "included": 1 - } - ] - }, { "name": "Thread Network Diagnostics", "code": 53, @@ -3451,229 +3274,105 @@ "reportableChange": 0 } ] - }, + } + ] + }, + { + "id": 2, + "name": "MA-dimmablelight", + "deviceTypeRef": { + "code": 269, + "profileId": 259, + "label": "MA-extendedcolorlight", + "name": "MA-extendedcolorlight" + }, + "deviceTypes": [ + { + "code": 269, + "profileId": 259, + "label": "MA-extendedcolorlight", + "name": "MA-extendedcolorlight" + } + ], + "deviceVersions": [ + 1 + ], + "deviceIdentifiers": [ + 269 + ], + "deviceTypeName": "MA-extendedcolorlight", + "deviceTypeCode": 269, + "deviceTypeProfileId": 259, + "clusters": [ { - "name": "Fixed Label", - "code": 64, + "name": "Identify", + "code": 3, "mfgCode": null, - "define": "FIXED_LABEL_CLUSTER", + "define": "IDENTIFY_CLUSTER", "side": "server", "enabled": 1, + "commands": [ + { + "name": "Identify", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "TriggerEffect", + "code": 64, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + } + ], "attributes": [ { - "name": "LabelList", + "name": "IdentifyTime", "code": 0, "mfgCode": null, "side": "server", - "type": "array", + "type": "int16u", "included": 1, - "storageOption": "External", + "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, + "defaultValue": "0x0000", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, "reportableChange": 0 }, { - "name": "FeatureMap", - "code": 65532, + "name": "IdentifyType", + "code": 1, "mfgCode": null, "side": "server", - "type": "bitmap32", + "type": "IdentifyTypeEnum", "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0", - "reportable": 1, + "defaultValue": "0x0", + "reportable": 0, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 }, { - "name": "ClusterRevision", - "code": 65533, + "name": "GeneratedCommandList", + "code": 65528, "mfgCode": null, "side": "server", - "type": "int16u", + "type": "array", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - } - ] - }, - { - "name": "User Label", - "code": 65, - "mfgCode": null, - "define": "USER_LABEL_CLUSTER", - "side": "server", - "enabled": 1, - "attributes": [ - { - "name": "LabelList", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "server", - "type": "bitmap32", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - } - ] - } - ] - }, - { - "id": 2, - "name": "MA-dimmablelight", - "deviceTypeRef": { - "code": 257, - "profileId": 259, - "label": "MA-dimmablelight", - "name": "MA-dimmablelight" - }, - "deviceTypes": [ - { - "code": 257, - "profileId": 259, - "label": "MA-dimmablelight", - "name": "MA-dimmablelight" - }, - { - "code": 17, - "profileId": 259, - "label": "MA-powersource", - "name": "MA-powersource" - } - ], - "deviceVersions": [ - 1, - 1 - ], - "deviceIdentifiers": [ - 257, - 17 - ], - "deviceTypeName": "MA-dimmablelight", - "deviceTypeCode": 257, - "deviceTypeProfileId": 259, - "clusters": [ - { - "name": "Identify", - "code": 3, - "mfgCode": null, - "define": "IDENTIFY_CLUSTER", - "side": "server", - "enabled": 1, - "commands": [ - { - "name": "Identify", - "code": 0, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - }, - { - "name": "TriggerEffect", - "code": 64, - "mfgCode": null, - "source": "client", - "isIncoming": 1, - "isEnabled": 1 - } - ], - "attributes": [ - { - "name": "IdentifyTime", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0000", - "reportable": 1, - "minInterval": 0, - "maxInterval": 65344, - "reportableChange": 0 - }, - { - "name": "IdentifyType", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "IdentifyTypeEnum", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0x0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "GeneratedCommandList", - "code": 65528, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, + "defaultValue": null, "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -3862,7 +3561,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -4034,7 +3733,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x00", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -4050,7 +3749,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x01", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -4066,7 +3765,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x0000", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -4082,7 +3781,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x0000", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -4098,7 +3797,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0xFF", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -4286,7 +3985,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x01", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -4302,7 +4001,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x0000", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -4318,7 +4017,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x01", - "reportable": 1, + "reportable": 0, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 @@ -4398,7 +4097,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x00", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -4430,7 +4129,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0xFF", - "reportable": 1, + "reportable": 0, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 @@ -4494,7 +4193,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "255", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -4632,7 +4331,7 @@ "singleton": 0, "bounded": 0, "defaultValue": null, - "reportable": 1, + "reportable": 0, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 @@ -4648,7 +4347,7 @@ "singleton": 0, "bounded": 0, "defaultValue": null, - "reportable": 1, + "reportable": 0, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 @@ -4664,7 +4363,7 @@ "singleton": 0, "bounded": 0, "defaultValue": null, - "reportable": 1, + "reportable": 0, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 @@ -4767,288 +4466,6 @@ } ] }, - { - "name": "Power Source", - "code": 47, - "mfgCode": null, - "define": "POWER_SOURCE_CLUSTER", - "side": "server", - "enabled": 1, - "attributes": [ - { - "name": "Status", - "code": 0, - "mfgCode": null, - "side": "server", - "type": "PowerSourceStatusEnum", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "Order", - "code": 1, - "mfgCode": null, - "side": "server", - "type": "int8u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "0", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "Description", - "code": 2, - "mfgCode": null, - "side": "server", - "type": "char_string", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "USB", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "WiredAssessedInputVoltage", - "code": 3, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "WiredAssessedInputFrequency", - "code": 4, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "WiredCurrentType", - "code": 5, - "mfgCode": null, - "side": "server", - "type": "WiredCurrentTypeEnum", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "WiredAssessedCurrent", - "code": 6, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "WiredNominalVoltage", - "code": 7, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "5000", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "WiredMaximumCurrent", - "code": 8, - "mfgCode": null, - "side": "server", - "type": "int32u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1000", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "WiredPresent", - "code": 9, - "mfgCode": null, - "side": "server", - "type": "boolean", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "EndpointList", - "code": 31, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "GeneratedCommandList", - "code": 65528, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "AcceptedCommandList", - "code": 65529, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "EventList", - "code": 65530, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "AttributeList", - "code": 65531, - "mfgCode": null, - "side": "server", - "type": "array", - "included": 1, - "storageOption": "External", - "singleton": 0, - "bounded": 0, - "defaultValue": null, - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "FeatureMap", - "code": 65532, - "mfgCode": null, - "side": "server", - "type": "bitmap32", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "1", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - }, - { - "name": "ClusterRevision", - "code": 65533, - "mfgCode": null, - "side": "server", - "type": "int16u", - "included": 1, - "storageOption": "RAM", - "singleton": 0, - "bounded": 0, - "defaultValue": "2", - "reportable": 1, - "minInterval": 1, - "maxInterval": 65534, - "reportableChange": 0 - } - ] - }, { "name": "Scenes Management", "code": 98, @@ -5515,7 +4932,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x0000", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -5531,7 +4948,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x616B", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -5547,7 +4964,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x607D", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -5563,7 +4980,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x00FA", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -5579,7 +4996,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x01", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -5595,7 +5012,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x00", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -5611,7 +5028,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -5643,7 +5060,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x01", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -5739,7 +5156,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x1F", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -5755,7 +5172,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0x0000", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -5771,7 +5188,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "0xFEFF", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -5787,7 +5204,7 @@ "singleton": 0, "bounded": 0, "defaultValue": "", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 @@ -5803,11 +5220,75 @@ "singleton": 0, "bounded": 0, "defaultValue": "", - "reportable": 1, + "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, + { + "name": "GeneratedCommandList", + "code": 65528, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AcceptedCommandList", + "code": 65529, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "EventList", + "code": 65530, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "type": "array", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "FeatureMap", "code": 65532, diff --git a/examples/lighting-app/silabs/openthread.gni b/examples/lighting-app/silabs/openthread.gni index 71fa3271ea5073..b39a1cb8e5878d 100644 --- a/examples/lighting-app/silabs/openthread.gni +++ b/examples/lighting-app/silabs/openthread.gni @@ -23,5 +23,8 @@ app_data_model = chip_enable_ota_requestor = true chip_enable_openthread = true +# Not needed for the Lighting-app +chip_enable_read_client = false + openthread_external_platform = "${chip_root}/third_party/openthread/platforms/efr32:libopenthread-efr32" diff --git a/examples/platform/linux/ControllerShellCommands.cpp b/examples/platform/linux/ControllerShellCommands.cpp index 49b1e20dc97eb8..aefbb3fafa4353 100644 --- a/examples/platform/linux/ControllerShellCommands.cpp +++ b/examples/platform/linux/ControllerShellCommands.cpp @@ -124,8 +124,8 @@ static CHIP_ERROR display(bool printHeader) else { streamer_printf(sout, " Entry %d instanceName=%s host=%s longDiscriminator=%d vendorId=%d productId=%d\r\n", i, - next->commissionData.instanceName, next->resolutionData.hostName, - next->commissionData.longDiscriminator, next->commissionData.vendorId, next->commissionData.productId); + next->nodeData.instanceName, next->resolutionData.hostName, next->nodeData.longDiscriminator, + next->nodeData.vendorId, next->nodeData.productId); } } diff --git a/examples/platform/silabs/matter-platform.slcp b/examples/platform/silabs/matter-platform.slcp index bc30556be60fe5..3e1c52a6ec66f5 100644 --- a/examples/platform/silabs/matter-platform.slcp +++ b/examples/platform/silabs/matter-platform.slcp @@ -31,22 +31,19 @@ sdk: {id: gecko_sdk, version: 4.3.1} toolchain_settings: [] component: -- {id: bluetooth_feature_nvm} +#bluetooth components +- {id: gatt_configuration} - {id: bluetooth_feature_gatt_server} -- {id: nvm3_lib} -- {id: bluetooth_feature_sm} -- {id: bluetooth_feature_gap} - {id: bluetooth_feature_legacy_advertiser} -- {id: gatt_configuration} -- {id: freertos} +- {id: bluetooth_feature_connection} +- {id: bluetooth_feature_system} - {id: bluetooth_stack} +# Other components +- {id: nvm3_lib} +- {id: freertos} - {id: brd4002a} - {id: rail_util_pti} -- {id: bluetooth_feature_gatt} -- {id: bluetooth_feature_connection} - {id: rail_lib_multiprotocol} -- {id: bluetooth_feature_system} -- {id: bluetooth_feature_scanner} - {id: rail_util_power_manager_init} - {id: psa_crypto} - {id: psa_crypto_aes} @@ -62,7 +59,6 @@ component: - {id: mbedtls_platform_dynamic_memory_allocation_config_init_runtime } - {id: mbedtls_base64} - {id: ot_psa_crypto} -- {id: bluetooth_crypto} - {id: iostream_rtt} # Necessary componenets for ot coap cert lib # - {id: mbedtls_dtls} # Requried by COAP lib diff --git a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp index 2c3001cf5cabea..fd66ba44649cea 100644 --- a/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp +++ b/examples/tv-casting-app/android/App/app/src/main/jni/cpp/ConversionUtils.cpp @@ -324,53 +324,50 @@ CHIP_ERROR convertJDiscoveredNodeDataToCppDiscoveredNodeData(jobject jDiscovered jstring jInstanceName = static_cast(env->GetObjectField(jDiscoveredNodeData, getInstanceNameField)); if (jInstanceName != nullptr) { - chip::Platform::CopyString(outCppDiscoveredNodeData.commissionData.instanceName, + chip::Platform::CopyString(outCppDiscoveredNodeData.nodeData.instanceName, chip::Dnssd::Commission::kInstanceNameMaxLength + 1, env->GetStringUTFChars(jInstanceName, 0)); } jfieldID jLongDiscriminatorField = env->GetFieldID(jDiscoveredNodeDataClass, "longDiscriminator", "J"); - outCppDiscoveredNodeData.commissionData.vendorId = + outCppDiscoveredNodeData.nodeData.vendorId = static_cast(env->GetLongField(jDiscoveredNodeData, jLongDiscriminatorField)); - jfieldID jVendorIdField = env->GetFieldID(jDiscoveredNodeDataClass, "vendorId", "J"); - outCppDiscoveredNodeData.commissionData.vendorId = - static_cast(env->GetLongField(jDiscoveredNodeData, jVendorIdField)); + jfieldID jVendorIdField = env->GetFieldID(jDiscoveredNodeDataClass, "vendorId", "J"); + outCppDiscoveredNodeData.nodeData.vendorId = static_cast(env->GetLongField(jDiscoveredNodeData, jVendorIdField)); - jfieldID jProductIdField = env->GetFieldID(jDiscoveredNodeDataClass, "productId", "J"); - outCppDiscoveredNodeData.commissionData.productId = - static_cast(env->GetLongField(jDiscoveredNodeData, jProductIdField)); + jfieldID jProductIdField = env->GetFieldID(jDiscoveredNodeDataClass, "productId", "J"); + outCppDiscoveredNodeData.nodeData.productId = static_cast(env->GetLongField(jDiscoveredNodeData, jProductIdField)); jfieldID jCommissioningModeField = env->GetFieldID(jDiscoveredNodeDataClass, "commissioningMode", "B"); - outCppDiscoveredNodeData.commissionData.commissioningMode = + outCppDiscoveredNodeData.nodeData.commissioningMode = static_cast(env->GetByteField(jDiscoveredNodeData, jCommissioningModeField)); - jfieldID jDeviceTypeField = env->GetFieldID(jDiscoveredNodeDataClass, "deviceType", "J"); - outCppDiscoveredNodeData.commissionData.deviceType = - static_cast(env->GetLongField(jDiscoveredNodeData, jDeviceTypeField)); + jfieldID jDeviceTypeField = env->GetFieldID(jDiscoveredNodeDataClass, "deviceType", "J"); + outCppDiscoveredNodeData.nodeData.deviceType = static_cast(env->GetLongField(jDiscoveredNodeData, jDeviceTypeField)); jfieldID getDeviceNameField = env->GetFieldID(jDiscoveredNodeDataClass, "deviceName", "Ljava/lang/String;"); jstring jDeviceName = static_cast(env->GetObjectField(jDiscoveredNodeData, getDeviceNameField)); if (jDeviceName != nullptr) { - chip::Platform::CopyString(outCppDiscoveredNodeData.commissionData.deviceName, chip::Dnssd::kMaxDeviceNameLen + 1, + chip::Platform::CopyString(outCppDiscoveredNodeData.nodeData.deviceName, chip::Dnssd::kMaxDeviceNameLen + 1, env->GetStringUTFChars(jDeviceName, 0)); } // TODO: map rotating ID jfieldID jRotatingIdLenField = env->GetFieldID(jDiscoveredNodeDataClass, "rotatingIdLen", "I"); - outCppDiscoveredNodeData.commissionData.rotatingIdLen = + outCppDiscoveredNodeData.nodeData.rotatingIdLen = static_cast(env->GetIntField(jDiscoveredNodeData, jRotatingIdLenField)); jfieldID jPairingHintField = env->GetFieldID(jDiscoveredNodeDataClass, "pairingHint", "S"); - outCppDiscoveredNodeData.commissionData.pairingHint = + outCppDiscoveredNodeData.nodeData.pairingHint = static_cast(env->GetShortField(jDiscoveredNodeData, jPairingHintField)); jfieldID getPairingInstructionField = env->GetFieldID(jDiscoveredNodeDataClass, "pairingInstruction", "Ljava/lang/String;"); jstring jPairingInstruction = static_cast(env->GetObjectField(jDiscoveredNodeData, getPairingInstructionField)); if (jPairingInstruction != nullptr) { - chip::Platform::CopyString(outCppDiscoveredNodeData.commissionData.pairingInstruction, - chip::Dnssd::kMaxPairingInstructionLen + 1, env->GetStringUTFChars(jPairingInstruction, 0)); + chip::Platform::CopyString(outCppDiscoveredNodeData.nodeData.pairingInstruction, chip::Dnssd::kMaxPairingInstructionLen + 1, + env->GetStringUTFChars(jPairingInstruction, 0)); } jfieldID jPortField = env->GetFieldID(jDiscoveredNodeDataClass, "port", "I"); diff --git a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/ConversionUtils.mm b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/ConversionUtils.mm index a13f231b09b6c0..902e386ae551e1 100644 --- a/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/ConversionUtils.mm +++ b/examples/tv-casting-app/darwin/MatterTvCastingBridge/MatterTvCastingBridge/ConversionUtils.mm @@ -48,20 +48,20 @@ + (CHIP_ERROR)convertToCppDiscoveredNodeDataFrom:(DiscoveredNodeData * _Nonnull) outDiscoveredNodeData:(chip::Dnssd::DiscoveredNodeData &)outDiscoveredNodeData { // setting CommissionNodeData - outDiscoveredNodeData.commissionData.deviceType = objCDiscoveredNodeData.deviceType; - outDiscoveredNodeData.commissionData.vendorId = objCDiscoveredNodeData.vendorId; - outDiscoveredNodeData.commissionData.productId = objCDiscoveredNodeData.productId; - outDiscoveredNodeData.commissionData.longDiscriminator = objCDiscoveredNodeData.longDiscriminator; - outDiscoveredNodeData.commissionData.commissioningMode = objCDiscoveredNodeData.commissioningMode; - outDiscoveredNodeData.commissionData.pairingHint = objCDiscoveredNodeData.pairingHint; - memset(outDiscoveredNodeData.commissionData.deviceName, '\0', sizeof(outDiscoveredNodeData.commissionData.deviceName)); + outDiscoveredNodeData.nodeData.deviceType = objCDiscoveredNodeData.deviceType; + outDiscoveredNodeData.nodeData.vendorId = objCDiscoveredNodeData.vendorId; + outDiscoveredNodeData.nodeData.productId = objCDiscoveredNodeData.productId; + outDiscoveredNodeData.nodeData.longDiscriminator = objCDiscoveredNodeData.longDiscriminator; + outDiscoveredNodeData.nodeData.commissioningMode = objCDiscoveredNodeData.commissioningMode; + outDiscoveredNodeData.nodeData.pairingHint = objCDiscoveredNodeData.pairingHint; + memset(outDiscoveredNodeData.nodeData.deviceName, '\0', sizeof(outDiscoveredNodeData.nodeData.deviceName)); if (objCDiscoveredNodeData.deviceName != nullptr) { - chip::Platform::CopyString(outDiscoveredNodeData.commissionData.deviceName, chip::Dnssd::kMaxDeviceNameLen + 1, + chip::Platform::CopyString(outDiscoveredNodeData.nodeData.deviceName, chip::Dnssd::kMaxDeviceNameLen + 1, [objCDiscoveredNodeData.deviceName UTF8String]); } - outDiscoveredNodeData.commissionData.rotatingIdLen = objCDiscoveredNodeData.rotatingIdLen; + outDiscoveredNodeData.nodeData.rotatingIdLen = objCDiscoveredNodeData.rotatingIdLen; memcpy( - outDiscoveredNodeData.commissionData.rotatingId, objCDiscoveredNodeData.rotatingId, objCDiscoveredNodeData.rotatingIdLen); + outDiscoveredNodeData.nodeData.rotatingId, objCDiscoveredNodeData.rotatingId, objCDiscoveredNodeData.rotatingIdLen); // setting CommonResolutionData outDiscoveredNodeData.resolutionData.port = objCDiscoveredNodeData.port; @@ -121,17 +121,17 @@ + (DiscoveredNodeData *)convertToObjCDiscoveredNodeDataFrom:(const chip::Dnssd:: DiscoveredNodeData * objCDiscoveredNodeData = [DiscoveredNodeData new]; // from CommissionNodeData - objCDiscoveredNodeData.deviceType = cppDiscoveredNodedata->commissionData.deviceType; - objCDiscoveredNodeData.vendorId = cppDiscoveredNodedata->commissionData.vendorId; - objCDiscoveredNodeData.productId = cppDiscoveredNodedata->commissionData.productId; - objCDiscoveredNodeData.longDiscriminator = cppDiscoveredNodedata->commissionData.longDiscriminator; - objCDiscoveredNodeData.commissioningMode = cppDiscoveredNodedata->commissionData.commissioningMode; - objCDiscoveredNodeData.pairingHint = cppDiscoveredNodedata->commissionData.pairingHint; - objCDiscoveredNodeData.deviceName = [NSString stringWithCString:cppDiscoveredNodedata->commissionData.deviceName + objCDiscoveredNodeData.deviceType = cppDiscoveredNodedata->nodeData.deviceType; + objCDiscoveredNodeData.vendorId = cppDiscoveredNodedata->nodeData.vendorId; + objCDiscoveredNodeData.productId = cppDiscoveredNodedata->nodeData.productId; + objCDiscoveredNodeData.longDiscriminator = cppDiscoveredNodedata->nodeData.longDiscriminator; + objCDiscoveredNodeData.commissioningMode = cppDiscoveredNodedata->nodeData.commissioningMode; + objCDiscoveredNodeData.pairingHint = cppDiscoveredNodedata->nodeData.pairingHint; + objCDiscoveredNodeData.deviceName = [NSString stringWithCString:cppDiscoveredNodedata->nodeData.deviceName encoding:NSUTF8StringEncoding]; - objCDiscoveredNodeData.rotatingIdLen = cppDiscoveredNodedata->commissionData.rotatingIdLen; - objCDiscoveredNodeData.rotatingId = cppDiscoveredNodedata->commissionData.rotatingId; - objCDiscoveredNodeData.instanceName = [NSString stringWithCString:cppDiscoveredNodedata->commissionData.instanceName + objCDiscoveredNodeData.rotatingIdLen = cppDiscoveredNodedata->nodeData.rotatingIdLen; + objCDiscoveredNodeData.rotatingId = cppDiscoveredNodedata->nodeData.rotatingId; + objCDiscoveredNodeData.instanceName = [NSString stringWithCString:cppDiscoveredNodedata->nodeData.instanceName encoding:NSUTF8StringEncoding]; // from CommonResolutionData diff --git a/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp b/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp index 402febdb9f6b97..9b26a868efd8c1 100644 --- a/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp +++ b/examples/tv-casting-app/tv-casting-common/core/CastingPlayerDiscovery.cpp @@ -83,10 +83,10 @@ void DeviceDiscoveryDelegateImpl::OnDiscoveredDevice(const chip::Dnssd::Discover CastingPlayerAttributes attributes; snprintf(attributes.id, kIdMaxLength + 1, "%s%u", nodeData.resolutionData.hostName, nodeData.resolutionData.port); - chip::Platform::CopyString(attributes.deviceName, chip::Dnssd::kMaxDeviceNameLen + 1, nodeData.commissionData.deviceName); + chip::Platform::CopyString(attributes.deviceName, chip::Dnssd::kMaxDeviceNameLen + 1, nodeData.nodeData.deviceName); chip::Platform::CopyString(attributes.hostName, chip::Dnssd::kHostNameMaxLength + 1, nodeData.resolutionData.hostName); chip::Platform::CopyString(attributes.instanceName, chip::Dnssd::Commission::kInstanceNameMaxLength + 1, - nodeData.commissionData.instanceName); + nodeData.nodeData.instanceName); attributes.numIPs = (unsigned int) nodeData.resolutionData.numIPs; for (unsigned j = 0; j < attributes.numIPs; j++) @@ -95,9 +95,9 @@ void DeviceDiscoveryDelegateImpl::OnDiscoveredDevice(const chip::Dnssd::Discover } attributes.interfaceId = nodeData.resolutionData.interfaceId; attributes.port = nodeData.resolutionData.port; - attributes.productId = nodeData.commissionData.productId; - attributes.vendorId = nodeData.commissionData.vendorId; - attributes.deviceType = nodeData.commissionData.deviceType; + attributes.productId = nodeData.nodeData.productId; + attributes.vendorId = nodeData.nodeData.vendorId; + attributes.deviceType = nodeData.nodeData.deviceType; memory::Strong player = std::make_shared(attributes); diff --git a/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp b/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp index 4cb72732292a2e..b98647db802050 100644 --- a/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp +++ b/examples/tv-casting-app/tv-casting-common/src/CastingServer.cpp @@ -226,20 +226,20 @@ CHIP_ERROR CastingServer::SendUserDirectedCommissioningRequest(Dnssd::Discovered getIpAddressForUDCRequest(selectedCommissioner->resolutionData.ipAddress, selectedCommissioner->resolutionData.numIPs); ReturnErrorOnFailure(SendUserDirectedCommissioningRequest(chip::Transport::PeerAddress::UDP( *ipAddressToUse, selectedCommissioner->resolutionData.port, selectedCommissioner->resolutionData.interfaceId))); - mTargetVideoPlayerVendorId = selectedCommissioner->commissionData.vendorId; - mTargetVideoPlayerProductId = selectedCommissioner->commissionData.productId; - mTargetVideoPlayerDeviceType = selectedCommissioner->commissionData.deviceType; + mTargetVideoPlayerVendorId = selectedCommissioner->nodeData.vendorId; + mTargetVideoPlayerProductId = selectedCommissioner->nodeData.productId; + mTargetVideoPlayerDeviceType = selectedCommissioner->nodeData.deviceType; mTargetVideoPlayerNumIPs = selectedCommissioner->resolutionData.numIPs; for (size_t i = 0; i < mTargetVideoPlayerNumIPs && i < chip::Dnssd::CommonResolutionData::kMaxIPAddresses; i++) { mTargetVideoPlayerIpAddress[i] = selectedCommissioner->resolutionData.ipAddress[i]; } chip::Platform::CopyString(mTargetVideoPlayerDeviceName, chip::Dnssd::kMaxDeviceNameLen + 1, - selectedCommissioner->commissionData.deviceName); + selectedCommissioner->nodeData.deviceName); chip::Platform::CopyString(mTargetVideoPlayerHostName, chip::Dnssd::kHostNameMaxLength + 1, selectedCommissioner->resolutionData.hostName); chip::Platform::CopyString(mTargetVideoPlayerInstanceName, chip::Dnssd::Commission::kInstanceNameMaxLength + 1, - selectedCommissioner->commissionData.instanceName); + selectedCommissioner->nodeData.instanceName); mTargetVideoPlayerPort = selectedCommissioner->resolutionData.port; return CHIP_NO_ERROR; } diff --git a/examples/tv-casting-app/tv-casting-common/src/ConversionUtils.cpp b/examples/tv-casting-app/tv-casting-common/src/ConversionUtils.cpp index 322e9d46bec8c4..a57e2548009ada 100644 --- a/examples/tv-casting-app/tv-casting-common/src/ConversionUtils.cpp +++ b/examples/tv-casting-app/tv-casting-common/src/ConversionUtils.cpp @@ -23,10 +23,10 @@ CHIP_ERROR ConvertToDiscoveredNodeData(TargetVideoPlayerInfo * inPlayer, chip::D if (inPlayer == nullptr) return CHIP_ERROR_INVALID_ARGUMENT; - outNodeData.commissionData.vendorId = inPlayer->GetVendorId(); - outNodeData.commissionData.productId = static_cast(inPlayer->GetProductId()); - outNodeData.commissionData.deviceType = inPlayer->GetDeviceType(); - outNodeData.resolutionData.numIPs = inPlayer->GetNumIPs(); + outNodeData.nodeData.vendorId = inPlayer->GetVendorId(); + outNodeData.nodeData.productId = static_cast(inPlayer->GetProductId()); + outNodeData.nodeData.deviceType = inPlayer->GetDeviceType(); + outNodeData.resolutionData.numIPs = inPlayer->GetNumIPs(); const chip::Inet::IPAddress * ipAddresses = inPlayer->GetIpAddresses(); if (ipAddresses != nullptr) @@ -37,8 +37,7 @@ CHIP_ERROR ConvertToDiscoveredNodeData(TargetVideoPlayerInfo * inPlayer, chip::D } } - chip::Platform::CopyString(outNodeData.commissionData.deviceName, chip::Dnssd::kMaxDeviceNameLen + 1, - inPlayer->GetDeviceName()); + chip::Platform::CopyString(outNodeData.nodeData.deviceName, chip::Dnssd::kMaxDeviceNameLen + 1, inPlayer->GetDeviceName()); chip::Platform::CopyString(outNodeData.resolutionData.hostName, chip::Dnssd::kHostNameMaxLength + 1, inPlayer->GetHostName()); return CHIP_NO_ERROR; diff --git a/examples/tv-casting-app/tv-casting-common/src/TargetVideoPlayerInfo.cpp b/examples/tv-casting-app/tv-casting-common/src/TargetVideoPlayerInfo.cpp index 7d9c7d51168eaf..c182856039975a 100644 --- a/examples/tv-casting-app/tv-casting-common/src/TargetVideoPlayerInfo.cpp +++ b/examples/tv-casting-app/tv-casting-common/src/TargetVideoPlayerInfo.cpp @@ -232,6 +232,6 @@ bool TargetVideoPlayerInfo::IsSameAs(const chip::Dnssd::DiscoveredNodeData * dis return false; } - return IsSameAs(discoveredNodeData->resolutionData.hostName, discoveredNodeData->commissionData.deviceName, + return IsSameAs(discoveredNodeData->resolutionData.hostName, discoveredNodeData->nodeData.deviceName, discoveredNodeData->resolutionData.numIPs, discoveredNodeData->resolutionData.ipAddress); } diff --git a/src/app/BUILD.gn b/src/app/BUILD.gn index 312fe005d88f0b..76bd115a851a21 100644 --- a/src/app/BUILD.gn +++ b/src/app/BUILD.gn @@ -146,6 +146,10 @@ source_set("constants") { ] } +source_set("test-event-trigger") { + sources = [ "TestEventTriggerDelegate.h" ] +} + # interaction-model is a static-library because it currently requires global functions (app/util/...) that are stubbed in different test files that depend on the app static_library # which in tern depens on the interaction-model. # Using source_set prevents the unit test to build correctly. diff --git a/src/app/icd/server/BUILD.gn b/src/app/icd/server/BUILD.gn index a6c5096dde7d0c..c100cc7d041e84 100644 --- a/src/app/icd/server/BUILD.gn +++ b/src/app/icd/server/BUILD.gn @@ -81,6 +81,7 @@ source_set("manager") { ":notifier", ":observer", "${chip_root}/src/app:subscription-info-provider", + "${chip_root}/src/app:test-event-trigger", "${chip_root}/src/credentials:credentials", "${chip_root}/src/messaging", ] diff --git a/src/app/icd/server/ICDManager.cpp b/src/app/icd/server/ICDManager.cpp index f4442e85972ee2..479fb9a240bc30 100644 --- a/src/app/icd/server/ICDManager.cpp +++ b/src/app/icd/server/ICDManager.cpp @@ -28,6 +28,14 @@ #include #include +namespace { +enum class ICDTestEventTriggerEvent : uint64_t +{ + kAddActiveModeReq = 0x0046'0000'00000001, + kRemoveActiveModeReq = 0x0046'0000'00000002, +}; +} // namespace + namespace chip { namespace app { @@ -643,6 +651,27 @@ void ICDManager::ExtendActiveMode(Milliseconds16 extendDuration) } } +CHIP_ERROR ICDManager::HandleEventTrigger(uint64_t eventTrigger) +{ + ICDTestEventTriggerEvent trigger = static_cast(eventTrigger); + CHIP_ERROR err = CHIP_NO_ERROR; + + switch (trigger) + { + case ICDTestEventTriggerEvent::kAddActiveModeReq: + SetKeepActiveModeRequirements(KeepActiveFlag::kTestEventTriggerActiveMode, true); + break; + case ICDTestEventTriggerEvent::kRemoveActiveModeReq: + SetKeepActiveModeRequirements(KeepActiveFlag::kTestEventTriggerActiveMode, false); + break; + default: + err = CHIP_ERROR_INVALID_ARGUMENT; + break; + } + + return err; +} + ICDManager::ObserverPointer * ICDManager::RegisterObserver(ICDStateObserver * observer) { return mStateObserverPool.CreateObject(observer); diff --git a/src/app/icd/server/ICDManager.h b/src/app/icd/server/ICDManager.h index 058285802eb309..43a5386d4d7844 100644 --- a/src/app/icd/server/ICDManager.h +++ b/src/app/icd/server/ICDManager.h @@ -16,16 +16,11 @@ */ #pragma once -#include - #include -#if CHIP_CONFIG_ENABLE_ICD_CIP -#include // nogncheck -#include // nogncheck -#endif // CHIP_CONFIG_ENABLE_ICD_CIP - +#include #include +#include #include #include #include @@ -38,6 +33,11 @@ #include #include +#if CHIP_CONFIG_ENABLE_ICD_CIP +#include // nogncheck +#include // nogncheck +#endif // CHIP_CONFIG_ENABLE_ICD_CIP + namespace chip { namespace Crypto { using SymmetricKeystore = SessionKeystore; @@ -54,7 +54,7 @@ class TestICDManager; /** * @brief ICD Manager is responsible of processing the events and triggering the correct action for an ICD */ -class ICDManager : public ICDListener +class ICDManager : public ICDListener, public TestEventTriggerHandler { public: // This structure is used for the creation an ObjectPool of ICDStateObserver pointers @@ -129,6 +129,15 @@ class ICDManager : public ICDListener */ uint32_t StayActiveRequest(uint32_t stayActiveDuration); + /** + * @brief TestEventTriggerHandler for the ICD feature set + * + * @param eventTrigger Event trigger to handle. + * @return CHIP_ERROR CHIP_NO_ERROR - No erros during the processing + * CHIP_ERROR_INVALID_ARGUMENT - eventTrigger isn't a valid value + */ + CHIP_ERROR HandleEventTrigger(uint64_t eventTrigger) override; + #if CHIP_CONFIG_ENABLE_ICD_CIP void SendCheckInMsgs(); @@ -165,14 +174,14 @@ class ICDManager : public ICDListener void OnSubscriptionReport() override; protected: + friend class TestICDManager; + /** * @brief Hepler function that extends the Active Mode duration as well as the Active Mode Jitter timer for the transition to * iddle mode. */ void ExtendActiveMode(System::Clock::Milliseconds16 extendDuration); - friend class TestICDManager; - static void OnIdleModeDone(System::Layer * aLayer, void * appState); static void OnActiveModeDone(System::Layer * aLayer, void * appState); diff --git a/src/app/icd/server/ICDNotifier.h b/src/app/icd/server/ICDNotifier.h index 5db14503a296d7..785fd1e08c9879 100644 --- a/src/app/icd/server/ICDNotifier.h +++ b/src/app/icd/server/ICDNotifier.h @@ -39,11 +39,12 @@ class ICDListener public: enum class KeepActiveFlagsValues : uint8_t { - kCommissioningWindowOpen = 0x01, - kFailSafeArmed = 0x02, - kExchangeContextOpen = 0x04, - kCheckInInProgress = 0x08, - kInvalidFlag = 0x10, // Move up when adding more flags + kCommissioningWindowOpen = 0x01, + kFailSafeArmed = 0x02, + kExchangeContextOpen = 0x04, + kCheckInInProgress = 0x08, + kTestEventTriggerActiveMode = 0x10, + kInvalidFlag = 0x20, // Move up when adding more flags }; enum class ICDManagementEvents : uint8_t diff --git a/src/app/server/BUILD.gn b/src/app/server/BUILD.gn index 7c661464bbaea3..51a259c86d2552 100644 --- a/src/app/server/BUILD.gn +++ b/src/app/server/BUILD.gn @@ -52,6 +52,7 @@ static_library("server") { public_deps = [ "${chip_root}/src/app", + "${chip_root}/src/app:test-event-trigger", "${chip_root}/src/app/icd/server:icd-server-config", "${chip_root}/src/app/icd/server:observer", "${chip_root}/src/lib/address_resolve", diff --git a/src/app/server/Server.cpp b/src/app/server/Server.cpp index eff11222bfae7b..57abf8087f59ca 100644 --- a/src/app/server/Server.cpp +++ b/src/app/server/Server.cpp @@ -348,6 +348,10 @@ CHIP_ERROR Server::Init(const ServerInitParams & initParams) mICDManager.Init(mDeviceStorage, &GetFabricTable(), mSessionKeystore, &mExchangeMgr, chip::app::InteractionModelEngine::GetInstance()); + + // Register Test Event Trigger Handler + mTestEventTriggerDelegate->AddHandler(&mICDManager); + #endif // CHIP_CONFIG_ENABLE_ICD_SERVER // This code is necessary to restart listening to existing groups after a reboot @@ -592,6 +596,8 @@ void Server::Shutdown() Access::ResetAccessControlToDefault(); Credentials::SetGroupDataProvider(nullptr); #if CHIP_CONFIG_ENABLE_ICD_SERVER + // Remove Test Event Trigger Handler + mTestEventTriggerDelegate->RemoveHandler(&mICDManager); mICDManager.Shutdown(); #endif // CHIP_CONFIG_ENABLE_ICD_SERVER mAttributePersister.Shutdown(); diff --git a/src/app/tests/TestCommissionManager.cpp b/src/app/tests/TestCommissionManager.cpp index c88b459742de16..c314421d4e3a9a 100644 --- a/src/app/tests/TestCommissionManager.cpp +++ b/src/app/tests/TestCommissionManager.cpp @@ -15,6 +15,7 @@ * limitations under the License. */ +#include #include #include #include @@ -100,6 +101,8 @@ void InitializeChip(nlTestSuite * suite) static chip::app::DefaultTimerDelegate sTimerDelegate; static chip::app::reporting::ReportSchedulerImpl sReportScheduler(&sTimerDelegate); initParams.reportScheduler = &sReportScheduler; + static chip::SimpleTestEventTriggerDelegate sSimpleTestEventTriggerDelegate; + initParams.testEventTriggerDelegate = &sSimpleTestEventTriggerDelegate; (void) initParams.InitializeStaticResourcesBeforeServerInit(); err = chip::Server::GetInstance().Init(initParams); diff --git a/src/app/tests/TestICDManager.cpp b/src/app/tests/TestICDManager.cpp index ac8c220351fd86..fd93a146cf2755 100644 --- a/src/app/tests/TestICDManager.cpp +++ b/src/app/tests/TestICDManager.cpp @@ -17,6 +17,7 @@ */ #include #include +#include #include #include #include @@ -66,6 +67,13 @@ constexpr uint8_t kKeyBuffer2b[] = { 0xf2, 0xe2, 0xd2, 0xc2, 0xb2, 0xa2, 0x92, 0x82, 0x72, 0x62, 0x52, 0x42, 0x32, 0x22, 0x12, 0x02 }; +// Taken from the ICDManager Implementation +enum class ICDTestEventTriggerEvent : uint64_t +{ + kAddActiveModeReq = 0x0046'0000'00000001, + kRemoveActiveModeReq = 0x0046'0000'00000002, +}; + class TestICDStateObserver : public app::ICDStateObserver { public: @@ -115,6 +123,7 @@ class TestContext : public chip::Test::AppContext // Performs setup for each individual test in the test suite CHIP_ERROR SetUp() override { + ReturnErrorOnFailure(chip::Test::AppContext::SetUp()); mICDManager.Init(&testStorage, &GetFabricTable(), &mKeystore, &GetExchangeManager(), &mSubInfoProvider); mICDManager.RegisterObserver(&mICDStateObserver); @@ -692,6 +701,26 @@ class TestICDManager NL_TEST_ASSERT(aSuite, ctx->mICDManager.ShouldCheckInMsgsBeSentAtActiveModeFunction(kTestFabricIndex1, kClientNodeId11)); } #endif // CHIP_CONFIG_PERSIST_SUBSCRIPTIONS + + static void TestHandleTestEventTriggerActiveModeReq(nlTestSuite * aSuite, void * aContext) + { + TestContext * ctx = static_cast(aContext); + + // Verify That ICDManager starts in Idle + NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); + + // Add ActiveMode req for the Test event trigger event + ctx->mICDManager.HandleEventTrigger(static_cast(ICDTestEventTriggerEvent::kAddActiveModeReq)); + NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); + + // Advance clock by the ActiveModeDuration and check that the device is still in ActiveMode + AdvanceClockAndRunEventLoop(ctx, ICDConfigurationData::GetInstance().GetActiveModeDuration() + 1_ms32); + NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::ActiveMode); + + // Remove req and device should go to IdleMode + ctx->mICDManager.HandleEventTrigger(static_cast(ICDTestEventTriggerEvent::kRemoveActiveModeReq)); + NL_TEST_ASSERT(aSuite, ctx->mICDManager.mOperationalState == ICDManager::OperationalState::IdleMode); + } }; } // namespace app @@ -710,6 +739,7 @@ static const nlTest sTests[] = { NL_TEST_DEF("TestICDCounter", TestICDManager::TestICDCounter), NL_TEST_DEF("TestICDStayActive", TestICDManager::TestICDMStayActive), NL_TEST_DEF("TestShouldCheckInMsgsBeSentAtActiveModeFunction", TestICDManager::TestShouldCheckInMsgsBeSentAtActiveModeFunction), + NL_TEST_DEF("TestHandleTestEventTriggerActiveModeReq", TestICDManager::TestHandleTestEventTriggerActiveModeReq), NL_TEST_SENTINEL(), }; diff --git a/src/controller/AbstractDnssdDiscoveryController.h b/src/controller/AbstractDnssdDiscoveryController.h index 6e50d7b40c89ca..c8c9053f878ff3 100644 --- a/src/controller/AbstractDnssdDiscoveryController.h +++ b/src/controller/AbstractDnssdDiscoveryController.h @@ -36,7 +36,7 @@ namespace Controller { * to maintain a list of DiscoveredNodes and providing the implementation * of the template GetDiscoveredNodes() function. */ -class DLL_EXPORT AbstractDnssdDiscoveryController : public Dnssd::CommissioningResolveDelegate +class DLL_EXPORT AbstractDnssdDiscoveryController : public Dnssd::DiscoverNodeDelegate { public: explicit AbstractDnssdDiscoveryController(Dnssd::Resolver * resolver = nullptr) : mDNSResolver(resolver) {} diff --git a/src/controller/CHIPCommissionableNodeController.cpp b/src/controller/CHIPCommissionableNodeController.cpp index d187cc1289a851..f116928b585d82 100644 --- a/src/controller/CHIPCommissionableNodeController.cpp +++ b/src/controller/CHIPCommissionableNodeController.cpp @@ -36,13 +36,13 @@ CHIP_ERROR CommissionableNodeController::DiscoverCommissioners(Dnssd::DiscoveryF mDNSResolver.Shutdown(); // reset if already inited ReturnErrorOnFailure(mDNSResolver.Init(DeviceLayer::UDPEndPointManager())); #endif - mDNSResolver.SetCommissioningDelegate(this); + mDNSResolver.SetDiscoveryDelegate(this); return mDNSResolver.DiscoverCommissioners(discoveryFilter); } CommissionableNodeController::~CommissionableNodeController() { - mDNSResolver.SetCommissioningDelegate(nullptr); + mDNSResolver.SetDiscoveryDelegate(nullptr); } const Dnssd::DiscoveredNodeData * CommissionableNodeController::GetDiscoveredCommissioner(int idx) diff --git a/src/controller/CHIPDeviceController.cpp b/src/controller/CHIPDeviceController.cpp index c67c48c0cce2be..a9c41d87fd04fa 100644 --- a/src/controller/CHIPDeviceController.cpp +++ b/src/controller/CHIPDeviceController.cpp @@ -110,7 +110,7 @@ CHIP_ERROR DeviceController::Init(ControllerInitParams params) VerifyOrReturnError(params.systemState->TransportMgr() != nullptr, CHIP_ERROR_INVALID_ARGUMENT); ReturnErrorOnFailure(mDNSResolver.Init(params.systemState->UDPEndPointManager())); - mDNSResolver.SetCommissioningDelegate(this); + mDNSResolver.SetDiscoveryDelegate(this); RegisterDeviceDiscoveryDelegate(params.deviceDiscoveryDelegate); mVendorId = params.controllerVendorId; diff --git a/src/controller/SetUpCodePairer.cpp b/src/controller/SetUpCodePairer.cpp index db09d91fd74441..3a995a6e93579a 100644 --- a/src/controller/SetUpCodePairer.cpp +++ b/src/controller/SetUpCodePairer.cpp @@ -332,23 +332,22 @@ bool SetUpCodePairer::IdIsPresent(uint16_t vendorOrProductID) bool SetUpCodePairer::NodeMatchesCurrentFilter(const Dnssd::DiscoveredNodeData & nodeData) const { - if (nodeData.commissionData.commissioningMode == 0) + if (nodeData.nodeData.commissioningMode == 0) { ChipLogProgress(Controller, "Discovered device does not have an open commissioning window."); return false; } // The advertisement may not include a vendor id. - if (IdIsPresent(mPayloadVendorID) && IdIsPresent(nodeData.commissionData.vendorId) && - mPayloadVendorID != nodeData.commissionData.vendorId) + if (IdIsPresent(mPayloadVendorID) && IdIsPresent(nodeData.nodeData.vendorId) && mPayloadVendorID != nodeData.nodeData.vendorId) { ChipLogProgress(Controller, "Discovered device does not match our vendor id."); return false; } // The advertisement may not include a product id. - if (IdIsPresent(mPayloadProductID) && IdIsPresent(nodeData.commissionData.productId) && - mPayloadProductID != nodeData.commissionData.productId) + if (IdIsPresent(mPayloadProductID) && IdIsPresent(nodeData.nodeData.productId) && + mPayloadProductID != nodeData.nodeData.productId) { ChipLogProgress(Controller, "Discovered device does not match our product id."); return false; @@ -358,10 +357,10 @@ bool SetUpCodePairer::NodeMatchesCurrentFilter(const Dnssd::DiscoveredNodeData & switch (mCurrentFilter.type) { case Dnssd::DiscoveryFilterType::kShortDiscriminator: - discriminatorMatches = (((nodeData.commissionData.longDiscriminator >> 8) & 0x0F) == mCurrentFilter.code); + discriminatorMatches = (((nodeData.nodeData.longDiscriminator >> 8) & 0x0F) == mCurrentFilter.code); break; case Dnssd::DiscoveryFilterType::kLongDiscriminator: - discriminatorMatches = (nodeData.commissionData.longDiscriminator == mCurrentFilter.code); + discriminatorMatches = (nodeData.nodeData.longDiscriminator == mCurrentFilter.code); break; default: ChipLogError(Controller, "Unknown filter type; all matches will fail"); diff --git a/src/controller/java/CHIPDeviceController-JNI.cpp b/src/controller/java/CHIPDeviceController-JNI.cpp index aa1dd41149189e..82a0485718a21e 100644 --- a/src/controller/java/CHIPDeviceController-JNI.cpp +++ b/src/controller/java/CHIPDeviceController-JNI.cpp @@ -1905,7 +1905,7 @@ JNI_METHOD(jobject, getDiscoveredDevice)(JNIEnv * env, jobject self, jlong handl jobject discoveredObj = env->NewObject(discoveredDeviceCls, constructor); - env->SetLongField(discoveredObj, discrminatorID, data->commissionData.longDiscriminator); + env->SetLongField(discoveredObj, discrminatorID, data->nodeData.longDiscriminator); char ipAddress[100]; data->resolutionData.ipAddress[0].ToString(ipAddress, 100); @@ -1913,13 +1913,13 @@ JNI_METHOD(jobject, getDiscoveredDevice)(JNIEnv * env, jobject self, jlong handl env->SetObjectField(discoveredObj, ipAddressID, jniipAdress); env->SetIntField(discoveredObj, portID, static_cast(data->resolutionData.port)); - env->SetLongField(discoveredObj, deviceTypeID, static_cast(data->commissionData.deviceType)); - env->SetIntField(discoveredObj, vendorIdID, static_cast(data->commissionData.vendorId)); - env->SetIntField(discoveredObj, productIdID, static_cast(data->commissionData.productId)); + env->SetLongField(discoveredObj, deviceTypeID, static_cast(data->nodeData.deviceType)); + env->SetIntField(discoveredObj, vendorIdID, static_cast(data->nodeData.vendorId)); + env->SetIntField(discoveredObj, productIdID, static_cast(data->nodeData.productId)); jbyteArray jRotatingId; - CHIP_ERROR err = JniReferences::GetInstance().N2J_ByteArray( - env, data->commissionData.rotatingId, static_cast(data->commissionData.rotatingIdLen), jRotatingId); + CHIP_ERROR err = JniReferences::GetInstance().N2J_ByteArray(env, data->nodeData.rotatingId, + static_cast(data->nodeData.rotatingIdLen), jRotatingId); if (err != CHIP_NO_ERROR) { @@ -1927,12 +1927,12 @@ JNI_METHOD(jobject, getDiscoveredDevice)(JNIEnv * env, jobject self, jlong handl return nullptr; } env->SetObjectField(discoveredObj, rotatingIdID, static_cast(jRotatingId)); - env->SetObjectField(discoveredObj, instanceNameID, env->NewStringUTF(data->commissionData.instanceName)); - env->SetObjectField(discoveredObj, deviceNameID, env->NewStringUTF(data->commissionData.deviceName)); - env->SetObjectField(discoveredObj, pairingInstructionID, env->NewStringUTF(data->commissionData.pairingInstruction)); + env->SetObjectField(discoveredObj, instanceNameID, env->NewStringUTF(data->nodeData.instanceName)); + env->SetObjectField(discoveredObj, deviceNameID, env->NewStringUTF(data->nodeData.deviceName)); + env->SetObjectField(discoveredObj, pairingInstructionID, env->NewStringUTF(data->nodeData.pairingInstruction)); - env->CallVoidMethod(discoveredObj, setCommissioningModeID, static_cast(data->commissionData.commissioningMode)); - env->CallVoidMethod(discoveredObj, setPairingHintID, static_cast(data->commissionData.pairingHint)); + env->CallVoidMethod(discoveredObj, setCommissioningModeID, static_cast(data->nodeData.commissioningMode)); + env->CallVoidMethod(discoveredObj, setPairingHintID, static_cast(data->nodeData.pairingHint)); return discoveredObj; } diff --git a/src/controller/python/ChipCommissionableNodeController-ScriptBinding.cpp b/src/controller/python/ChipCommissionableNodeController-ScriptBinding.cpp index c82dd13f0e452f..39d70e350ae4db 100644 --- a/src/controller/python/ChipCommissionableNodeController-ScriptBinding.cpp +++ b/src/controller/python/ChipCommissionableNodeController-ScriptBinding.cpp @@ -82,22 +82,22 @@ void pychip_CommissionableNodeController_PrintDiscoveredCommissioners( continue; } char rotatingId[chip::Dnssd::kMaxRotatingIdLen * 2 + 1] = ""; - Encoding::BytesToUppercaseHexString(dnsSdInfo->commissionData.rotatingId, dnsSdInfo->commissionData.rotatingIdLen, - rotatingId, sizeof(rotatingId)); + Encoding::BytesToUppercaseHexString(dnsSdInfo->nodeData.rotatingId, dnsSdInfo->nodeData.rotatingIdLen, rotatingId, + sizeof(rotatingId)); ChipLogProgress(Discovery, "Commissioner %d", i); - ChipLogProgress(Discovery, "\tInstance name:\t\t%s", dnsSdInfo->commissionData.instanceName); + ChipLogProgress(Discovery, "\tInstance name:\t\t%s", dnsSdInfo->nodeData.instanceName); ChipLogProgress(Discovery, "\tHost name:\t\t%s", dnsSdInfo->resolutionData.hostName); ChipLogProgress(Discovery, "\tPort:\t\t\t%u", dnsSdInfo->resolutionData.port); - ChipLogProgress(Discovery, "\tLong discriminator:\t%u", dnsSdInfo->commissionData.longDiscriminator); - ChipLogProgress(Discovery, "\tVendor ID:\t\t%u", dnsSdInfo->commissionData.vendorId); - ChipLogProgress(Discovery, "\tProduct ID:\t\t%u", dnsSdInfo->commissionData.productId); - ChipLogProgress(Discovery, "\tCommissioning Mode\t%u", dnsSdInfo->commissionData.commissioningMode); - ChipLogProgress(Discovery, "\tDevice Type\t\t%u", dnsSdInfo->commissionData.deviceType); - ChipLogProgress(Discovery, "\tDevice Name\t\t%s", dnsSdInfo->commissionData.deviceName); + ChipLogProgress(Discovery, "\tLong discriminator:\t%u", dnsSdInfo->nodeData.longDiscriminator); + ChipLogProgress(Discovery, "\tVendor ID:\t\t%u", dnsSdInfo->nodeData.vendorId); + ChipLogProgress(Discovery, "\tProduct ID:\t\t%u", dnsSdInfo->nodeData.productId); + ChipLogProgress(Discovery, "\tCommissioning Mode\t%u", dnsSdInfo->nodeData.commissioningMode); + ChipLogProgress(Discovery, "\tDevice Type\t\t%u", dnsSdInfo->nodeData.deviceType); + ChipLogProgress(Discovery, "\tDevice Name\t\t%s", dnsSdInfo->nodeData.deviceName); ChipLogProgress(Discovery, "\tRotating Id\t\t%s", rotatingId); - ChipLogProgress(Discovery, "\tPairing Instruction\t%s", dnsSdInfo->commissionData.pairingInstruction); - ChipLogProgress(Discovery, "\tPairing Hint\t\t%u", dnsSdInfo->commissionData.pairingHint); + ChipLogProgress(Discovery, "\tPairing Instruction\t%s", dnsSdInfo->nodeData.pairingInstruction); + ChipLogProgress(Discovery, "\tPairing Hint\t\t%u", dnsSdInfo->nodeData.pairingHint); if (dnsSdInfo->resolutionData.GetMrpRetryIntervalIdle().HasValue()) { ChipLogProgress(Discovery, "\tMrp Interval idle\t%u", diff --git a/src/controller/python/ChipDeviceController-Discovery.cpp b/src/controller/python/ChipDeviceController-Discovery.cpp index 7b502140a36bb6..a8896628680a8f 100644 --- a/src/controller/python/ChipDeviceController-Discovery.cpp +++ b/src/controller/python/ChipDeviceController-Discovery.cpp @@ -110,21 +110,21 @@ void pychip_DeviceController_IterateDiscoveredCommissionableNodes(Controller::De Json::Value jsonVal; char rotatingId[Dnssd::kMaxRotatingIdLen * 2 + 1] = ""; - Encoding::BytesToUppercaseHexString(dnsSdInfo->commissionData.rotatingId, dnsSdInfo->commissionData.rotatingIdLen, - rotatingId, sizeof(rotatingId)); + Encoding::BytesToUppercaseHexString(dnsSdInfo->nodeData.rotatingId, dnsSdInfo->nodeData.rotatingIdLen, rotatingId, + sizeof(rotatingId)); ChipLogProgress(Discovery, "Commissionable Node %d", i); - jsonVal["instanceName"] = dnsSdInfo->commissionData.instanceName; + jsonVal["instanceName"] = dnsSdInfo->nodeData.instanceName; jsonVal["hostName"] = dnsSdInfo->resolutionData.hostName; jsonVal["port"] = dnsSdInfo->resolutionData.port; - jsonVal["longDiscriminator"] = dnsSdInfo->commissionData.longDiscriminator; - jsonVal["vendorId"] = dnsSdInfo->commissionData.vendorId; - jsonVal["productId"] = dnsSdInfo->commissionData.productId; - jsonVal["commissioningMode"] = dnsSdInfo->commissionData.commissioningMode; - jsonVal["deviceType"] = dnsSdInfo->commissionData.deviceType; - jsonVal["deviceName"] = dnsSdInfo->commissionData.deviceName; - jsonVal["pairingInstruction"] = dnsSdInfo->commissionData.pairingInstruction; - jsonVal["pairingHint"] = dnsSdInfo->commissionData.pairingHint; + jsonVal["longDiscriminator"] = dnsSdInfo->nodeData.longDiscriminator; + jsonVal["vendorId"] = dnsSdInfo->nodeData.vendorId; + jsonVal["productId"] = dnsSdInfo->nodeData.productId; + jsonVal["commissioningMode"] = dnsSdInfo->nodeData.commissioningMode; + jsonVal["deviceType"] = dnsSdInfo->nodeData.deviceType; + jsonVal["deviceName"] = dnsSdInfo->nodeData.deviceName; + jsonVal["pairingInstruction"] = dnsSdInfo->nodeData.pairingInstruction; + jsonVal["pairingHint"] = dnsSdInfo->nodeData.pairingHint; if (dnsSdInfo->resolutionData.GetMrpRetryIntervalIdle().HasValue()) { jsonVal["mrpRetryIntervalIdle"] = dnsSdInfo->resolutionData.GetMrpRetryIntervalIdle().Value().count(); @@ -152,7 +152,7 @@ void pychip_DeviceController_IterateDiscoveredCommissionableNodes(Controller::De { jsonVal["isICDOperatingAsLIT"] = dnsSdInfo->resolutionData.isICDOperatingAsLIT.Value(); } - if (dnsSdInfo->commissionData.rotatingIdLen > 0) + if (dnsSdInfo->nodeData.rotatingIdLen > 0) { jsonVal["rotatingId"] = rotatingId; } @@ -174,22 +174,22 @@ void pychip_DeviceController_PrintDiscoveredDevices(Controller::DeviceCommission continue; } char rotatingId[Dnssd::kMaxRotatingIdLen * 2 + 1] = ""; - Encoding::BytesToUppercaseHexString(dnsSdInfo->commissionData.rotatingId, dnsSdInfo->commissionData.rotatingIdLen, - rotatingId, sizeof(rotatingId)); + Encoding::BytesToUppercaseHexString(dnsSdInfo->nodeData.rotatingId, dnsSdInfo->nodeData.rotatingIdLen, rotatingId, + sizeof(rotatingId)); ChipLogProgress(Discovery, "Commissionable Node %d", i); - ChipLogProgress(Discovery, "\tInstance name:\t\t%s", dnsSdInfo->commissionData.instanceName); + ChipLogProgress(Discovery, "\tInstance name:\t\t%s", dnsSdInfo->nodeData.instanceName); ChipLogProgress(Discovery, "\tHost name:\t\t%s", dnsSdInfo->resolutionData.hostName); ChipLogProgress(Discovery, "\tPort:\t\t\t%u", dnsSdInfo->resolutionData.port); - ChipLogProgress(Discovery, "\tLong discriminator:\t%u", dnsSdInfo->commissionData.longDiscriminator); - ChipLogProgress(Discovery, "\tVendor ID:\t\t%u", dnsSdInfo->commissionData.vendorId); - ChipLogProgress(Discovery, "\tProduct ID:\t\t%u", dnsSdInfo->commissionData.productId); - ChipLogProgress(Discovery, "\tCommissioning Mode\t%u", dnsSdInfo->commissionData.commissioningMode); - ChipLogProgress(Discovery, "\tDevice Type\t\t%u", dnsSdInfo->commissionData.deviceType); - ChipLogProgress(Discovery, "\tDevice Name\t\t%s", dnsSdInfo->commissionData.deviceName); + ChipLogProgress(Discovery, "\tLong discriminator:\t%u", dnsSdInfo->nodeData.longDiscriminator); + ChipLogProgress(Discovery, "\tVendor ID:\t\t%u", dnsSdInfo->nodeData.vendorId); + ChipLogProgress(Discovery, "\tProduct ID:\t\t%u", dnsSdInfo->nodeData.productId); + ChipLogProgress(Discovery, "\tCommissioning Mode\t%u", dnsSdInfo->nodeData.commissioningMode); + ChipLogProgress(Discovery, "\tDevice Type\t\t%u", dnsSdInfo->nodeData.deviceType); + ChipLogProgress(Discovery, "\tDevice Name\t\t%s", dnsSdInfo->nodeData.deviceName); ChipLogProgress(Discovery, "\tRotating Id\t\t%s", rotatingId); - ChipLogProgress(Discovery, "\tPairing Instruction\t%s", dnsSdInfo->commissionData.pairingInstruction); - ChipLogProgress(Discovery, "\tPairing Hint\t\t%u", dnsSdInfo->commissionData.pairingHint); + ChipLogProgress(Discovery, "\tPairing Instruction\t%s", dnsSdInfo->nodeData.pairingInstruction); + ChipLogProgress(Discovery, "\tPairing Hint\t\t%u", dnsSdInfo->nodeData.pairingHint); if (dnsSdInfo->resolutionData.GetMrpRetryIntervalIdle().HasValue()) { ChipLogProgress(Discovery, "\tMrp Interval idle\t%u", diff --git a/src/controller/python/ChipDeviceController-ScriptPairingDeviceDiscoveryDelegate.cpp b/src/controller/python/ChipDeviceController-ScriptPairingDeviceDiscoveryDelegate.cpp index e5cb7d768e4d18..a83a56c1b813f9 100644 --- a/src/controller/python/ChipDeviceController-ScriptPairingDeviceDiscoveryDelegate.cpp +++ b/src/controller/python/ChipDeviceController-ScriptPairingDeviceDiscoveryDelegate.cpp @@ -24,7 +24,7 @@ namespace Controller { void ScriptPairingDeviceDiscoveryDelegate::OnDiscoveredDevice(const Dnssd::DiscoveredNodeData & nodeData) { // Ignore nodes with closed comissioning window - VerifyOrReturn(nodeData.commissionData.commissioningMode != 0); + VerifyOrReturn(nodeData.nodeData.commissioningMode != 0); VerifyOrReturn(mActiveDeviceCommissioner != nullptr); const uint16_t port = nodeData.resolutionData.port; diff --git a/src/controller/tests/TestCommissionableNodeController.cpp b/src/controller/tests/TestCommissionableNodeController.cpp index c2aafe500c293d..760b62e97386b0 100644 --- a/src/controller/tests/TestCommissionableNodeController.cpp +++ b/src/controller/tests/TestCommissionableNodeController.cpp @@ -38,9 +38,10 @@ class MockResolver : public Resolver void SetOperationalDelegate(OperationalResolveDelegate * delegate) override {} CHIP_ERROR ResolveNodeId(const PeerId & peerId) override { return ResolveNodeIdStatus; } void NodeIdResolutionNoLongerNeeded(const PeerId & peerId) override {} - CHIP_ERROR DiscoverCommissioners(DiscoveryFilter filter, DiscoveryContext &) override { return DiscoverCommissionersStatus; } - CHIP_ERROR DiscoverCommissionableNodes(DiscoveryFilter filter, DiscoveryContext &) override + CHIP_ERROR StartDiscovery(DiscoveryType type, DiscoveryFilter filter, DiscoveryContext &) override { + if (DiscoveryType::kCommissionerNode == type) + return DiscoverCommissionersStatus; return CHIP_ERROR_NOT_IMPLEMENTED; } CHIP_ERROR StopDiscovery(DiscoveryContext &) override { return CHIP_ERROR_NOT_IMPLEMENTED; } diff --git a/src/darwin/Framework/CHIP/MTRAsyncWorkQueue.mm b/src/darwin/Framework/CHIP/MTRAsyncWorkQueue.mm index 4a717e5daa24aa..eff85b1b0cb503 100644 --- a/src/darwin/Framework/CHIP/MTRAsyncWorkQueue.mm +++ b/src/darwin/Framework/CHIP/MTRAsyncWorkQueue.mm @@ -225,18 +225,11 @@ - (instancetype)initWithContext:(id)context return self; } -- (NSString *)_lockedSelfDescription:(const ContextSnapshot &)context -{ - os_unfair_lock_assert_owner(&_lock); - - return [NSString stringWithFormat:@"%@, items count: %tu", context.description, _items.count]; -} - - (NSString *)description { ContextSnapshot context(self); std::lock_guard lock(_lock); - return [NSString stringWithFormat:@"<%@ context: %@>", self.class, [self _lockedSelfDescription:context]]; + return [NSString stringWithFormat:@"<%@ context: %@, items count: %tu>", self.class, context.description, _items.count]; } - (void)enqueueWorkItem:(MTRAsyncWorkItem *)item @@ -268,9 +261,9 @@ - (void)enqueueWorkItem:(MTRAsyncWorkItem *)item // Logging the description once is enough because other log messages // related to the work item (execution, completion etc) can easily be // correlated using the unique id. - MTR_LOG_DEFAULT("MTRAsyncWorkQueue<%@> enqueued work item [%llu]: %@", [self _lockedSelfDescription:context], item.uniqueID, description); + MTR_LOG_DEFAULT("MTRAsyncWorkQueue<%@, items count: %tu> enqueued work item [%llu]: %@", context.description, _items.count, item.uniqueID, description); } else { - MTR_LOG_DEFAULT("MTRAsyncWorkQueue<%@> enqueued work item [%llu]", [self _lockedSelfDescription:context], item.uniqueID); + MTR_LOG_DEFAULT("MTRAsyncWorkQueue<%@, items count: %tu> enqueued work item [%llu]", context.description, _items.count, item.uniqueID); } [self _callNextReadyWorkItemWithContext:context]; @@ -304,7 +297,7 @@ - (void)_postProcessWorkItem:(MTRAsyncWorkItem *)workItem } else { [workItem markComplete]; [_items removeObjectAtIndex:0]; - MTR_LOG_DEFAULT("MTRAsyncWorkQueue<%@> completed work item [%llu]", [self _lockedSelfDescription:context], workItem.uniqueID); + MTR_LOG_DEFAULT("MTRAsyncWorkQueue<%@, items count: %tu> completed work item [%llu]", context.description, _items.count, workItem.uniqueID); } // when "concurrency width" is implemented this will be decremented instead diff --git a/src/darwin/Framework/CHIP/MTRCommissionableBrowser.mm b/src/darwin/Framework/CHIP/MTRCommissionableBrowser.mm index a0ccfd380a232d..bf975b672decd5 100644 --- a/src/darwin/Framework/CHIP/MTRCommissionableBrowser.mm +++ b/src/darwin/Framework/CHIP/MTRCommissionableBrowser.mm @@ -53,7 +53,7 @@ @interface MTRCommissionableBrowserResult () @implementation MTRCommissionableBrowserResult @end -class CommissionableBrowserInternal : public CommissioningResolveDelegate, +class CommissionableBrowserInternal : public DiscoverNodeDelegate, public DnssdBrowseDelegate #if CONFIG_NETWORK_LAYER_BLE , @@ -156,12 +156,12 @@ void ClearDnssdDiscoveredDevices() mDiscoveredResults = discoveredResultsCopy; } - /////////// CommissioningResolveDelegate Interface ///////// + /////////// DiscoverNodeDelegate Interface ///////// void OnNodeDiscovered(const DiscoveredNodeData & nodeData) override { assertChipStackLockedByCurrentThread(); - auto & commissionData = nodeData.commissionData; + auto & commissionData = nodeData.nodeData; auto key = [NSString stringWithUTF8String:commissionData.instanceName]; if ([mDiscoveredResults objectForKey:key] == nil) { // It should not happens. diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.mm b/src/darwin/Framework/CHIP/MTRDeviceController.mm index 22d52cd5b4a684..961b6f87694536 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController.mm @@ -139,25 +139,15 @@ - (nullable instancetype)initWithParameters:(MTRDeviceControllerAbstractParamete { if (![parameters isKindOfClass:MTRDeviceControllerParameters.class]) { MTR_LOG_ERROR("Unsupported type of MTRDeviceControllerAbstractParameters: %@", parameters); - if (error) { *error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_ARGUMENT]; } return nil; } + auto * controllerParameters = static_cast(parameters); - __auto_type * factory = [MTRDeviceControllerFactory sharedInstance]; - if (!factory.isRunning) { - auto * params = [[MTRDeviceControllerFactoryParams alloc] initWithoutStorage]; - - if (![factory startControllerFactory:params error:error]) { - return nil; - } - } - - auto * parametersForFactory = static_cast(parameters); - - return [factory initializeController:self withParameters:parametersForFactory error:error]; + // MTRDeviceControllerFactory will auto-start in per-controller-storage mode if necessary + return [MTRDeviceControllerFactory.sharedInstance initializeController:self withParameters:controllerParameters error:error]; } - (instancetype)initWithFactory:(MTRDeviceControllerFactory *)factory diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm b/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm index 5941a799b5b514..b31003c238bea5 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerFactory.mm @@ -417,7 +417,14 @@ - (CHIP_ERROR)_initFabricTable:(FabricTable &)fabricTable return [NSArray arrayWithArray:fabricList]; } -- (BOOL)startControllerFactory:(MTRDeviceControllerFactoryParams *)startupParams error:(NSError * __autoreleasing *)error; +- (BOOL)startControllerFactory:(MTRDeviceControllerFactoryParams *)startupParams error:(NSError * __autoreleasing *)error +{ + return [self _startControllerFactory:startupParams startingController:NO error:error]; +} + +- (BOOL)_startControllerFactory:(MTRDeviceControllerFactoryParams *)startupParams + startingController:(BOOL)startingController + error:(NSError * __autoreleasing *)error { [self _assertCurrentQueueIsNotMatterQueue]; @@ -535,6 +542,7 @@ - (BOOL)startControllerFactory:(MTRDeviceControllerFactoryParams *)startupParams // state is brought up live on factory init, and not when it comes time // to actually start a controller, and does not actually clean itself up // until its refcount (which starts as 0) goes to 0. + // TODO: Don't cause a stack shutdown and restart if startingController _controllerFactory->RetainSystemState(); _controllerFactory->ReleaseSystemState(); @@ -597,11 +605,6 @@ - (MTRDeviceController * _Nullable)_startDeviceController:(MTRDeviceController * { [self _assertCurrentQueueIsNotMatterQueue]; - if (![self checkIsRunning:error]) { - MTR_LOG_ERROR("Trying to start controller while Matter controller factory is not running"); - return nil; - } - id _Nullable storageDelegate; dispatch_queue_t _Nullable storageDelegateQueue; NSUUID * uniqueIdentifier; @@ -623,9 +626,28 @@ - (MTRDeviceController * _Nullable)_startDeviceController:(MTRDeviceController * otaProviderDelegateQueue = nil; } else { MTR_LOG_ERROR("Unknown kind of startup params: %@", startupParams); + if (error != nil) { + *error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_ARGUMENT]; + } return nil; } + if (![self isRunning]) { + if (storageDelegate != nil) { + MTR_LOG_DEFAULT("Auto-starting Matter controller factory in per-controller storage mode"); + auto * params = [[MTRDeviceControllerFactoryParams alloc] initWithoutStorage]; + if (![self _startControllerFactory:params startingController:YES error:error]) { + return nil; + } + } else { + MTR_LOG_ERROR("Trying to start controller while Matter controller factory is not running"); + if (error != nil) { + *error = [MTRError errorForCHIPErrorCode:CHIP_ERROR_INCORRECT_STATE]; + } + return nil; + } + } + if (_usingPerControllerStorage && storageDelegate == nil) { MTR_LOG_ERROR("Must have a controller storage delegate when we do not have storage for the controller factory"); if (error != nil) { diff --git a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj index 1e540620fe2632..80c451c937e2de 100644 --- a/src/darwin/Framework/Matter.xcodeproj/project.pbxproj +++ b/src/darwin/Framework/Matter.xcodeproj/project.pbxproj @@ -2256,6 +2256,7 @@ OTHER_CPLUSPLUSFLAGS = ( "$(OTHER_CFLAGS)", "-fno-c++-static-destructors", + "-DCHIP_CONFIG_GLOBALS_NO_DESTRUCT=1", ); OTHER_LDFLAGS = ""; "OTHER_LDFLAGS[sdk=*]" = ( @@ -2421,6 +2422,7 @@ OTHER_CPLUSPLUSFLAGS = ( "$(OTHER_CFLAGS)", "-fno-c++-static-destructors", + "-DCHIP_CONFIG_GLOBALS_NO_DESTRUCT=1", ); OTHER_LDFLAGS = ""; "OTHER_LDFLAGS[sdk=*]" = ( diff --git a/src/lib/dnssd/ActiveResolveAttempts.h b/src/lib/dnssd/ActiveResolveAttempts.h index 15796abf85b20c..ba6d8cf7a54f6e 100644 --- a/src/lib/dnssd/ActiveResolveAttempts.h +++ b/src/lib/dnssd/ActiveResolveAttempts.h @@ -159,17 +159,17 @@ class ActiveResolveAttempts case chip::Dnssd::DiscoveryFilterType::kNone: return true; case chip::Dnssd::DiscoveryFilterType::kShortDiscriminator: - return browse.filter.code == static_cast((data.commissionData.longDiscriminator >> 8) & 0x0F); + return browse.filter.code == static_cast((data.nodeData.longDiscriminator >> 8) & 0x0F); case chip::Dnssd::DiscoveryFilterType::kLongDiscriminator: - return browse.filter.code == data.commissionData.longDiscriminator; + return browse.filter.code == data.nodeData.longDiscriminator; case chip::Dnssd::DiscoveryFilterType::kVendorId: - return browse.filter.code == data.commissionData.vendorId; + return browse.filter.code == data.nodeData.vendorId; case chip::Dnssd::DiscoveryFilterType::kDeviceType: - return browse.filter.code == data.commissionData.deviceType; + return browse.filter.code == data.nodeData.deviceType; case chip::Dnssd::DiscoveryFilterType::kCommissioningMode: - return browse.filter.code == data.commissionData.commissioningMode; + return browse.filter.code == data.nodeData.commissioningMode; case chip::Dnssd::DiscoveryFilterType::kInstanceName: - return strncmp(browse.filter.instanceName, data.commissionData.instanceName, + return strncmp(browse.filter.instanceName, data.nodeData.instanceName, chip::Dnssd::Commission::kInstanceNameMaxLength + 1) == 0; case chip::Dnssd::DiscoveryFilterType::kCommissioner: case chip::Dnssd::DiscoveryFilterType::kCompressedFabricId: diff --git a/src/lib/dnssd/Discovery_ImplPlatform.cpp b/src/lib/dnssd/Discovery_ImplPlatform.cpp index 6904480a4d1691..c12019ca60b5fd 100644 --- a/src/lib/dnssd/Discovery_ImplPlatform.cpp +++ b/src/lib/dnssd/Discovery_ImplPlatform.cpp @@ -340,7 +340,7 @@ void DiscoveryImplPlatform::HandleNodeIdResolve(void * context, DnssdService * r void DnssdService::ToDiscoveredNodeData(const Span & addresses, DiscoveredNodeData & nodeData) { auto & resolutionData = nodeData.resolutionData; - auto & commissionData = nodeData.commissionData; + auto & commissionData = nodeData.nodeData; Platform::CopyString(resolutionData.hostName, mHostName); Platform::CopyString(commissionData.instanceName, mName); @@ -743,6 +743,21 @@ CHIP_ERROR DiscoveryImplPlatform::DiscoverCommissioners(DiscoveryFilter filter, return error; } +CHIP_ERROR DiscoveryImplPlatform::StartDiscovery(DiscoveryType type, DiscoveryFilter filter, DiscoveryContext & context) +{ + switch (type) + { + case DiscoveryType::kCommissionableNode: + return DiscoverCommissionableNodes(filter, context); + case DiscoveryType::kCommissionerNode: + return DiscoverCommissioners(filter, context); + case DiscoveryType::kOperational: + return CHIP_ERROR_NOT_IMPLEMENTED; + default: + return CHIP_ERROR_INVALID_ARGUMENT; + } +} + CHIP_ERROR DiscoveryImplPlatform::StopDiscovery(DiscoveryContext & context) { if (!context.GetBrowseIdentifier().HasValue()) diff --git a/src/lib/dnssd/Discovery_ImplPlatform.h b/src/lib/dnssd/Discovery_ImplPlatform.h index a3f79796ca535c..c6ba929801ba7b 100644 --- a/src/lib/dnssd/Discovery_ImplPlatform.h +++ b/src/lib/dnssd/Discovery_ImplPlatform.h @@ -53,8 +53,9 @@ class DiscoveryImplPlatform : public ServiceAdvertiser, public Resolver void SetOperationalDelegate(OperationalResolveDelegate * delegate) override { mOperationalDelegate = delegate; } CHIP_ERROR ResolveNodeId(const PeerId & peerId) override; void NodeIdResolutionNoLongerNeeded(const PeerId & peerId) override; - CHIP_ERROR DiscoverCommissionableNodes(DiscoveryFilter filter, DiscoveryContext & context) override; - CHIP_ERROR DiscoverCommissioners(DiscoveryFilter filter, DiscoveryContext & context) override; + CHIP_ERROR DiscoverCommissionableNodes(DiscoveryFilter filter, DiscoveryContext & context); + CHIP_ERROR DiscoverCommissioners(DiscoveryFilter filter, DiscoveryContext & context); + CHIP_ERROR StartDiscovery(DiscoveryType type, DiscoveryFilter filter, DiscoveryContext & context) override; CHIP_ERROR StopDiscovery(DiscoveryContext & context) override; CHIP_ERROR ReconfirmRecord(const char * hostname, Inet::IPAddress address, Inet::InterfaceId interfaceId) override; diff --git a/src/lib/dnssd/IncrementalResolve.cpp b/src/lib/dnssd/IncrementalResolve.cpp index c36efbde177a6d..766d979e33a4ba 100644 --- a/src/lib/dnssd/IncrementalResolve.cpp +++ b/src/lib/dnssd/IncrementalResolve.cpp @@ -189,7 +189,7 @@ CHIP_ERROR IncrementalResolver::InitializeParsing(mdns::Minimal::SerializedQName break; case ServiceNameType::kCommissioner: case ServiceNameType::kCommissionable: - mSpecificResolutionData.Set(); + mSpecificResolutionData.Set(); { // Commission addresses start with instance name @@ -199,10 +199,10 @@ CHIP_ERROR IncrementalResolver::InitializeParsing(mdns::Minimal::SerializedQName return CHIP_ERROR_INVALID_ARGUMENT; } - Platform::CopyString(mSpecificResolutionData.Get().instanceName, nameCopy.Value()); + Platform::CopyString(mSpecificResolutionData.Get().instanceName, nameCopy.Value()); } - LogFoundCommissionSrvRecord(mSpecificResolutionData.Get().instanceName, mTargetHostName.Get()); + LogFoundCommissionSrvRecord(mSpecificResolutionData.Get().instanceName, mTargetHostName.Get()); break; default: return CHIP_ERROR_INVALID_ARGUMENT; @@ -304,9 +304,9 @@ CHIP_ERROR IncrementalResolver::OnTxtRecord(const ResourceData & data, BytesRang } } - if (IsActiveCommissionParse()) + if (IsActiveBrowseParse()) { - TxtParser delegate(mSpecificResolutionData.Get()); + TxtParser delegate(mSpecificResolutionData.Get()); if (!ParseTxtRecord(data.GetData(), &delegate)) { return CHIP_ERROR_INVALID_ARGUMENT; @@ -343,12 +343,12 @@ CHIP_ERROR IncrementalResolver::OnIpAddress(Inet::InterfaceId interface, const I CHIP_ERROR IncrementalResolver::Take(DiscoveredNodeData & outputData) { - VerifyOrReturnError(IsActiveCommissionParse(), CHIP_ERROR_INCORRECT_STATE); + VerifyOrReturnError(IsActiveBrowseParse(), CHIP_ERROR_INCORRECT_STATE); IPAddressSorter::Sort(mCommonResolutionData.ipAddress, mCommonResolutionData.numIPs, mCommonResolutionData.interfaceId); outputData.resolutionData = mCommonResolutionData; - outputData.commissionData = mSpecificResolutionData.Get(); + outputData.nodeData = mSpecificResolutionData.Get(); ResetToInactive(); diff --git a/src/lib/dnssd/IncrementalResolve.h b/src/lib/dnssd/IncrementalResolve.h index b28b3cb897b5f3..9d2386472d7eba 100644 --- a/src/lib/dnssd/IncrementalResolve.h +++ b/src/lib/dnssd/IncrementalResolve.h @@ -99,7 +99,7 @@ class IncrementalResolver /// method. bool IsActive() const { return mSpecificResolutionData.Valid(); } - bool IsActiveCommissionParse() const { return mSpecificResolutionData.Is(); } + bool IsActiveBrowseParse() const { return mSpecificResolutionData.Is(); } bool IsActiveOperationalParse() const { return mSpecificResolutionData.Is(); } ServiceNameType GetCurrentType() const { return mServiceNameType; } @@ -143,7 +143,7 @@ class IncrementalResolver /// Take the current value of the object and clear it once returned. /// - /// Object must be in `IsActiveCommissionParse()` for this to succeed. + /// Object must be in `IsActiveBrowseParse()` for this to succeed. /// Data will be returned (and cleared) even if not yet complete based /// on `GetMissingRequiredInformation()`. This method takes as much data as /// it was parsed so far. @@ -170,7 +170,7 @@ class IncrementalResolver /// Input data MUST have GetType() == QType::TXT CHIP_ERROR OnTxtRecord(const mdns::Minimal::ResourceData & data, mdns::Minimal::BytesRange packetRange); - /// Notify that a new IP addres has been found. + /// Notify that a new IP address has been found. /// /// This is to be called on both A (if IPv4 support is enabled) and AAAA /// addresses. @@ -178,7 +178,7 @@ class IncrementalResolver /// Prerequisite: IP address belongs to the right nost name CHIP_ERROR OnIpAddress(Inet::InterfaceId interface, const Inet::IPAddress & addr); - using ParsedRecordSpecificData = Variant; + using ParsedRecordSpecificData = Variant; StoredServerName mRecordName; // Record name for what is parsed (SRV/PTR/TXT) StoredServerName mTargetHostName; // `Target` for the SRV record diff --git a/src/lib/dnssd/Resolver.h b/src/lib/dnssd/Resolver.h index 6f9827b82218a6..bf684cef6a12a5 100644 --- a/src/lib/dnssd/Resolver.h +++ b/src/lib/dnssd/Resolver.h @@ -78,12 +78,12 @@ class DiscoveryContext : public ReferenceCounted void ClearBrowseIdentifier() { mBrowseIdentifier.ClearValue(); } const Optional & GetBrowseIdentifier() const { return mBrowseIdentifier; } - void SetCommissioningDelegate(CommissioningResolveDelegate * delegate) { mCommissioningDelegate = delegate; } + void SetDiscoveryDelegate(DiscoverNodeDelegate * delegate) { mDelegate = delegate; } void OnNodeDiscovered(const DiscoveredNodeData & nodeData) { - if (mCommissioningDelegate != nullptr) + if (mDelegate != nullptr) { - mCommissioningDelegate->OnNodeDiscovered(nodeData); + mDelegate->OnNodeDiscovered(nodeData); } else { @@ -92,7 +92,7 @@ class DiscoveryContext : public ReferenceCounted } private: - CommissioningResolveDelegate * mCommissioningDelegate = nullptr; + DiscoverNodeDelegate * mDelegate = nullptr; Optional mBrowseIdentifier; }; @@ -168,31 +168,19 @@ class Resolver virtual void NodeIdResolutionNoLongerNeeded(const PeerId & peerId) = 0; /** - * Finds all commissionable nodes matching the given filter. + * Finds all nodes of given type matching the given filter. * * Whenever a new matching node is found, the node information is passed to - * the `OnNodeDiscovered` method of the commissioning delegate configured + * the `OnNodeDiscovered` method of the discovery delegate configured * in the context object. * * This method is expected to increase the reference count of the context * object for as long as it takes to complete the discovery request. */ - virtual CHIP_ERROR DiscoverCommissionableNodes(DiscoveryFilter filter, DiscoveryContext & context) = 0; + virtual CHIP_ERROR StartDiscovery(DiscoveryType type, DiscoveryFilter filter, DiscoveryContext & context) = 0; /** - * Finds all commissioner nodes matching the given filter. - * - * Whenever a new matching node is found, the node information is passed to - * the `OnNodeDiscovered` method of the commissioning delegate configured - * in the context object. - * - * This method is expected to increase the reference count of the context - * object for as long as it takes to complete the discovery request. - */ - virtual CHIP_ERROR DiscoverCommissioners(DiscoveryFilter filter, DiscoveryContext & context) = 0; - - /** - * Stop discovery (of commissionable or commissioner nodes). + * Stop discovery (of all node types). * * Some back ends may not support stopping discovery, so consumers should * not assume they will stop getting callbacks after calling this. diff --git a/src/lib/dnssd/ResolverProxy.cpp b/src/lib/dnssd/ResolverProxy.cpp index 3e7446ebbbdc6b..e43028ee54023d 100644 --- a/src/lib/dnssd/ResolverProxy.cpp +++ b/src/lib/dnssd/ResolverProxy.cpp @@ -36,7 +36,7 @@ CHIP_ERROR ResolverProxy::Init(Inet::EndPointManager * udpEnd void ResolverProxy::Shutdown() { VerifyOrReturn(mContext != nullptr); - mContext->SetCommissioningDelegate(nullptr); + mContext->SetDiscoveryDelegate(nullptr); mContext->Release(); mContext = nullptr; } @@ -45,14 +45,14 @@ CHIP_ERROR ResolverProxy::DiscoverCommissionableNodes(DiscoveryFilter filter) { VerifyOrReturnError(mContext != nullptr, CHIP_ERROR_INCORRECT_STATE); - return mResolver.DiscoverCommissionableNodes(filter, *mContext); + return mResolver.StartDiscovery(DiscoveryType::kCommissionableNode, filter, *mContext); } CHIP_ERROR ResolverProxy::DiscoverCommissioners(DiscoveryFilter filter) { VerifyOrReturnError(mContext != nullptr, CHIP_ERROR_INCORRECT_STATE); - return mResolver.DiscoverCommissioners(filter, *mContext); + return mResolver.StartDiscovery(DiscoveryType::kCommissionerNode, filter, *mContext); } CHIP_ERROR ResolverProxy::StopDiscovery() diff --git a/src/lib/dnssd/ResolverProxy.h b/src/lib/dnssd/ResolverProxy.h index 09a50e89c1a209..58617b0d0162d7 100644 --- a/src/lib/dnssd/ResolverProxy.h +++ b/src/lib/dnssd/ResolverProxy.h @@ -44,11 +44,11 @@ class ResolverProxy CHIP_ERROR Init(Inet::EndPointManager * udpEndPoint = nullptr); void Shutdown(); - void SetCommissioningDelegate(CommissioningResolveDelegate * delegate) + void SetDiscoveryDelegate(DiscoverNodeDelegate * delegate) { if (mContext != nullptr) { - mContext->SetCommissioningDelegate(delegate); + mContext->SetDiscoveryDelegate(delegate); } } diff --git a/src/lib/dnssd/Resolver_ImplMinimalMdns.cpp b/src/lib/dnssd/Resolver_ImplMinimalMdns.cpp index b74d0ae87d8507..a5e7117a72a005 100644 --- a/src/lib/dnssd/Resolver_ImplMinimalMdns.cpp +++ b/src/lib/dnssd/Resolver_ImplMinimalMdns.cpp @@ -285,8 +285,7 @@ class MinMdnsResolver : public Resolver, public MdnsPacketDelegate void SetOperationalDelegate(OperationalResolveDelegate * delegate) override { mOperationalDelegate = delegate; } CHIP_ERROR ResolveNodeId(const PeerId & peerId) override; void NodeIdResolutionNoLongerNeeded(const PeerId & peerId) override; - CHIP_ERROR DiscoverCommissionableNodes(DiscoveryFilter filter, DiscoveryContext & context) override; - CHIP_ERROR DiscoverCommissioners(DiscoveryFilter filter, DiscoveryContext & context) override; + CHIP_ERROR StartDiscovery(DiscoveryType type, DiscoveryFilter filter, DiscoveryContext & context) override; CHIP_ERROR StopDiscovery(DiscoveryContext & context) override; CHIP_ERROR ReconfirmRecord(const char * hostname, Inet::IPAddress address, Inet::InterfaceId interfaceId) override; @@ -386,7 +385,7 @@ void MinMdnsResolver::AdvancePendingResolverStates() } // SUCCESS. Call the delegates - if (resolver->IsActiveCommissionParse()) + if (resolver->IsActiveBrowseParse()) { MATTER_TRACE_SCOPE("Active commissioning delegate call", "MinMdnsResolver"); DiscoveredNodeData nodeData; @@ -412,13 +411,15 @@ void MinMdnsResolver::AdvancePendingResolverStates() case IncrementalResolver::ServiceNameType::kCommissioner: discoveredNodeIsRelevant = mActiveResolves.HasBrowseFor(chip::Dnssd::DiscoveryType::kCommissionerNode); mActiveResolves.CompleteCommissioner(nodeData); + nodeData.nodeType = DiscoveryType::kCommissionerNode; break; case IncrementalResolver::ServiceNameType::kCommissionable: discoveredNodeIsRelevant = mActiveResolves.HasBrowseFor(chip::Dnssd::DiscoveryType::kCommissionableNode); mActiveResolves.CompleteCommissionable(nodeData); + nodeData.nodeType = DiscoveryType::kCommissionableNode; break; default: - ChipLogError(Discovery, "Unexpected type for commission data parsing"); + ChipLogError(Discovery, "Unexpected type for browse data parsing"); continue; } @@ -685,20 +686,12 @@ void MinMdnsResolver::ExpireIncrementalResolvers() } } -CHIP_ERROR MinMdnsResolver::DiscoverCommissionableNodes(DiscoveryFilter filter, DiscoveryContext & context) +CHIP_ERROR MinMdnsResolver::StartDiscovery(DiscoveryType type, DiscoveryFilter filter, DiscoveryContext & context) { // minmdns currently supports only one discovery context at a time so override the previous context SetDiscoveryContext(&context); - return BrowseNodes(DiscoveryType::kCommissionableNode, filter); -} - -CHIP_ERROR MinMdnsResolver::DiscoverCommissioners(DiscoveryFilter filter, DiscoveryContext & context) -{ - // minmdns currently supports only one discovery context at a time so override the previous context - SetDiscoveryContext(&context); - - return BrowseNodes(DiscoveryType::kCommissionerNode, filter); + return BrowseNodes(type, filter); } CHIP_ERROR MinMdnsResolver::StopDiscovery(DiscoveryContext & context) diff --git a/src/lib/dnssd/Resolver_ImplNone.cpp b/src/lib/dnssd/Resolver_ImplNone.cpp index 36e2bd9aead89f..497c82af9e53d9 100644 --- a/src/lib/dnssd/Resolver_ImplNone.cpp +++ b/src/lib/dnssd/Resolver_ImplNone.cpp @@ -40,11 +40,7 @@ class NoneResolver : public Resolver { ChipLogError(Discovery, "Failed to stop resolving node ID: dnssd resolving not available"); } - CHIP_ERROR DiscoverCommissionableNodes(DiscoveryFilter filter, DiscoveryContext & context) override - { - return CHIP_ERROR_NOT_IMPLEMENTED; - } - CHIP_ERROR DiscoverCommissioners(DiscoveryFilter filter, DiscoveryContext & context) override + CHIP_ERROR StartDiscovery(DiscoveryType type, DiscoveryFilter filter, DiscoveryContext & context) override { return CHIP_ERROR_NOT_IMPLEMENTED; } diff --git a/src/lib/dnssd/TxtFields.cpp b/src/lib/dnssd/TxtFields.cpp index d43650748e53a2..b77d991784867d 100644 --- a/src/lib/dnssd/TxtFields.cpp +++ b/src/lib/dnssd/TxtFields.cpp @@ -225,7 +225,7 @@ TxtFieldKey GetTxtFieldKey(const ByteSpan & key) } // namespace Internal -void FillNodeDataFromTxt(const ByteSpan & key, const ByteSpan & val, CommissionNodeData & nodeData) +void FillNodeDataFromTxt(const ByteSpan & key, const ByteSpan & val, DnssdNodeData & nodeData) { TxtFieldKey keyType = Internal::GetTxtFieldKey(key); switch (keyType) diff --git a/src/lib/dnssd/TxtFields.h b/src/lib/dnssd/TxtFields.h index 5546493624119d..194750451289a4 100644 --- a/src/lib/dnssd/TxtFields.h +++ b/src/lib/dnssd/TxtFields.h @@ -192,7 +192,7 @@ constexpr size_t ValSize(TxtFieldKey key) } void FillNodeDataFromTxt(const ByteSpan & key, const ByteSpan & value, CommonResolutionData & nodeData); -void FillNodeDataFromTxt(const ByteSpan & key, const ByteSpan & value, CommissionNodeData & nodeData); +void FillNodeDataFromTxt(const ByteSpan & key, const ByteSpan & value, DnssdNodeData & nodeData); } // namespace Dnssd } // namespace chip diff --git a/src/lib/dnssd/Types.h b/src/lib/dnssd/Types.h index 3718d9b2757aec..15dbf90670ac34 100644 --- a/src/lib/dnssd/Types.h +++ b/src/lib/dnssd/Types.h @@ -205,7 +205,7 @@ inline constexpr size_t kMaxRotatingIdLen = 50; inline constexpr size_t kMaxPairingInstructionLen = 128; /// Data that is specific to commisionable/commissioning node discovery -struct CommissionNodeData +struct DnssdNodeData { size_t rotatingIdLen = 0; uint32_t deviceType = 0; @@ -220,13 +220,13 @@ struct CommissionNodeData char deviceName[kMaxDeviceNameLen + 1] = {}; char pairingInstruction[kMaxPairingInstructionLen + 1] = {}; - CommissionNodeData() {} + DnssdNodeData() {} void Reset() { // Let constructor clear things as default - this->~CommissionNodeData(); - new (this) CommissionNodeData(); + this->~DnssdNodeData(); + new (this) DnssdNodeData(); } bool IsInstanceName(const char * instance) const { return strcmp(instance, instanceName) == 0; } @@ -298,12 +298,14 @@ struct ResolvedNodeData struct DiscoveredNodeData { CommonResolutionData resolutionData; - CommissionNodeData commissionData; + DnssdNodeData nodeData; + DiscoveryType nodeType; void Reset() { resolutionData.Reset(); - commissionData.Reset(); + nodeData.Reset(); + nodeType = DiscoveryType::kUnknown; } DiscoveredNodeData() { Reset(); } @@ -311,7 +313,7 @@ struct DiscoveredNodeData { ChipLogDetail(Discovery, "Discovered node:"); resolutionData.LogDetail(); - commissionData.LogDetail(); + nodeData.LogDetail(); } }; @@ -319,10 +321,10 @@ struct DiscoveredNodeData /// - Commissioners /// - Nodes in commissioning modes over IP (e.g. ethernet devices, devices already /// connected to thread/wifi or devices with a commissioning window open) -class CommissioningResolveDelegate +class DiscoverNodeDelegate { public: - virtual ~CommissioningResolveDelegate() = default; + virtual ~DiscoverNodeDelegate() = default; /// Called within the CHIP event loop once a node is discovered. /// diff --git a/src/lib/dnssd/platform/Dnssd.h b/src/lib/dnssd/platform/Dnssd.h index 778e9bc05f1d9c..fcbeabe1ce8d51 100644 --- a/src/lib/dnssd/platform/Dnssd.h +++ b/src/lib/dnssd/platform/Dnssd.h @@ -288,8 +288,7 @@ CHIP_ERROR ChipDnssdResolve(DnssdService * browseResult, chip::Inet::InterfaceId * @retval Error code The resolve fails. * */ -CHIP_ERROR ChipDnssdResolve(DnssdService * browseResult, chip::Inet::InterfaceId interface, - CommissioningResolveDelegate * delegate); +CHIP_ERROR ChipDnssdResolve(DnssdService * browseResult, chip::Inet::InterfaceId interface, DiscoverNodeDelegate * delegate); #endif // CHIP_DEVICE_LAYER_TARGET_DARWIN /** diff --git a/src/lib/dnssd/tests/TestActiveResolveAttempts.cpp b/src/lib/dnssd/tests/TestActiveResolveAttempts.cpp index 574268bb3c8e55..f4ef2f202c4def 100644 --- a/src/lib/dnssd/tests/TestActiveResolveAttempts.cpp +++ b/src/lib/dnssd/tests/TestActiveResolveAttempts.cpp @@ -126,7 +126,7 @@ void TestSingleBrowseAddRemove(nlTestSuite * inSuite, void * inContext) // once complete, nothing to schedule Dnssd::DiscoveredNodeData data; - data.commissionData.longDiscriminator = 1234; + data.nodeData.longDiscriminator = 1234; attempts.CompleteCommissionable(data); NL_TEST_ASSERT(inSuite, !attempts.GetTimeUntilNextExpectedResponse().HasValue()); NL_TEST_ASSERT(inSuite, !attempts.NextScheduled().HasValue()); @@ -375,7 +375,7 @@ void TestCombination(nlTestSuite * inSuite, void * inContext) attempts.Complete(MakePeerId(2)); attempts.Complete(MakePeerId(1)); Dnssd::DiscoveredNodeData data; - data.commissionData.longDiscriminator = 1234; + data.nodeData.longDiscriminator = 1234; attempts.CompleteCommissionable(data); NL_TEST_ASSERT(inSuite, !attempts.GetTimeUntilNextExpectedResponse().HasValue()); diff --git a/src/lib/dnssd/tests/TestIncrementalResolve.cpp b/src/lib/dnssd/tests/TestIncrementalResolve.cpp index 1cc3b714d28ae3..03b585c4ce14c3 100644 --- a/src/lib/dnssd/tests/TestIncrementalResolve.cpp +++ b/src/lib/dnssd/tests/TestIncrementalResolve.cpp @@ -163,7 +163,7 @@ void TestCreation(nlTestSuite * inSuite, void * inContext) IncrementalResolver resolver; NL_TEST_ASSERT(inSuite, !resolver.IsActive()); - NL_TEST_ASSERT(inSuite, !resolver.IsActiveCommissionParse()); + NL_TEST_ASSERT(inSuite, !resolver.IsActiveBrowseParse()); NL_TEST_ASSERT(inSuite, !resolver.IsActiveOperationalParse()); NL_TEST_ASSERT( inSuite, @@ -183,7 +183,7 @@ void TestInactiveResetOnInitError(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, resolver.InitializeParsing(kTestHostName.Serialized(), srvRecord) != CHIP_NO_ERROR); NL_TEST_ASSERT(inSuite, !resolver.IsActive()); - NL_TEST_ASSERT(inSuite, !resolver.IsActiveCommissionParse()); + NL_TEST_ASSERT(inSuite, !resolver.IsActiveBrowseParse()); NL_TEST_ASSERT(inSuite, !resolver.IsActiveOperationalParse()); } @@ -199,7 +199,7 @@ void TestStartOperational(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, resolver.InitializeParsing(kTestOperationalName.Serialized(), srvRecord) == CHIP_NO_ERROR); NL_TEST_ASSERT(inSuite, resolver.IsActive()); - NL_TEST_ASSERT(inSuite, !resolver.IsActiveCommissionParse()); + NL_TEST_ASSERT(inSuite, !resolver.IsActiveBrowseParse()); NL_TEST_ASSERT(inSuite, resolver.IsActiveOperationalParse()); NL_TEST_ASSERT(inSuite, resolver.GetMissingRequiredInformation().HasOnly(IncrementalResolver::RequiredInformationBitFlags::kIpAddress)); @@ -218,7 +218,7 @@ void TestStartCommissionable(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, resolver.InitializeParsing(kTestCommissionableNode.Serialized(), srvRecord) == CHIP_NO_ERROR); NL_TEST_ASSERT(inSuite, resolver.IsActive()); - NL_TEST_ASSERT(inSuite, resolver.IsActiveCommissionParse()); + NL_TEST_ASSERT(inSuite, resolver.IsActiveBrowseParse()); NL_TEST_ASSERT(inSuite, !resolver.IsActiveOperationalParse()); NL_TEST_ASSERT(inSuite, resolver.GetMissingRequiredInformation().HasOnly(IncrementalResolver::RequiredInformationBitFlags::kIpAddress)); @@ -237,7 +237,7 @@ void TestStartCommissioner(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, resolver.InitializeParsing(kTestCommissionerNode.Serialized(), srvRecord) == CHIP_NO_ERROR); NL_TEST_ASSERT(inSuite, resolver.IsActive()); - NL_TEST_ASSERT(inSuite, resolver.IsActiveCommissionParse()); + NL_TEST_ASSERT(inSuite, resolver.IsActiveBrowseParse()); NL_TEST_ASSERT(inSuite, !resolver.IsActiveOperationalParse()); NL_TEST_ASSERT(inSuite, resolver.GetMissingRequiredInformation().HasOnly(IncrementalResolver::RequiredInformationBitFlags::kIpAddress)); @@ -336,7 +336,7 @@ void TestParseCommissionable(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, resolver.InitializeParsing(kTestCommissionableNode.Serialized(), srvRecord) == CHIP_NO_ERROR); // once initialized, parsing should be ready however no IP address is available - NL_TEST_ASSERT(inSuite, resolver.IsActiveCommissionParse()); + NL_TEST_ASSERT(inSuite, resolver.IsActiveBrowseParse()); NL_TEST_ASSERT(inSuite, resolver.GetMissingRequiredInformation().HasOnly(IncrementalResolver::RequiredInformationBitFlags::kIpAddress)); NL_TEST_ASSERT(inSuite, resolver.GetTargetHostName() == kTestHostName.Serialized()); @@ -414,10 +414,10 @@ void TestParseCommissionable(nlTestSuite * inSuite, void * inContext) NL_TEST_ASSERT(inSuite, nodeData.resolutionData.ipAddress[1] == addr); // parsed txt data for discovered nodes - NL_TEST_ASSERT(inSuite, nodeData.commissionData.longDiscriminator == 22345); - NL_TEST_ASSERT(inSuite, nodeData.commissionData.vendorId == 321); - NL_TEST_ASSERT(inSuite, nodeData.commissionData.productId == 654); - NL_TEST_ASSERT(inSuite, strcmp(nodeData.commissionData.deviceName, "mytest") == 0); + NL_TEST_ASSERT(inSuite, nodeData.nodeData.longDiscriminator == 22345); + NL_TEST_ASSERT(inSuite, nodeData.nodeData.vendorId == 321); + NL_TEST_ASSERT(inSuite, nodeData.nodeData.productId == 654); + NL_TEST_ASSERT(inSuite, strcmp(nodeData.nodeData.deviceName, "mytest") == 0); } const nlTest sTests[] = { diff --git a/src/lib/dnssd/tests/TestTxtFields.cpp b/src/lib/dnssd/tests/TestTxtFields.cpp index 95f13b5d60c091..4593a4903b1a01 100644 --- a/src/lib/dnssd/tests/TestTxtFields.cpp +++ b/src/lib/dnssd/tests/TestTxtFields.cpp @@ -304,20 +304,20 @@ void TestGetCommissionerPasscode(nlTestSuite * inSuite, void * inContext) bool NodeDataIsEmpty(const DiscoveredNodeData & node) { - if (node.commissionData.longDiscriminator != 0 || node.commissionData.vendorId != 0 || node.commissionData.productId != 0 || - node.commissionData.commissioningMode != 0 || node.commissionData.deviceType != 0 || - node.commissionData.rotatingIdLen != 0 || node.commissionData.pairingHint != 0 || - node.resolutionData.mrpRetryIntervalIdle.HasValue() || node.resolutionData.mrpRetryIntervalActive.HasValue() || - node.resolutionData.mrpRetryActiveThreshold.HasValue() || node.resolutionData.isICDOperatingAsLIT.HasValue() || - node.resolutionData.supportsTcp || node.commissionData.commissionerPasscode != 0) + if (node.nodeData.longDiscriminator != 0 || node.nodeData.vendorId != 0 || node.nodeData.productId != 0 || + node.nodeData.commissioningMode != 0 || node.nodeData.deviceType != 0 || node.nodeData.rotatingIdLen != 0 || + node.nodeData.pairingHint != 0 || node.resolutionData.mrpRetryIntervalIdle.HasValue() || + node.resolutionData.mrpRetryIntervalActive.HasValue() || node.resolutionData.mrpRetryActiveThreshold.HasValue() || + node.resolutionData.isICDOperatingAsLIT.HasValue() || node.resolutionData.supportsTcp || + node.nodeData.commissionerPasscode != 0) { return false; } - if (strcmp(node.commissionData.deviceName, "") != 0 || strcmp(node.commissionData.pairingInstruction, "") != 0) + if (strcmp(node.nodeData.deviceName, "") != 0 || strcmp(node.nodeData.pairingInstruction, "") != 0) { return false; } - for (uint8_t id : node.commissionData.rotatingId) + for (uint8_t id : node.nodeData.rotatingId) { if (id != 0) { @@ -337,78 +337,78 @@ void TestFillDiscoveredNodeDataFromTxt(nlTestSuite * inSuite, void * inContext) // Long discriminator strcpy(key, "D"); strcpy(val, "840"); - FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.commissionData); - NL_TEST_ASSERT(inSuite, filled.commissionData.longDiscriminator == 840); - filled.commissionData.longDiscriminator = 0; + FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.nodeData); + NL_TEST_ASSERT(inSuite, filled.nodeData.longDiscriminator == 840); + filled.nodeData.longDiscriminator = 0; NL_TEST_ASSERT(inSuite, NodeDataIsEmpty(filled)); // vendor and product strcpy(key, "VP"); strcpy(val, "123+456"); - FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.commissionData); - NL_TEST_ASSERT(inSuite, filled.commissionData.vendorId == 123); - NL_TEST_ASSERT(inSuite, filled.commissionData.productId == 456); - filled.commissionData.vendorId = 0; - filled.commissionData.productId = 0; + FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.nodeData); + NL_TEST_ASSERT(inSuite, filled.nodeData.vendorId == 123); + NL_TEST_ASSERT(inSuite, filled.nodeData.productId == 456); + filled.nodeData.vendorId = 0; + filled.nodeData.productId = 0; NL_TEST_ASSERT(inSuite, NodeDataIsEmpty(filled)); // Commissioning mode strcpy(key, "CM"); strcpy(val, "1"); - FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.commissionData); - NL_TEST_ASSERT(inSuite, filled.commissionData.commissioningMode == 1); - filled.commissionData.commissioningMode = 0; + FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.nodeData); + NL_TEST_ASSERT(inSuite, filled.nodeData.commissioningMode == 1); + filled.nodeData.commissioningMode = 0; NL_TEST_ASSERT(inSuite, NodeDataIsEmpty(filled)); // Commissioning mode strcpy(key, "CP"); strcpy(val, "1"); - FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.commissionData); - NL_TEST_ASSERT(inSuite, filled.commissionData.commissionerPasscode == 1); - filled.commissionData.commissionerPasscode = 0; + FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.nodeData); + NL_TEST_ASSERT(inSuite, filled.nodeData.commissionerPasscode == 1); + filled.nodeData.commissionerPasscode = 0; NL_TEST_ASSERT(inSuite, NodeDataIsEmpty(filled)); // Device type strcpy(key, "DT"); strcpy(val, "1"); - FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.commissionData); - NL_TEST_ASSERT(inSuite, filled.commissionData.deviceType == 1); - filled.commissionData.deviceType = 0; + FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.nodeData); + NL_TEST_ASSERT(inSuite, filled.nodeData.deviceType == 1); + filled.nodeData.deviceType = 0; NL_TEST_ASSERT(inSuite, NodeDataIsEmpty(filled)); // Device name strcpy(key, "DN"); strcpy(val, "abc"); - FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.commissionData); - NL_TEST_ASSERT(inSuite, strcmp(filled.commissionData.deviceName, "abc") == 0); - memset(filled.commissionData.deviceName, 0, sizeof(filled.commissionData.deviceName)); + FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.nodeData); + NL_TEST_ASSERT(inSuite, strcmp(filled.nodeData.deviceName, "abc") == 0); + memset(filled.nodeData.deviceName, 0, sizeof(filled.nodeData.deviceName)); NL_TEST_ASSERT(inSuite, NodeDataIsEmpty(filled)); // Rotating device id strcpy(key, "RI"); strcpy(val, "1A2B"); - FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.commissionData); - NL_TEST_ASSERT(inSuite, filled.commissionData.rotatingId[0] == 0x1A); - NL_TEST_ASSERT(inSuite, filled.commissionData.rotatingId[1] == 0x2B); - NL_TEST_ASSERT(inSuite, filled.commissionData.rotatingIdLen == 2); - filled.commissionData.rotatingIdLen = 0; - memset(filled.commissionData.rotatingId, 0, sizeof(filled.commissionData.rotatingId)); + FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.nodeData); + NL_TEST_ASSERT(inSuite, filled.nodeData.rotatingId[0] == 0x1A); + NL_TEST_ASSERT(inSuite, filled.nodeData.rotatingId[1] == 0x2B); + NL_TEST_ASSERT(inSuite, filled.nodeData.rotatingIdLen == 2); + filled.nodeData.rotatingIdLen = 0; + memset(filled.nodeData.rotatingId, 0, sizeof(filled.nodeData.rotatingId)); NL_TEST_ASSERT(inSuite, NodeDataIsEmpty(filled)); // Pairing instruction strcpy(key, "PI"); strcpy(val, "hint"); - FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.commissionData); - NL_TEST_ASSERT(inSuite, strcmp(filled.commissionData.pairingInstruction, "hint") == 0); - memset(filled.commissionData.pairingInstruction, 0, sizeof(filled.commissionData.pairingInstruction)); + FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.nodeData); + NL_TEST_ASSERT(inSuite, strcmp(filled.nodeData.pairingInstruction, "hint") == 0); + memset(filled.nodeData.pairingInstruction, 0, sizeof(filled.nodeData.pairingInstruction)); NL_TEST_ASSERT(inSuite, NodeDataIsEmpty(filled)); // Pairing hint strcpy(key, "PH"); strcpy(val, "1"); - FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.commissionData); - NL_TEST_ASSERT(inSuite, filled.commissionData.pairingHint == 1); - filled.commissionData.pairingHint = 0; + FillNodeDataFromTxt(GetSpan(key), GetSpan(val), filled.nodeData); + NL_TEST_ASSERT(inSuite, filled.nodeData.pairingHint == 1); + filled.nodeData.pairingHint = 0; NL_TEST_ASSERT(inSuite, NodeDataIsEmpty(filled)); } diff --git a/src/lib/shell/commands/Dns.cpp b/src/lib/shell/commands/Dns.cpp index 6abb2dc0393fec..14955335daaad0 100644 --- a/src/lib/shell/commands/Dns.cpp +++ b/src/lib/shell/commands/Dns.cpp @@ -40,7 +40,7 @@ Shell::Engine sShellDnsBrowseSubcommands; Shell::Engine sShellDnsSubcommands; Dnssd::ResolverProxy sResolverProxy; -class DnsShellResolverDelegate : public Dnssd::CommissioningResolveDelegate, public AddressResolve::NodeListener +class DnsShellResolverDelegate : public Dnssd::DiscoverNodeDelegate, public AddressResolve::NodeListener { public: DnsShellResolverDelegate() { mSelfHandle.SetListener(this); } @@ -92,20 +92,20 @@ class DnsShellResolverDelegate : public Dnssd::CommissioningResolveDelegate, pub } char rotatingId[Dnssd::kMaxRotatingIdLen * 2 + 1]; - Encoding::BytesToUppercaseHexString(nodeData.commissionData.rotatingId, nodeData.commissionData.rotatingIdLen, rotatingId, + Encoding::BytesToUppercaseHexString(nodeData.nodeData.rotatingId, nodeData.nodeData.rotatingIdLen, rotatingId, sizeof(rotatingId)); streamer_printf(streamer_get(), "DNS browse succeeded: \r\n"); + streamer_printf(streamer_get(), " Node Type: %u\r\n", nodeData.nodeType); streamer_printf(streamer_get(), " Hostname: %s\r\n", nodeData.resolutionData.hostName); - streamer_printf(streamer_get(), " Vendor ID: %u\r\n", nodeData.commissionData.vendorId); - streamer_printf(streamer_get(), " Product ID: %u\r\n", nodeData.commissionData.productId); - streamer_printf(streamer_get(), " Long discriminator: %u\r\n", nodeData.commissionData.longDiscriminator); - streamer_printf(streamer_get(), " Device type: %u\r\n", nodeData.commissionData.deviceType); - streamer_printf(streamer_get(), " Device name: %s\n", nodeData.commissionData.deviceName); - streamer_printf(streamer_get(), " Commissioning mode: %d\r\n", - static_cast(nodeData.commissionData.commissioningMode)); - streamer_printf(streamer_get(), " Pairing hint: %u\r\n", nodeData.commissionData.pairingHint); - streamer_printf(streamer_get(), " Pairing instruction: %s\r\n", nodeData.commissionData.pairingInstruction); + streamer_printf(streamer_get(), " Vendor ID: %u\r\n", nodeData.nodeData.vendorId); + streamer_printf(streamer_get(), " Product ID: %u\r\n", nodeData.nodeData.productId); + streamer_printf(streamer_get(), " Long discriminator: %u\r\n", nodeData.nodeData.longDiscriminator); + streamer_printf(streamer_get(), " Device type: %u\r\n", nodeData.nodeData.deviceType); + streamer_printf(streamer_get(), " Device name: %s\n", nodeData.nodeData.deviceName); + streamer_printf(streamer_get(), " Commissioning mode: %d\r\n", static_cast(nodeData.nodeData.commissioningMode)); + streamer_printf(streamer_get(), " Pairing hint: %u\r\n", nodeData.nodeData.pairingHint); + streamer_printf(streamer_get(), " Pairing instruction: %s\r\n", nodeData.nodeData.pairingInstruction); streamer_printf(streamer_get(), " Rotating ID %s\r\n", rotatingId); auto retryInterval = nodeData.resolutionData.GetMrpRetryIntervalIdle(); @@ -237,7 +237,7 @@ CHIP_ERROR BrowseHandler(int argc, char ** argv) } sResolverProxy.Init(DeviceLayer::UDPEndPointManager()); - sResolverProxy.SetCommissioningDelegate(&sDnsShellResolverDelegate); + sResolverProxy.SetDiscoveryDelegate(&sDnsShellResolverDelegate); return sShellDnsBrowseSubcommands.ExecCommand(argc, argv); } diff --git a/src/platform/Darwin/DnssdContexts.cpp b/src/platform/Darwin/DnssdContexts.cpp index 27a9d8158c0d20..46c7bb34fc4365 100644 --- a/src/platform/Darwin/DnssdContexts.cpp +++ b/src/platform/Darwin/DnssdContexts.cpp @@ -478,7 +478,7 @@ ResolveContext::ResolveContext(void * cbContext, DnssdResolveCallback cb, chip:: consumerCounter = std::move(consumerCounterToUse); } -ResolveContext::ResolveContext(CommissioningResolveDelegate * delegate, chip::Inet::IPAddressType cbAddressType, +ResolveContext::ResolveContext(DiscoverNodeDelegate * delegate, chip::Inet::IPAddressType cbAddressType, const char * instanceNameToResolve, std::shared_ptr && consumerCounterToUse) : browseThatCausedResolve(nullptr) { @@ -608,7 +608,7 @@ bool ResolveContext::TryReportingResultsForInterfaceIndex(uint32_t interfaceInde auto addresses = Span(ips.data(), ips.size()); if (nullptr == callback) { - auto delegate = static_cast(context); + auto delegate = static_cast(context); DiscoveredNodeData nodeData; service.ToDiscoveredNodeData(addresses, nodeData); delegate->OnNodeDiscovered(nodeData); diff --git a/src/platform/Darwin/DnssdImpl.cpp b/src/platform/Darwin/DnssdImpl.cpp index e9314f7fa76c0d..a9dccf21ef47f5 100644 --- a/src/platform/Darwin/DnssdImpl.cpp +++ b/src/platform/Darwin/DnssdImpl.cpp @@ -408,7 +408,7 @@ static CHIP_ERROR Resolve(void * context, DnssdResolveCallback callback, uint32_ return Resolve(sdCtx, interfaceId, addressType, type, name, domain); } -static CHIP_ERROR Resolve(CommissioningResolveDelegate * delegate, uint32_t interfaceId, chip::Inet::IPAddressType addressType, +static CHIP_ERROR Resolve(DiscoverNodeDelegate * delegate, uint32_t interfaceId, chip::Inet::IPAddressType addressType, const char * type, const char * name) { auto counterHolder = GetCounterHolder(name); @@ -570,7 +570,7 @@ CHIP_ERROR ChipDnssdResolve(DnssdService * service, chip::Inet::InterfaceId inte return Resolve(context, callback, interfaceId, service->mAddressType, regtype.c_str(), service->mName, domain); } -CHIP_ERROR ChipDnssdResolve(DnssdService * service, chip::Inet::InterfaceId interface, CommissioningResolveDelegate * delegate) +CHIP_ERROR ChipDnssdResolve(DnssdService * service, chip::Inet::InterfaceId interface, DiscoverNodeDelegate * delegate) { VerifyOrReturnError(service != nullptr, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError(IsSupportedProtocol(service->mProtocol), CHIP_ERROR_INVALID_ARGUMENT); diff --git a/src/platform/Darwin/DnssdImpl.h b/src/platform/Darwin/DnssdImpl.h index 351926a7705dde..de5419b0bf7907 100644 --- a/src/platform/Darwin/DnssdImpl.h +++ b/src/platform/Darwin/DnssdImpl.h @@ -274,8 +274,8 @@ struct ResolveContext : public GenericContext ResolveContext(void * cbContext, DnssdResolveCallback cb, chip::Inet::IPAddressType cbAddressType, const char * instanceNameToResolve, BrowseContext * browseCausingResolve, std::shared_ptr && consumerCounterToUse); - ResolveContext(CommissioningResolveDelegate * delegate, chip::Inet::IPAddressType cbAddressType, - const char * instanceNameToResolve, std::shared_ptr && consumerCounterToUse); + ResolveContext(DiscoverNodeDelegate * delegate, chip::Inet::IPAddressType cbAddressType, const char * instanceNameToResolve, + std::shared_ptr && consumerCounterToUse); virtual ~ResolveContext(); void DispatchFailure(const char * errorStr, CHIP_ERROR err) override; diff --git a/src/platform/nxp/k32w/k32w0/BUILD.gn b/src/platform/nxp/k32w/k32w0/BUILD.gn index 9d1ef45db9fdb5..c8aea6ee945f22 100644 --- a/src/platform/nxp/k32w/k32w0/BUILD.gn +++ b/src/platform/nxp/k32w/k32w0/BUILD.gn @@ -108,7 +108,10 @@ static_library("nxp_platform") { deps = [ "${chip_root}/src/platform/logging:headers" ] - public_deps = [ "${chip_root}/src/platform:platform_base" ] + public_deps = [ + "${chip_root}/src/app:test-event-trigger", + "${chip_root}/src/platform:platform_base", + ] if (chip_crypto == "platform") { if (chip_crypto_flavor == "tinycrypt") { diff --git a/src/platform/nxp/k32w/k32w1/BUILD.gn b/src/platform/nxp/k32w/k32w1/BUILD.gn index 30352203eebaaa..34dc5ca1b4e38a 100644 --- a/src/platform/nxp/k32w/k32w1/BUILD.gn +++ b/src/platform/nxp/k32w/k32w1/BUILD.gn @@ -77,7 +77,10 @@ static_library("nxp_platform") { "${chip_root}/src/platform/nxp/k32w/k32w1/SMU2Manager.h", ] - public_deps = [ "${chip_root}/src/platform:platform_base" ] + public_deps = [ + "${chip_root}/src/app:test-event-trigger", + "${chip_root}/src/platform:platform_base", + ] if (chip_with_low_power != 0) { sources += [ "LowPowerHooks.cpp" ] diff --git a/src/platform/silabs/ConfigurationManagerImpl.cpp b/src/platform/silabs/ConfigurationManagerImpl.cpp index 8412075de3a914..5ebf349c15484b 100644 --- a/src/platform/silabs/ConfigurationManagerImpl.cpp +++ b/src/platform/silabs/ConfigurationManagerImpl.cpp @@ -255,7 +255,9 @@ CHIP_ERROR ConfigurationManagerImpl::WriteConfigValueBin(Key key, const uint8_t void ConfigurationManagerImpl::RunConfigUnitTest(void) { +#if CONFIG_BUILD_FOR_HOST_UNIT_TEST SilabsConfig::RunConfigUnitTest(); +#endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST } void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) diff --git a/src/platform/silabs/SilabsConfig.cpp b/src/platform/silabs/SilabsConfig.cpp index 6c362d41c2c330..356aa4c39b1703 100644 --- a/src/platform/silabs/SilabsConfig.cpp +++ b/src/platform/silabs/SilabsConfig.cpp @@ -552,11 +552,13 @@ bool SilabsConfig::ValidConfigKey(Key key) return false; } +#if CONFIG_BUILD_FOR_HOST_UNIT_TEST void SilabsConfig::RunConfigUnitTest() { // Run common unit test. ::chip::DeviceLayer::Internal::RunConfigUnitTest(); } +#endif // CONFIG_BUILD_FOR_HOST_UNIT_TEST void SilabsConfig::RepackNvm3Flash(void) { diff --git a/src/protocols/user_directed_commissioning/UserDirectedCommissioningServer.cpp b/src/protocols/user_directed_commissioning/UserDirectedCommissioningServer.cpp index 9e787124507536..f63a10c94965f5 100644 --- a/src/protocols/user_directed_commissioning/UserDirectedCommissioningServer.cpp +++ b/src/protocols/user_directed_commissioning/UserDirectedCommissioningServer.cpp @@ -405,17 +405,16 @@ void UserDirectedCommissioningServer::OnCommissionableNodeFound(const Dnssd::Dis if (nodeData.resolutionData.numIPs == 0) { ChipLogError(AppServer, "OnCommissionableNodeFound no IP addresses returned for instance name=%s", - nodeData.commissionData.instanceName); + nodeData.nodeData.instanceName); return; } if (nodeData.resolutionData.port == 0) { - ChipLogError(AppServer, "OnCommissionableNodeFound no port returned for instance name=%s", - nodeData.commissionData.instanceName); + ChipLogError(AppServer, "OnCommissionableNodeFound no port returned for instance name=%s", nodeData.nodeData.instanceName); return; } - UDCClientState * client = mUdcClients.FindUDCClientState(nodeData.commissionData.instanceName); + UDCClientState * client = mUdcClients.FindUDCClientState(nodeData.nodeData.instanceName); if (client != nullptr && client->GetUDCClientProcessingState() == UDCClientProcessingState::kDiscoveringNode) { ChipLogDetail(AppServer, "OnCommissionableNodeFound instance: name=%s old_state=%d new_state=%d", client->GetInstanceName(), @@ -458,17 +457,17 @@ void UserDirectedCommissioningServer::OnCommissionableNodeFound(const Dnssd::Dis if (!foundV6) { ChipLogError(AppServer, "OnCommissionableNodeFound no v6 returned for instance name=%s", - nodeData.commissionData.instanceName); + nodeData.nodeData.instanceName); client->SetPeerAddress( chip::Transport::PeerAddress::UDP(nodeData.resolutionData.ipAddress[0], nodeData.resolutionData.port)); } #endif // INET_CONFIG_ENABLE_IPV4 - client->SetDeviceName(nodeData.commissionData.deviceName); - client->SetLongDiscriminator(nodeData.commissionData.longDiscriminator); - client->SetVendorId(nodeData.commissionData.vendorId); - client->SetProductId(nodeData.commissionData.productId); - client->SetRotatingId(nodeData.commissionData.rotatingId, nodeData.commissionData.rotatingIdLen); + client->SetDeviceName(nodeData.nodeData.deviceName); + client->SetLongDiscriminator(nodeData.nodeData.longDiscriminator); + client->SetVendorId(nodeData.nodeData.vendorId); + client->SetProductId(nodeData.nodeData.productId); + client->SetRotatingId(nodeData.nodeData.rotatingId, nodeData.nodeData.rotatingIdLen); // Call the registered mUserConfirmationProvider, if any. if (mUserConfirmationProvider != nullptr) diff --git a/src/protocols/user_directed_commissioning/tests/TestUdcMessages.cpp b/src/protocols/user_directed_commissioning/tests/TestUdcMessages.cpp index f7e7c2ab4a65d9..9c171b5efad5b8 100644 --- a/src/protocols/user_directed_commissioning/tests/TestUdcMessages.cpp +++ b/src/protocols/user_directed_commissioning/tests/TestUdcMessages.cpp @@ -86,15 +86,15 @@ void TestUDCServerUserConfirmationProvider(nlTestSuite * inSuite, void * inConte nodeData1.resolutionData.port = 5540; nodeData1.resolutionData.ipAddress[0] = address; nodeData1.resolutionData.numIPs = 1; - Platform::CopyString(nodeData1.commissionData.instanceName, instanceName1); + Platform::CopyString(nodeData1.nodeData.instanceName, instanceName1); Dnssd::DiscoveredNodeData nodeData2; - nodeData2.resolutionData.port = 5540; - nodeData2.resolutionData.ipAddress[0] = address; - nodeData2.resolutionData.numIPs = 1; - nodeData2.commissionData.longDiscriminator = disc2; - Platform::CopyString(nodeData2.commissionData.instanceName, instanceName2); - Platform::CopyString(nodeData2.commissionData.deviceName, deviceName2); + nodeData2.resolutionData.port = 5540; + nodeData2.resolutionData.ipAddress[0] = address; + nodeData2.resolutionData.numIPs = 1; + nodeData2.nodeData.longDiscriminator = disc2; + Platform::CopyString(nodeData2.nodeData.instanceName, instanceName2); + Platform::CopyString(nodeData2.nodeData.deviceName, deviceName2); // test empty UserConfirmationProvider udcServer.OnCommissionableNodeFound(nodeData2); diff --git a/src/python_testing/TC_ICDManagementCluster.py b/src/python_testing/TC_ICDManagementCluster.py new file mode 100644 index 00000000000000..a5b769ba30272c --- /dev/null +++ b/src/python_testing/TC_ICDManagementCluster.py @@ -0,0 +1,63 @@ +# +# Copyright (c) 2024 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +import chip.clusters as Clusters +from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main +from mobly import asserts + +# Assumes `--enable-key 000102030405060708090a0b0c0d0e0f` on Linux app command line, or a DUT +# that has that Enable Key +kTestEventTriggerKey = bytes([b for b in range(16)]) + +kAddActiveModeReq = 0x0046000000000001 +kRemoveActiveModeReq = 0x0046000000000002 + + +class TestICDManagementCluster(MatterBaseTest): + @async_test_body + async def test_active_mode_test_event_trigger(self): + dev_ctrl = self.default_controller + is_test_event_triggers_enabled = await self.read_single_attribute( + dev_ctrl, + self.dut_node_id, + endpoint=0, + attribute=Clusters.GeneralDiagnostics.Attributes.TestEventTriggersEnabled + ) + asserts.assert_true(is_test_event_triggers_enabled, + "This test expects Test Event Triggers are Enabled") + + # No response to command --> Success yields "None". + asserts.assert_is_none( + await dev_ctrl.SendCommand( + self.dut_node_id, + endpoint=0, + payload=Clusters.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=kTestEventTriggerKey, + eventTrigger=kAddActiveModeReq) + ) + ) + + asserts.assert_is_none( + await dev_ctrl.SendCommand( + self.dut_node_id, + endpoint=0, + payload=Clusters.GeneralDiagnostics.Commands.TestEventTrigger(enableKey=kTestEventTriggerKey, + eventTrigger=kRemoveActiveModeReq) + ) + ) + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index 53f098de9fdc7d..0dbd0dd89fa90d 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit 53f098de9fdc7db248a72eabbe07d8ce4876daab +Subproject commit 0dbd0dd89fa90dc6e0d1d2636563ea980c010c19