diff --git a/connectedhomeip/connectedhomeip b/connectedhomeip/connectedhomeip index 903e149bd..f207bc656 160000 --- a/connectedhomeip/connectedhomeip +++ b/connectedhomeip/connectedhomeip @@ -1 +1 @@ -Subproject commit 903e149bd636a5cd1a8821864cb073b4f7a9d3d8 +Subproject commit f207bc65639cdd9deb27f4f029d991fb3bc8ba11 diff --git a/examples/light/main/CMakeLists.txt b/examples/light/main/CMakeLists.txt index 857943152..3b74c11a8 100644 --- a/examples/light/main/CMakeLists.txt +++ b/examples/light/main/CMakeLists.txt @@ -1,11 +1,14 @@ set(SRC_DIRS_LIST "${CMAKE_CURRENT_LIST_DIR}" - "${CMAKE_CURRENT_LIST_DIR}/gen" + "${CMAKE_CURRENT_LIST_DIR}/zap-generated" + "${MATTER_SDK_PATH}/src/app/common/gen/attributes" "${MATTER_SDK_PATH}/src/app/server" "${MATTER_SDK_PATH}/src/app/util" "${MATTER_SDK_PATH}/src/app/reporting" "${MATTER_SDK_PATH}/src/app/clusters/basic" + "${MATTER_SDK_PATH}/src/app/clusters/administrator-commissioning-server" "${MATTER_SDK_PATH}/src/app/clusters/general-commissioning-server" "${MATTER_SDK_PATH}/src/app/clusters/network-commissioning" + "${MATTER_SDK_PATH}/src/app/clusters/wifi_network_diagnostics_server" "${MATTER_SDK_PATH}/src/app/clusters/on-off-server" "${MATTER_SDK_PATH}/src/app/clusters/operational-credentials-server" "${MATTER_SDK_PATH}/src/app/clusters/level-control" diff --git a/examples/light/main/light.zap b/examples/light/main/light.zap index 0b6391524..c43219a36 100644 --- a/examples/light/main/light.zap +++ b/examples/light/main/light.zap @@ -1,5 +1,5 @@ { - "featureLevel": 39, + "featureLevel": 45, "creator": "zap", "keyValuePairs": [ { @@ -18,13 +18,13 @@ "package": [ { "pathRelativity": "relativeToZap", - "path": "../../../../connectedhomeip/src/app/zap-templates/zcl/zcl.json", + "path": "../../../connectedhomeip/connectedhomeip/src/app/zap-templates/zcl/zcl.json", "version": "ZCL Test Data", "type": "zcl-properties" }, { "pathRelativity": "relativeToZap", - "path": "../../../../connectedhomeip/src/app/zap-templates/app-templates.json", + "path": "../../../connectedhomeip/connectedhomeip/src/app/zap-templates/app-templates.json", "version": "chip-v1", "type": "gen-templates-json" } @@ -63,7 +63,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -113,7 +113,7 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -139,7 +139,7 @@ "commands": [], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -460,7 +460,7 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -511,7 +511,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -562,7 +562,7 @@ ], "attributes": [ { - "name": "FabricId", + "name": "Breadcrumb", "code": 0, "mfgCode": null, "side": "server", @@ -570,14 +570,14 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "o", + "defaultValue": "0x0000000000000000", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "Breadcrumb", + "name": "BasicCommissioningInfoList", "code": 1, "mfgCode": null, "side": "server", @@ -592,7 +592,7 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -691,7 +691,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -782,7 +782,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -805,10 +805,19 @@ "define": "WIFI_NETWORK_DIAGNOSTICS_CLUSTER", "side": "client", "enabled": 0, - "commands": [], + "commands": [ + { + "name": "ResetCounts", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -909,7 +918,84 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "AdministratorCommissioning", + "code": 60, + "mfgCode": null, + "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "OpenCommissioningWindow", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "OpenBasicCommissioningWindow", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RevokeCommissioning", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "AdministratorCommissioning", + "code": 60, + "mfgCode": null, + "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -933,14 +1019,6 @@ "side": "client", "enabled": 0, "commands": [ - { - "name": "SetFabric", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, { "name": "OpCSRRequest", "code": 4, @@ -950,13 +1028,21 @@ "outgoing": 1 }, { - "name": "AddOpCert", + "name": "AddNOC", "code": 6, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 }, + { + "name": "UpdateNOC", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, { "name": "UpdateFabricLabel", "code": 9, @@ -974,24 +1060,16 @@ "outgoing": 1 }, { - "name": "RemoveAllFabrics", + "name": "AddTrustedRootCertificate", "code": 11, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 }, - { - "name": "AddTrustedRootCertificate", - "code": 161, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, { "name": "RemoveTrustedRootCertificate", - "code": 162, + "code": 12, "mfgCode": null, "source": "client", "incoming": 1, @@ -1000,7 +1078,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -1024,14 +1102,6 @@ "side": "server", "enabled": 1, "commands": [ - { - "name": "SetFabricResponse", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, { "name": "OpCSRResponse", "code": 5, @@ -1041,7 +1111,7 @@ "outgoing": 1 }, { - "name": "OpCertResponse", + "name": "NOCResponse", "code": 8, "mfgCode": null, "source": "server", @@ -1066,7 +1136,37 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "SupportedFabrics", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CommissionedFabrics", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -1125,7 +1225,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -1175,7 +1275,7 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -1192,7 +1292,7 @@ ] }, { - "name": "On/off", + "name": "On/Off", "code": 6, "mfgCode": null, "define": "ON_OFF_CLUSTER", @@ -1250,7 +1350,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -1267,7 +1367,7 @@ ] }, { - "name": "On/off", + "name": "On/Off", "code": 6, "mfgCode": null, "define": "ON_OFF_CLUSTER", @@ -1276,7 +1376,7 @@ "commands": [], "attributes": [ { - "name": "on/off", + "name": "OnOff", "code": 0, "mfgCode": null, "side": "server", @@ -1291,7 +1391,7 @@ "reportableChange": 0 }, { - "name": "global scene control", + "name": "GlobalSceneControl", "code": 16384, "mfgCode": null, "side": "server", @@ -1306,7 +1406,7 @@ "reportableChange": 0 }, { - "name": "on time", + "name": "OnTime", "code": 16385, "mfgCode": null, "side": "server", @@ -1321,7 +1421,7 @@ "reportableChange": 0 }, { - "name": "off wait time", + "name": "OffWaitTime", "code": 16386, "mfgCode": null, "side": "server", @@ -1336,7 +1436,7 @@ "reportableChange": 0 }, { - "name": "start up on off", + "name": "StartUpOnOff", "code": 16387, "mfgCode": null, "side": "server", @@ -1351,7 +1451,7 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -1442,7 +1542,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -1528,7 +1628,7 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -1554,7 +1654,7 @@ "commands": [], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -1770,7 +1870,7 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -1949,7 +2049,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -2320,7 +2420,7 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", diff --git a/examples/light/main/gen/CHIPClientCallbacks.cpp b/examples/light/main/zap-generated/CHIPClientCallbacks.cpp similarity index 100% rename from examples/light/main/gen/CHIPClientCallbacks.cpp rename to examples/light/main/zap-generated/CHIPClientCallbacks.cpp diff --git a/examples/light/main/gen/CHIPClientCallbacks.h b/examples/light/main/zap-generated/CHIPClientCallbacks.h similarity index 100% rename from examples/light/main/gen/CHIPClientCallbacks.h rename to examples/light/main/zap-generated/CHIPClientCallbacks.h diff --git a/examples/light/main/gen/CHIPClusters.h b/examples/light/main/zap-generated/CHIPClusters.cpp similarity index 100% rename from examples/light/main/gen/CHIPClusters.h rename to examples/light/main/zap-generated/CHIPClusters.cpp diff --git a/examples/rainmaker_light/main/gen/CHIPClusters.h b/examples/light/main/zap-generated/CHIPClusters.h similarity index 100% rename from examples/rainmaker_light/main/gen/CHIPClusters.h rename to examples/light/main/zap-generated/CHIPClusters.h diff --git a/examples/rainmaker_light/main/gen/IMClusterCommandHandler.cpp b/examples/light/main/zap-generated/IMClusterCommandHandler.cpp similarity index 82% rename from examples/rainmaker_light/main/gen/IMClusterCommandHandler.cpp rename to examples/light/main/zap-generated/IMClusterCommandHandler.cpp index e468b570d..820e047c8 100644 --- a/examples/rainmaker_light/main/gen/IMClusterCommandHandler.cpp +++ b/examples/light/main/zap-generated/IMClusterCommandHandler.cpp @@ -34,13 +34,215 @@ namespace chip { namespace app { +namespace { +void ReportCommandUnsupported(Command * aCommandObj, EndpointId aEndpointId, ClusterId aClusterId, CommandId aCommandId) +{ + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + aClusterId, aCommandId, (CommandPathFlags::kEndpointIdValid) }; + aCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandId), + ChipLogValueMEI(aClusterId)); +} +} // anonymous namespace + // Cluster specific command parsing namespace clusters { +namespace AdministratorCommissioning { + +void DispatchServerCommand(CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::AdministratorCommissioning::Commands::Ids::OpenBasicCommissioningWindow: { + expectArgumentCount = 1; + uint16_t CommissioningTimeout; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(CommissioningTimeout); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + wasHandled = emberAfAdministratorCommissioningClusterOpenBasicCommissioningWindowCallback(aEndpointId, apCommandObj, + CommissioningTimeout); + } + break; + } + case Clusters::AdministratorCommissioning::Commands::Ids::OpenCommissioningWindow: { + expectArgumentCount = 6; + uint16_t CommissioningTimeout; + chip::ByteSpan PAKEVerifier; + uint16_t Discriminator; + uint32_t Iterations; + chip::ByteSpan Salt; + uint16_t PasscodeID; + bool argExists[6]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 6) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(CommissioningTimeout); + break; + case 1: + TLVUnpackError = aDataTlv.Get(PAKEVerifier); + break; + case 2: + TLVUnpackError = aDataTlv.Get(Discriminator); + break; + case 3: + TLVUnpackError = aDataTlv.Get(Iterations); + break; + case 4: + TLVUnpackError = aDataTlv.Get(Salt); + break; + case 5: + TLVUnpackError = aDataTlv.Get(PasscodeID); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 6 == validArgumentCount) + { + wasHandled = emberAfAdministratorCommissioningClusterOpenCommissioningWindowCallback( + aEndpointId, apCommandObj, CommissioningTimeout, PAKEVerifier, Discriminator, Iterations, Salt, PasscodeID); + } + break; + } + case Clusters::AdministratorCommissioning::Commands::Ids::RevokeCommissioning: { + + wasHandled = emberAfAdministratorCommissioningClusterRevokeCommissioningCallback(aEndpointId, apCommandObj); + break; + } + default: { + // Unrecognized command ID, error status will apply. + ReportCommandUnsupported(apCommandObj, aEndpointId, Clusters::AdministratorCommissioning::Id, aCommandId); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::AdministratorCommissioning::Id, aCommandId, + (CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); + } +} + +} // namespace AdministratorCommissioning + namespace ColorControl { -void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +void DispatchServerCommand(CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) { // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. @@ -133,9 +335,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 7 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterColorLoopSetCallback(apCommandObj, updateFlags, action, direction, time, - startHue, optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterColorLoopSetCallback( + aEndpointId, apCommandObj, updateFlags, action, direction, time, startHue, optionsMask, optionsOverride); } break; } @@ -205,9 +406,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfColorControlClusterEnhancedMoveHueCallback(apCommandObj, moveMode, rate, optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterEnhancedMoveHueCallback(aEndpointId, apCommandObj, moveMode, rate, + optionsMask, optionsOverride); } break; } @@ -281,8 +481,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterEnhancedMoveToHueCallback(apCommandObj, enhancedHue, direction, + wasHandled = emberAfColorControlClusterEnhancedMoveToHueCallback(aEndpointId, apCommandObj, enhancedHue, direction, transitionTime, optionsMask, optionsOverride); } break; @@ -357,9 +556,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. wasHandled = emberAfColorControlClusterEnhancedMoveToHueAndSaturationCallback( - apCommandObj, enhancedHue, saturation, transitionTime, optionsMask, optionsOverride); + aEndpointId, apCommandObj, enhancedHue, saturation, transitionTime, optionsMask, optionsOverride); } break; } @@ -433,9 +631,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterEnhancedStepHueCallback(apCommandObj, stepMode, stepSize, transitionTime, - optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterEnhancedStepHueCallback(aEndpointId, apCommandObj, stepMode, stepSize, + transitionTime, optionsMask, optionsOverride); } break; } @@ -505,8 +702,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterMoveColorCallback(apCommandObj, rateX, rateY, optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterMoveColorCallback(aEndpointId, apCommandObj, rateX, rateY, optionsMask, + optionsOverride); } break; } @@ -584,9 +781,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 6 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. wasHandled = emberAfColorControlClusterMoveColorTemperatureCallback( - apCommandObj, moveMode, rate, colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + aEndpointId, apCommandObj, moveMode, rate, colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, + optionsOverride); } break; } @@ -656,8 +853,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterMoveHueCallback(apCommandObj, moveMode, rate, optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterMoveHueCallback(aEndpointId, apCommandObj, moveMode, rate, optionsMask, + optionsOverride); } break; } @@ -727,9 +924,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfColorControlClusterMoveSaturationCallback(apCommandObj, moveMode, rate, optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterMoveSaturationCallback(aEndpointId, apCommandObj, moveMode, rate, + optionsMask, optionsOverride); } break; } @@ -803,9 +999,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterMoveToColorCallback(apCommandObj, colorX, colorY, transitionTime, - optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterMoveToColorCallback(aEndpointId, apCommandObj, colorX, colorY, + transitionTime, optionsMask, optionsOverride); } break; } @@ -875,8 +1070,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterMoveToColorTemperatureCallback(apCommandObj, colorTemperature, + wasHandled = emberAfColorControlClusterMoveToColorTemperatureCallback(aEndpointId, apCommandObj, colorTemperature, transitionTime, optionsMask, optionsOverride); } break; @@ -951,9 +1145,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterMoveToHueCallback(apCommandObj, hue, direction, transitionTime, optionsMask, - optionsOverride); + wasHandled = emberAfColorControlClusterMoveToHueCallback(aEndpointId, apCommandObj, hue, direction, transitionTime, + optionsMask, optionsOverride); } break; } @@ -1027,9 +1220,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterMoveToHueAndSaturationCallback(apCommandObj, hue, saturation, transitionTime, - optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterMoveToHueAndSaturationCallback(aEndpointId, apCommandObj, hue, saturation, + transitionTime, optionsMask, optionsOverride); } break; } @@ -1099,9 +1291,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterMoveToSaturationCallback(apCommandObj, saturation, transitionTime, - optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterMoveToSaturationCallback(aEndpointId, apCommandObj, saturation, + transitionTime, optionsMask, optionsOverride); } break; } @@ -1175,9 +1366,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterStepColorCallback(apCommandObj, stepX, stepY, transitionTime, optionsMask, - optionsOverride); + wasHandled = emberAfColorControlClusterStepColorCallback(aEndpointId, apCommandObj, stepX, stepY, transitionTime, + optionsMask, optionsOverride); } break; } @@ -1259,10 +1449,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 7 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. wasHandled = emberAfColorControlClusterStepColorTemperatureCallback( - apCommandObj, stepMode, stepSize, transitionTime, colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, - optionsOverride); + aEndpointId, apCommandObj, stepMode, stepSize, transitionTime, colorTemperatureMinimum, colorTemperatureMaximum, + optionsMask, optionsOverride); } break; } @@ -1336,9 +1525,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterStepHueCallback(apCommandObj, stepMode, stepSize, transitionTime, - optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterStepHueCallback(aEndpointId, apCommandObj, stepMode, stepSize, + transitionTime, optionsMask, optionsOverride); } break; } @@ -1412,9 +1600,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterStepSaturationCallback(apCommandObj, stepMode, stepSize, transitionTime, - optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterStepSaturationCallback(aEndpointId, apCommandObj, stepMode, stepSize, + transitionTime, optionsMask, optionsOverride); } break; } @@ -1476,21 +1663,14 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterStopMoveStepCallback(apCommandObj, optionsMask, optionsOverride); + wasHandled = + emberAfColorControlClusterStopMoveStepCallback(aEndpointId, apCommandObj, optionsMask, optionsOverride); } break; } default: { // Unrecognized command ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::ColorControl::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, - Protocols::SecureChannel::Id, - Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::ColorControl::Id); + ReportCommandUnsupported(apCommandObj, aEndpointId, Clusters::ColorControl::Id, aCommandId); return; } } @@ -1498,16 +1678,19 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::ColorControl::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::ColorControl::Id, aCommandId, (CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); } } @@ -1515,7 +1698,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En namespace GeneralCommissioning { -void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +void DispatchServerCommand(CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) { // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. @@ -1592,16 +1775,14 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfGeneralCommissioningClusterArmFailSafeCallback(apCommandObj, expiryLengthSeconds, breadcrumb, timeoutMs); + wasHandled = emberAfGeneralCommissioningClusterArmFailSafeCallback(aEndpointId, apCommandObj, expiryLengthSeconds, + breadcrumb, timeoutMs); } break; } case Clusters::GeneralCommissioning::Commands::Ids::CommissioningComplete: { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfGeneralCommissioningClusterCommissioningCompleteCallback(apCommandObj); + wasHandled = emberAfGeneralCommissioningClusterCommissioningCompleteCallback(aEndpointId, apCommandObj); break; } case Clusters::GeneralCommissioning::Commands::Ids::SetRegulatoryConfig: { @@ -1671,22 +1852,14 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. wasHandled = emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback( - apCommandObj, location, const_cast(countryCode), breadcrumb, timeoutMs); + aEndpointId, apCommandObj, location, const_cast(countryCode), breadcrumb, timeoutMs); } break; } default: { // Unrecognized command ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::GeneralCommissioning::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, - Protocols::SecureChannel::Id, - Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::GeneralCommissioning::Id); + ReportCommandUnsupported(apCommandObj, aEndpointId, Clusters::GeneralCommissioning::Id, aCommandId); return; } } @@ -1694,16 +1867,20 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::GeneralCommissioning::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::GeneralCommissioning::Id, aCommandId, + (CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); } } @@ -1711,7 +1888,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En namespace LevelControl { -void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +void DispatchServerCommand(CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) { // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. @@ -1792,8 +1969,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfLevelControlClusterMoveCallback(apCommandObj, moveMode, rate, optionMask, optionOverride); + wasHandled = + emberAfLevelControlClusterMoveCallback(aEndpointId, apCommandObj, moveMode, rate, optionMask, optionOverride); } break; } @@ -1863,9 +2040,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfLevelControlClusterMoveToLevelCallback(apCommandObj, level, transitionTime, optionMask, optionOverride); + wasHandled = emberAfLevelControlClusterMoveToLevelCallback(aEndpointId, apCommandObj, level, transitionTime, + optionMask, optionOverride); } break; } @@ -1927,8 +2103,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfLevelControlClusterMoveToLevelWithOnOffCallback(apCommandObj, level, transitionTime); + wasHandled = + emberAfLevelControlClusterMoveToLevelWithOnOffCallback(aEndpointId, apCommandObj, level, transitionTime); } break; } @@ -1990,8 +2166,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfLevelControlClusterMoveWithOnOffCallback(apCommandObj, moveMode, rate); + wasHandled = emberAfLevelControlClusterMoveWithOnOffCallback(aEndpointId, apCommandObj, moveMode, rate); } break; } @@ -2065,9 +2240,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfLevelControlClusterStepCallback(apCommandObj, stepMode, stepSize, transitionTime, optionMask, - optionOverride); + wasHandled = emberAfLevelControlClusterStepCallback(aEndpointId, apCommandObj, stepMode, stepSize, transitionTime, + optionMask, optionOverride); } break; } @@ -2133,8 +2307,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfLevelControlClusterStepWithOnOffCallback(apCommandObj, stepMode, stepSize, transitionTime); + wasHandled = + emberAfLevelControlClusterStepWithOnOffCallback(aEndpointId, apCommandObj, stepMode, stepSize, transitionTime); } break; } @@ -2196,27 +2370,18 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfLevelControlClusterStopCallback(apCommandObj, optionMask, optionOverride); + wasHandled = emberAfLevelControlClusterStopCallback(aEndpointId, apCommandObj, optionMask, optionOverride); } break; } case Clusters::LevelControl::Commands::Ids::StopWithOnOff: { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfLevelControlClusterStopWithOnOffCallback(apCommandObj); + wasHandled = emberAfLevelControlClusterStopWithOnOffCallback(aEndpointId, apCommandObj); break; } default: { // Unrecognized command ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::LevelControl::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, - Protocols::SecureChannel::Id, - Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::LevelControl::Id); + ReportCommandUnsupported(apCommandObj, aEndpointId, Clusters::LevelControl::Id, aCommandId); return; } } @@ -2224,16 +2389,19 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::LevelControl::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::LevelControl::Id, aCommandId, (CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); } } @@ -2241,7 +2409,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En namespace NetworkCommissioning { -void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +void DispatchServerCommand(CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) { // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. @@ -2290,12 +2458,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - operationalDataset = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(operationalDataset); + break; case 1: TLVUnpackError = aDataTlv.Get(breadcrumb); break; @@ -2321,9 +2486,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterAddThreadNetworkCallback(apCommandObj, operationalDataset, - breadcrumb, timeoutMs); + wasHandled = emberAfNetworkCommissioningClusterAddThreadNetworkCallback(aEndpointId, apCommandObj, + operationalDataset, breadcrumb, timeoutMs); } break; } @@ -2362,18 +2526,12 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - ssid = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; - case 1: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - credentials = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(ssid); + break; + case 1: + TLVUnpackError = aDataTlv.Get(credentials); + break; case 2: TLVUnpackError = aDataTlv.Get(breadcrumb); break; @@ -2399,9 +2557,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(apCommandObj, ssid, credentials, breadcrumb, - timeoutMs); + wasHandled = emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(aEndpointId, apCommandObj, ssid, credentials, + breadcrumb, timeoutMs); } break; } @@ -2439,12 +2596,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - networkID = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(networkID); + break; case 1: TLVUnpackError = aDataTlv.Get(breadcrumb); break; @@ -2470,9 +2624,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfNetworkCommissioningClusterDisableNetworkCallback(apCommandObj, networkID, breadcrumb, timeoutMs); + wasHandled = emberAfNetworkCommissioningClusterDisableNetworkCallback(aEndpointId, apCommandObj, networkID, + breadcrumb, timeoutMs); } break; } @@ -2510,12 +2663,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - networkID = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(networkID); + break; case 1: TLVUnpackError = aDataTlv.Get(breadcrumb); break; @@ -2541,9 +2691,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfNetworkCommissioningClusterEnableNetworkCallback(apCommandObj, networkID, breadcrumb, timeoutMs); + wasHandled = emberAfNetworkCommissioningClusterEnableNetworkCallback(aEndpointId, apCommandObj, networkID, + breadcrumb, timeoutMs); } break; } @@ -2601,8 +2750,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(apCommandObj, timeoutMs); + wasHandled = emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(aEndpointId, apCommandObj, + timeoutMs); } break; } @@ -2640,12 +2789,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - NetworkID = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(NetworkID); + break; case 1: TLVUnpackError = aDataTlv.Get(Breadcrumb); break; @@ -2671,9 +2817,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfNetworkCommissioningClusterRemoveNetworkCallback(apCommandObj, NetworkID, Breadcrumb, TimeoutMs); + wasHandled = emberAfNetworkCommissioningClusterRemoveNetworkCallback(aEndpointId, apCommandObj, NetworkID, + Breadcrumb, TimeoutMs); } break; } @@ -2711,12 +2856,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - ssid = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(ssid); + break; case 1: TLVUnpackError = aDataTlv.Get(breadcrumb); break; @@ -2742,8 +2884,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterScanNetworksCallback(apCommandObj, ssid, breadcrumb, timeoutMs); + wasHandled = + emberAfNetworkCommissioningClusterScanNetworksCallback(aEndpointId, apCommandObj, ssid, breadcrumb, timeoutMs); } break; } @@ -2781,12 +2923,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - operationalDataset = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(operationalDataset); + break; case 1: TLVUnpackError = aDataTlv.Get(breadcrumb); break; @@ -2812,9 +2951,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback(apCommandObj, operationalDataset, - breadcrumb, timeoutMs); + wasHandled = emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback( + aEndpointId, apCommandObj, operationalDataset, breadcrumb, timeoutMs); } break; } @@ -2853,18 +2991,12 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - ssid = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; - case 1: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - credentials = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(ssid); + break; + case 1: + TLVUnpackError = aDataTlv.Get(credentials); + break; case 2: TLVUnpackError = aDataTlv.Get(breadcrumb); break; @@ -2890,22 +3022,14 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(apCommandObj, ssid, credentials, - breadcrumb, timeoutMs); + wasHandled = emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(aEndpointId, apCommandObj, ssid, + credentials, breadcrumb, timeoutMs); } break; } default: { // Unrecognized command ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::NetworkCommissioning::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, - Protocols::SecureChannel::Id, - Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::NetworkCommissioning::Id); + ReportCommandUnsupported(apCommandObj, aEndpointId, Clusters::NetworkCommissioning::Id, aCommandId); return; } } @@ -2913,16 +3037,20 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::NetworkCommissioning::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::NetworkCommissioning::Id, aCommandId, + (CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); } } @@ -2930,7 +3058,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En namespace OnOff { -void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +void DispatchServerCommand(CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) { // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. @@ -2947,32 +3075,22 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En { case Clusters::OnOff::Commands::Ids::Off: { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOnOffClusterOffCallback(apCommandObj); + wasHandled = emberAfOnOffClusterOffCallback(aEndpointId, apCommandObj); break; } case Clusters::OnOff::Commands::Ids::On: { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOnOffClusterOnCallback(apCommandObj); + wasHandled = emberAfOnOffClusterOnCallback(aEndpointId, apCommandObj); break; } case Clusters::OnOff::Commands::Ids::Toggle: { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOnOffClusterToggleCallback(apCommandObj); + wasHandled = emberAfOnOffClusterToggleCallback(aEndpointId, apCommandObj); break; } default: { // Unrecognized command ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::OnOff::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, - Protocols::SecureChannel::Id, - Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::OnOff::Id); + ReportCommandUnsupported(apCommandObj, aEndpointId, Clusters::OnOff::Id, aCommandId); return; } } @@ -2980,16 +3098,19 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::OnOff::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::OnOff::Id, aCommandId, (CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); } } @@ -2997,7 +3118,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En namespace OperationalCredentials { -void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +void DispatchServerCommand(CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) { // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. @@ -3012,7 +3133,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En { switch (aCommandId) { - case Clusters::OperationalCredentials::Commands::Ids::AddOpCert: { + case Clusters::OperationalCredentials::Commands::Ids::AddNOC: { expectArgumentCount = 4; chip::ByteSpan NOCArray; chip::ByteSpan IPKValue; @@ -3047,18 +3168,12 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - NOCArray = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; - case 1: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - IPKValue = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(NOCArray); + break; + case 1: + TLVUnpackError = aDataTlv.Get(IPKValue); + break; case 2: TLVUnpackError = aDataTlv.Get(CaseAdminNode); break; @@ -3084,9 +3199,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterAddOpCertCallback(apCommandObj, NOCArray, IPKValue, CaseAdminNode, - AdminVendorId); + wasHandled = emberAfOperationalCredentialsClusterAddNOCCallback(aEndpointId, apCommandObj, NOCArray, IPKValue, + CaseAdminNode, AdminVendorId); } break; } @@ -3122,12 +3236,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - RootCertificate = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(RootCertificate); + break; default: // Unsupported tag, ignore it. ChipLogProgress(Zcl, "Unknown TLV tag during processing."); @@ -3147,8 +3258,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterAddTrustedRootCertificateCallback(apCommandObj, RootCertificate); + wasHandled = emberAfOperationalCredentialsClusterAddTrustedRootCertificateCallback(aEndpointId, apCommandObj, + RootCertificate); } break; } @@ -3184,12 +3295,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - CSRNonce = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(CSRNonce); + break; default: // Unsupported tag, ignore it. ChipLogProgress(Zcl, "Unknown TLV tag during processing."); @@ -3209,23 +3317,14 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterOpCSRRequestCallback(apCommandObj, CSRNonce); + wasHandled = emberAfOperationalCredentialsClusterOpCSRRequestCallback(aEndpointId, apCommandObj, CSRNonce); } break; } - case Clusters::OperationalCredentials::Commands::Ids::RemoveAllFabrics: { - - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterRemoveAllFabricsCallback(apCommandObj); - break; - } case Clusters::OperationalCredentials::Commands::Ids::RemoveFabric: { - expectArgumentCount = 3; - chip::FabricId FabricId; - chip::NodeId NodeId; - uint16_t VendorId; - bool argExists[3]; + expectArgumentCount = 1; + uint8_t FabricIndex; + bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -3238,7 +3337,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 3) + if (currentDecodeTagId < 1) { if (argExists[currentDecodeTagId]) { @@ -3255,13 +3354,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(FabricId); - break; - case 1: - TLVUnpackError = aDataTlv.Get(NodeId); - break; - case 2: - TLVUnpackError = aDataTlv.Get(VendorId); + TLVUnpackError = aDataTlv.Get(FabricIndex); break; default: // Unsupported tag, ignore it. @@ -3280,10 +3373,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterRemoveFabricCallback(apCommandObj, FabricId, NodeId, VendorId); + wasHandled = emberAfOperationalCredentialsClusterRemoveFabricCallback(aEndpointId, apCommandObj, FabricIndex); } break; } @@ -3294,69 +3386,6 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En memset(argExists, 0, sizeof argExists); - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - TrustedRootIdentifier = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) - { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfOperationalCredentialsClusterRemoveTrustedRootCertificateCallback(apCommandObj, TrustedRootIdentifier); - } - break; - } - case Clusters::OperationalCredentials::Commands::Ids::SetFabric: { - expectArgumentCount = 1; - uint16_t VendorId; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) { // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. @@ -3383,7 +3412,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(VendorId); + TLVUnpackError = aDataTlv.Get(TrustedRootIdentifier); break; default: // Unsupported tag, ignore it. @@ -3404,8 +3433,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterSetFabricCallback(apCommandObj, VendorId); + wasHandled = emberAfOperationalCredentialsClusterRemoveTrustedRootCertificateCallback(aEndpointId, apCommandObj, + TrustedRootIdentifier); } break; } @@ -3464,22 +3493,72 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfOperationalCredentialsClusterUpdateFabricLabelCallback(apCommandObj, const_cast(Label)); + wasHandled = emberAfOperationalCredentialsClusterUpdateFabricLabelCallback(aEndpointId, apCommandObj, + const_cast(Label)); + } + break; + } + case Clusters::OperationalCredentials::Commands::Ids::UpdateNOC: { + expectArgumentCount = 1; + chip::ByteSpan NOCArray; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(NOCArray); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + wasHandled = emberAfOperationalCredentialsClusterUpdateNOCCallback(aEndpointId, apCommandObj, NOCArray); } break; } default: { // Unrecognized command ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::OperationalCredentials::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, - Protocols::SecureChannel::Id, - Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::OperationalCredentials::Id); + ReportCommandUnsupported(apCommandObj, aEndpointId, Clusters::OperationalCredentials::Id, aCommandId); return; } } @@ -3487,33 +3566,91 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::OperationalCredentials::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::OperationalCredentials::Id, aCommandId, + (CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); } } } // namespace OperationalCredentials +namespace WiFiNetworkDiagnostics { + +void DispatchServerCommand(CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::WiFiNetworkDiagnostics::Commands::Ids::ResetCounts: { + + wasHandled = emberAfWiFiNetworkDiagnosticsClusterResetCountsCallback(aEndpointId, apCommandObj); + break; + } + default: { + // Unrecognized command ID, error status will apply. + ReportCommandUnsupported(apCommandObj, aEndpointId, Clusters::WiFiNetworkDiagnostics::Id, aCommandId); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::WiFiNetworkDiagnostics::Id, aCommandId, + (CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); + } +} + +} // namespace WiFiNetworkDiagnostics + } // namespace clusters -void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aCommandId, chip::EndpointId aEndPointId, - chip::TLV::TLVReader & aReader, Command * apCommandObj) +void DispatchSingleClusterCommand(ClusterId aClusterId, CommandId aCommandId, EndpointId aEndPointId, TLV::TLVReader & aReader, + CommandHandler * apCommandObj) { - ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx32 " Command=%" PRIx32 " Endpoint=%" PRIx16, aClusterId, - aCommandId, aEndPointId); + ChipLogDetail(Zcl, "Received Cluster Command: Cluster=" ChipLogFormatMEI " Command=" ChipLogFormatMEI " Endpoint=%" PRIx16, + ChipLogValueMEI(aClusterId), ChipLogValueMEI(aCommandId), aEndPointId); Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); switch (aClusterId) { + case Clusters::AdministratorCommissioning::Id: + clusters::AdministratorCommissioning::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; case Clusters::ColorControl::Id: clusters::ColorControl::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; @@ -3532,12 +3669,14 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC case Clusters::OperationalCredentials::Id: clusters::OperationalCredentials::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; + case Clusters::WiFiNetworkDiagnostics::Id: + clusters::WiFiNetworkDiagnostics::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; default: // Unrecognized cluster ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndPointId, - 0, // GroupId - aClusterId, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; + CommandPathParams returnStatusParam = { aEndPointId, + 0, // GroupId + aClusterId, aCommandId, (CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); ChipLogError(Zcl, "Unknown cluster %" PRIx32, aClusterId); @@ -3548,5 +3687,30 @@ exit: aReader.ExitContainer(dataTlvType); } +void DispatchSingleClusterResponseCommand(ClusterId aClusterId, CommandId aCommandId, EndpointId aEndPointId, + TLV::TLVReader & aReader, CommandSender * apCommandObj) +{ + ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx32 " Command=%" PRIx32 " Endpoint=%" PRIx16, aClusterId, + aCommandId, aEndPointId); + Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); + TLV::TLVType dataTlvType; + SuccessOrExit(aReader.EnterContainer(dataTlvType)); + switch (aClusterId) + { + default: + // Unrecognized cluster ID, error status will apply. + CommandPathParams returnStatusParam = { aEndPointId, + 0, // GroupId + aClusterId, aCommandId, (CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aClusterId)); + break; + } +exit: + Compatibility::ResetEmberAfObjects(); + aReader.ExitContainer(dataTlvType); +} + } // namespace app } // namespace chip diff --git a/examples/light/main/gen/af-gen-event.h b/examples/light/main/zap-generated/af-gen-event.h similarity index 100% rename from examples/light/main/gen/af-gen-event.h rename to examples/light/main/zap-generated/af-gen-event.h diff --git a/examples/rainmaker_light/main/gen/attribute-size.cpp b/examples/light/main/zap-generated/attribute-size.cpp similarity index 74% rename from examples/rainmaker_light/main/gen/attribute-size.cpp rename to examples/light/main/zap-generated/attribute-size.cpp index 97e2effb1..6a5f759d4 100644 --- a/examples/rainmaker_light/main/gen/attribute-size.cpp +++ b/examples/light/main/zap-generated/attribute-size.cpp @@ -69,7 +69,7 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo return kSizeLengthInBytes; } - if (!chip::CanCastTo(index)) + if (!CanCastTo(index)) { ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); return 0; @@ -78,6 +78,30 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo uint16_t entryLength = 0; switch (clusterId) { + case 0x0030: // General Commissioning Cluster + { + uint16_t entryOffset = kSizeLengthInBytes; + switch (am->attributeId) + { + case 0x0001: // BasicCommissioningInfoList + { + entryLength = 4; + if (((index - 1) * entryLength) > (am->size - entryLength)) + { + ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); + return 0; + } + entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); + // Struct _BasicCommissioningInfoType + _BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest); + copyListMember(write ? dest : (uint8_t *) &entry->FailSafeExpiryLengthMs, + write ? (uint8_t *) &entry->FailSafeExpiryLengthMs : src, write, &entryOffset, + sizeof(entry->FailSafeExpiryLengthMs)); // INT32U + break; + } + } + break; + } case 0x003E: // Operational Credentials Cluster { uint16_t entryOffset = kSizeLengthInBytes; @@ -99,8 +123,8 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, &entryOffset, sizeof(entry->VendorId)); // INT16U copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, - sizeof(entry->NodeId)); // NODE_ID - chip::ByteSpan * LabelSpan = &entry->Label; // OCTET_STRING + sizeof(entry->NodeId)); // NODE_ID + ByteSpan * LabelSpan = &entry->Label; // OCTET_STRING if (CHIP_NO_ERROR != (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) { @@ -132,6 +156,15 @@ uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attribut uint16_t entryLength = 0; switch (clusterId) { + case 0x0030: // General Commissioning Cluster + switch (attributeId) + { + case 0x0001: // BasicCommissioningInfoList + // Struct _BasicCommissioningInfoType + entryLength = 4; + break; + } + break; case 0x003E: // Operational Credentials Cluster switch (attributeId) { @@ -144,9 +177,10 @@ uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attribut } uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!chip::CanCastTo(totalSize)) + if (!CanCastTo(totalSize)) { - ChipLogError(Zcl, "Cluster %" PRIx32 ": Size of attribute %" PRIx32 " is too large.", clusterId, attributeId); + ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", + ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); return 0; } diff --git a/examples/rainmaker_light/main/gen/callback-stub.cpp b/examples/light/main/zap-generated/callback-stub.cpp similarity index 97% rename from examples/rainmaker_light/main/gen/callback-stub.cpp rename to examples/light/main/zap-generated/callback-stub.cpp index 6d93baaae..bad51ab7a 100644 --- a/examples/rainmaker_light/main/gen/callback-stub.cpp +++ b/examples/light/main/zap-generated/callback-stub.cpp @@ -28,6 +28,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) { switch (clusterId) { + case ZCL_ADMINISTRATOR_COMMISSIONING_CLUSTER_ID: + emberAfAdministratorCommissioningClusterInitCallback(endpoint); + break; case ZCL_BASIC_CLUSTER_ID: emberAfBasicClusterInitCallback(endpoint); break; @@ -58,6 +61,11 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) } } +void __attribute__((weak)) emberAfAdministratorCommissioningClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfBasicClusterInitCallback(EndpointId endpoint) { // To prevent warning @@ -475,22 +483,6 @@ emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, E return EMBER_ZCL_STATUS_FAILURE; } -/** @brief Write Attributes Response - * - * This function is called by the application framework when a Write Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of write attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool __attribute__((weak)) emberAfWriteAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) -{ - return false; -} - /** @brief External Attribute Write * * This function is called whenever the Application Framework needs to write an diff --git a/examples/light/main/gen/callback.h b/examples/light/main/zap-generated/callback.h similarity index 100% rename from examples/light/main/gen/callback.h rename to examples/light/main/zap-generated/callback.h diff --git a/examples/light/main/gen/chip-zcl-zpro-codec-api.h b/examples/light/main/zap-generated/chip-zcl-zpro-codec-api.h similarity index 100% rename from examples/light/main/gen/chip-zcl-zpro-codec-api.h rename to examples/light/main/zap-generated/chip-zcl-zpro-codec-api.h diff --git a/examples/light/main/gen/encoder.cpp b/examples/light/main/zap-generated/encoder.cpp similarity index 100% rename from examples/light/main/gen/encoder.cpp rename to examples/light/main/zap-generated/encoder.cpp diff --git a/examples/light/main/gen/endpoint_config.h b/examples/light/main/zap-generated/endpoint_config.h similarity index 88% rename from examples/light/main/gen/endpoint_config.h rename to examples/light/main/zap-generated/endpoint_config.h index 466148aff..a8a7f39cf 100644 --- a/examples/light/main/gen/endpoint_config.h +++ b/examples/light/main/zap-generated/endpoint_config.h @@ -91,20 +91,33 @@ \ /* Endpoint: 0, Cluster: General Commissioning (server), big-endian */ \ \ - /* 628 - FabricId, */ \ - 1, 'o', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - \ - /* 636 - Breadcrumb, */ \ + /* 628 - Breadcrumb, */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ \ + /* 636 - BasicCommissioningInfoList, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ /* Endpoint: 0, Cluster: WiFi Network Diagnostics (server), big-endian */ \ \ - /* 644 - bssid, */ \ + /* 890 - bssid, */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ \ /* Endpoint: 0, Cluster: Operational Credentials (server), big-endian */ \ \ - /* 650 - fabrics list, */ \ + /* 896 - fabrics list, */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ @@ -189,20 +202,33 @@ \ /* Endpoint: 0, Cluster: General Commissioning (server), little-endian */ \ \ - /* 628 - FabricId, */ \ - 1, 'o', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - \ - /* 636 - Breadcrumb, */ \ + /* 628 - Breadcrumb, */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ \ + /* 636 - BasicCommissioningInfoList, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ /* Endpoint: 0, Cluster: WiFi Network Diagnostics (server), little-endian */ \ \ - /* 644 - bssid, */ \ + /* 890 - bssid, */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ \ /* Endpoint: 0, Cluster: Operational Credentials (server), little-endian */ \ \ - /* 650 - fabrics list, */ \ + /* 896 - fabrics list, */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ @@ -249,7 +275,7 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 64 +#define GENERATED_ATTRIBUTE_COUNT 67 #define GENERATED_ATTRIBUTES \ { \ \ @@ -278,42 +304,47 @@ { 0x0010, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ ZAP_SIMPLE_DEFAULT(0) }, /* LocalConfigDisabled */ \ { 0x0011, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(SINGLETON), ZAP_SIMPLE_DEFAULT(1) }, /* Reachable */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), ZAP_SIMPLE_DEFAULT(3) }, /* cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), ZAP_SIMPLE_DEFAULT(3) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: General Commissioning (server) */ \ - { 0x0000, ZAP_TYPE(OCTET_STRING), 8, 0, ZAP_LONG_DEFAULTS_INDEX(628) }, /* FabricId */ \ - { 0x0001, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_LONG_DEFAULTS_INDEX(636) }, /* Breadcrumb */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ + { 0x0000, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_LONG_DEFAULTS_INDEX(628) }, /* Breadcrumb */ \ + { 0x0001, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(636) }, /* BasicCommissioningInfoList */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Network Commissioning (server) */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: WiFi Network Diagnostics (server) */ \ - { 0x0000, ZAP_TYPE(OCTET_STRING), 6, 0, ZAP_LONG_DEFAULTS_INDEX(644) }, /* bssid */ \ + { 0x0000, ZAP_TYPE(OCTET_STRING), 6, 0, ZAP_LONG_DEFAULTS_INDEX(890) }, /* bssid */ \ { 0x0001, ZAP_TYPE(ENUM8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* SecurityType */ \ { 0x0002, ZAP_TYPE(ENUM8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* WiFiVersion */ \ { 0x0003, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0000) }, /* ChannelNumber */ \ { 0x0004, ZAP_TYPE(INT8S), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* Rssi */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Operational Credentials (server) */ \ - { 0x0001, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(650) }, /* fabrics list */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ + { 0x0001, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(896) }, /* fabrics list */ \ + { 0x0002, ZAP_TYPE(INT8U), 1, 0, ZAP_EMPTY_DEFAULT() }, /* SupportedFabrics */ \ + { 0x0003, ZAP_TYPE(INT8U), 1, 0, ZAP_EMPTY_DEFAULT() }, /* CommissionedFabrics */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ - /* Endpoint: 1, Cluster: On/off (server) */ \ - { 0x0000, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* on/off */ \ - { 0x4000, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x01) }, /* global scene control */ \ - { 0x4001, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* on time */ \ - { 0x4002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* off wait time */ \ - { 0x4003, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_EMPTY_DEFAULT() }, /* start up on off */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(2) }, /* cluster revision */ \ + /* Endpoint: 1, Cluster: On/Off (server) */ \ + { 0x0000, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* OnOff */ \ + { 0x4000, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x01) }, /* GlobalSceneControl */ \ + { 0x4001, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* OnTime */ \ + { 0x4002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* OffWaitTime */ \ + { 0x4003, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_EMPTY_DEFAULT() }, /* StartUpOnOff */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(2) }, /* ClusterRevision */ \ \ /* Endpoint: 1, Cluster: Level Control (server) */ \ { 0x0000, ZAP_TYPE(INT8U), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* current level */ \ { 0x0001, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0000) }, /* remaining time */ \ { 0x000F, ZAP_TYPE(BITMAP8), 1, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* options */ \ { 0x4000, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_EMPTY_DEFAULT() }, /* start up current level */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(3) }, /* cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(3) }, /* ClusterRevision */ \ \ /* Endpoint: 1, Cluster: Color Control (server) */ \ { 0x0000, ZAP_TYPE(INT8U), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* current hue */ \ @@ -338,7 +369,7 @@ { 0x400D, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* couple color temp to level min-mireds */ \ { 0x4010, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), \ ZAP_EMPTY_DEFAULT() }, /* start up color temperature mireds */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(3) }, /* cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(3) }, /* ClusterRevision */ \ } // This is an array of EmberAfCluster structures. @@ -360,7 +391,7 @@ }; #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 8 +#define GENERATED_CLUSTER_COUNT 9 #define GENERATED_CLUSTERS \ { \ { 0x0028, \ @@ -370,7 +401,7 @@ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayBasicServer }, /* Endpoint: 0, Cluster: Basic (server) */ \ { \ - 0x0030, ZAP_ATTRIBUTE_INDEX(19), 3, 18, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0030, ZAP_ATTRIBUTE_INDEX(19), 3, 264, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: General Commissioning (server) */ \ { \ 0x0031, ZAP_ATTRIBUTE_INDEX(22), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ @@ -379,22 +410,25 @@ 0x0036, ZAP_ATTRIBUTE_INDEX(23), 6, 13, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: WiFi Network Diagnostics (server) */ \ { \ - 0x003E, ZAP_ATTRIBUTE_INDEX(29), 2, 256, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x003C, ZAP_ATTRIBUTE_INDEX(29), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ + { \ + 0x003E, ZAP_ATTRIBUTE_INDEX(30), 4, 258, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: Operational Credentials (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(31), \ + ZAP_ATTRIBUTE_INDEX(34), \ 6, \ 9, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ - chipFuncArrayOnOffServer }, /* Endpoint: 1, Cluster: On/off (server) */ \ + chipFuncArrayOnOffServer }, /* Endpoint: 1, Cluster: On/Off (server) */ \ { 0x0008, \ - ZAP_ATTRIBUTE_INDEX(37), \ + ZAP_ATTRIBUTE_INDEX(40), \ 5, \ 7, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayLevelControlServer }, /* Endpoint: 1, Cluster: Level Control (server) */ \ { 0x0300, \ - ZAP_ATTRIBUTE_INDEX(42), \ + ZAP_ATTRIBUTE_INDEX(45), \ 22, \ 36, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ @@ -406,7 +440,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 5, 931 }, { ZAP_CLUSTER_INDEX(5), 3, 52 }, \ + { ZAP_CLUSTER_INDEX(0), 6, 1181 }, { ZAP_CLUSTER_INDEX(6), 3, 52 }, \ } // Largest attribute size is needed for various buffers @@ -416,7 +450,7 @@ #define ATTRIBUTE_SINGLETONS_SIZE (642) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (983) +#define ATTRIBUTE_MAX_SIZE (1233) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (2) @@ -460,7 +494,7 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (70) +#define EMBER_AF_GENERATED_COMMAND_COUNT (72) #define GENERATED_COMMANDS \ { \ \ @@ -496,20 +530,26 @@ { 0x0031, 0x0F, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* DisableNetworkResponse */ \ { 0x0031, 0x10, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* GetLastNetworkCommissioningResult */ \ \ + /* Endpoint: 0, Cluster: WiFi Network Diagnostics (server) */ \ + { 0x0036, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* ResetCounts */ \ + \ + /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ + { 0x003C, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* OpenCommissioningWindow */ \ + { 0x003C, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* OpenBasicCommissioningWindow */ \ + { 0x003C, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RevokeCommissioning */ \ + \ /* Endpoint: 0, Cluster: Operational Credentials (server) */ \ - { 0x003E, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* SetFabric */ \ - { 0x003E, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* SetFabricResponse */ \ { 0x003E, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* OpCSRRequest */ \ { 0x003E, 0x05, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* OpCSRResponse */ \ - { 0x003E, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* AddOpCert */ \ - { 0x003E, 0x08, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* OpCertResponse */ \ + { 0x003E, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* AddNOC */ \ + { 0x003E, 0x07, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* UpdateNOC */ \ + { 0x003E, 0x08, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* NOCResponse */ \ { 0x003E, 0x09, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* UpdateFabricLabel */ \ { 0x003E, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveFabric */ \ - { 0x003E, 0x0B, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveAllFabrics */ \ - { 0x003E, 0xA1, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* AddTrustedRootCertificate */ \ - { 0x003E, 0xA2, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveTrustedRootCertificate */ \ + { 0x003E, 0x0B, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* AddTrustedRootCertificate */ \ + { 0x003E, 0x0C, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveTrustedRootCertificate */ \ \ - /* Endpoint: 1, Cluster: On/off (server) */ \ + /* Endpoint: 1, Cluster: On/Off (server) */ \ { 0x0006, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Off */ \ { 0x0006, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* On */ \ { 0x0006, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Toggle */ \ diff --git a/examples/light/main/gen/gen_config.h b/examples/light/main/zap-generated/gen_config.h similarity index 89% rename from examples/light/main/gen/gen_config.h rename to examples/light/main/zap-generated/gen_config.h index a4faf8dd2..deb00616e 100644 --- a/examples/light/main/gen/gen_config.h +++ b/examples/light/main/zap-generated/gen_config.h @@ -29,6 +29,7 @@ #define EMBER_APS_UNICAST_MESSAGE_COUNT 10 /**** Cluster endpoint counts ****/ +#define EMBER_AF_ADMINISTRATOR_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_GENERAL_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) @@ -40,6 +41,11 @@ /**** Cluster Plugins ****/ +// Use this macro to check if the server side of the AdministratorCommissioning cluster is included +#define ZCL_USING_ADMINISTRATOR_COMMISSIONING_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_ADMINISTRATOR_COMMISSIONING_SERVER +#define EMBER_AF_PLUGIN_ADMINISTRATOR_COMMISSIONING + // Use this macro to check if the server side of the Basic cluster is included #define ZCL_USING_BASIC_CLUSTER_SERVER #define EMBER_AF_PLUGIN_BASIC_SERVER @@ -73,7 +79,7 @@ #define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING_SERVER #define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING -// Use this macro to check if the server side of the On/off cluster is included +// Use this macro to check if the server side of the On/Off cluster is included #define ZCL_USING_ON_OFF_CLUSTER_SERVER #define EMBER_AF_PLUGIN_ON_OFF_SERVER #define EMBER_AF_PLUGIN_ON_OFF diff --git a/examples/light/main/gen/gen_tokens.h b/examples/light/main/zap-generated/gen_tokens.h similarity index 100% rename from examples/light/main/gen/gen_tokens.h rename to examples/light/main/zap-generated/gen_tokens.h diff --git a/examples/light/sdkconfig.defaults b/examples/light/sdkconfig.defaults index 522a6fa78..23c2c7d7a 100644 --- a/examples/light/sdkconfig.defaults +++ b/examples/light/sdkconfig.defaults @@ -19,3 +19,7 @@ CONFIG_PARTITION_TABLE_FILENAME="partitions.csv" # Enable chip shell CONFIG_ENABLE_CHIP_SHELL=y + +# Main task needs a bit more stack than the default +# default is 3584, bump this up to 5k. +CONFIG_ESP_MAIN_TASK_STACK_SIZE=5120 diff --git a/examples/rainmaker_light/main/CMakeLists.txt b/examples/rainmaker_light/main/CMakeLists.txt index ce33e1e65..3bd28cd33 100644 --- a/examples/rainmaker_light/main/CMakeLists.txt +++ b/examples/rainmaker_light/main/CMakeLists.txt @@ -1,11 +1,14 @@ set(SRC_DIRS_LIST "${CMAKE_CURRENT_LIST_DIR}" - "${CMAKE_CURRENT_LIST_DIR}/gen" + "${CMAKE_CURRENT_LIST_DIR}/zap-generated" + "${MATTER_SDK_PATH}/src/app/common/gen/attributes" "${MATTER_SDK_PATH}/src/app/server" "${MATTER_SDK_PATH}/src/app/util" "${MATTER_SDK_PATH}/src/app/reporting" "${MATTER_SDK_PATH}/src/app/clusters/basic" + "${MATTER_SDK_PATH}/src/app/clusters/administrator-commissioning-server" "${MATTER_SDK_PATH}/src/app/clusters/general-commissioning-server" "${MATTER_SDK_PATH}/src/app/clusters/network-commissioning" + "${MATTER_SDK_PATH}/src/app/clusters/wifi_network_diagnostics_server" "${MATTER_SDK_PATH}/src/app/clusters/on-off-server" "${MATTER_SDK_PATH}/src/app/clusters/operational-credentials-server" "${MATTER_SDK_PATH}/src/app/clusters/level-control" diff --git a/examples/rainmaker_light/main/rainmaker_light.zap b/examples/rainmaker_light/main/rainmaker_light.zap index 0b6391524..c43219a36 100644 --- a/examples/rainmaker_light/main/rainmaker_light.zap +++ b/examples/rainmaker_light/main/rainmaker_light.zap @@ -1,5 +1,5 @@ { - "featureLevel": 39, + "featureLevel": 45, "creator": "zap", "keyValuePairs": [ { @@ -18,13 +18,13 @@ "package": [ { "pathRelativity": "relativeToZap", - "path": "../../../../connectedhomeip/src/app/zap-templates/zcl/zcl.json", + "path": "../../../connectedhomeip/connectedhomeip/src/app/zap-templates/zcl/zcl.json", "version": "ZCL Test Data", "type": "zcl-properties" }, { "pathRelativity": "relativeToZap", - "path": "../../../../connectedhomeip/src/app/zap-templates/app-templates.json", + "path": "../../../connectedhomeip/connectedhomeip/src/app/zap-templates/app-templates.json", "version": "chip-v1", "type": "gen-templates-json" } @@ -63,7 +63,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -113,7 +113,7 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -139,7 +139,7 @@ "commands": [], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -460,7 +460,7 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -511,7 +511,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -562,7 +562,7 @@ ], "attributes": [ { - "name": "FabricId", + "name": "Breadcrumb", "code": 0, "mfgCode": null, "side": "server", @@ -570,14 +570,14 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "o", + "defaultValue": "0x0000000000000000", "reportable": 0, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "Breadcrumb", + "name": "BasicCommissioningInfoList", "code": 1, "mfgCode": null, "side": "server", @@ -592,7 +592,7 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -691,7 +691,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -782,7 +782,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -805,10 +805,19 @@ "define": "WIFI_NETWORK_DIAGNOSTICS_CLUSTER", "side": "client", "enabled": 0, - "commands": [], + "commands": [ + { + "name": "ResetCounts", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -909,7 +918,84 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "AdministratorCommissioning", + "code": 60, + "mfgCode": null, + "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", + "side": "client", + "enabled": 0, + "commands": [ + { + "name": "OpenCommissioningWindow", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "OpenBasicCommissioningWindow", + "code": 1, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + }, + { + "name": "RevokeCommissioning", + "code": 2, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 1 + } + ], + "attributes": [ + { + "name": "ClusterRevision", + "code": 65533, + "mfgCode": null, + "side": "client", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0x0001", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + } + ] + }, + { + "name": "AdministratorCommissioning", + "code": 60, + "mfgCode": null, + "define": "ADMINISTRATOR_COMMISSIONING_CLUSTER", + "side": "server", + "enabled": 1, + "commands": [], + "attributes": [ + { + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -933,14 +1019,6 @@ "side": "client", "enabled": 0, "commands": [ - { - "name": "SetFabric", - "code": 0, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 1 - }, { "name": "OpCSRRequest", "code": 4, @@ -950,13 +1028,21 @@ "outgoing": 1 }, { - "name": "AddOpCert", + "name": "AddNOC", "code": 6, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 }, + { + "name": "UpdateNOC", + "code": 7, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + }, { "name": "UpdateFabricLabel", "code": 9, @@ -974,24 +1060,16 @@ "outgoing": 1 }, { - "name": "RemoveAllFabrics", + "name": "AddTrustedRootCertificate", "code": 11, "mfgCode": null, "source": "client", "incoming": 1, "outgoing": 1 }, - { - "name": "AddTrustedRootCertificate", - "code": 161, - "mfgCode": null, - "source": "client", - "incoming": 1, - "outgoing": 0 - }, { "name": "RemoveTrustedRootCertificate", - "code": 162, + "code": 12, "mfgCode": null, "source": "client", "incoming": 1, @@ -1000,7 +1078,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -1024,14 +1102,6 @@ "side": "server", "enabled": 1, "commands": [ - { - "name": "SetFabricResponse", - "code": 1, - "mfgCode": null, - "source": "server", - "incoming": 1, - "outgoing": 1 - }, { "name": "OpCSRResponse", "code": 5, @@ -1041,7 +1111,7 @@ "outgoing": 1 }, { - "name": "OpCertResponse", + "name": "NOCResponse", "code": 8, "mfgCode": null, "source": "server", @@ -1066,7 +1136,37 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "SupportedFabrics", + "code": 2, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "CommissionedFabrics", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 0, + "maxInterval": 65344, + "reportableChange": 0 + }, + { + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -1125,7 +1225,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -1175,7 +1275,7 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -1192,7 +1292,7 @@ ] }, { - "name": "On/off", + "name": "On/Off", "code": 6, "mfgCode": null, "define": "ON_OFF_CLUSTER", @@ -1250,7 +1350,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -1267,7 +1367,7 @@ ] }, { - "name": "On/off", + "name": "On/Off", "code": 6, "mfgCode": null, "define": "ON_OFF_CLUSTER", @@ -1276,7 +1376,7 @@ "commands": [], "attributes": [ { - "name": "on/off", + "name": "OnOff", "code": 0, "mfgCode": null, "side": "server", @@ -1291,7 +1391,7 @@ "reportableChange": 0 }, { - "name": "global scene control", + "name": "GlobalSceneControl", "code": 16384, "mfgCode": null, "side": "server", @@ -1306,7 +1406,7 @@ "reportableChange": 0 }, { - "name": "on time", + "name": "OnTime", "code": 16385, "mfgCode": null, "side": "server", @@ -1321,7 +1421,7 @@ "reportableChange": 0 }, { - "name": "off wait time", + "name": "OffWaitTime", "code": 16386, "mfgCode": null, "side": "server", @@ -1336,7 +1436,7 @@ "reportableChange": 0 }, { - "name": "start up on off", + "name": "StartUpOnOff", "code": 16387, "mfgCode": null, "side": "server", @@ -1351,7 +1451,7 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -1442,7 +1542,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -1528,7 +1628,7 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -1554,7 +1654,7 @@ "commands": [], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -1770,7 +1870,7 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", @@ -1949,7 +2049,7 @@ ], "attributes": [ { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "client", @@ -2320,7 +2420,7 @@ "reportableChange": 0 }, { - "name": "cluster revision", + "name": "ClusterRevision", "code": 65533, "mfgCode": null, "side": "server", diff --git a/examples/rainmaker_light/main/gen/CHIPClientCallbacks.cpp b/examples/rainmaker_light/main/zap-generated/CHIPClientCallbacks.cpp similarity index 100% rename from examples/rainmaker_light/main/gen/CHIPClientCallbacks.cpp rename to examples/rainmaker_light/main/zap-generated/CHIPClientCallbacks.cpp diff --git a/examples/rainmaker_light/main/gen/CHIPClientCallbacks.h b/examples/rainmaker_light/main/zap-generated/CHIPClientCallbacks.h similarity index 100% rename from examples/rainmaker_light/main/gen/CHIPClientCallbacks.h rename to examples/rainmaker_light/main/zap-generated/CHIPClientCallbacks.h diff --git a/examples/rainmaker_light/main/gen/chip-zcl-zpro-codec-api.h b/examples/rainmaker_light/main/zap-generated/CHIPClusters.cpp similarity index 100% rename from examples/rainmaker_light/main/gen/chip-zcl-zpro-codec-api.h rename to examples/rainmaker_light/main/zap-generated/CHIPClusters.cpp diff --git a/examples/rainmaker_light/main/gen/encoder.cpp b/examples/rainmaker_light/main/zap-generated/CHIPClusters.h similarity index 100% rename from examples/rainmaker_light/main/gen/encoder.cpp rename to examples/rainmaker_light/main/zap-generated/CHIPClusters.h diff --git a/examples/light/main/gen/IMClusterCommandHandler.cpp b/examples/rainmaker_light/main/zap-generated/IMClusterCommandHandler.cpp similarity index 82% rename from examples/light/main/gen/IMClusterCommandHandler.cpp rename to examples/rainmaker_light/main/zap-generated/IMClusterCommandHandler.cpp index e468b570d..820e047c8 100644 --- a/examples/light/main/gen/IMClusterCommandHandler.cpp +++ b/examples/rainmaker_light/main/zap-generated/IMClusterCommandHandler.cpp @@ -34,13 +34,215 @@ namespace chip { namespace app { +namespace { +void ReportCommandUnsupported(Command * aCommandObj, EndpointId aEndpointId, ClusterId aClusterId, CommandId aCommandId) +{ + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + aClusterId, aCommandId, (CommandPathFlags::kEndpointIdValid) }; + aCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, ChipLogValueMEI(aCommandId), + ChipLogValueMEI(aClusterId)); +} +} // anonymous namespace + // Cluster specific command parsing namespace clusters { +namespace AdministratorCommissioning { + +void DispatchServerCommand(CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::AdministratorCommissioning::Commands::Ids::OpenBasicCommissioningWindow: { + expectArgumentCount = 1; + uint16_t CommissioningTimeout; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(CommissioningTimeout); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + wasHandled = emberAfAdministratorCommissioningClusterOpenBasicCommissioningWindowCallback(aEndpointId, apCommandObj, + CommissioningTimeout); + } + break; + } + case Clusters::AdministratorCommissioning::Commands::Ids::OpenCommissioningWindow: { + expectArgumentCount = 6; + uint16_t CommissioningTimeout; + chip::ByteSpan PAKEVerifier; + uint16_t Discriminator; + uint32_t Iterations; + chip::ByteSpan Salt; + uint16_t PasscodeID; + bool argExists[6]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 6) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(CommissioningTimeout); + break; + case 1: + TLVUnpackError = aDataTlv.Get(PAKEVerifier); + break; + case 2: + TLVUnpackError = aDataTlv.Get(Discriminator); + break; + case 3: + TLVUnpackError = aDataTlv.Get(Iterations); + break; + case 4: + TLVUnpackError = aDataTlv.Get(Salt); + break; + case 5: + TLVUnpackError = aDataTlv.Get(PasscodeID); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 6 == validArgumentCount) + { + wasHandled = emberAfAdministratorCommissioningClusterOpenCommissioningWindowCallback( + aEndpointId, apCommandObj, CommissioningTimeout, PAKEVerifier, Discriminator, Iterations, Salt, PasscodeID); + } + break; + } + case Clusters::AdministratorCommissioning::Commands::Ids::RevokeCommissioning: { + + wasHandled = emberAfAdministratorCommissioningClusterRevokeCommissioningCallback(aEndpointId, apCommandObj); + break; + } + default: { + // Unrecognized command ID, error status will apply. + ReportCommandUnsupported(apCommandObj, aEndpointId, Clusters::AdministratorCommissioning::Id, aCommandId); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::AdministratorCommissioning::Id, aCommandId, + (CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); + } +} + +} // namespace AdministratorCommissioning + namespace ColorControl { -void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +void DispatchServerCommand(CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) { // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. @@ -133,9 +335,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 7 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterColorLoopSetCallback(apCommandObj, updateFlags, action, direction, time, - startHue, optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterColorLoopSetCallback( + aEndpointId, apCommandObj, updateFlags, action, direction, time, startHue, optionsMask, optionsOverride); } break; } @@ -205,9 +406,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfColorControlClusterEnhancedMoveHueCallback(apCommandObj, moveMode, rate, optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterEnhancedMoveHueCallback(aEndpointId, apCommandObj, moveMode, rate, + optionsMask, optionsOverride); } break; } @@ -281,8 +481,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterEnhancedMoveToHueCallback(apCommandObj, enhancedHue, direction, + wasHandled = emberAfColorControlClusterEnhancedMoveToHueCallback(aEndpointId, apCommandObj, enhancedHue, direction, transitionTime, optionsMask, optionsOverride); } break; @@ -357,9 +556,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. wasHandled = emberAfColorControlClusterEnhancedMoveToHueAndSaturationCallback( - apCommandObj, enhancedHue, saturation, transitionTime, optionsMask, optionsOverride); + aEndpointId, apCommandObj, enhancedHue, saturation, transitionTime, optionsMask, optionsOverride); } break; } @@ -433,9 +631,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterEnhancedStepHueCallback(apCommandObj, stepMode, stepSize, transitionTime, - optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterEnhancedStepHueCallback(aEndpointId, apCommandObj, stepMode, stepSize, + transitionTime, optionsMask, optionsOverride); } break; } @@ -505,8 +702,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterMoveColorCallback(apCommandObj, rateX, rateY, optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterMoveColorCallback(aEndpointId, apCommandObj, rateX, rateY, optionsMask, + optionsOverride); } break; } @@ -584,9 +781,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 6 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. wasHandled = emberAfColorControlClusterMoveColorTemperatureCallback( - apCommandObj, moveMode, rate, colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, optionsOverride); + aEndpointId, apCommandObj, moveMode, rate, colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, + optionsOverride); } break; } @@ -656,8 +853,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterMoveHueCallback(apCommandObj, moveMode, rate, optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterMoveHueCallback(aEndpointId, apCommandObj, moveMode, rate, optionsMask, + optionsOverride); } break; } @@ -727,9 +924,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfColorControlClusterMoveSaturationCallback(apCommandObj, moveMode, rate, optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterMoveSaturationCallback(aEndpointId, apCommandObj, moveMode, rate, + optionsMask, optionsOverride); } break; } @@ -803,9 +999,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterMoveToColorCallback(apCommandObj, colorX, colorY, transitionTime, - optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterMoveToColorCallback(aEndpointId, apCommandObj, colorX, colorY, + transitionTime, optionsMask, optionsOverride); } break; } @@ -875,8 +1070,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterMoveToColorTemperatureCallback(apCommandObj, colorTemperature, + wasHandled = emberAfColorControlClusterMoveToColorTemperatureCallback(aEndpointId, apCommandObj, colorTemperature, transitionTime, optionsMask, optionsOverride); } break; @@ -951,9 +1145,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterMoveToHueCallback(apCommandObj, hue, direction, transitionTime, optionsMask, - optionsOverride); + wasHandled = emberAfColorControlClusterMoveToHueCallback(aEndpointId, apCommandObj, hue, direction, transitionTime, + optionsMask, optionsOverride); } break; } @@ -1027,9 +1220,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterMoveToHueAndSaturationCallback(apCommandObj, hue, saturation, transitionTime, - optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterMoveToHueAndSaturationCallback(aEndpointId, apCommandObj, hue, saturation, + transitionTime, optionsMask, optionsOverride); } break; } @@ -1099,9 +1291,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterMoveToSaturationCallback(apCommandObj, saturation, transitionTime, - optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterMoveToSaturationCallback(aEndpointId, apCommandObj, saturation, + transitionTime, optionsMask, optionsOverride); } break; } @@ -1175,9 +1366,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterStepColorCallback(apCommandObj, stepX, stepY, transitionTime, optionsMask, - optionsOverride); + wasHandled = emberAfColorControlClusterStepColorCallback(aEndpointId, apCommandObj, stepX, stepY, transitionTime, + optionsMask, optionsOverride); } break; } @@ -1259,10 +1449,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 7 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. wasHandled = emberAfColorControlClusterStepColorTemperatureCallback( - apCommandObj, stepMode, stepSize, transitionTime, colorTemperatureMinimum, colorTemperatureMaximum, optionsMask, - optionsOverride); + aEndpointId, apCommandObj, stepMode, stepSize, transitionTime, colorTemperatureMinimum, colorTemperatureMaximum, + optionsMask, optionsOverride); } break; } @@ -1336,9 +1525,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterStepHueCallback(apCommandObj, stepMode, stepSize, transitionTime, - optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterStepHueCallback(aEndpointId, apCommandObj, stepMode, stepSize, + transitionTime, optionsMask, optionsOverride); } break; } @@ -1412,9 +1600,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterStepSaturationCallback(apCommandObj, stepMode, stepSize, transitionTime, - optionsMask, optionsOverride); + wasHandled = emberAfColorControlClusterStepSaturationCallback(aEndpointId, apCommandObj, stepMode, stepSize, + transitionTime, optionsMask, optionsOverride); } break; } @@ -1476,21 +1663,14 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfColorControlClusterStopMoveStepCallback(apCommandObj, optionsMask, optionsOverride); + wasHandled = + emberAfColorControlClusterStopMoveStepCallback(aEndpointId, apCommandObj, optionsMask, optionsOverride); } break; } default: { // Unrecognized command ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::ColorControl::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, - Protocols::SecureChannel::Id, - Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::ColorControl::Id); + ReportCommandUnsupported(apCommandObj, aEndpointId, Clusters::ColorControl::Id, aCommandId); return; } } @@ -1498,16 +1678,19 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::ColorControl::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::ColorControl::Id, aCommandId, (CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); } } @@ -1515,7 +1698,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En namespace GeneralCommissioning { -void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +void DispatchServerCommand(CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) { // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. @@ -1592,16 +1775,14 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfGeneralCommissioningClusterArmFailSafeCallback(apCommandObj, expiryLengthSeconds, breadcrumb, timeoutMs); + wasHandled = emberAfGeneralCommissioningClusterArmFailSafeCallback(aEndpointId, apCommandObj, expiryLengthSeconds, + breadcrumb, timeoutMs); } break; } case Clusters::GeneralCommissioning::Commands::Ids::CommissioningComplete: { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfGeneralCommissioningClusterCommissioningCompleteCallback(apCommandObj); + wasHandled = emberAfGeneralCommissioningClusterCommissioningCompleteCallback(aEndpointId, apCommandObj); break; } case Clusters::GeneralCommissioning::Commands::Ids::SetRegulatoryConfig: { @@ -1671,22 +1852,14 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. wasHandled = emberAfGeneralCommissioningClusterSetRegulatoryConfigCallback( - apCommandObj, location, const_cast(countryCode), breadcrumb, timeoutMs); + aEndpointId, apCommandObj, location, const_cast(countryCode), breadcrumb, timeoutMs); } break; } default: { // Unrecognized command ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::GeneralCommissioning::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, - Protocols::SecureChannel::Id, - Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::GeneralCommissioning::Id); + ReportCommandUnsupported(apCommandObj, aEndpointId, Clusters::GeneralCommissioning::Id, aCommandId); return; } } @@ -1694,16 +1867,20 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::GeneralCommissioning::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::GeneralCommissioning::Id, aCommandId, + (CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); } } @@ -1711,7 +1888,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En namespace LevelControl { -void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +void DispatchServerCommand(CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) { // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. @@ -1792,8 +1969,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfLevelControlClusterMoveCallback(apCommandObj, moveMode, rate, optionMask, optionOverride); + wasHandled = + emberAfLevelControlClusterMoveCallback(aEndpointId, apCommandObj, moveMode, rate, optionMask, optionOverride); } break; } @@ -1863,9 +2040,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfLevelControlClusterMoveToLevelCallback(apCommandObj, level, transitionTime, optionMask, optionOverride); + wasHandled = emberAfLevelControlClusterMoveToLevelCallback(aEndpointId, apCommandObj, level, transitionTime, + optionMask, optionOverride); } break; } @@ -1927,8 +2103,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfLevelControlClusterMoveToLevelWithOnOffCallback(apCommandObj, level, transitionTime); + wasHandled = + emberAfLevelControlClusterMoveToLevelWithOnOffCallback(aEndpointId, apCommandObj, level, transitionTime); } break; } @@ -1990,8 +2166,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfLevelControlClusterMoveWithOnOffCallback(apCommandObj, moveMode, rate); + wasHandled = emberAfLevelControlClusterMoveWithOnOffCallback(aEndpointId, apCommandObj, moveMode, rate); } break; } @@ -2065,9 +2240,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 5 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfLevelControlClusterStepCallback(apCommandObj, stepMode, stepSize, transitionTime, optionMask, - optionOverride); + wasHandled = emberAfLevelControlClusterStepCallback(aEndpointId, apCommandObj, stepMode, stepSize, transitionTime, + optionMask, optionOverride); } break; } @@ -2133,8 +2307,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfLevelControlClusterStepWithOnOffCallback(apCommandObj, stepMode, stepSize, transitionTime); + wasHandled = + emberAfLevelControlClusterStepWithOnOffCallback(aEndpointId, apCommandObj, stepMode, stepSize, transitionTime); } break; } @@ -2196,27 +2370,18 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 2 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfLevelControlClusterStopCallback(apCommandObj, optionMask, optionOverride); + wasHandled = emberAfLevelControlClusterStopCallback(aEndpointId, apCommandObj, optionMask, optionOverride); } break; } case Clusters::LevelControl::Commands::Ids::StopWithOnOff: { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfLevelControlClusterStopWithOnOffCallback(apCommandObj); + wasHandled = emberAfLevelControlClusterStopWithOnOffCallback(aEndpointId, apCommandObj); break; } default: { // Unrecognized command ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::LevelControl::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, - Protocols::SecureChannel::Id, - Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::LevelControl::Id); + ReportCommandUnsupported(apCommandObj, aEndpointId, Clusters::LevelControl::Id, aCommandId); return; } } @@ -2224,16 +2389,19 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::LevelControl::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::LevelControl::Id, aCommandId, (CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); } } @@ -2241,7 +2409,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En namespace NetworkCommissioning { -void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +void DispatchServerCommand(CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) { // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. @@ -2290,12 +2458,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - operationalDataset = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(operationalDataset); + break; case 1: TLVUnpackError = aDataTlv.Get(breadcrumb); break; @@ -2321,9 +2486,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterAddThreadNetworkCallback(apCommandObj, operationalDataset, - breadcrumb, timeoutMs); + wasHandled = emberAfNetworkCommissioningClusterAddThreadNetworkCallback(aEndpointId, apCommandObj, + operationalDataset, breadcrumb, timeoutMs); } break; } @@ -2362,18 +2526,12 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - ssid = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; - case 1: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - credentials = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(ssid); + break; + case 1: + TLVUnpackError = aDataTlv.Get(credentials); + break; case 2: TLVUnpackError = aDataTlv.Get(breadcrumb); break; @@ -2399,9 +2557,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(apCommandObj, ssid, credentials, breadcrumb, - timeoutMs); + wasHandled = emberAfNetworkCommissioningClusterAddWiFiNetworkCallback(aEndpointId, apCommandObj, ssid, credentials, + breadcrumb, timeoutMs); } break; } @@ -2439,12 +2596,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - networkID = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(networkID); + break; case 1: TLVUnpackError = aDataTlv.Get(breadcrumb); break; @@ -2470,9 +2624,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfNetworkCommissioningClusterDisableNetworkCallback(apCommandObj, networkID, breadcrumb, timeoutMs); + wasHandled = emberAfNetworkCommissioningClusterDisableNetworkCallback(aEndpointId, apCommandObj, networkID, + breadcrumb, timeoutMs); } break; } @@ -2510,12 +2663,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - networkID = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(networkID); + break; case 1: TLVUnpackError = aDataTlv.Get(breadcrumb); break; @@ -2541,9 +2691,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfNetworkCommissioningClusterEnableNetworkCallback(apCommandObj, networkID, breadcrumb, timeoutMs); + wasHandled = emberAfNetworkCommissioningClusterEnableNetworkCallback(aEndpointId, apCommandObj, networkID, + breadcrumb, timeoutMs); } break; } @@ -2601,8 +2750,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(apCommandObj, timeoutMs); + wasHandled = emberAfNetworkCommissioningClusterGetLastNetworkCommissioningResultCallback(aEndpointId, apCommandObj, + timeoutMs); } break; } @@ -2640,12 +2789,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - NetworkID = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(NetworkID); + break; case 1: TLVUnpackError = aDataTlv.Get(Breadcrumb); break; @@ -2671,9 +2817,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfNetworkCommissioningClusterRemoveNetworkCallback(apCommandObj, NetworkID, Breadcrumb, TimeoutMs); + wasHandled = emberAfNetworkCommissioningClusterRemoveNetworkCallback(aEndpointId, apCommandObj, NetworkID, + Breadcrumb, TimeoutMs); } break; } @@ -2711,12 +2856,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - ssid = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(ssid); + break; case 1: TLVUnpackError = aDataTlv.Get(breadcrumb); break; @@ -2742,8 +2884,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterScanNetworksCallback(apCommandObj, ssid, breadcrumb, timeoutMs); + wasHandled = + emberAfNetworkCommissioningClusterScanNetworksCallback(aEndpointId, apCommandObj, ssid, breadcrumb, timeoutMs); } break; } @@ -2781,12 +2923,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - operationalDataset = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(operationalDataset); + break; case 1: TLVUnpackError = aDataTlv.Get(breadcrumb); break; @@ -2812,9 +2951,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback(apCommandObj, operationalDataset, - breadcrumb, timeoutMs); + wasHandled = emberAfNetworkCommissioningClusterUpdateThreadNetworkCallback( + aEndpointId, apCommandObj, operationalDataset, breadcrumb, timeoutMs); } break; } @@ -2853,18 +2991,12 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - ssid = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; - case 1: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - credentials = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(ssid); + break; + case 1: + TLVUnpackError = aDataTlv.Get(credentials); + break; case 2: TLVUnpackError = aDataTlv.Get(breadcrumb); break; @@ -2890,22 +3022,14 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(apCommandObj, ssid, credentials, - breadcrumb, timeoutMs); + wasHandled = emberAfNetworkCommissioningClusterUpdateWiFiNetworkCallback(aEndpointId, apCommandObj, ssid, + credentials, breadcrumb, timeoutMs); } break; } default: { // Unrecognized command ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::NetworkCommissioning::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, - Protocols::SecureChannel::Id, - Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::NetworkCommissioning::Id); + ReportCommandUnsupported(apCommandObj, aEndpointId, Clusters::NetworkCommissioning::Id, aCommandId); return; } } @@ -2913,16 +3037,20 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::NetworkCommissioning::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::NetworkCommissioning::Id, aCommandId, + (CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); } } @@ -2930,7 +3058,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En namespace OnOff { -void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +void DispatchServerCommand(CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) { // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. @@ -2947,32 +3075,22 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En { case Clusters::OnOff::Commands::Ids::Off: { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOnOffClusterOffCallback(apCommandObj); + wasHandled = emberAfOnOffClusterOffCallback(aEndpointId, apCommandObj); break; } case Clusters::OnOff::Commands::Ids::On: { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOnOffClusterOnCallback(apCommandObj); + wasHandled = emberAfOnOffClusterOnCallback(aEndpointId, apCommandObj); break; } case Clusters::OnOff::Commands::Ids::Toggle: { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOnOffClusterToggleCallback(apCommandObj); + wasHandled = emberAfOnOffClusterToggleCallback(aEndpointId, apCommandObj); break; } default: { // Unrecognized command ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::OnOff::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, - Protocols::SecureChannel::Id, - Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::OnOff::Id); + ReportCommandUnsupported(apCommandObj, aEndpointId, Clusters::OnOff::Id, aCommandId); return; } } @@ -2980,16 +3098,19 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::OnOff::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::OnOff::Id, aCommandId, (CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); } } @@ -2997,7 +3118,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En namespace OperationalCredentials { -void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +void DispatchServerCommand(CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) { // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. @@ -3012,7 +3133,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En { switch (aCommandId) { - case Clusters::OperationalCredentials::Commands::Ids::AddOpCert: { + case Clusters::OperationalCredentials::Commands::Ids::AddNOC: { expectArgumentCount = 4; chip::ByteSpan NOCArray; chip::ByteSpan IPKValue; @@ -3047,18 +3168,12 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - NOCArray = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; - case 1: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - IPKValue = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(NOCArray); + break; + case 1: + TLVUnpackError = aDataTlv.Get(IPKValue); + break; case 2: TLVUnpackError = aDataTlv.Get(CaseAdminNode); break; @@ -3084,9 +3199,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 4 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterAddOpCertCallback(apCommandObj, NOCArray, IPKValue, CaseAdminNode, - AdminVendorId); + wasHandled = emberAfOperationalCredentialsClusterAddNOCCallback(aEndpointId, apCommandObj, NOCArray, IPKValue, + CaseAdminNode, AdminVendorId); } break; } @@ -3122,12 +3236,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - RootCertificate = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(RootCertificate); + break; default: // Unsupported tag, ignore it. ChipLogProgress(Zcl, "Unknown TLV tag during processing."); @@ -3147,8 +3258,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterAddTrustedRootCertificateCallback(apCommandObj, RootCertificate); + wasHandled = emberAfOperationalCredentialsClusterAddTrustedRootCertificateCallback(aEndpointId, apCommandObj, + RootCertificate); } break; } @@ -3184,12 +3295,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En } switch (currentDecodeTagId) { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - CSRNonce = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; + case 0: + TLVUnpackError = aDataTlv.Get(CSRNonce); + break; default: // Unsupported tag, ignore it. ChipLogProgress(Zcl, "Unknown TLV tag during processing."); @@ -3209,23 +3317,14 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterOpCSRRequestCallback(apCommandObj, CSRNonce); + wasHandled = emberAfOperationalCredentialsClusterOpCSRRequestCallback(aEndpointId, apCommandObj, CSRNonce); } break; } - case Clusters::OperationalCredentials::Commands::Ids::RemoveAllFabrics: { - - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterRemoveAllFabricsCallback(apCommandObj); - break; - } case Clusters::OperationalCredentials::Commands::Ids::RemoveFabric: { - expectArgumentCount = 3; - chip::FabricId FabricId; - chip::NodeId NodeId; - uint16_t VendorId; - bool argExists[3]; + expectArgumentCount = 1; + uint8_t FabricIndex; + bool argExists[1]; memset(argExists, 0, sizeof argExists); @@ -3238,7 +3337,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En continue; } currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 3) + if (currentDecodeTagId < 1) { if (argExists[currentDecodeTagId]) { @@ -3255,13 +3354,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(FabricId); - break; - case 1: - TLVUnpackError = aDataTlv.Get(NodeId); - break; - case 2: - TLVUnpackError = aDataTlv.Get(VendorId); + TLVUnpackError = aDataTlv.Get(FabricIndex); break; default: // Unsupported tag, ignore it. @@ -3280,10 +3373,9 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En TLVError = CHIP_NO_ERROR; } - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 3 == validArgumentCount) + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterRemoveFabricCallback(apCommandObj, FabricId, NodeId, VendorId); + wasHandled = emberAfOperationalCredentialsClusterRemoveFabricCallback(aEndpointId, apCommandObj, FabricIndex); } break; } @@ -3294,69 +3386,6 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En memset(argExists, 0, sizeof argExists); - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) - { - // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. - // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. - if (!TLV::IsContextTag(aDataTlv.GetTag())) - { - continue; - } - currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); - if (currentDecodeTagId < 1) - { - if (argExists[currentDecodeTagId]) - { - ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); - TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; - break; - } - else - { - argExists[currentDecodeTagId] = true; - validArgumentCount++; - } - } - switch (currentDecodeTagId) - { - case 0: { - const uint8_t * data = nullptr; - TLVUnpackError = aDataTlv.GetDataPtr(data); - TrustedRootIdentifier = chip::ByteSpan(data, aDataTlv.GetLength()); - } - break; - default: - // Unsupported tag, ignore it. - ChipLogProgress(Zcl, "Unknown TLV tag during processing."); - break; - } - if (CHIP_NO_ERROR != TLVUnpackError) - { - break; - } - } - - if (CHIP_END_OF_TLV == TLVError) - { - // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. - TLVError = CHIP_NO_ERROR; - } - - if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) - { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfOperationalCredentialsClusterRemoveTrustedRootCertificateCallback(apCommandObj, TrustedRootIdentifier); - } - break; - } - case Clusters::OperationalCredentials::Commands::Ids::SetFabric: { - expectArgumentCount = 1; - uint16_t VendorId; - bool argExists[1]; - - memset(argExists, 0, sizeof argExists); - while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) { // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. @@ -3383,7 +3412,7 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En switch (currentDecodeTagId) { case 0: - TLVUnpackError = aDataTlv.Get(VendorId); + TLVUnpackError = aDataTlv.Get(TrustedRootIdentifier); break; default: // Unsupported tag, ignore it. @@ -3404,8 +3433,8 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = emberAfOperationalCredentialsClusterSetFabricCallback(apCommandObj, VendorId); + wasHandled = emberAfOperationalCredentialsClusterRemoveTrustedRootCertificateCallback(aEndpointId, apCommandObj, + TrustedRootIdentifier); } break; } @@ -3464,22 +3493,72 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) { - // TODO(#5098) We should pass the Command Object and EndpointId to the cluster callbacks. - wasHandled = - emberAfOperationalCredentialsClusterUpdateFabricLabelCallback(apCommandObj, const_cast(Label)); + wasHandled = emberAfOperationalCredentialsClusterUpdateFabricLabelCallback(aEndpointId, apCommandObj, + const_cast(Label)); + } + break; + } + case Clusters::OperationalCredentials::Commands::Ids::UpdateNOC: { + expectArgumentCount = 1; + chip::ByteSpan NOCArray; + bool argExists[1]; + + memset(argExists, 0, sizeof argExists); + + while ((TLVError = aDataTlv.Next()) == CHIP_NO_ERROR) + { + // Since call to aDataTlv.Next() is CHIP_NO_ERROR, the read head always points to an element. + // Skip this element if it is not a ContextTag, not consider it as an error if other values are valid. + if (!TLV::IsContextTag(aDataTlv.GetTag())) + { + continue; + } + currentDecodeTagId = TLV::TagNumFromTag(aDataTlv.GetTag()); + if (currentDecodeTagId < 1) + { + if (argExists[currentDecodeTagId]) + { + ChipLogProgress(Zcl, "Duplicate TLV tag %" PRIx32, TLV::TagNumFromTag(aDataTlv.GetTag())); + TLVUnpackError = CHIP_ERROR_IM_MALFORMED_COMMAND_DATA_ELEMENT; + break; + } + else + { + argExists[currentDecodeTagId] = true; + validArgumentCount++; + } + } + switch (currentDecodeTagId) + { + case 0: + TLVUnpackError = aDataTlv.Get(NOCArray); + break; + default: + // Unsupported tag, ignore it. + ChipLogProgress(Zcl, "Unknown TLV tag during processing."); + break; + } + if (CHIP_NO_ERROR != TLVUnpackError) + { + break; + } + } + + if (CHIP_END_OF_TLV == TLVError) + { + // CHIP_END_OF_TLV means we have iterated all items in the structure, which is not a real error. + TLVError = CHIP_NO_ERROR; + } + + if (CHIP_NO_ERROR == TLVError && CHIP_NO_ERROR == TLVUnpackError && 1 == validArgumentCount) + { + wasHandled = emberAfOperationalCredentialsClusterUpdateNOCCallback(aEndpointId, apCommandObj, NOCArray); } break; } default: { // Unrecognized command ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::OperationalCredentials::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; - apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, - Protocols::SecureChannel::Id, - Protocols::InteractionModel::ProtocolCode::UnsupportedCommand); - ChipLogError(Zcl, "Unknown command %" PRIx32 " for cluster %" PRIx32, aCommandId, Clusters::OperationalCredentials::Id); + ReportCommandUnsupported(apCommandObj, aEndpointId, Clusters::OperationalCredentials::Id, aCommandId); return; } } @@ -3487,33 +3566,91 @@ void DispatchServerCommand(app::Command * apCommandObj, CommandId aCommandId, En if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) { - chip::app::CommandPathParams returnStatusParam = { aEndpointId, - 0, // GroupId - Clusters::OperationalCredentials::Id, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::OperationalCredentials::Id, aCommandId, + (CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); ChipLogProgress(Zcl, "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, - validArgumentCount, expectArgumentCount, TLVError, TLVUnpackError, currentDecodeTagId); + validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); } } } // namespace OperationalCredentials +namespace WiFiNetworkDiagnostics { + +void DispatchServerCommand(CommandHandler * apCommandObj, CommandId aCommandId, EndpointId aEndpointId, TLV::TLVReader & aDataTlv) +{ + // We are using TLVUnpackError and TLVError here since both of them can be CHIP_END_OF_TLV + // When TLVError is CHIP_END_OF_TLV, it means we have iterated all of the items, which is not a real error. + // Any error value TLVUnpackError means we have received an illegal value. + // The following variables are used for all commands to save code size. + CHIP_ERROR TLVError = CHIP_NO_ERROR; + CHIP_ERROR TLVUnpackError = CHIP_NO_ERROR; + uint32_t validArgumentCount = 0; + uint32_t expectArgumentCount = 0; + uint32_t currentDecodeTagId = 0; + bool wasHandled = false; + { + switch (aCommandId) + { + case Clusters::WiFiNetworkDiagnostics::Commands::Ids::ResetCounts: { + + wasHandled = emberAfWiFiNetworkDiagnosticsClusterResetCountsCallback(aEndpointId, apCommandObj); + break; + } + default: { + // Unrecognized command ID, error status will apply. + ReportCommandUnsupported(apCommandObj, aEndpointId, Clusters::WiFiNetworkDiagnostics::Id, aCommandId); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || CHIP_NO_ERROR != TLVUnpackError || expectArgumentCount != validArgumentCount || !wasHandled) + { + CommandPathParams returnStatusParam = { aEndpointId, + 0, // GroupId + Clusters::WiFiNetworkDiagnostics::Id, aCommandId, + (CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kBadRequest, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogProgress(Zcl, + "Failed to dispatch command, %" PRIu32 "/%" PRIu32 " arguments parsed, TLVError=%" CHIP_ERROR_FORMAT + ", UnpackError=%" CHIP_ERROR_FORMAT " (last decoded tag = %" PRIu32, + validArgumentCount, expectArgumentCount, TLVError.Format(), TLVUnpackError.Format(), currentDecodeTagId); + // A command with no arguments would never write currentDecodeTagId. If + // progress logging is also disabled, it would look unused. Silence that + // warning. + UNUSED_VAR(currentDecodeTagId); + } +} + +} // namespace WiFiNetworkDiagnostics + } // namespace clusters -void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aCommandId, chip::EndpointId aEndPointId, - chip::TLV::TLVReader & aReader, Command * apCommandObj) +void DispatchSingleClusterCommand(ClusterId aClusterId, CommandId aCommandId, EndpointId aEndPointId, TLV::TLVReader & aReader, + CommandHandler * apCommandObj) { - ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx32 " Command=%" PRIx32 " Endpoint=%" PRIx16, aClusterId, - aCommandId, aEndPointId); + ChipLogDetail(Zcl, "Received Cluster Command: Cluster=" ChipLogFormatMEI " Command=" ChipLogFormatMEI " Endpoint=%" PRIx16, + ChipLogValueMEI(aClusterId), ChipLogValueMEI(aCommandId), aEndPointId); Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); TLV::TLVType dataTlvType; SuccessOrExit(aReader.EnterContainer(dataTlvType)); switch (aClusterId) { + case Clusters::AdministratorCommissioning::Id: + clusters::AdministratorCommissioning::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; case Clusters::ColorControl::Id: clusters::ColorControl::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; @@ -3532,12 +3669,14 @@ void DispatchSingleClusterCommand(chip::ClusterId aClusterId, chip::CommandId aC case Clusters::OperationalCredentials::Id: clusters::OperationalCredentials::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); break; + case Clusters::WiFiNetworkDiagnostics::Id: + clusters::WiFiNetworkDiagnostics::DispatchServerCommand(apCommandObj, aCommandId, aEndPointId, aReader); + break; default: // Unrecognized cluster ID, error status will apply. - chip::app::CommandPathParams returnStatusParam = { aEndPointId, - 0, // GroupId - aClusterId, aCommandId, - (chip::app::CommandPathFlags::kEndpointIdValid) }; + CommandPathParams returnStatusParam = { aEndPointId, + 0, // GroupId + aClusterId, aCommandId, (CommandPathFlags::kEndpointIdValid) }; apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); ChipLogError(Zcl, "Unknown cluster %" PRIx32, aClusterId); @@ -3548,5 +3687,30 @@ exit: aReader.ExitContainer(dataTlvType); } +void DispatchSingleClusterResponseCommand(ClusterId aClusterId, CommandId aCommandId, EndpointId aEndPointId, + TLV::TLVReader & aReader, CommandSender * apCommandObj) +{ + ChipLogDetail(Zcl, "Received Cluster Command: Cluster=%" PRIx32 " Command=%" PRIx32 " Endpoint=%" PRIx16, aClusterId, + aCommandId, aEndPointId); + Compatibility::SetupEmberAfObjects(apCommandObj, aClusterId, aCommandId, aEndPointId); + TLV::TLVType dataTlvType; + SuccessOrExit(aReader.EnterContainer(dataTlvType)); + switch (aClusterId) + { + default: + // Unrecognized cluster ID, error status will apply. + CommandPathParams returnStatusParam = { aEndPointId, + 0, // GroupId + aClusterId, aCommandId, (CommandPathFlags::kEndpointIdValid) }; + apCommandObj->AddStatusCode(returnStatusParam, Protocols::SecureChannel::GeneralStatusCode::kNotFound, + Protocols::SecureChannel::Id, Protocols::InteractionModel::ProtocolCode::InvalidCommand); + ChipLogError(Zcl, "Unknown cluster " ChipLogFormatMEI, ChipLogValueMEI(aClusterId)); + break; + } +exit: + Compatibility::ResetEmberAfObjects(); + aReader.ExitContainer(dataTlvType); +} + } // namespace app } // namespace chip diff --git a/examples/rainmaker_light/main/gen/af-gen-event.h b/examples/rainmaker_light/main/zap-generated/af-gen-event.h similarity index 100% rename from examples/rainmaker_light/main/gen/af-gen-event.h rename to examples/rainmaker_light/main/zap-generated/af-gen-event.h diff --git a/examples/light/main/gen/attribute-size.cpp b/examples/rainmaker_light/main/zap-generated/attribute-size.cpp similarity index 74% rename from examples/light/main/gen/attribute-size.cpp rename to examples/rainmaker_light/main/zap-generated/attribute-size.cpp index 97e2effb1..6a5f759d4 100644 --- a/examples/light/main/gen/attribute-size.cpp +++ b/examples/rainmaker_light/main/zap-generated/attribute-size.cpp @@ -69,7 +69,7 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo return kSizeLengthInBytes; } - if (!chip::CanCastTo(index)) + if (!CanCastTo(index)) { ChipLogError(Zcl, "Index %" PRId32 " is invalid. Should be between 1 and 65534", index); return 0; @@ -78,6 +78,30 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo uint16_t entryLength = 0; switch (clusterId) { + case 0x0030: // General Commissioning Cluster + { + uint16_t entryOffset = kSizeLengthInBytes; + switch (am->attributeId) + { + case 0x0001: // BasicCommissioningInfoList + { + entryLength = 4; + if (((index - 1) * entryLength) > (am->size - entryLength)) + { + ChipLogError(Zcl, "Index %" PRId32 " is invalid.", index); + return 0; + } + entryOffset = static_cast(entryOffset + ((index - 1) * entryLength)); + // Struct _BasicCommissioningInfoType + _BasicCommissioningInfoType * entry = reinterpret_cast<_BasicCommissioningInfoType *>(write ? src : dest); + copyListMember(write ? dest : (uint8_t *) &entry->FailSafeExpiryLengthMs, + write ? (uint8_t *) &entry->FailSafeExpiryLengthMs : src, write, &entryOffset, + sizeof(entry->FailSafeExpiryLengthMs)); // INT32U + break; + } + } + break; + } case 0x003E: // Operational Credentials Cluster { uint16_t entryOffset = kSizeLengthInBytes; @@ -99,8 +123,8 @@ uint16_t emberAfCopyList(ClusterId clusterId, EmberAfAttributeMetadata * am, boo copyListMember(write ? dest : (uint8_t *) &entry->VendorId, write ? (uint8_t *) &entry->VendorId : src, write, &entryOffset, sizeof(entry->VendorId)); // INT16U copyListMember(write ? dest : (uint8_t *) &entry->NodeId, write ? (uint8_t *) &entry->NodeId : src, write, &entryOffset, - sizeof(entry->NodeId)); // NODE_ID - chip::ByteSpan * LabelSpan = &entry->Label; // OCTET_STRING + sizeof(entry->NodeId)); // NODE_ID + ByteSpan * LabelSpan = &entry->Label; // OCTET_STRING if (CHIP_NO_ERROR != (write ? WriteByteSpan(dest + entryOffset, 34, LabelSpan) : ReadByteSpan(src + entryOffset, 34, LabelSpan))) { @@ -132,6 +156,15 @@ uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attribut uint16_t entryLength = 0; switch (clusterId) { + case 0x0030: // General Commissioning Cluster + switch (attributeId) + { + case 0x0001: // BasicCommissioningInfoList + // Struct _BasicCommissioningInfoType + entryLength = 4; + break; + } + break; case 0x003E: // Operational Credentials Cluster switch (attributeId) { @@ -144,9 +177,10 @@ uint16_t emberAfAttributeValueListSize(ClusterId clusterId, AttributeId attribut } uint32_t totalSize = kSizeLengthInBytes + (entryCount * entryLength); - if (!chip::CanCastTo(totalSize)) + if (!CanCastTo(totalSize)) { - ChipLogError(Zcl, "Cluster %" PRIx32 ": Size of attribute %" PRIx32 " is too large.", clusterId, attributeId); + ChipLogError(Zcl, "Cluster " ChipLogFormatMEI ": Size of attribute " ChipLogFormatMEI " is too large.", + ChipLogValueMEI(clusterId), ChipLogValueMEI(attributeId)); return 0; } diff --git a/examples/light/main/gen/callback-stub.cpp b/examples/rainmaker_light/main/zap-generated/callback-stub.cpp similarity index 97% rename from examples/light/main/gen/callback-stub.cpp rename to examples/rainmaker_light/main/zap-generated/callback-stub.cpp index 6d93baaae..bad51ab7a 100644 --- a/examples/light/main/gen/callback-stub.cpp +++ b/examples/rainmaker_light/main/zap-generated/callback-stub.cpp @@ -28,6 +28,9 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) { switch (clusterId) { + case ZCL_ADMINISTRATOR_COMMISSIONING_CLUSTER_ID: + emberAfAdministratorCommissioningClusterInitCallback(endpoint); + break; case ZCL_BASIC_CLUSTER_ID: emberAfBasicClusterInitCallback(endpoint); break; @@ -58,6 +61,11 @@ void emberAfClusterInitCallback(EndpointId endpoint, ClusterId clusterId) } } +void __attribute__((weak)) emberAfAdministratorCommissioningClusterInitCallback(EndpointId endpoint) +{ + // To prevent warning + (void) endpoint; +} void __attribute__((weak)) emberAfBasicClusterInitCallback(EndpointId endpoint) { // To prevent warning @@ -475,22 +483,6 @@ emberAfExternalAttributeReadCallback(EndpointId endpoint, ClusterId clusterId, E return EMBER_ZCL_STATUS_FAILURE; } -/** @brief Write Attributes Response - * - * This function is called by the application framework when a Write Attributes - * Response command is received from an external device. The application should - * return true if the message was processed or false if it was not. - * - * @param clusterId The cluster identifier of this response. Ver.: always - * @param buffer Buffer containing the list of write attribute status records. - * Ver.: always - * @param bufLen The length in bytes of the list. Ver.: always - */ -bool __attribute__((weak)) emberAfWriteAttributesResponseCallback(ClusterId clusterId, uint8_t * buffer, uint16_t bufLen) -{ - return false; -} - /** @brief External Attribute Write * * This function is called whenever the Application Framework needs to write an diff --git a/examples/rainmaker_light/main/gen/callback.h b/examples/rainmaker_light/main/zap-generated/callback.h similarity index 100% rename from examples/rainmaker_light/main/gen/callback.h rename to examples/rainmaker_light/main/zap-generated/callback.h diff --git a/examples/light/main/gen/CHIPClusters.cpp b/examples/rainmaker_light/main/zap-generated/chip-zcl-zpro-codec-api.h similarity index 60% rename from examples/light/main/gen/CHIPClusters.cpp rename to examples/rainmaker_light/main/zap-generated/chip-zcl-zpro-codec-api.h index 2913d05ab..759d13c50 100644 --- a/examples/light/main/gen/CHIPClusters.cpp +++ b/examples/rainmaker_light/main/zap-generated/chip-zcl-zpro-codec-api.h @@ -16,20 +16,3 @@ */ // THIS FILE IS GENERATED BY ZAP -#include "CHIPClusters.h" - -#include - -#include "chip-zcl-zpro-codec-api.h" -#include -#include - -namespace chip { -namespace Controller { - -// TODO(#4502): onCompletion is not used by IM for now. -// TODO(#4503): length should be passed to commands when byte string is in argument list. -// TODO(#4503): Commands should take group id as an argument. - -} // namespace Controller -} // namespace chip diff --git a/examples/rainmaker_light/main/gen/CHIPClusters.cpp b/examples/rainmaker_light/main/zap-generated/encoder.cpp similarity index 60% rename from examples/rainmaker_light/main/gen/CHIPClusters.cpp rename to examples/rainmaker_light/main/zap-generated/encoder.cpp index 2913d05ab..759d13c50 100644 --- a/examples/rainmaker_light/main/gen/CHIPClusters.cpp +++ b/examples/rainmaker_light/main/zap-generated/encoder.cpp @@ -16,20 +16,3 @@ */ // THIS FILE IS GENERATED BY ZAP -#include "CHIPClusters.h" - -#include - -#include "chip-zcl-zpro-codec-api.h" -#include -#include - -namespace chip { -namespace Controller { - -// TODO(#4502): onCompletion is not used by IM for now. -// TODO(#4503): length should be passed to commands when byte string is in argument list. -// TODO(#4503): Commands should take group id as an argument. - -} // namespace Controller -} // namespace chip diff --git a/examples/rainmaker_light/main/gen/endpoint_config.h b/examples/rainmaker_light/main/zap-generated/endpoint_config.h similarity index 88% rename from examples/rainmaker_light/main/gen/endpoint_config.h rename to examples/rainmaker_light/main/zap-generated/endpoint_config.h index 466148aff..a8a7f39cf 100644 --- a/examples/rainmaker_light/main/gen/endpoint_config.h +++ b/examples/rainmaker_light/main/zap-generated/endpoint_config.h @@ -91,20 +91,33 @@ \ /* Endpoint: 0, Cluster: General Commissioning (server), big-endian */ \ \ - /* 628 - FabricId, */ \ - 1, 'o', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - \ - /* 636 - Breadcrumb, */ \ + /* 628 - Breadcrumb, */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ \ + /* 636 - BasicCommissioningInfoList, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ /* Endpoint: 0, Cluster: WiFi Network Diagnostics (server), big-endian */ \ \ - /* 644 - bssid, */ \ + /* 890 - bssid, */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ \ /* Endpoint: 0, Cluster: Operational Credentials (server), big-endian */ \ \ - /* 650 - fabrics list, */ \ + /* 896 - fabrics list, */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ @@ -189,20 +202,33 @@ \ /* Endpoint: 0, Cluster: General Commissioning (server), little-endian */ \ \ - /* 628 - FabricId, */ \ - 1, 'o', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ - \ - /* 636 - Breadcrumb, */ \ + /* 628 - Breadcrumb, */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ \ + /* 636 - BasicCommissioningInfoList, */ \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ + \ /* Endpoint: 0, Cluster: WiFi Network Diagnostics (server), little-endian */ \ \ - /* 644 - bssid, */ \ + /* 890 - bssid, */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ \ /* Endpoint: 0, Cluster: Operational Credentials (server), little-endian */ \ \ - /* 650 - fabrics list, */ \ + /* 896 - fabrics list, */ \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \ @@ -249,7 +275,7 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 64 +#define GENERATED_ATTRIBUTE_COUNT 67 #define GENERATED_ATTRIBUTES \ { \ \ @@ -278,42 +304,47 @@ { 0x0010, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(SINGLETON) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ ZAP_SIMPLE_DEFAULT(0) }, /* LocalConfigDisabled */ \ { 0x0011, ZAP_TYPE(BOOLEAN), 1, ZAP_ATTRIBUTE_MASK(SINGLETON), ZAP_SIMPLE_DEFAULT(1) }, /* Reachable */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), ZAP_SIMPLE_DEFAULT(3) }, /* cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(SINGLETON), ZAP_SIMPLE_DEFAULT(3) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: General Commissioning (server) */ \ - { 0x0000, ZAP_TYPE(OCTET_STRING), 8, 0, ZAP_LONG_DEFAULTS_INDEX(628) }, /* FabricId */ \ - { 0x0001, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_LONG_DEFAULTS_INDEX(636) }, /* Breadcrumb */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ + { 0x0000, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_LONG_DEFAULTS_INDEX(628) }, /* Breadcrumb */ \ + { 0x0001, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(636) }, /* BasicCommissioningInfoList */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Network Commissioning (server) */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: WiFi Network Diagnostics (server) */ \ - { 0x0000, ZAP_TYPE(OCTET_STRING), 6, 0, ZAP_LONG_DEFAULTS_INDEX(644) }, /* bssid */ \ + { 0x0000, ZAP_TYPE(OCTET_STRING), 6, 0, ZAP_LONG_DEFAULTS_INDEX(890) }, /* bssid */ \ { 0x0001, ZAP_TYPE(ENUM8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* SecurityType */ \ { 0x0002, ZAP_TYPE(ENUM8), 1, 0, ZAP_EMPTY_DEFAULT() }, /* WiFiVersion */ \ { 0x0003, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0000) }, /* ChannelNumber */ \ { 0x0004, ZAP_TYPE(INT8S), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* Rssi */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ + \ + /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Operational Credentials (server) */ \ - { 0x0001, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(650) }, /* fabrics list */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* cluster revision */ \ + { 0x0001, ZAP_TYPE(ARRAY), 254, 0, ZAP_LONG_DEFAULTS_INDEX(896) }, /* fabrics list */ \ + { 0x0002, ZAP_TYPE(INT8U), 1, 0, ZAP_EMPTY_DEFAULT() }, /* SupportedFabrics */ \ + { 0x0003, ZAP_TYPE(INT8U), 1, 0, ZAP_EMPTY_DEFAULT() }, /* CommissionedFabrics */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ - /* Endpoint: 1, Cluster: On/off (server) */ \ - { 0x0000, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* on/off */ \ - { 0x4000, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x01) }, /* global scene control */ \ - { 0x4001, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* on time */ \ - { 0x4002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* off wait time */ \ - { 0x4003, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_EMPTY_DEFAULT() }, /* start up on off */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(2) }, /* cluster revision */ \ + /* Endpoint: 1, Cluster: On/Off (server) */ \ + { 0x0000, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* OnOff */ \ + { 0x4000, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(0x01) }, /* GlobalSceneControl */ \ + { 0x4001, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* OnTime */ \ + { 0x4002, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x0000) }, /* OffWaitTime */ \ + { 0x4003, ZAP_TYPE(ENUM8), 1, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_EMPTY_DEFAULT() }, /* StartUpOnOff */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(2) }, /* ClusterRevision */ \ \ /* Endpoint: 1, Cluster: Level Control (server) */ \ { 0x0000, ZAP_TYPE(INT8U), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* current level */ \ { 0x0001, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0000) }, /* remaining time */ \ { 0x000F, ZAP_TYPE(BITMAP8), 1, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_SIMPLE_DEFAULT(0x00) }, /* options */ \ { 0x4000, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_EMPTY_DEFAULT() }, /* start up current level */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(3) }, /* cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(3) }, /* ClusterRevision */ \ \ /* Endpoint: 1, Cluster: Color Control (server) */ \ { 0x0000, ZAP_TYPE(INT8U), 1, 0, ZAP_SIMPLE_DEFAULT(0x00) }, /* current hue */ \ @@ -338,7 +369,7 @@ { 0x400D, ZAP_TYPE(INT16U), 2, 0, ZAP_EMPTY_DEFAULT() }, /* couple color temp to level min-mireds */ \ { 0x4010, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(WRITABLE), \ ZAP_EMPTY_DEFAULT() }, /* start up color temperature mireds */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(3) }, /* cluster revision */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(3) }, /* ClusterRevision */ \ } // This is an array of EmberAfCluster structures. @@ -360,7 +391,7 @@ }; #define ZAP_CLUSTER_MASK(mask) CLUSTER_MASK_##mask -#define GENERATED_CLUSTER_COUNT 8 +#define GENERATED_CLUSTER_COUNT 9 #define GENERATED_CLUSTERS \ { \ { 0x0028, \ @@ -370,7 +401,7 @@ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayBasicServer }, /* Endpoint: 0, Cluster: Basic (server) */ \ { \ - 0x0030, ZAP_ATTRIBUTE_INDEX(19), 3, 18, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0030, ZAP_ATTRIBUTE_INDEX(19), 3, 264, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: General Commissioning (server) */ \ { \ 0x0031, ZAP_ATTRIBUTE_INDEX(22), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ @@ -379,22 +410,25 @@ 0x0036, ZAP_ATTRIBUTE_INDEX(23), 6, 13, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: WiFi Network Diagnostics (server) */ \ { \ - 0x003E, ZAP_ATTRIBUTE_INDEX(29), 2, 256, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x003C, ZAP_ATTRIBUTE_INDEX(29), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + }, /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ + { \ + 0x003E, ZAP_ATTRIBUTE_INDEX(30), 4, 258, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: Operational Credentials (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(31), \ + ZAP_ATTRIBUTE_INDEX(34), \ 6, \ 9, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ - chipFuncArrayOnOffServer }, /* Endpoint: 1, Cluster: On/off (server) */ \ + chipFuncArrayOnOffServer }, /* Endpoint: 1, Cluster: On/Off (server) */ \ { 0x0008, \ - ZAP_ATTRIBUTE_INDEX(37), \ + ZAP_ATTRIBUTE_INDEX(40), \ 5, \ 7, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayLevelControlServer }, /* Endpoint: 1, Cluster: Level Control (server) */ \ { 0x0300, \ - ZAP_ATTRIBUTE_INDEX(42), \ + ZAP_ATTRIBUTE_INDEX(45), \ 22, \ 36, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ @@ -406,7 +440,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 5, 931 }, { ZAP_CLUSTER_INDEX(5), 3, 52 }, \ + { ZAP_CLUSTER_INDEX(0), 6, 1181 }, { ZAP_CLUSTER_INDEX(6), 3, 52 }, \ } // Largest attribute size is needed for various buffers @@ -416,7 +450,7 @@ #define ATTRIBUTE_SINGLETONS_SIZE (642) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (983) +#define ATTRIBUTE_MAX_SIZE (1233) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (2) @@ -460,7 +494,7 @@ // Array of EmberAfCommandMetadata structs. #define ZAP_COMMAND_MASK(mask) COMMAND_MASK_##mask -#define EMBER_AF_GENERATED_COMMAND_COUNT (70) +#define EMBER_AF_GENERATED_COMMAND_COUNT (72) #define GENERATED_COMMANDS \ { \ \ @@ -496,20 +530,26 @@ { 0x0031, 0x0F, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* DisableNetworkResponse */ \ { 0x0031, 0x10, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* GetLastNetworkCommissioningResult */ \ \ + /* Endpoint: 0, Cluster: WiFi Network Diagnostics (server) */ \ + { 0x0036, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* ResetCounts */ \ + \ + /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ + { 0x003C, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* OpenCommissioningWindow */ \ + { 0x003C, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* OpenBasicCommissioningWindow */ \ + { 0x003C, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RevokeCommissioning */ \ + \ /* Endpoint: 0, Cluster: Operational Credentials (server) */ \ - { 0x003E, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* SetFabric */ \ - { 0x003E, 0x01, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* SetFabricResponse */ \ { 0x003E, 0x04, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* OpCSRRequest */ \ { 0x003E, 0x05, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* OpCSRResponse */ \ - { 0x003E, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* AddOpCert */ \ - { 0x003E, 0x08, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* OpCertResponse */ \ + { 0x003E, 0x06, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* AddNOC */ \ + { 0x003E, 0x07, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* UpdateNOC */ \ + { 0x003E, 0x08, ZAP_COMMAND_MASK(INCOMING_CLIENT) }, /* NOCResponse */ \ { 0x003E, 0x09, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* UpdateFabricLabel */ \ { 0x003E, 0x0A, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveFabric */ \ - { 0x003E, 0x0B, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveAllFabrics */ \ - { 0x003E, 0xA1, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* AddTrustedRootCertificate */ \ - { 0x003E, 0xA2, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveTrustedRootCertificate */ \ + { 0x003E, 0x0B, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* AddTrustedRootCertificate */ \ + { 0x003E, 0x0C, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* RemoveTrustedRootCertificate */ \ \ - /* Endpoint: 1, Cluster: On/off (server) */ \ + /* Endpoint: 1, Cluster: On/Off (server) */ \ { 0x0006, 0x00, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Off */ \ { 0x0006, 0x01, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* On */ \ { 0x0006, 0x02, ZAP_COMMAND_MASK(INCOMING_SERVER) }, /* Toggle */ \ diff --git a/examples/rainmaker_light/main/gen/gen_config.h b/examples/rainmaker_light/main/zap-generated/gen_config.h similarity index 89% rename from examples/rainmaker_light/main/gen/gen_config.h rename to examples/rainmaker_light/main/zap-generated/gen_config.h index a4faf8dd2..deb00616e 100644 --- a/examples/rainmaker_light/main/gen/gen_config.h +++ b/examples/rainmaker_light/main/zap-generated/gen_config.h @@ -29,6 +29,7 @@ #define EMBER_APS_UNICAST_MESSAGE_COUNT 10 /**** Cluster endpoint counts ****/ +#define EMBER_AF_ADMINISTRATOR_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_BASIC_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_COLOR_CONTROL_CLUSTER_SERVER_ENDPOINT_COUNT (1) #define EMBER_AF_GENERAL_COMMISSIONING_CLUSTER_SERVER_ENDPOINT_COUNT (1) @@ -40,6 +41,11 @@ /**** Cluster Plugins ****/ +// Use this macro to check if the server side of the AdministratorCommissioning cluster is included +#define ZCL_USING_ADMINISTRATOR_COMMISSIONING_CLUSTER_SERVER +#define EMBER_AF_PLUGIN_ADMINISTRATOR_COMMISSIONING_SERVER +#define EMBER_AF_PLUGIN_ADMINISTRATOR_COMMISSIONING + // Use this macro to check if the server side of the Basic cluster is included #define ZCL_USING_BASIC_CLUSTER_SERVER #define EMBER_AF_PLUGIN_BASIC_SERVER @@ -73,7 +79,7 @@ #define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING_SERVER #define EMBER_AF_PLUGIN_NETWORK_COMMISSIONING -// Use this macro to check if the server side of the On/off cluster is included +// Use this macro to check if the server side of the On/Off cluster is included #define ZCL_USING_ON_OFF_CLUSTER_SERVER #define EMBER_AF_PLUGIN_ON_OFF_SERVER #define EMBER_AF_PLUGIN_ON_OFF diff --git a/examples/rainmaker_light/main/gen/gen_tokens.h b/examples/rainmaker_light/main/zap-generated/gen_tokens.h similarity index 100% rename from examples/rainmaker_light/main/gen/gen_tokens.h rename to examples/rainmaker_light/main/zap-generated/gen_tokens.h diff --git a/examples/rainmaker_light/sdkconfig.defaults b/examples/rainmaker_light/sdkconfig.defaults index 59362f807..3c7753d7b 100644 --- a/examples/rainmaker_light/sdkconfig.defaults +++ b/examples/rainmaker_light/sdkconfig.defaults @@ -29,3 +29,7 @@ CONFIG_MBEDTLS_DYNAMIC_FREE_CONFIG_DATA=y # Temporary Fix for Timer Overflows CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=3120 + +# Main task needs a bit more stack than the default +# default is 3584, bump this up to 5k. +CONFIG_ESP_MAIN_TASK_STACK_SIZE=5120