diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index db4fdf6ecc0a55..dc9e785fc8256e 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -1428,6 +1428,36 @@ } ], "attributes": [ + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "ClusterRevision", "code": 65533, @@ -1452,7 +1482,16 @@ "define": "OTA_REQUESTOR_CLUSTER", "side": "client", "enabled": 0, - "commands": [], + "commands": [ + { + "name": "AnnounceOtaProvider", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], "attributes": [ { "name": "ClusterRevision", @@ -1481,7 +1520,22 @@ "commands": [], "attributes": [ { - "name": "default ota provider", + "name": "DefaultOtaProviders", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "UpdatePossible", "code": 1, "mfgCode": null, "side": "server", @@ -1489,14 +1543,14 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "1", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "update possible", + "name": "UpdateState", "code": 2, "mfgCode": null, "side": "server", @@ -1504,12 +1558,57 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, + { + "name": "UpdateStateProgress", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "ClusterRevision", "code": 65533, @@ -19660,5 +19759,6 @@ "endpointVersion": 1, "deviceIdentifier": 22 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/all-clusters-app/all-clusters-common/src/ota-requestor-stub.cpp b/examples/all-clusters-app/all-clusters-common/src/ota-requestor-stub.cpp new file mode 100644 index 00000000000000..ceff034374f750 --- /dev/null +++ b/examples/all-clusters-app/all-clusters-common/src/ota-requestor-stub.cpp @@ -0,0 +1,87 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +using namespace chip; +using namespace chip::app; +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::OtaSoftwareUpdateRequestor; + +namespace { + +class OtaSoftwareUpdateRequestorAttrAccess : public AttributeAccessInterface +{ +public: + // Register for the OTA Requestor Cluster on all endpoints. + OtaSoftwareUpdateRequestorAttrAccess() : + AttributeAccessInterface(Optional::Missing(), OtaSoftwareUpdateRequestor::Id) + {} + + CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; + CHIP_ERROR Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) override; +}; + +OtaSoftwareUpdateRequestorAttrAccess gAttrAccess; + +CHIP_ERROR OtaSoftwareUpdateRequestorAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) +{ + switch (aPath.mAttributeId) + { + case Attributes::DefaultOtaProviders::Id: + return aEncoder.Encode(DataModel::List()); + default: + break; + } + + return CHIP_NO_ERROR; +} + +CHIP_ERROR OtaSoftwareUpdateRequestorAttrAccess::Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) +{ + switch (aPath.mAttributeId) + { + case Attributes::DefaultOtaProviders::Id: { + DataModel::DecodableList list; + ReturnErrorOnFailure(aDecoder.Decode(list)); + break; + } + default: + break; + } + return CHIP_NO_ERROR; +} + +} // namespace + +bool emberAfOtaSoftwareUpdateRequestorClusterAnnounceOtaProviderCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::OtaSoftwareUpdateRequestor::Commands::AnnounceOtaProvider::DecodableType & commandData) +{ + return false; +} + +// ----------------------------------------------------------------------------- +// Plugin initialization + +void MatterOtaSoftwareUpdateRequestorPluginServerInitCallback(void) +{ + registerAttributeAccessOverride(&gAttrAccess); +} diff --git a/examples/all-clusters-app/ameba/chip_main.cmake b/examples/all-clusters-app/ameba/chip_main.cmake index db77f4bce9cd26..6f83d394ad9f39 100755 --- a/examples/all-clusters-app/ameba/chip_main.cmake +++ b/examples/all-clusters-app/ameba/chip_main.cmake @@ -19,6 +19,7 @@ list( ${chip_dir}/zzz_generated/all-clusters-app/zap-generated/CHIPClusters.cpp ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp + ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/ota-requestor-stub.cpp ${chip_dir}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp ${chip_dir}/examples/all-clusters-app/ameba/main/chipinterface.cpp diff --git a/examples/all-clusters-app/linux/BUILD.gn b/examples/all-clusters-app/linux/BUILD.gn index 351b79e8f5f316..f0558592bbde7d 100644 --- a/examples/all-clusters-app/linux/BUILD.gn +++ b/examples/all-clusters-app/linux/BUILD.gn @@ -18,6 +18,7 @@ import("//build_overrides/chip.gni") executable("chip-all-clusters-app") { sources = [ "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/ota-requestor-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", "include/tv-callbacks.cpp", "main.cpp", diff --git a/examples/all-clusters-app/mbed/CMakeLists.txt b/examples/all-clusters-app/mbed/CMakeLists.txt index 52231736125945..e2f809e5d30eac 100644 --- a/examples/all-clusters-app/mbed/CMakeLists.txt +++ b/examples/all-clusters-app/mbed/CMakeLists.txt @@ -68,6 +68,7 @@ target_sources(${APP_TARGET} PRIVATE ${CHIP_ROOT}/src/app/server/CommissioningWindowManager.cpp ${CHIP_ROOT}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp + ${CHIP_ROOT}/examples/all-clusters-app/all-clusters-common/src/ota-requestor-stub.cpp ${CHIP_ROOT}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp ${APP_UTIL}/DataModelHandler.cpp diff --git a/examples/all-clusters-app/p6/BUILD.gn b/examples/all-clusters-app/p6/BUILD.gn index 5b99c3f3b3b6f6..ccd4ac152789de 100644 --- a/examples/all-clusters-app/p6/BUILD.gn +++ b/examples/all-clusters-app/p6/BUILD.gn @@ -61,6 +61,7 @@ p6_executable("clusters_app") { sources = [ "${chip_root}/examples/all-clusters-app/all-clusters-common/src/bridged-actions-stub.cpp", + "${chip_root}/examples/all-clusters-app/all-clusters-common/src/ota-requestor-stub.cpp", "${chip_root}/examples/all-clusters-app/all-clusters-common/src/static-supported-modes-manager.cpp", "${examples_plat_dir}/LEDWidget.cpp", "${examples_plat_dir}/init_p6Platform.cpp", diff --git a/examples/ota-requestor-app/ota-requestor-common/BUILD.gn b/examples/ota-requestor-app/ota-requestor-common/BUILD.gn index 44b115461860d4..1d5d7bf413cd30 100644 --- a/examples/ota-requestor-app/ota-requestor-common/BUILD.gn +++ b/examples/ota-requestor-app/ota-requestor-common/BUILD.gn @@ -33,8 +33,8 @@ chip_data_model("ota-requestor-common") { sources = [ "${chip_root}/src/app/clusters/ota-requestor/BDXDownloader.cpp", "${chip_root}/src/app/clusters/ota-requestor/BDXDownloader.h", - "${chip_root}/src/app/clusters/ota-requestor/ClusterInterface.cpp", "${chip_root}/src/app/clusters/ota-requestor/OTARequestor.cpp", + "${chip_root}/src/app/clusters/ota-requestor/ota-requestor-server.cpp", ] is_server = true diff --git a/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.zap b/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.zap index 6e13613ab83e9e..9cb1e4a6837e87 100644 --- a/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.zap +++ b/examples/ota-requestor-app/ota-requestor-common/ota-requestor-app.zap @@ -1100,7 +1100,22 @@ "commands": [], "attributes": [ { - "name": "default ota provider", + "name": "DefaultOtaProviders", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "UpdatePossible", "code": 1, "mfgCode": null, "side": "server", @@ -1108,14 +1123,14 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "1", "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 }, { - "name": "update possible", + "name": "UpdateState", "code": 2, "mfgCode": null, "side": "server", @@ -1123,12 +1138,57 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "UpdateStateProgress", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", "reportable": 1, "minInterval": 1, "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "AttributeList", + "code": 65531, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "server", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "ClusterRevision", "code": 65533, diff --git a/examples/thermostat/thermostat-common/thermostat.zap b/examples/thermostat/thermostat-common/thermostat.zap index 72a105e2ef979a..c2a6032ef7efa6 100644 --- a/examples/thermostat/thermostat-common/thermostat.zap +++ b/examples/thermostat/thermostat-common/thermostat.zap @@ -4068,7 +4068,7 @@ "commands": [], "attributes": [ { - "name": "groups", + "name": "groupKeyMap", "code": 0, "mfgCode": null, "side": "server", @@ -4083,7 +4083,7 @@ "reportableChange": 0 }, { - "name": "group keys", + "name": "groupTable", "code": 1, "mfgCode": null, "side": "server", @@ -8938,7 +8938,7 @@ "commands": [], "attributes": [ { - "name": "groups", + "name": "groupKeyMap", "code": 0, "mfgCode": null, "side": "server", @@ -8953,7 +8953,7 @@ "reportableChange": 0 }, { - "name": "group keys", + "name": "groupTable", "code": 1, "mfgCode": null, "side": "server", diff --git a/examples/tv-app/tv-common/tv-app.zap b/examples/tv-app/tv-common/tv-app.zap index 0597f0a333dd27..fb854cdb7ff74b 100644 --- a/examples/tv-app/tv-common/tv-app.zap +++ b/examples/tv-app/tv-common/tv-app.zap @@ -4083,7 +4083,7 @@ "commands": [], "attributes": [ { - "name": "groups", + "name": "groupKeyMap", "code": 0, "mfgCode": null, "side": "server", @@ -4098,7 +4098,7 @@ "reportableChange": 0 }, { - "name": "group keys", + "name": "groupTable", "code": 1, "mfgCode": null, "side": "server", diff --git a/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap b/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap index 4a41c7eead8a24..9161a35cfdfe63 100644 --- a/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap +++ b/examples/tv-casting-app/tv-casting-common/tv-casting-app.zap @@ -4068,7 +4068,7 @@ "commands": [], "attributes": [ { - "name": "groups", + "name": "groupKeyMap", "code": 0, "mfgCode": null, "side": "server", @@ -4083,7 +4083,7 @@ "reportableChange": 0 }, { - "name": "group keys", + "name": "groupTable", "code": 1, "mfgCode": null, "side": "server", @@ -8770,7 +8770,7 @@ "commands": [], "attributes": [ { - "name": "groups", + "name": "groupKeyMap", "code": 0, "mfgCode": null, "side": "server", @@ -8785,7 +8785,7 @@ "reportableChange": 0 }, { - "name": "group keys", + "name": "groupTable", "code": 1, "mfgCode": null, "side": "server", diff --git a/src/app/AttributeAccessInterface.h b/src/app/AttributeAccessInterface.h index 259d2ad1d3c920..4b0ad05dcf456d 100644 --- a/src/app/AttributeAccessInterface.h +++ b/src/app/AttributeAccessInterface.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include diff --git a/src/app/clusters/ota-requestor/ClusterInterface.cpp b/src/app/clusters/ota-requestor/ClusterInterface.cpp deleted file mode 100644 index 8ae3958a5108b0..00000000000000 --- a/src/app/clusters/ota-requestor/ClusterInterface.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* This file contains the glue code for passing the incoming OTA Requestor cluster commands - * to the OTA Requestor object that handles them - */ - -#include -#include - -// OTA Software Update Requestor Cluster AnnounceOtaProvider Command callback -bool emberAfOtaSoftwareUpdateRequestorClusterAnnounceOtaProviderCallback( - chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, - const chip::app::Clusters::OtaSoftwareUpdateRequestor::Commands::AnnounceOtaProvider::DecodableType & commandData) -{ - EmberAfStatus status; - chip::OTARequestorInterface * requestor = chip::GetRequestorInstance(); - - if (requestor != nullptr) - { - status = requestor->HandleAnnounceOTAProvider(commandObj, commandPath, commandData); - } - else - { - status = EMBER_ZCL_STATUS_FAILURE; - } - - emberAfSendImmediateDefaultResponse(status); - return true; -} - -// TBD for now. Not clear what is the API for registering a command response handler -/* Callbacks for QueryImage response */ -// Callback mQueryImageResponseCallback(QueryImageResponseHandler, -// nullptr); - -// void QueryImageResponseHandler(void * context, const QueryImageResponse::DecodableType & response) -//{ } diff --git a/src/app/clusters/ota-requestor/OTARequestor.cpp b/src/app/clusters/ota-requestor/OTARequestor.cpp index 8772bd6229e9cb..f1eac9912a9b25 100644 --- a/src/app/clusters/ota-requestor/OTARequestor.cpp +++ b/src/app/clusters/ota-requestor/OTARequestor.cpp @@ -183,7 +183,7 @@ EmberAfStatus OTARequestor::HandleAnnounceOTAProvider(app::CommandHandler * comm const app::ConcreteCommandPath & commandPath, const AnnounceOtaProvider::DecodableType & commandData) { - auto & providerLocation = commandData.providerLocation; + auto & providerNodeId = commandData.providerNodeId; auto & announcementReason = commandData.announcementReason; if (commandObj == nullptr || commandObj->GetExchangeContext() == nullptr) @@ -192,7 +192,7 @@ EmberAfStatus OTARequestor::HandleAnnounceOTAProvider(app::CommandHandler * comm return EMBER_ZCL_STATUS_FAILURE; } - mProviderNodeId = providerLocation; + mProviderNodeId = providerNodeId; mProviderFabricIndex = commandObj->GetExchangeContext()->GetSessionHandle().GetFabricIndex(); ChipLogProgress(SoftwareUpdate, "OTA Requestor received AnnounceOTAProvider"); diff --git a/src/app/clusters/ota-requestor/ota-requestor-server.cpp b/src/app/clusters/ota-requestor/ota-requestor-server.cpp new file mode 100644 index 00000000000000..a38957ad3cd30b --- /dev/null +++ b/src/app/clusters/ota-requestor/ota-requestor-server.cpp @@ -0,0 +1,107 @@ +/* + * + * Copyright (c) 2021 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* This file contains the glue code for passing the incoming OTA Requestor cluster commands + * to the OTA Requestor object that handles them + */ + +#include +#include +#include +#include + +using namespace chip; +using namespace chip::app; +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::OtaSoftwareUpdateRequestor; + +namespace { + +class OtaSoftwareUpdateRequestorAttrAccess : public AttributeAccessInterface +{ +public: + // Register for the OTA Requestor Cluster on all endpoints. + OtaSoftwareUpdateRequestorAttrAccess() : + AttributeAccessInterface(Optional::Missing(), OtaSoftwareUpdateRequestor::Id) + {} + + // TODO: Implement Read/Write for OtaSoftwareUpdateRequestorAttrAccess + CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override; + CHIP_ERROR Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) override; +}; + +OtaSoftwareUpdateRequestorAttrAccess gAttrAccess; + +CHIP_ERROR OtaSoftwareUpdateRequestorAttrAccess::Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) +{ + switch (aPath.mAttributeId) + { + case Attributes::DefaultOtaProviders::Id: + return aEncoder.Encode(DataModel::List()); + default: + break; + } + + return CHIP_NO_ERROR; +} + +CHIP_ERROR OtaSoftwareUpdateRequestorAttrAccess::Write(const ConcreteDataAttributePath & aPath, AttributeValueDecoder & aDecoder) +{ + switch (aPath.mAttributeId) + { + case Attributes::DefaultOtaProviders::Id: { + DataModel::DecodableList list; + ReturnErrorOnFailure(aDecoder.Decode(list)); + // Ignore the list for now + break; + } + default: + break; + } + return CHIP_NO_ERROR; +} + +} // namespace + +bool emberAfOtaSoftwareUpdateRequestorClusterAnnounceOtaProviderCallback( + chip::app::CommandHandler * commandObj, const chip::app::ConcreteCommandPath & commandPath, + const chip::app::Clusters::OtaSoftwareUpdateRequestor::Commands::AnnounceOtaProvider::DecodableType & commandData) +{ + EmberAfStatus status; + chip::OTARequestorInterface * requestor = chip::GetRequestorInstance(); + + if (requestor != nullptr) + { + status = requestor->HandleAnnounceOTAProvider(commandObj, commandPath, commandData); + } + else + { + status = EMBER_ZCL_STATUS_FAILURE; + } + + emberAfSendImmediateDefaultResponse(status); + return true; +} + +// ----------------------------------------------------------------------------- +// Plugin initialization + +void MatterOtaSoftwareUpdateRequestorPluginServerInitCallback(void) +{ + registerAttributeAccessOverride(&gAttrAccess); +} diff --git a/src/app/util/util.cpp b/src/app/util/util.cpp index 4a99b32d53d890..6efe0a6398c75d 100644 --- a/src/app/util/util.cpp +++ b/src/app/util/util.cpp @@ -294,7 +294,6 @@ void emberAfTick(void) void MatterBooleanStatePluginServerInitCallback() {} void MatterBridgedDeviceBasicPluginServerInitCallback() {} void MatterElectricalMeasurementPluginServerInitCallback() {} -void MatterOtaSoftwareUpdateRequestorPluginServerInitCallback() {} void MatterRelativeHumidityMeasurementPluginServerInitCallback() {} void MatterIlluminanceMeasurementPluginServerInitCallback() {} void MatterBinaryInputBasicPluginServerInitCallback() {} diff --git a/src/app/zap-templates/zcl/data-model/chip/chip-ota.xml b/src/app/zap-templates/zcl/data-model/chip/chip-ota.xml index dccca1f98327c1..4abaa4849b326c 100644 --- a/src/app/zap-templates/zcl/data-model/chip/chip-ota.xml +++ b/src/app/zap-templates/zcl/data-model/chip/chip-ota.xml @@ -39,7 +39,7 @@ limitations under the License. OTA Software Update Provider CHIP - + Provides an interface for providing OTA software updates 0x0029 OTA_PROVIDER_CLUSTER true @@ -107,42 +107,51 @@ limitations under the License. - + + + + + + + OTA Software Update Requestor CHIP - TODO + Provides an interface for downloading and applying OTA software updates 0x002a OTA_REQUESTOR_CLUSTER true true - default ota provider - update possible - - Notify OTA Provider that an update was applied - - + DefaultOtaProviders + UpdatePossible + UpdateState + UpdateStateProgress + + Announce the presence of an OTA Provider + + + This event SHALL be generated when a change of the UpdateState attribute occurs due to an OTA Requestor moving through the states necessary to query for updates. - + - + This event SHALL be generated whenever a new version starts executing after being applied due to a software update. - + This event SHALL be generated whenever an error occurs during OTA Requestor download operation. - - + + diff --git a/src/controller/data_model/controller-clusters.zap b/src/controller/data_model/controller-clusters.zap index 7290cbb0c2b783..f8d1086c73f3c3 100644 --- a/src/controller/data_model/controller-clusters.zap +++ b/src/controller/data_model/controller-clusters.zap @@ -2248,6 +2248,21 @@ } ], "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "ClusterRevision", "code": 65533, @@ -2336,11 +2351,26 @@ "code": 0, "mfgCode": null, "source": "client", - "incoming": 0, + "incoming": 1, "outgoing": 1 } ], "attributes": [ + { + "name": "FeatureMap", + "code": 65532, + "mfgCode": null, + "side": "client", + "included": 0, + "storageOption": "RAM", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 0, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "ClusterRevision", "code": 65533, @@ -2368,35 +2398,65 @@ "commands": [], "attributes": [ { - "name": "default ota provider", + "name": "DefaultOtaProviders", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, + { + "name": "UpdatePossible", "code": 1, "mfgCode": null, "side": "server", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "1", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, { - "name": "update possible", + "name": "UpdateState", "code": 2, "mfgCode": null, "side": "server", "included": 1, - "storageOption": "RAM", + "storageOption": "External", "singleton": 0, "bounded": 0, - "defaultValue": "", + "defaultValue": "0", "reportable": 1, "minInterval": 0, "maxInterval": 65344, "reportableChange": 0 }, + { + "name": "UpdateStateProgress", + "code": 3, + "mfgCode": null, + "side": "server", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "0", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "AttributeList", "code": 65531, diff --git a/src/controller/java/zap-generated/CHIPCallbackTypes.h b/src/controller/java/zap-generated/CHIPCallbackTypes.h index 531732aec635a7..64f5d676992256 100644 --- a/src/controller/java/zap-generated/CHIPCallbackTypes.h +++ b/src/controller/java/zap-generated/CHIPCallbackTypes.h @@ -692,10 +692,14 @@ typedef void (*CHIPOtaSoftwareUpdateProviderClusterAttributeListAttributeCallbac typedef void (*CHIPOtaSoftwareUpdateProviderClusterClusterRevisionAttributeCallbackType)( void *, chip::app::Clusters::OtaSoftwareUpdateProvider::Attributes::ClusterRevision::TypeInfo::DecodableArgType); -typedef void (*CHIPOtaSoftwareUpdateRequestorClusterDefaultOtaProviderAttributeCallbackType)( - void *, chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::DefaultOtaProvider::TypeInfo::DecodableArgType); +typedef void (*CHIPOtaSoftwareUpdateRequestorClusterDefaultOtaProvidersAttributeCallbackType)( + void *, const chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::DefaultOtaProviders::TypeInfo::DecodableType &); typedef void (*CHIPOtaSoftwareUpdateRequestorClusterUpdatePossibleAttributeCallbackType)( void *, chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::UpdatePossible::TypeInfo::DecodableArgType); +typedef void (*CHIPOtaSoftwareUpdateRequestorClusterUpdateStateAttributeCallbackType)( + void *, chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::UpdateState::TypeInfo::DecodableArgType); +typedef void (*CHIPOtaSoftwareUpdateRequestorClusterUpdateStateProgressAttributeCallbackType)( + void *, chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::UpdateStateProgress::TypeInfo::DecodableArgType); typedef void (*CHIPOtaSoftwareUpdateRequestorClusterAttributeListAttributeCallbackType)( void *, const chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::AttributeList::TypeInfo::DecodableType &); typedef void (*CHIPOtaSoftwareUpdateRequestorClusterClusterRevisionAttributeCallbackType)( diff --git a/src/controller/java/zap-generated/CHIPClusters-JNI.cpp b/src/controller/java/zap-generated/CHIPClusters-JNI.cpp index f184dfeae17ca9..d4965e577fd456 100644 --- a/src/controller/java/zap-generated/CHIPClusters-JNI.cpp +++ b/src/controller/java/zap-generated/CHIPClusters-JNI.cpp @@ -13777,8 +13777,8 @@ JNI_METHOD(jlong, OtaSoftwareUpdateRequestorCluster, initWithDevice)(JNIEnv * en } JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, announceOtaProvider) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject providerLocation, jobject vendorId, - jobject announcementReason, jobject metadataForNode) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jobject providerNodeId, jobject vendorId, + jobject announcementReason, jobject metadataForNode, jobject endpoint) { chip::DeviceLayer::StackLock lock; CHIP_ERROR err = CHIP_NO_ERROR; @@ -13786,14 +13786,15 @@ JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, announceOtaProvider) chip::app::Clusters::OtaSoftwareUpdateRequestor::Commands::AnnounceOtaProvider::Type request; - request.providerLocation = - static_cast(chip::JniReferences::GetInstance().LongToPrimitive(providerLocation)); + request.providerNodeId = + static_cast(chip::JniReferences::GetInstance().LongToPrimitive(providerNodeId)); request.vendorId = static_cast(chip::JniReferences::GetInstance().IntegerToPrimitive(vendorId)); request.announcementReason = static_cast( chip::JniReferences::GetInstance().IntegerToPrimitive(announcementReason)); chip::JniReferences::GetInstance().GetOptionalValue(metadataForNode, metadataForNode); request.metadataForNode = chip::Optional(chip::JniByteArray(env, static_cast(metadataForNode)).byteSpan()); + request.endpoint = static_cast(chip::JniReferences::GetInstance().IntegerToPrimitive(endpoint)); std::unique_ptr onSuccess( Platform::New(callback), Platform::Delete); @@ -13822,24 +13823,18 @@ JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, announceOtaProvider) onSuccess.release(); onFailure.release(); } - -JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, writeDefaultOtaProviderAttribute) -(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jbyteArray value) +JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeUpdatePossibleAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) { chip::DeviceLayer::StackLock lock; - using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::DefaultOtaProvider::TypeInfo; - TypeInfo::Type cppValue; - - cppValue = chip::JniByteArray(env, static_cast(value)).byteSpan(); - - std::unique_ptr onSuccess( - Platform::New(callback), Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback, true), chip::Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); std::unique_ptr onFailure( - Platform::New(callback), Platform::Delete); + Platform::New(callback), chip::Platform::Delete); VerifyOrReturn(onFailure.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); @@ -13850,22 +13845,28 @@ JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, writeDefaultOtaProviderAttri chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - auto successFn = chip::Callback::Callback::FromCancelable(onSuccess->Cancel()); + using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::UpdatePossible::TypeInfo; + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->WriteAttribute(cppValue, onSuccess->mContext, successFn->mCall, failureFn->mCall); - VerifyOrReturn( - err == CHIP_NO_ERROR, - chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error writing attribute", err)); + + err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, + static_cast(minInterval), static_cast(maxInterval), + CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + VerifyOrReturn(err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error subscribing to attribute", err)); onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeDefaultOtaProviderAttribute) +JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeUpdateStateAttribute) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + std::unique_ptr onSuccess( + Platform::New(callback, true), chip::Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); @@ -13882,15 +13883,15 @@ JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeDefaultOtaProviderA chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::DefaultOtaProvider::TypeInfo; + using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::UpdateState::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable( + chip::Callback::Callback::FromCancelable( onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), static_cast(maxInterval), - CHIPOctetStringAttributeCallback::OnSubscriptionEstablished); + CHIPInt8uAttributeCallback::OnSubscriptionEstablished); VerifyOrReturn(err == CHIP_NO_ERROR, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error subscribing to attribute", err)); @@ -13898,12 +13899,14 @@ JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeDefaultOtaProviderA onSuccess.release(); onFailure.release(); } -JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeUpdatePossibleAttribute) +JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeUpdateStateProgressAttribute) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback, jint minInterval, jint maxInterval) { chip::DeviceLayer::StackLock lock; - std::unique_ptr onSuccess( - Platform::New(callback, true), chip::Platform::Delete); + std::unique_ptr + onSuccess(Platform::New(callback, true), + chip::Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); @@ -13920,15 +13923,16 @@ JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, subscribeUpdatePossibleAttri chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); - using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::UpdatePossible::TypeInfo; + using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::UpdateStateProgress::TypeInfo; auto successFn = - chip::Callback::Callback::FromCancelable( + chip::Callback::Callback::FromCancelable( onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); - err = cppCluster->SubscribeAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall, - static_cast(minInterval), static_cast(maxInterval), - CHIPBooleanAttributeCallback::OnSubscriptionEstablished); + err = cppCluster->SubscribeAttribute( + onSuccess->mContext, successFn->mCall, failureFn->mCall, static_cast(minInterval), + static_cast(maxInterval), + CHIPOtaSoftwareUpdateRequestorUpdateStateProgressAttributeCallback::OnSubscriptionEstablished); VerifyOrReturn(err == CHIP_NO_ERROR, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error subscribing to attribute", err)); diff --git a/src/controller/java/zap-generated/CHIPClustersRead-JNI.cpp b/src/controller/java/zap-generated/CHIPClustersRead-JNI.cpp index d34965f01cd872..a4623fff8a86b1 100644 --- a/src/controller/java/zap-generated/CHIPClustersRead-JNI.cpp +++ b/src/controller/java/zap-generated/CHIPClustersRead-JNI.cpp @@ -9819,14 +9819,15 @@ JNI_METHOD(void, OtaSoftwareUpdateProviderCluster, readClusterRevisionAttribute) onFailure.release(); } -JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, readDefaultOtaProviderAttribute) +JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, readDefaultOtaProvidersAttribute) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback) { chip::DeviceLayer::StackLock lock; - using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::DefaultOtaProvider::TypeInfo; - std::unique_ptr onSuccess( - chip::Platform::New(callback, false), - chip::Platform::Delete); + using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::DefaultOtaProviders::TypeInfo; + std::unique_ptr + onSuccess(chip::Platform::New(callback, false), + chip::Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); @@ -9845,7 +9846,7 @@ JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, readDefaultOtaProviderAttrib env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); auto successFn = - chip::Callback::Callback::FromCancelable( + chip::Callback::Callback::FromCancelable( onSuccess->Cancel()); auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); err = cppCluster->ReadAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall); @@ -9894,6 +9895,82 @@ JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, readUpdatePossibleAttribute) onFailure.release(); } +JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, readUpdateStateAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback) +{ + chip::DeviceLayer::StackLock lock; + using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::UpdateState::TypeInfo; + std::unique_ptr onSuccess( + chip::Platform::New(callback, false), chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OtaSoftwareUpdateRequestorCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + err = cppCluster->ReadAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error reading attribute", err)); + + onSuccess.release(); + onFailure.release(); +} + +JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, readUpdateStateProgressAttribute) +(JNIEnv * env, jobject self, jlong clusterPtr, jobject callback) +{ + chip::DeviceLayer::StackLock lock; + using TypeInfo = chip::app::Clusters::OtaSoftwareUpdateRequestor::Attributes::UpdateStateProgress::TypeInfo; + std::unique_ptr + onSuccess(chip::Platform::New(callback, false), + chip::Platform::Delete); + VerifyOrReturn(onSuccess.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); + + std::unique_ptr onFailure( + chip::Platform::New(callback), chip::Platform::Delete); + VerifyOrReturn(onFailure.get() != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Error creating native failure callback", CHIP_ERROR_NO_MEMORY)); + + CHIP_ERROR err = CHIP_NO_ERROR; + chip::Controller::OtaSoftwareUpdateRequestorCluster * cppCluster = + reinterpret_cast(clusterPtr); + VerifyOrReturn(cppCluster != nullptr, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException( + env, callback, "Could not get native cluster", CHIP_ERROR_INCORRECT_STATE)); + + auto successFn = + chip::Callback::Callback::FromCancelable( + onSuccess->Cancel()); + auto failureFn = chip::Callback::Callback::FromCancelable(onFailure->Cancel()); + err = cppCluster->ReadAttribute(onSuccess->mContext, successFn->mCall, failureFn->mCall); + VerifyOrReturn( + err == CHIP_NO_ERROR, + chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error reading attribute", err)); + + onSuccess.release(); + onFailure.release(); +} + JNI_METHOD(void, OtaSoftwareUpdateRequestorCluster, readAttributeListAttribute) (JNIEnv * env, jobject self, jlong clusterPtr, jobject callback) { diff --git a/src/controller/java/zap-generated/CHIPReadCallbacks.cpp b/src/controller/java/zap-generated/CHIPReadCallbacks.cpp index bfcae76141533c..828d6b8423c075 100644 --- a/src/controller/java/zap-generated/CHIPReadCallbacks.cpp +++ b/src/controller/java/zap-generated/CHIPReadCallbacks.cpp @@ -7316,6 +7316,210 @@ void CHIPOtaSoftwareUpdateProviderAttributeListAttributeCallback::CallbackFn( env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); } +CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersAttributeCallback:: + CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersAttributeCallback(jobject javaCallback, bool keepAlive) : + chip::Callback::Callback(CallbackFn, this), + keepAlive(keepAlive) +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersAttributeCallback:: + ~CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersAttributeCallback::CallbackFn( + void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType> & list) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + + std::unique_ptr cppCallback( + reinterpret_cast(context), maybeDestroy); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jclass arrayListClass; + err = chip::JniReferences::GetInstance().GetClassRef(env, "java/util/ArrayList", arrayListClass); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error using Java ArrayList")); + chip::JniClass arrayListJniClass(arrayListClass); + jmethodID arrayListCtor = env->GetMethodID(arrayListClass, "", "()V"); + jmethodID arrayListAddMethod = env->GetMethodID(arrayListClass, "add", "(Ljava/lang/Object;)Z"); + VerifyOrReturn(arrayListCtor != nullptr && arrayListAddMethod != nullptr, + ChipLogError(Zcl, "Error finding Java ArrayList methods")); + jobject arrayListObj = env->NewObject(arrayListClass, arrayListCtor); + VerifyOrReturn(arrayListObj != nullptr, ChipLogError(Zcl, "Error creating Java ArrayList")); + + jmethodID javaMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/List;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jclass attributeClass; + err = chip::JniReferences::GetInstance().GetClassRef( + env, "chip/devicecontroller/ChipClusters$OtaSoftwareUpdateRequestorCluster$DefaultOtaProvidersAttribute", attributeClass); + VerifyOrReturn( + err == CHIP_NO_ERROR, + ChipLogError(Zcl, + "Could not find class " + "chip/devicecontroller/ChipClusters$OtaSoftwareUpdateRequestorCluster$DefaultOtaProvidersAttribute")); + chip::JniClass attributeJniClass(attributeClass); + jmethodID attributeCtor = + env->GetMethodID(attributeClass, "", "(Ljava/lang/Integer;Ljava/lang/Long;Ljava/lang/Integer;)V"); + VerifyOrReturn(attributeCtor != nullptr, ChipLogError(Zcl, "Could not find DefaultOtaProvidersAttribute constructor")); + + auto iter = list.begin(); + while (iter.Next()) + { + auto & entry = iter.GetValue(); + (void) entry; + bool fabricIndexNull = false; + bool fabricIndexHasValue = true; + + chip::FabricIndex fabricIndexValue = entry.fabricIndex; + + jobject fabricIndex = nullptr; + if (!fabricIndexNull && fabricIndexHasValue) + { + jclass fabricIndexEntryCls; + chip::JniReferences::GetInstance().GetClassRef(env, "java/lang/Integer", fabricIndexEntryCls); + chip::JniClass fabricIndexJniClass(fabricIndexEntryCls); + jmethodID fabricIndexEntryTypeCtor = env->GetMethodID(fabricIndexEntryCls, "", "(I)V"); + fabricIndex = env->NewObject(fabricIndexEntryCls, fabricIndexEntryTypeCtor, fabricIndexValue); + } + + bool providerNodeIDNull = false; + bool providerNodeIDHasValue = true; + + chip::NodeId providerNodeIDValue = entry.providerNodeID; + + jobject providerNodeID = nullptr; + if (!providerNodeIDNull && providerNodeIDHasValue) + { + jclass providerNodeIDEntryCls; + chip::JniReferences::GetInstance().GetClassRef(env, "java/lang/Long", providerNodeIDEntryCls); + chip::JniClass providerNodeIDJniClass(providerNodeIDEntryCls); + jmethodID providerNodeIDEntryTypeCtor = env->GetMethodID(providerNodeIDEntryCls, "", "(J)V"); + providerNodeID = env->NewObject(providerNodeIDEntryCls, providerNodeIDEntryTypeCtor, providerNodeIDValue); + } + + bool endpointNull = false; + bool endpointHasValue = true; + + chip::EndpointId endpointValue = entry.endpoint; + + jobject endpoint = nullptr; + if (!endpointNull && endpointHasValue) + { + jclass endpointEntryCls; + chip::JniReferences::GetInstance().GetClassRef(env, "java/lang/Integer", endpointEntryCls); + chip::JniClass endpointJniClass(endpointEntryCls); + jmethodID endpointEntryTypeCtor = env->GetMethodID(endpointEntryCls, "", "(I)V"); + endpoint = env->NewObject(endpointEntryCls, endpointEntryTypeCtor, endpointValue); + } + + jobject attributeObj = env->NewObject(attributeClass, attributeCtor, fabricIndex, providerNodeID, endpoint); + VerifyOrReturn(attributeObj != nullptr, ChipLogError(Zcl, "Could not create DefaultOtaProvidersAttribute object")); + + env->CallBooleanMethod(arrayListObj, arrayListAddMethod, attributeObj); + } + VerifyOrReturn( + iter.GetStatus() == CHIP_NO_ERROR, + ChipLogError(Zcl, "Error decoding DefaultOtaProvidersAttribute value: %" CHIP_ERROR_FORMAT, iter.GetStatus().Format())); + + env->ExceptionClear(); + env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); +} + +CHIPOtaSoftwareUpdateRequestorUpdateStateProgressAttributeCallback:: + CHIPOtaSoftwareUpdateRequestorUpdateStateProgressAttributeCallback(jobject javaCallback, bool keepAlive) : + chip::Callback::Callback(CallbackFn, this), + keepAlive(keepAlive) +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + return; + } + + javaCallbackRef = env->NewGlobalRef(javaCallback); + if (javaCallbackRef == nullptr) + { + ChipLogError(Zcl, "Could not create global reference for Java callback"); + } +} + +CHIPOtaSoftwareUpdateRequestorUpdateStateProgressAttributeCallback:: + ~CHIPOtaSoftwareUpdateRequestorUpdateStateProgressAttributeCallback() +{ + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + if (env == nullptr) + { + ChipLogError(Zcl, "Could not delete global reference for Java callback"); + return; + } + env->DeleteGlobalRef(javaCallbackRef); +} + +void CHIPOtaSoftwareUpdateRequestorUpdateStateProgressAttributeCallback::CallbackFn( + void * context, const chip::app::DataModel::Nullable & value) +{ + chip::DeviceLayer::StackUnlock unlock; + CHIP_ERROR err = CHIP_NO_ERROR; + JNIEnv * env = chip::JniReferences::GetInstance().GetEnvForCurrentThread(); + jobject javaCallbackRef; + + VerifyOrReturn(env != nullptr, ChipLogError(Zcl, "Could not get JNI env")); + std::unique_ptr cppCallback( + reinterpret_cast(context), maybeDestroy); + + // It's valid for javaCallbackRef to be nullptr if the Java code passed in a null callback. + javaCallbackRef = cppCallback.get()->javaCallbackRef; + VerifyOrReturn(javaCallbackRef != nullptr, + ChipLogProgress(Zcl, "Early return from attribute callback since Java callback is null")); + + jmethodID javaMethod; + err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/lang/Integer;)V", &javaMethod); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); + + jobject javaValue; + + std::string javaValueClassName = "java/lang/Integer"; + std::string javaValueCtorSignature = "(I)V"; + chip::JniReferences::GetInstance().CreateBoxedObject(javaValueClassName.c_str(), javaValueCtorSignature.c_str(), + value.Value(), javaValue); + + env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue); +} + CHIPOtaSoftwareUpdateRequestorAttributeListAttributeCallback::CHIPOtaSoftwareUpdateRequestorAttributeListAttributeCallback( jobject javaCallback, bool keepAlive) : chip::Callback::Callback(CallbackFn, this), diff --git a/src/controller/java/zap-generated/CHIPReadCallbacks.h b/src/controller/java/zap-generated/CHIPReadCallbacks.h index b896fa62716f37..94c461472370c1 100644 --- a/src/controller/java/zap-generated/CHIPReadCallbacks.h +++ b/src/controller/java/zap-generated/CHIPReadCallbacks.h @@ -2526,6 +2526,68 @@ class CHIPOtaSoftwareUpdateProviderAttributeListAttributeCallback bool keepAlive; }; +class CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersAttributeCallback + : public chip::Callback::Callback +{ +public: + CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersAttributeCallback(jobject javaCallback, bool keepAlive = false); + + ~CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersAttributeCallback(); + + static void maybeDestroy(CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersAttributeCallback * callback) + { + if (!callback->keepAlive) + { + callback->Cancel(); + chip::Platform::Delete(callback); + } + } + + static void CallbackFn(void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType> & list); + static void OnSubscriptionEstablished(void * context) + { + CHIP_ERROR err = chip::JniReferences::GetInstance().CallSubscriptionEstablished( + reinterpret_cast(context)->javaCallbackRef); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error calling onSubscriptionEstablished: %s", ErrorStr(err))); + }; + +private: + jobject javaCallbackRef; + bool keepAlive; +}; + +class CHIPOtaSoftwareUpdateRequestorUpdateStateProgressAttributeCallback + : public chip::Callback::Callback +{ +public: + CHIPOtaSoftwareUpdateRequestorUpdateStateProgressAttributeCallback(jobject javaCallback, bool keepAlive = false); + + ~CHIPOtaSoftwareUpdateRequestorUpdateStateProgressAttributeCallback(); + + static void maybeDestroy(CHIPOtaSoftwareUpdateRequestorUpdateStateProgressAttributeCallback * callback) + { + if (!callback->keepAlive) + { + callback->Cancel(); + chip::Platform::Delete(callback); + } + } + + static void CallbackFn(void * context, const chip::app::DataModel::Nullable & value); + static void OnSubscriptionEstablished(void * context) + { + CHIP_ERROR err = chip::JniReferences::GetInstance().CallSubscriptionEstablished( + reinterpret_cast(context)->javaCallbackRef); + VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error calling onSubscriptionEstablished: %s", ErrorStr(err))); + }; + +private: + jobject javaCallbackRef; + bool keepAlive; +}; + class CHIPOtaSoftwareUpdateRequestorAttributeListAttributeCallback : public chip::Callback::Callback { diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java index 2357f6512e7e17..e95106bdaa0383 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ChipClusters.java @@ -7200,46 +7200,87 @@ public static long clusterId() { public void announceOtaProvider( DefaultClusterCallback callback, - Long providerLocation, + Long providerNodeId, Integer vendorId, Integer announcementReason, - Optional metadataForNode) { + Optional metadataForNode, + Integer endpoint) { announceOtaProvider( chipClusterPtr, callback, - providerLocation, + providerNodeId, vendorId, announcementReason, - metadataForNode); + metadataForNode, + endpoint); } private native void announceOtaProvider( long chipClusterPtr, DefaultClusterCallback Callback, - Long providerLocation, + Long providerNodeId, Integer vendorId, Integer announcementReason, - Optional metadataForNode); + Optional metadataForNode, + Integer endpoint); - public interface AttributeListAttributeCallback { - void onSuccess(List valueList); + public static class DefaultOtaProvidersAttribute { + public Integer fabricIndex; + public Long providerNodeID; + public Integer endpoint; + + public DefaultOtaProvidersAttribute( + Integer fabricIndex, Long providerNodeID, Integer endpoint) { + this.fabricIndex = fabricIndex; + this.providerNodeID = providerNodeID; + this.endpoint = endpoint; + } + + @Override + public String toString() { + StringBuilder output = new StringBuilder(""); + output.append("int fabricIndex: "); + output.append(this.fabricIndex); + output.append("\n"); + + output.append("long providerNodeID: "); + output.append(this.providerNodeID); + output.append("\n"); + + output.append("int endpoint: "); + output.append(this.endpoint); + output.append("\n"); + + return output.toString(); + } + } + + public interface DefaultOtaProvidersAttributeCallback { + void onSuccess(List valueList); void onError(Exception ex); default void onSubscriptionEstablished() {} } - public void readDefaultOtaProviderAttribute(OctetStringAttributeCallback callback) { - readDefaultOtaProviderAttribute(chipClusterPtr, callback); + public interface UpdateStateProgressAttributeCallback { + void onSuccess(@Nullable Integer value); + + void onError(Exception ex); + + default void onSubscriptionEstablished() {} } - public void writeDefaultOtaProviderAttribute(DefaultClusterCallback callback, byte[] value) { - writeDefaultOtaProviderAttribute(chipClusterPtr, callback, value); + public interface AttributeListAttributeCallback { + void onSuccess(List valueList); + + void onError(Exception ex); + + default void onSubscriptionEstablished() {} } - public void subscribeDefaultOtaProviderAttribute( - OctetStringAttributeCallback callback, int minInterval, int maxInterval) { - subscribeDefaultOtaProviderAttribute(chipClusterPtr, callback, minInterval, maxInterval); + public void readDefaultOtaProvidersAttribute(DefaultOtaProvidersAttributeCallback callback) { + readDefaultOtaProvidersAttribute(chipClusterPtr, callback); } public void readUpdatePossibleAttribute(BooleanAttributeCallback callback) { @@ -7251,6 +7292,24 @@ public void subscribeUpdatePossibleAttribute( subscribeUpdatePossibleAttribute(chipClusterPtr, callback, minInterval, maxInterval); } + public void readUpdateStateAttribute(IntegerAttributeCallback callback) { + readUpdateStateAttribute(chipClusterPtr, callback); + } + + public void subscribeUpdateStateAttribute( + IntegerAttributeCallback callback, int minInterval, int maxInterval) { + subscribeUpdateStateAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + + public void readUpdateStateProgressAttribute(UpdateStateProgressAttributeCallback callback) { + readUpdateStateProgressAttribute(chipClusterPtr, callback); + } + + public void subscribeUpdateStateProgressAttribute( + UpdateStateProgressAttributeCallback callback, int minInterval, int maxInterval) { + subscribeUpdateStateProgressAttribute(chipClusterPtr, callback, minInterval, maxInterval); + } + public void readAttributeListAttribute(AttributeListAttributeCallback callback) { readAttributeListAttribute(chipClusterPtr, callback); } @@ -7264,17 +7323,8 @@ public void subscribeClusterRevisionAttribute( subscribeClusterRevisionAttribute(chipClusterPtr, callback, minInterval, maxInterval); } - private native void readDefaultOtaProviderAttribute( - long chipClusterPtr, OctetStringAttributeCallback callback); - - private native void writeDefaultOtaProviderAttribute( - long chipClusterPtr, DefaultClusterCallback callback, byte[] value); - - private native void subscribeDefaultOtaProviderAttribute( - long chipClusterPtr, - OctetStringAttributeCallback callback, - int minInterval, - int maxInterval); + private native void readDefaultOtaProvidersAttribute( + long chipClusterPtr, DefaultOtaProvidersAttributeCallback callback); private native void readUpdatePossibleAttribute( long chipClusterPtr, BooleanAttributeCallback callback); @@ -7282,6 +7332,21 @@ private native void readUpdatePossibleAttribute( private native void subscribeUpdatePossibleAttribute( long chipClusterPtr, BooleanAttributeCallback callback, int minInterval, int maxInterval); + private native void readUpdateStateAttribute( + long chipClusterPtr, IntegerAttributeCallback callback); + + private native void subscribeUpdateStateAttribute( + long chipClusterPtr, IntegerAttributeCallback callback, int minInterval, int maxInterval); + + private native void readUpdateStateProgressAttribute( + long chipClusterPtr, UpdateStateProgressAttributeCallback callback); + + private native void subscribeUpdateStateProgressAttribute( + long chipClusterPtr, + UpdateStateProgressAttributeCallback callback, + int minInterval, + int maxInterval); + private native void readAttributeListAttribute( long chipClusterPtr, AttributeListAttributeCallback callback); diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java b/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java index cf50c03395cdbb..dc416282ef8867 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ClusterInfoMapping.java @@ -2807,6 +2807,37 @@ public void onError(Exception ex) { } } + public static class DelegatedOtaSoftwareUpdateRequestorClusterDefaultOtaProvidersAttributeCallback + implements ChipClusters.OtaSoftwareUpdateRequestorCluster + .DefaultOtaProvidersAttributeCallback, + DelegatedClusterCallback { + private ClusterCommandCallback callback; + + @Override + public void setCallbackDelegate(ClusterCommandCallback callback) { + this.callback = callback; + } + + @Override + public void onSuccess( + List + valueList) { + Map responseValues = new LinkedHashMap<>(); + CommandResponseInfo commandResponseInfo = + new CommandResponseInfo( + "valueList", + "List"); + + responseValues.put(commandResponseInfo, valueList); + callback.onSuccess(responseValues); + } + + @Override + public void onError(Exception ex) { + callback.onFailure(ex); + } + } + public static class DelegatedOtaSoftwareUpdateRequestorClusterAttributeListAttributeCallback implements ChipClusters.OtaSoftwareUpdateRequestorCluster.AttributeListAttributeCallback, DelegatedClusterCallback { @@ -8094,11 +8125,11 @@ public Map> getCommandMap() { Map otaSoftwareUpdateRequestorannounceOtaProviderCommandParams = new LinkedHashMap(); CommandParameterInfo - otaSoftwareUpdateRequestorannounceOtaProviderproviderLocationCommandParameterInfo = - new CommandParameterInfo("providerLocation", long.class); + otaSoftwareUpdateRequestorannounceOtaProviderproviderNodeIdCommandParameterInfo = + new CommandParameterInfo("providerNodeId", long.class); otaSoftwareUpdateRequestorannounceOtaProviderCommandParams.put( - "providerLocation", - otaSoftwareUpdateRequestorannounceOtaProviderproviderLocationCommandParameterInfo); + "providerNodeId", + otaSoftwareUpdateRequestorannounceOtaProviderproviderNodeIdCommandParameterInfo); CommandParameterInfo otaSoftwareUpdateRequestorannounceOtaProvidervendorIdCommandParameterInfo = new CommandParameterInfo("vendorId", int.class); @@ -8119,6 +8150,11 @@ public Map> getCommandMap() { "metadataForNode", otaSoftwareUpdateRequestorannounceOtaProvidermetadataForNodeCommandParameterInfo); + CommandParameterInfo otaSoftwareUpdateRequestorannounceOtaProviderendpointCommandParameterInfo = + new CommandParameterInfo("endpoint", int.class); + otaSoftwareUpdateRequestorannounceOtaProviderCommandParams.put( + "endpoint", otaSoftwareUpdateRequestorannounceOtaProviderendpointCommandParameterInfo); + // Populate commands InteractionInfo otaSoftwareUpdateRequestorannounceOtaProviderInteractionInfo = new InteractionInfo( @@ -8126,10 +8162,11 @@ public Map> getCommandMap() { ((ChipClusters.OtaSoftwareUpdateRequestorCluster) cluster) .announceOtaProvider( (DefaultClusterCallback) callback, - (Long) commandArguments.get("providerLocation"), + (Long) commandArguments.get("providerNodeId"), (Integer) commandArguments.get("vendorId"), (Integer) commandArguments.get("announcementReason"), - (Optional) commandArguments.get("metadataForNode")); + (Optional) commandArguments.get("metadataForNode"), + (Integer) commandArguments.get("endpoint")); }, () -> new DelegatedDefaultClusterCallback(), otaSoftwareUpdateRequestorannounceOtaProviderCommandParams); diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ClusterReadMapping.java b/src/controller/java/zap-generated/chip/devicecontroller/ClusterReadMapping.java index b88892a190f0a1..e6cbbc74243475 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ClusterReadMapping.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ClusterReadMapping.java @@ -3760,20 +3760,24 @@ public Map> getReadAttributeMap() { Map readOtaSoftwareUpdateRequestorInteractionInfo = new LinkedHashMap<>(); Map - readOtaSoftwareUpdateRequestorDefaultOtaProviderCommandParams = + readOtaSoftwareUpdateRequestorDefaultOtaProvidersCommandParams = new LinkedHashMap(); - InteractionInfo readOtaSoftwareUpdateRequestorDefaultOtaProviderAttributeInteractionInfo = + InteractionInfo readOtaSoftwareUpdateRequestorDefaultOtaProvidersAttributeInteractionInfo = new InteractionInfo( (cluster, callback, commandArguments) -> { ((ChipClusters.OtaSoftwareUpdateRequestorCluster) cluster) - .readDefaultOtaProviderAttribute( - (ChipClusters.OctetStringAttributeCallback) callback); + .readDefaultOtaProvidersAttribute( + (ChipClusters.OtaSoftwareUpdateRequestorCluster + .DefaultOtaProvidersAttributeCallback) + callback); }, - () -> new ClusterInfoMapping.DelegatedOctetStringAttributeCallback(), - readOtaSoftwareUpdateRequestorDefaultOtaProviderCommandParams); + () -> + new ClusterInfoMapping + .DelegatedOtaSoftwareUpdateRequestorClusterDefaultOtaProvidersAttributeCallback(), + readOtaSoftwareUpdateRequestorDefaultOtaProvidersCommandParams); readOtaSoftwareUpdateRequestorInteractionInfo.put( - "readDefaultOtaProviderAttribute", - readOtaSoftwareUpdateRequestorDefaultOtaProviderAttributeInteractionInfo); + "readDefaultOtaProvidersAttribute", + readOtaSoftwareUpdateRequestorDefaultOtaProvidersAttributeInteractionInfo); Map readOtaSoftwareUpdateRequestorUpdatePossibleCommandParams = new LinkedHashMap(); InteractionInfo readOtaSoftwareUpdateRequestorUpdatePossibleAttributeInteractionInfo = @@ -3787,6 +3791,36 @@ public Map> getReadAttributeMap() { readOtaSoftwareUpdateRequestorInteractionInfo.put( "readUpdatePossibleAttribute", readOtaSoftwareUpdateRequestorUpdatePossibleAttributeInteractionInfo); + Map readOtaSoftwareUpdateRequestorUpdateStateCommandParams = + new LinkedHashMap(); + InteractionInfo readOtaSoftwareUpdateRequestorUpdateStateAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.OtaSoftwareUpdateRequestorCluster) cluster) + .readUpdateStateAttribute((ChipClusters.IntegerAttributeCallback) callback); + }, + () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), + readOtaSoftwareUpdateRequestorUpdateStateCommandParams); + readOtaSoftwareUpdateRequestorInteractionInfo.put( + "readUpdateStateAttribute", + readOtaSoftwareUpdateRequestorUpdateStateAttributeInteractionInfo); + Map + readOtaSoftwareUpdateRequestorUpdateStateProgressCommandParams = + new LinkedHashMap(); + InteractionInfo readOtaSoftwareUpdateRequestorUpdateStateProgressAttributeInteractionInfo = + new InteractionInfo( + (cluster, callback, commandArguments) -> { + ((ChipClusters.OtaSoftwareUpdateRequestorCluster) cluster) + .readUpdateStateProgressAttribute( + (ChipClusters.OtaSoftwareUpdateRequestorCluster + .UpdateStateProgressAttributeCallback) + callback); + }, + () -> new ClusterInfoMapping.DelegatedIntegerAttributeCallback(), + readOtaSoftwareUpdateRequestorUpdateStateProgressCommandParams); + readOtaSoftwareUpdateRequestorInteractionInfo.put( + "readUpdateStateProgressAttribute", + readOtaSoftwareUpdateRequestorUpdateStateProgressAttributeInteractionInfo); Map readOtaSoftwareUpdateRequestorAttributeListCommandParams = new LinkedHashMap(); InteractionInfo readOtaSoftwareUpdateRequestorAttributeListAttributeInteractionInfo = diff --git a/src/controller/java/zap-generated/chip/devicecontroller/ClusterWriteMapping.java b/src/controller/java/zap-generated/chip/devicecontroller/ClusterWriteMapping.java index 2036490065239e..a9142c66b7e062 100644 --- a/src/controller/java/zap-generated/chip/devicecontroller/ClusterWriteMapping.java +++ b/src/controller/java/zap-generated/chip/devicecontroller/ClusterWriteMapping.java @@ -745,25 +745,6 @@ public Map> getWriteAttributeMap() { "otaSoftwareUpdateProvider", writeOtaSoftwareUpdateProviderInteractionInfo); Map writeOtaSoftwareUpdateRequestorInteractionInfo = new LinkedHashMap<>(); - Map - writeOtaSoftwareUpdateRequestorDefaultOtaProviderCommandParams = - new LinkedHashMap(); - CommandParameterInfo otaSoftwareUpdateRequestordefaultOtaProviderCommandParameterInfo = - new CommandParameterInfo("value", byte[].class); - writeOtaSoftwareUpdateRequestorDefaultOtaProviderCommandParams.put( - "value", otaSoftwareUpdateRequestordefaultOtaProviderCommandParameterInfo); - InteractionInfo writeOtaSoftwareUpdateRequestorDefaultOtaProviderAttributeInteractionInfo = - new InteractionInfo( - (cluster, callback, commandArguments) -> { - ((ChipClusters.OtaSoftwareUpdateRequestorCluster) cluster) - .writeDefaultOtaProviderAttribute( - (DefaultClusterCallback) callback, (byte[]) commandArguments.get("value")); - }, - () -> new ClusterInfoMapping.DelegatedDefaultClusterCallback(), - writeOtaSoftwareUpdateRequestorDefaultOtaProviderCommandParams); - writeOtaSoftwareUpdateRequestorInteractionInfo.put( - "writeDefaultOtaProviderAttribute", - writeOtaSoftwareUpdateRequestorDefaultOtaProviderAttributeInteractionInfo); writeAttributeMap.put( "otaSoftwareUpdateRequestor", writeOtaSoftwareUpdateRequestorInteractionInfo); Map writeOccupancySensingInteractionInfo = new LinkedHashMap<>(); diff --git a/src/controller/python/chip/clusters/CHIPClusters.py b/src/controller/python/chip/clusters/CHIPClusters.py index b1bbe59f5c58a1..d7204b128e99d5 100644 --- a/src/controller/python/chip/clusters/CHIPClusters.py +++ b/src/controller/python/chip/clusters/CHIPClusters.py @@ -2939,25 +2939,38 @@ class ChipClusters: "commandId": 0x00000000, "commandName": "AnnounceOtaProvider", "args": { - "providerLocation": "int", + "providerNodeId": "int", "vendorId": "int", "announcementReason": "int", "metadataForNode": "bytes", + "endpoint": "int", }, }, }, "attributes": { + 0x00000000: { + "attributeName": "DefaultOtaProviders", + "attributeId": 0x00000000, + "type": "", + "reportable": True, + "writable": True, + }, 0x00000001: { - "attributeName": "DefaultOtaProvider", + "attributeName": "UpdatePossible", "attributeId": 0x00000001, - "type": "bytes", + "type": "bool", "reportable": True, - "writable": True, }, 0x00000002: { - "attributeName": "UpdatePossible", + "attributeName": "UpdateState", "attributeId": 0x00000002, - "type": "bool", + "type": "int", + "reportable": True, + }, + 0x00000003: { + "attributeName": "UpdateStateProgress", + "attributeId": 0x00000003, + "type": "int", "reportable": True, }, 0x0000FFFB: { diff --git a/src/controller/python/chip/clusters/Objects.py b/src/controller/python/chip/clusters/Objects.py index 9084dedbe98c6e..24b51078cee60f 100644 --- a/src/controller/python/chip/clusters/Objects.py +++ b/src/controller/python/chip/clusters/Objects.py @@ -6709,15 +6709,19 @@ class OtaSoftwareUpdateRequestor(Cluster): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields = [ - ClusterObjectFieldDescriptor(Label="defaultOtaProvider", Tag=0x00000001, Type=bytes), - ClusterObjectFieldDescriptor(Label="updatePossible", Tag=0x00000002, Type=bool), + ClusterObjectFieldDescriptor(Label="defaultOtaProviders", Tag=0x00000000, Type=typing.List[OtaSoftwareUpdateRequestor.Structs.ProviderLocation]), + ClusterObjectFieldDescriptor(Label="updatePossible", Tag=0x00000001, Type=bool), + ClusterObjectFieldDescriptor(Label="updateState", Tag=0x00000002, Type=OtaSoftwareUpdateRequestor.Enums.UpdateStateEnum), + ClusterObjectFieldDescriptor(Label="updateStateProgress", Tag=0x00000003, Type=typing.Union[Nullable, uint]), ClusterObjectFieldDescriptor(Label="attributeList", Tag=0x0000FFFB, Type=typing.List[uint]), ClusterObjectFieldDescriptor(Label="featureMap", Tag=0x0000FFFC, Type=typing.Optional[uint]), ClusterObjectFieldDescriptor(Label="clusterRevision", Tag=0x0000FFFD, Type=uint), ]) - defaultOtaProvider: 'bytes' = None + defaultOtaProviders: 'typing.List[OtaSoftwareUpdateRequestor.Structs.ProviderLocation]' = None updatePossible: 'bool' = None + updateState: 'OtaSoftwareUpdateRequestor.Enums.UpdateStateEnum' = None + updateStateProgress: 'typing.Union[Nullable, uint]' = None attributeList: 'typing.List[uint]' = None featureMap: 'typing.Optional[uint]' = None clusterRevision: 'uint' = None @@ -6747,6 +6751,23 @@ class UpdateStateEnum(IntEnum): kDelayedOnUserConsent = 0x08 + class Structs: + @dataclass + class ProviderLocation(ClusterObject): + @ChipUtility.classproperty + def descriptor(cls) -> ClusterObjectDescriptor: + return ClusterObjectDescriptor( + Fields = [ + ClusterObjectFieldDescriptor(Label="fabricIndex", Tag=0, Type=uint), + ClusterObjectFieldDescriptor(Label="providerNodeID", Tag=1, Type=uint), + ClusterObjectFieldDescriptor(Label="endpoint", Tag=2, Type=uint), + ]) + + fabricIndex: 'uint' = 0 + providerNodeID: 'uint' = 0 + endpoint: 'uint' = 0 + + class Commands: @dataclass @@ -6759,34 +6780,36 @@ class AnnounceOtaProvider(ClusterCommand): def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields = [ - ClusterObjectFieldDescriptor(Label="providerLocation", Tag=0, Type=uint), + ClusterObjectFieldDescriptor(Label="providerNodeId", Tag=0, Type=uint), ClusterObjectFieldDescriptor(Label="vendorId", Tag=1, Type=uint), ClusterObjectFieldDescriptor(Label="announcementReason", Tag=2, Type=OtaSoftwareUpdateRequestor.Enums.OTAAnnouncementReason), ClusterObjectFieldDescriptor(Label="metadataForNode", Tag=3, Type=typing.Optional[bytes]), + ClusterObjectFieldDescriptor(Label="endpoint", Tag=4, Type=uint), ]) - providerLocation: 'uint' = 0 + providerNodeId: 'uint' = 0 vendorId: 'uint' = 0 announcementReason: 'OtaSoftwareUpdateRequestor.Enums.OTAAnnouncementReason' = 0 metadataForNode: 'typing.Optional[bytes]' = None + endpoint: 'uint' = 0 class Attributes: @dataclass - class DefaultOtaProvider(ClusterAttributeDescriptor): + class DefaultOtaProviders(ClusterAttributeDescriptor): @ChipUtility.classproperty def cluster_id(cls) -> int: return 0x002A @ChipUtility.classproperty def attribute_id(cls) -> int: - return 0x00000001 + return 0x00000000 @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: - return ClusterObjectFieldDescriptor(Type=bytes) + return ClusterObjectFieldDescriptor(Type=typing.List[OtaSoftwareUpdateRequestor.Structs.ProviderLocation]) - value: 'bytes' = b"" + value: 'typing.List[OtaSoftwareUpdateRequestor.Structs.ProviderLocation]' = field(default_factory=lambda: []) @dataclass class UpdatePossible(ClusterAttributeDescriptor): @@ -6796,7 +6819,7 @@ def cluster_id(cls) -> int: @ChipUtility.classproperty def attribute_id(cls) -> int: - return 0x00000002 + return 0x00000001 @ChipUtility.classproperty def attribute_type(cls) -> ClusterObjectFieldDescriptor: @@ -6804,6 +6827,38 @@ def attribute_type(cls) -> ClusterObjectFieldDescriptor: value: 'bool' = False + @dataclass + class UpdateState(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x002A + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000002 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=OtaSoftwareUpdateRequestor.Enums.UpdateStateEnum) + + value: 'OtaSoftwareUpdateRequestor.Enums.UpdateStateEnum' = 0 + + @dataclass + class UpdateStateProgress(ClusterAttributeDescriptor): + @ChipUtility.classproperty + def cluster_id(cls) -> int: + return 0x002A + + @ChipUtility.classproperty + def attribute_id(cls) -> int: + return 0x00000003 + + @ChipUtility.classproperty + def attribute_type(cls) -> ClusterObjectFieldDescriptor: + return ClusterObjectFieldDescriptor(Type=typing.Union[Nullable, uint]) + + value: 'typing.Union[Nullable, uint]' = NullValue + @dataclass class AttributeList(ClusterAttributeDescriptor): @ChipUtility.classproperty @@ -6868,16 +6923,16 @@ def event_id(cls) -> int: def descriptor(cls) -> ClusterObjectDescriptor: return ClusterObjectDescriptor( Fields = [ - ClusterObjectFieldDescriptor(Label="previousState", Tag=0, Type=OtaSoftwareUpdateRequestor.Enums.UpdateStateEnum), + ClusterObjectFieldDescriptor(Label="previousState", Tag=0, Type=typing.Union[Nullable, OtaSoftwareUpdateRequestor.Enums.UpdateStateEnum]), ClusterObjectFieldDescriptor(Label="newState", Tag=1, Type=OtaSoftwareUpdateRequestor.Enums.UpdateStateEnum), ClusterObjectFieldDescriptor(Label="reason", Tag=2, Type=OtaSoftwareUpdateRequestor.Enums.ChangeReasonEnum), - ClusterObjectFieldDescriptor(Label="targetSoftwareVersion", Tag=3, Type=uint), + ClusterObjectFieldDescriptor(Label="targetSoftwareVersion", Tag=3, Type=typing.Union[Nullable, uint]), ]) - previousState: 'OtaSoftwareUpdateRequestor.Enums.UpdateStateEnum' = 0 + previousState: 'typing.Union[Nullable, OtaSoftwareUpdateRequestor.Enums.UpdateStateEnum]' = NullValue newState: 'OtaSoftwareUpdateRequestor.Enums.UpdateStateEnum' = 0 reason: 'OtaSoftwareUpdateRequestor.Enums.ChangeReasonEnum' = 0 - targetSoftwareVersion: 'uint' = 0 + targetSoftwareVersion: 'typing.Union[Nullable, uint]' = NullValue @dataclass class VersionApplied(ClusterEvent): @@ -6917,13 +6972,13 @@ def descriptor(cls) -> ClusterObjectDescriptor: ClusterObjectFieldDescriptor(Label="softwareVersion", Tag=0, Type=uint), ClusterObjectFieldDescriptor(Label="bytesDownloaded", Tag=1, Type=uint), ClusterObjectFieldDescriptor(Label="progressPercent", Tag=2, Type=uint), - ClusterObjectFieldDescriptor(Label="platformCode", Tag=3, Type=int), + ClusterObjectFieldDescriptor(Label="platformCode", Tag=3, Type=typing.Union[Nullable, int]), ]) softwareVersion: 'uint' = 0 bytesDownloaded: 'uint' = 0 progressPercent: 'uint' = 0 - platformCode: 'int' = 0 + platformCode: 'typing.Union[Nullable, int]' = NullValue @dataclass diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPAttributeTLVValueDecoder.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPAttributeTLVValueDecoder.mm index 3c4b84ec5f5d05..25f0df61b9060d 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPAttributeTLVValueDecoder.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPAttributeTLVValueDecoder.mm @@ -4525,15 +4525,33 @@ id CHIPDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader case Clusters::OtaSoftwareUpdateRequestor::Id: { using namespace Clusters::OtaSoftwareUpdateRequestor; switch (aPath.mAttributeId) { - case Attributes::DefaultOtaProvider::Id: { - using TypeInfo = Attributes::DefaultOtaProvider::TypeInfo; + case Attributes::DefaultOtaProviders::Id: { + using TypeInfo = Attributes::DefaultOtaProviders::TypeInfo; TypeInfo::DecodableType cppValue; *aError = DataModel::Decode(aReader, cppValue); if (*aError != CHIP_NO_ERROR) { return nil; } - NSData * _Nonnull value; - value = [NSData dataWithBytes:cppValue.data() length:cppValue.size()]; + NSArray * _Nonnull value; + auto * array_0 = [NSMutableArray new]; + auto iter_0 = cppValue.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + CHIPOtaSoftwareUpdateRequestorClusterProviderLocation * newElement_0; + newElement_0 = [CHIPOtaSoftwareUpdateRequestorClusterProviderLocation new]; + newElement_0.fabricIndex = [NSNumber numberWithUnsignedChar:entry_0.fabricIndex]; + newElement_0.providerNodeID = [NSNumber numberWithUnsignedLongLong:entry_0.providerNodeID]; + newElement_0.endpoint = [NSNumber numberWithUnsignedShort:entry_0.endpoint]; + [array_0 addObject:newElement_0]; + } + { // Scope for the error so we will know what it's named + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + *aError = err; + return nil; + } + } + value = array_0; return value; } case Attributes::UpdatePossible::Id: { @@ -4547,6 +4565,32 @@ id CHIPDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader value = [NSNumber numberWithBool:cppValue]; return value; } + case Attributes::UpdateState::Id: { + using TypeInfo = Attributes::UpdateState::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nonnull value; + value = [NSNumber numberWithUnsignedChar:chip::to_underlying(cppValue)]; + return value; + } + case Attributes::UpdateStateProgress::Id: { + using TypeInfo = Attributes::UpdateStateProgress::TypeInfo; + TypeInfo::DecodableType cppValue; + *aError = DataModel::Decode(aReader, cppValue); + if (*aError != CHIP_NO_ERROR) { + return nil; + } + NSNumber * _Nullable value; + if (cppValue.IsNull()) { + value = nil; + } else { + value = [NSNumber numberWithUnsignedChar:cppValue.Value()]; + } + return value; + } case Attributes::AttributeList::Id: { using TypeInfo = Attributes::AttributeList::TypeInfo; TypeInfo::DecodableType cppValue; diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm index c1203946f986ea..a34d7e3f39f3f8 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge.mm @@ -3208,6 +3208,50 @@ } } +void CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersListAttributeCallbackBridge::OnSuccessFn(void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType> & value) +{ + NSArray * _Nonnull objCValue; + auto * array_0 = [NSMutableArray new]; + auto iter_0 = value.begin(); + while (iter_0.Next()) { + auto & entry_0 = iter_0.GetValue(); + CHIPOtaSoftwareUpdateRequestorClusterProviderLocation * newElement_0; + newElement_0 = [CHIPOtaSoftwareUpdateRequestorClusterProviderLocation new]; + newElement_0.fabricIndex = [NSNumber numberWithUnsignedChar:entry_0.fabricIndex]; + newElement_0.providerNodeID = [NSNumber numberWithUnsignedLongLong:entry_0.providerNodeID]; + newElement_0.endpoint = [NSNumber numberWithUnsignedShort:entry_0.endpoint]; + [array_0 addObject:newElement_0]; + } + { // Scope for the error so we will know what it's named + CHIP_ERROR err = iter_0.GetStatus(); + if (err != CHIP_NO_ERROR) { + OnFailureFn(context, EMBER_ZCL_STATUS_INVALID_VALUE); + return; + } + } + objCValue = array_0; + DispatchSuccess(context, objCValue); +}; + +void CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersListAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished( + void * context) +{ + auto * self = static_cast(context); + if (!self->mQueue) { + return; + } + + if (self->mEstablishedHandler != nil) { + dispatch_async(self->mQueue, self->mEstablishedHandler); + // On failure, mEstablishedHandler will be cleaned up by our destructor, + // but we can clean it up earlier on successful subscription + // establishment. + self->mEstablishedHandler = nil; + } +} + void CHIPOtaSoftwareUpdateRequestorAttributeListListAttributeCallbackBridge::OnSuccessFn( void * context, const chip::app::DataModel::DecodableList & value) { diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge_internal.h b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge_internal.h index fcfd5825f302a2..653f8e0fa3bf2e 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge_internal.h +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPCallbackBridge_internal.h @@ -2930,6 +2930,37 @@ class CHIPOtaSoftwareUpdateProviderAttributeListListAttributeCallbackSubscriptio SubscriptionEstablishedHandler mEstablishedHandler; }; +class CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersListAttributeCallbackBridge + : public CHIPCallbackBridge +{ +public: + CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersListAttributeCallbackBridge(dispatch_queue_t queue, ResponseHandler handler, + CHIPActionBlock action, bool keepAlive = false) : + CHIPCallbackBridge(queue, handler, action, OnSuccessFn, + keepAlive){}; + + static void OnSuccessFn(void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType> & value); +}; + +class CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersListAttributeCallbackSubscriptionBridge + : public CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersListAttributeCallbackBridge +{ +public: + CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersListAttributeCallbackSubscriptionBridge( + dispatch_queue_t queue, ResponseHandler handler, CHIPActionBlock action, + SubscriptionEstablishedHandler establishedHandler) : + CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersListAttributeCallbackBridge(queue, handler, action, true), + mEstablishedHandler(establishedHandler) + {} + + static void OnSubscriptionEstablished(void * context); + +private: + SubscriptionEstablishedHandler mEstablishedHandler; +}; + class CHIPOtaSoftwareUpdateRequestorAttributeListListAttributeCallbackBridge : public CHIPCallbackBridge { diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h index 7cea8a544e8ed1..43be5d68df46d9 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.h @@ -2510,14 +2510,15 @@ NS_ASSUME_NONNULL_BEGIN - (void)announceOtaProviderWithParams:(CHIPOtaSoftwareUpdateRequestorClusterAnnounceOtaProviderParams *)params completionHandler:(StatusCompletion)completionHandler; -- (void)readAttributeDefaultOtaProviderWithCompletionHandler:(void (^)(NSData * _Nullable value, - NSError * _Nullable error))completionHandler; -- (void)writeAttributeDefaultOtaProviderWithValue:(NSData * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; -- (void)subscribeAttributeDefaultOtaProviderWithMinInterval:(uint16_t)minInterval - maxInterval:(uint16_t)maxInterval - subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler - reportHandler: - (void (^)(NSData * _Nullable value, NSError * _Nullable error))reportHandler; +- (void)readAttributeDefaultOtaProvidersWithCompletionHandler:(void (^)(NSArray * _Nullable value, + NSError * _Nullable error))completionHandler; +- (void)writeAttributeDefaultOtaProvidersWithValue:(NSArray * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; +- (void)subscribeAttributeDefaultOtaProvidersWithMinInterval:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + subscriptionEstablished: + (SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler + reportHandler: + (void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler; - (void)readAttributeUpdatePossibleWithCompletionHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))completionHandler; @@ -2527,6 +2528,22 @@ NS_ASSUME_NONNULL_BEGIN reportHandler: (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler; +- (void)readAttributeUpdateStateWithCompletionHandler:(void (^)( + NSNumber * _Nullable value, NSError * _Nullable error))completionHandler; +- (void)subscribeAttributeUpdateStateWithMinInterval:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler; + +- (void)readAttributeUpdateStateProgressWithCompletionHandler:(void (^)(NSNumber * _Nullable value, + NSError * _Nullable error))completionHandler; +- (void)subscribeAttributeUpdateStateProgressWithMinInterval:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + subscriptionEstablished: + (SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler + reportHandler: + (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler; + - (void)readAttributeAttributeListWithCompletionHandler:(void (^)( NSArray * _Nullable value, NSError * _Nullable error))completionHandler; diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm index 4662add387325b..73516d9029ccba 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPClustersObjc.mm @@ -10617,7 +10617,7 @@ - (void)announceOtaProviderWithParams:(CHIPOtaSoftwareUpdateRequestorClusterAnno { ListFreer listFreer; OtaSoftwareUpdateRequestor::Commands::AnnounceOtaProvider::Type request; - request.providerLocation = params.providerLocation.unsignedLongLongValue; + request.providerNodeId = params.providerNodeId.unsignedLongLongValue; request.vendorId = static_cast>(params.vendorId.unsignedShortValue); request.announcementReason = static_cast>(params.announcementReason.unsignedCharValue); @@ -10625,6 +10625,7 @@ - (void)announceOtaProviderWithParams:(CHIPOtaSoftwareUpdateRequestorClusterAnno auto & definedValue_0 = request.metadataForNode.Emplace(); definedValue_0 = [self asByteSpan:params.metadataForNode]; } + request.endpoint = params.endpoint.unsignedShortValue; new CHIPCommandSuccessCallbackBridge( self.callbackQueue, @@ -10638,19 +10639,19 @@ new CHIPCommandSuccessCallbackBridge( }); } -- (void)readAttributeDefaultOtaProviderWithCompletionHandler:(void (^)(NSData * _Nullable value, - NSError * _Nullable error))completionHandler +- (void)readAttributeDefaultOtaProvidersWithCompletionHandler:(void (^)(NSArray * _Nullable value, + NSError * _Nullable error))completionHandler { - new CHIPOctetStringAttributeCallbackBridge( + new CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersListAttributeCallbackBridge( self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { - using TypeInfo = OtaSoftwareUpdateRequestor::Attributes::DefaultOtaProvider::TypeInfo; - auto successFn = Callback::FromCancelable(success); + using TypeInfo = OtaSoftwareUpdateRequestor::Attributes::DefaultOtaProviders::TypeInfo; + auto successFn = Callback::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); }); } -- (void)writeAttributeDefaultOtaProviderWithValue:(NSData * _Nonnull)value completionHandler:(StatusCompletion)completionHandler +- (void)writeAttributeDefaultOtaProvidersWithValue:(NSArray * _Nonnull)value completionHandler:(StatusCompletion)completionHandler { new CHIPDefaultSuccessCallbackBridge( self.callbackQueue, @@ -10659,29 +10660,55 @@ new CHIPDefaultSuccessCallbackBridge( }, ^(Cancelable * success, Cancelable * failure) { ListFreer listFreer; - using TypeInfo = OtaSoftwareUpdateRequestor::Attributes::DefaultOtaProvider::TypeInfo; + using TypeInfo = OtaSoftwareUpdateRequestor::Attributes::DefaultOtaProviders::TypeInfo; TypeInfo::Type cppValue; - cppValue = [self asByteSpan:value]; + { + using ListType_0 = std::remove_reference_t; + using ListMemberType_0 = ListMemberTypeGetter::Type; + if (value.count != 0) { + auto * listHolder_0 = new ListHolder(value.count); + if (listHolder_0 == nullptr || listHolder_0->mList == nullptr) { + return CHIP_ERROR_INVALID_ARGUMENT; + } + listFreer.add(listHolder_0); + for (size_t i_0 = 0; i_0 < value.count; ++i_0) { + if (![value[i_0] isKindOfClass:[CHIPOtaSoftwareUpdateRequestorClusterProviderLocation class]]) { + // Wrong kind of value. + return CHIP_ERROR_INVALID_ARGUMENT; + } + auto element_0 = (CHIPOtaSoftwareUpdateRequestorClusterProviderLocation *) value[i_0]; + listHolder_0->mList[i_0].fabricIndex = element_0.fabricIndex.unsignedCharValue; + listHolder_0->mList[i_0].providerNodeID = element_0.providerNodeID.unsignedLongLongValue; + listHolder_0->mList[i_0].endpoint = element_0.endpoint.unsignedShortValue; + } + cppValue = ListType_0(listHolder_0->mList, value.count); + } else { + cppValue = ListType_0(); + } + } auto successFn = Callback::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); return self.cppCluster.WriteAttribute(cppValue, successFn->mContext, successFn->mCall, failureFn->mCall); }); } -- (void)subscribeAttributeDefaultOtaProviderWithMinInterval:(uint16_t)minInterval - maxInterval:(uint16_t)maxInterval - subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler - reportHandler: - (void (^)(NSData * _Nullable value, NSError * _Nullable error))reportHandler +- (void)subscribeAttributeDefaultOtaProvidersWithMinInterval:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + subscriptionEstablished: + (SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler + reportHandler: + (void (^)(NSArray * _Nullable value, NSError * _Nullable error))reportHandler { - new CHIPOctetStringAttributeCallbackSubscriptionBridge( + new CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersListAttributeCallbackSubscriptionBridge( self.callbackQueue, reportHandler, ^(Cancelable * success, Cancelable * failure) { - using TypeInfo = OtaSoftwareUpdateRequestor::Attributes::DefaultOtaProvider::TypeInfo; - auto successFn = Callback::FromCancelable(success); + using TypeInfo = OtaSoftwareUpdateRequestor::Attributes::DefaultOtaProviders::TypeInfo; + auto successFn = Callback::FromCancelable(success); auto failureFn = Callback::FromCancelable(failure); return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, - minInterval, maxInterval, CHIPOctetStringAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); + minInterval, maxInterval, + CHIPOtaSoftwareUpdateRequestorDefaultOtaProvidersListAttributeCallbackSubscriptionBridge:: + OnSubscriptionEstablished); }, subscriptionEstablishedHandler); } @@ -10715,6 +10742,67 @@ new CHIPBooleanAttributeCallbackSubscriptionBridge( subscriptionEstablishedHandler); } +- (void)readAttributeUpdateStateWithCompletionHandler:(void (^)( + NSNumber * _Nullable value, NSError * _Nullable error))completionHandler +{ + new CHIPOtaSoftwareUpdateRequestorClusterUpdateStateEnumAttributeCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + using TypeInfo = OtaSoftwareUpdateRequestor::Attributes::UpdateState::TypeInfo; + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); + }); +} + +- (void)subscribeAttributeUpdateStateWithMinInterval:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + subscriptionEstablished:(SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler + reportHandler:(void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + new CHIPOtaSoftwareUpdateRequestorClusterUpdateStateEnumAttributeCallbackSubscriptionBridge( + self.callbackQueue, reportHandler, + ^(Cancelable * success, Cancelable * failure) { + using TypeInfo = OtaSoftwareUpdateRequestor::Attributes::UpdateState::TypeInfo; + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, + minInterval, maxInterval, + CHIPOtaSoftwareUpdateRequestorClusterUpdateStateEnumAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); + }, + subscriptionEstablishedHandler); +} + +- (void)readAttributeUpdateStateProgressWithCompletionHandler:(void (^)(NSNumber * _Nullable value, + NSError * _Nullable error))completionHandler +{ + new CHIPNullableInt8uAttributeCallbackBridge( + self.callbackQueue, completionHandler, ^(Cancelable * success, Cancelable * failure) { + using TypeInfo = OtaSoftwareUpdateRequestor::Attributes::UpdateStateProgress::TypeInfo; + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.ReadAttribute(successFn->mContext, successFn->mCall, failureFn->mCall); + }); +} + +- (void)subscribeAttributeUpdateStateProgressWithMinInterval:(uint16_t)minInterval + maxInterval:(uint16_t)maxInterval + subscriptionEstablished: + (SubscriptionEstablishedHandler _Nullable)subscriptionEstablishedHandler + reportHandler: + (void (^)(NSNumber * _Nullable value, NSError * _Nullable error))reportHandler +{ + new CHIPNullableInt8uAttributeCallbackSubscriptionBridge( + self.callbackQueue, reportHandler, + ^(Cancelable * success, Cancelable * failure) { + using TypeInfo = OtaSoftwareUpdateRequestor::Attributes::UpdateStateProgress::TypeInfo; + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.SubscribeAttribute(successFn->mContext, successFn->mCall, failureFn->mCall, + minInterval, maxInterval, CHIPNullableInt8uAttributeCallbackSubscriptionBridge::OnSubscriptionEstablished); + }, + subscriptionEstablishedHandler); +} + - (void)readAttributeAttributeListWithCompletionHandler:(void (^)( NSArray * _Nullable value, NSError * _Nullable error))completionHandler { diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.h b/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.h index 79b5e1a071ec1a..e2e124dc0f31a5 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.h @@ -622,10 +622,11 @@ NS_ASSUME_NONNULL_BEGIN @end @interface CHIPOtaSoftwareUpdateRequestorClusterAnnounceOtaProviderParams : NSObject -@property (strong, nonatomic) NSNumber * _Nonnull providerLocation; +@property (strong, nonatomic) NSNumber * _Nonnull providerNodeId; @property (strong, nonatomic) NSNumber * _Nonnull vendorId; @property (strong, nonatomic) NSNumber * _Nonnull announcementReason; @property (strong, nonatomic) NSData * _Nullable metadataForNode; +@property (strong, nonatomic) NSNumber * _Nonnull endpoint; - (instancetype)init; @end diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.mm index bda8aafd5ef651..a9ee42f97c13a8 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPCommandPayloadsObjc.mm @@ -1307,13 +1307,15 @@ - (instancetype)init { if (self = [super init]) { - _providerLocation = @(0); + _providerNodeId = @(0); _vendorId = @(0); _announcementReason = @(0); _metadataForNode = nil; + + _endpoint = @(0); } return self; } diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.h b/src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.h index 0fd985e9cc0dd7..fb8d83823269f2 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.h @@ -101,6 +101,13 @@ NS_ASSUME_NONNULL_BEGIN - (instancetype)init; @end +@interface CHIPOtaSoftwareUpdateRequestorClusterProviderLocation : NSObject +@property (strong, nonatomic) NSNumber * _Nonnull fabricIndex; +@property (strong, nonatomic) NSNumber * _Nonnull providerNodeID; +@property (strong, nonatomic) NSNumber * _Nonnull endpoint; +- (instancetype)init; +@end + @interface CHIPGeneralCommissioningClusterBasicCommissioningInfoType : NSObject @property (strong, nonatomic) NSNumber * _Nonnull failSafeExpiryLengthMs; - (instancetype)init; diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.mm index 683bb5b8204734..16b408f0328dd4 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPStructsObjc.mm @@ -185,6 +185,21 @@ - (instancetype)init } @end +@implementation CHIPOtaSoftwareUpdateRequestorClusterProviderLocation +- (instancetype)init +{ + if (self = [super init]) { + + _fabricIndex = @(0); + + _providerNodeID = @(0); + + _endpoint = @(0); + } + return self; +} +@end + @implementation CHIPGeneralCommissioningClusterBasicCommissioningInfoType - (instancetype)init { diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPTestClustersObjc.h b/src/darwin/Framework/CHIP/zap-generated/CHIPTestClustersObjc.h index 00a81841930b3c..5f0e5bf6415fb1 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPTestClustersObjc.h +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPTestClustersObjc.h @@ -619,6 +619,9 @@ NS_ASSUME_NONNULL_BEGIN @interface CHIPTestOtaSoftwareUpdateRequestor : CHIPOtaSoftwareUpdateRequestor - (void)writeAttributeUpdatePossibleWithValue:(NSNumber * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; +- (void)writeAttributeUpdateStateWithValue:(NSNumber * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; +- (void)writeAttributeUpdateStateProgressWithValue:(NSNumber * _Nullable)value + completionHandler:(StatusCompletion)completionHandler; - (void)writeAttributeAttributeListWithValue:(NSArray * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; - (void)writeAttributeClusterRevisionWithValue:(NSNumber * _Nonnull)value completionHandler:(StatusCompletion)completionHandler; diff --git a/src/darwin/Framework/CHIP/zap-generated/CHIPTestClustersObjc.mm b/src/darwin/Framework/CHIP/zap-generated/CHIPTestClustersObjc.mm index c5af15f8019223..d018a05f5bdace 100644 --- a/src/darwin/Framework/CHIP/zap-generated/CHIPTestClustersObjc.mm +++ b/src/darwin/Framework/CHIP/zap-generated/CHIPTestClustersObjc.mm @@ -6159,6 +6159,47 @@ new CHIPDefaultSuccessCallbackBridge( }); } +- (void)writeAttributeUpdateStateWithValue:(NSNumber * _Nonnull)value completionHandler:(StatusCompletion)completionHandler +{ + new CHIPDefaultSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable ignored, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + ListFreer listFreer; + using TypeInfo = OtaSoftwareUpdateRequestor::Attributes::UpdateState::TypeInfo; + TypeInfo::Type cppValue; + cppValue = static_cast>(value.unsignedCharValue); + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.WriteAttribute(cppValue, successFn->mContext, successFn->mCall, failureFn->mCall); + }); +} + +- (void)writeAttributeUpdateStateProgressWithValue:(NSNumber * _Nullable)value completionHandler:(StatusCompletion)completionHandler +{ + new CHIPDefaultSuccessCallbackBridge( + self.callbackQueue, + ^(id _Nullable ignored, NSError * _Nullable error) { + completionHandler(error); + }, + ^(Cancelable * success, Cancelable * failure) { + ListFreer listFreer; + using TypeInfo = OtaSoftwareUpdateRequestor::Attributes::UpdateStateProgress::TypeInfo; + TypeInfo::Type cppValue; + if (value == nil) { + cppValue.SetNull(); + } else { + auto & nonNullValue_0 = cppValue.SetNonNull(); + nonNullValue_0 = value.unsignedCharValue; + } + auto successFn = Callback::FromCancelable(success); + auto failureFn = Callback::FromCancelable(failure); + return self.cppCluster.WriteAttribute(cppValue, successFn->mContext, successFn->mCall, failureFn->mCall); + }); +} + - (void)writeAttributeAttributeListWithValue:(NSArray * _Nonnull)value completionHandler:(StatusCompletion)completionHandler { new CHIPDefaultSuccessCallbackBridge( diff --git a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m index 6f4dc7267ea2ff..cd8d5c1fc4d139 100644 --- a/src/darwin/Framework/CHIPTests/CHIPClustersTests.m +++ b/src/darwin/Framework/CHIPTests/CHIPClustersTests.m @@ -43102,7 +43102,7 @@ - (void)testSendClusterOtaSoftwareUpdateProviderReadAttributeClusterRevisionWith [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterOtaSoftwareUpdateRequestorReadAttributeDefaultOtaProviderWithCompletionHandler +- (void)testSendClusterOtaSoftwareUpdateRequestorReadAttributeDefaultOtaProvidersWithCompletionHandler { dispatch_queue_t queue = dispatch_get_main_queue(); @@ -43118,10 +43118,10 @@ - (void)testSendClusterOtaSoftwareUpdateRequestorReadAttributeDefaultOtaProvider XCTAssertNotNil(cluster); XCTestExpectation * expectation = - [self expectationWithDescription:@"OtaSoftwareUpdateRequestorReadAttributeDefaultOtaProviderWithCompletionHandler"]; + [self expectationWithDescription:@"OtaSoftwareUpdateRequestorReadAttributeDefaultOtaProvidersWithCompletionHandler"]; - [cluster readAttributeDefaultOtaProviderWithCompletionHandler:^(NSData * _Nullable value, NSError * _Nullable err) { - NSLog(@"OtaSoftwareUpdateRequestor DefaultOtaProvider Error: %@", err); + [cluster readAttributeDefaultOtaProvidersWithCompletionHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + NSLog(@"OtaSoftwareUpdateRequestor DefaultOtaProviders Error: %@", err); XCTAssertEqual(err.code, 0); [expectation fulfill]; }]; @@ -43129,7 +43129,7 @@ - (void)testSendClusterOtaSoftwareUpdateRequestorReadAttributeDefaultOtaProvider [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)testSendClusterOtaSoftwareUpdateRequestorWriteAttributeDefaultOtaProviderWithValue +- (void)testSendClusterOtaSoftwareUpdateRequestorWriteAttributeDefaultOtaProvidersWithValue { dispatch_queue_t queue = dispatch_get_main_queue(); @@ -43145,15 +43145,15 @@ - (void)testSendClusterOtaSoftwareUpdateRequestorWriteAttributeDefaultOtaProvide XCTAssertNotNil(cluster); XCTestExpectation * expectation = - [self expectationWithDescription:@"OtaSoftwareUpdateRequestorWriteAttributeDefaultOtaProviderWithValue"]; + [self expectationWithDescription:@"OtaSoftwareUpdateRequestorWriteAttributeDefaultOtaProvidersWithValue"]; - NSData * _Nonnull value = [@"Test" dataUsingEncoding:NSUTF8StringEncoding]; - [cluster writeAttributeDefaultOtaProviderWithValue:value - completionHandler:^(NSError * _Nullable err) { - NSLog(@"OtaSoftwareUpdateRequestor DefaultOtaProvider Error: %@", err); - XCTAssertEqual(err.code, 0); - [expectation fulfill]; - }]; + NSArray * _Nonnull value = [NSArray array]; + [cluster writeAttributeDefaultOtaProvidersWithValue:value + completionHandler:^(NSError * _Nullable err) { + NSLog(@"OtaSoftwareUpdateRequestor DefaultOtaProviders Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } @@ -43184,6 +43184,60 @@ - (void)testSendClusterOtaSoftwareUpdateRequestorReadAttributeUpdatePossibleWith [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } +- (void)testSendClusterOtaSoftwareUpdateRequestorReadAttributeUpdateStateWithCompletionHandler +{ + dispatch_queue_t queue = dispatch_get_main_queue(); + + XCTestExpectation * connectedExpectation = + [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; + WaitForCommissionee(connectedExpectation, queue); + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + + CHIPDevice * device = GetConnectedDevice(); + CHIPOtaSoftwareUpdateRequestor * cluster = [[CHIPOtaSoftwareUpdateRequestor alloc] initWithDevice:device + endpoint:0 + queue:queue]; + XCTAssertNotNil(cluster); + + XCTestExpectation * expectation = + [self expectationWithDescription:@"OtaSoftwareUpdateRequestorReadAttributeUpdateStateWithCompletionHandler"]; + + [cluster readAttributeUpdateStateWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"OtaSoftwareUpdateRequestor UpdateState Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + +- (void)testSendClusterOtaSoftwareUpdateRequestorReadAttributeUpdateStateProgressWithCompletionHandler +{ + dispatch_queue_t queue = dispatch_get_main_queue(); + + XCTestExpectation * connectedExpectation = + [self expectationWithDescription:@"Wait for the commissioned device to be retrieved"]; + WaitForCommissionee(connectedExpectation, queue); + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; + + CHIPDevice * device = GetConnectedDevice(); + CHIPOtaSoftwareUpdateRequestor * cluster = [[CHIPOtaSoftwareUpdateRequestor alloc] initWithDevice:device + endpoint:0 + queue:queue]; + XCTAssertNotNil(cluster); + + XCTestExpectation * expectation = + [self expectationWithDescription:@"OtaSoftwareUpdateRequestorReadAttributeUpdateStateProgressWithCompletionHandler"]; + + [cluster readAttributeUpdateStateProgressWithCompletionHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + NSLog(@"OtaSoftwareUpdateRequestor UpdateStateProgress Error: %@", err); + XCTAssertEqual(err.code, 0); + [expectation fulfill]; + }]; + + [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; +} + - (void)testSendClusterOtaSoftwareUpdateRequestorReadAttributeAttributeListWithCompletionHandler { dispatch_queue_t queue = dispatch_get_main_queue(); diff --git a/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp b/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp index 000f19366fdda4..19dde822585be1 100644 --- a/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp +++ b/zzz_generated/all-clusters-app/zap-generated/IMClusterCommandHandler.cpp @@ -1253,6 +1253,48 @@ void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandP } // namespace OtaSoftwareUpdateProvider +namespace OtaSoftwareUpdateRequestor { + +void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, 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; + bool wasHandled = false; + { + switch (aCommandPath.mCommandId) + { + case Commands::AnnounceOtaProvider::Id: { + Commands::AnnounceOtaProvider::DecodableType commandData; + TLVError = DataModel::Decode(aDataTlv, commandData); + if (TLVError == CHIP_NO_ERROR) + { + wasHandled = + emberAfOtaSoftwareUpdateRequestorClusterAnnounceOtaProviderCallback(apCommandObj, aCommandPath, commandData); + } + break; + } + default: { + // Unrecognized command ID, error status will apply. + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::UnsupportedCommand); + ChipLogError(Zcl, "Unknown command " ChipLogFormatMEI " for cluster " ChipLogFormatMEI, + ChipLogValueMEI(aCommandPath.mCommandId), ChipLogValueMEI(aCommandPath.mClusterId)); + return; + } + } + } + + if (CHIP_NO_ERROR != TLVError || !wasHandled) + { + apCommandObj->AddStatus(aCommandPath, Protocols::InteractionModel::Status::InvalidCommand); + ChipLogProgress(Zcl, "Failed to dispatch command, TLVError=%" CHIP_ERROR_FORMAT, TLVError.Format()); + } +} + +} // namespace OtaSoftwareUpdateRequestor + namespace OnOff { void DispatchServerCommand(CommandHandler * apCommandObj, const ConcreteCommandPath & aCommandPath, TLV::TLVReader & aDataTlv) @@ -1963,6 +2005,9 @@ void DispatchSingleClusterCommand(const ConcreteCommandPath & aCommandPath, TLV: case Clusters::OtaSoftwareUpdateProvider::Id: Clusters::OtaSoftwareUpdateProvider::DispatchServerCommand(apCommandObj, aCommandPath, aReader); break; + case Clusters::OtaSoftwareUpdateRequestor::Id: + Clusters::OtaSoftwareUpdateRequestor::DispatchServerCommand(apCommandObj, aCommandPath, aReader); + break; case Clusters::OnOff::Id: Clusters::OnOff::DispatchServerCommand(apCommandObj, aCommandPath, aReader); break; diff --git a/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h b/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h index ed9a383989188f..201e01ef030e3f 100644 --- a/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h +++ b/zzz_generated/all-clusters-app/zap-generated/endpoint_config.h @@ -1392,7 +1392,7 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 588 +#define GENERATED_ATTRIBUTE_COUNT 590 #define GENERATED_ATTRIBUTES \ { \ \ @@ -1454,9 +1454,12 @@ { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(0x0001) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: OTA Software Update Requestor (server) */ \ - { 0x0001, ZAP_TYPE(OCTET_STRING), 17, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_EMPTY_DEFAULT() }, /* default ota provider */ \ - { 0x0002, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_EMPTY_DEFAULT() }, /* update possible */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + { 0x0000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + ZAP_SIMPLE_DEFAULT(0) }, /* DefaultOtaProviders */ \ + { 0x0001, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(1) }, /* UpdatePossible */ \ + { 0x0002, ZAP_TYPE(ENUM8), 1, 0, ZAP_SIMPLE_DEFAULT(0) }, /* UpdateState */ \ + { 0x0003, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0) }, /* UpdateStateProgress */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: Power Source Configuration (server) */ \ { 0x0000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE), ZAP_EMPTY_DEFAULT() }, /* Sources */ \ @@ -2319,246 +2322,246 @@ 0x0029, ZAP_ATTRIBUTE_INDEX(34), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: OTA Software Update Provider (server) */ \ { \ - 0x002A, ZAP_ATTRIBUTE_INDEX(35), 3, 20, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x002A, ZAP_ATTRIBUTE_INDEX(35), 5, 5, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: OTA Software Update Requestor (server) */ \ { \ - 0x002E, ZAP_ATTRIBUTE_INDEX(38), 2, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x002E, ZAP_ATTRIBUTE_INDEX(40), 2, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: Power Source Configuration (server) */ \ { \ - 0x0030, ZAP_ATTRIBUTE_INDEX(40), 6, 270, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0030, ZAP_ATTRIBUTE_INDEX(42), 6, 270, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: General Commissioning (server) */ \ { \ - 0x0031, ZAP_ATTRIBUTE_INDEX(46), 10, 60, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0031, ZAP_ATTRIBUTE_INDEX(48), 10, 60, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: Network Commissioning (server) */ \ { \ - 0x0032, ZAP_ATTRIBUTE_INDEX(56), 0, 0, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0032, ZAP_ATTRIBUTE_INDEX(58), 0, 0, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: Diagnostic Logs (server) */ \ { \ - 0x0033, ZAP_ATTRIBUTE_INDEX(56), 9, 17, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0033, ZAP_ATTRIBUTE_INDEX(58), 9, 17, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: General Diagnostics (server) */ \ { \ - 0x0034, ZAP_ATTRIBUTE_INDEX(65), 6, 30, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0034, ZAP_ATTRIBUTE_INDEX(67), 6, 30, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: Software Diagnostics (server) */ \ { \ - 0x0035, ZAP_ATTRIBUTE_INDEX(71), 65, 247, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0035, ZAP_ATTRIBUTE_INDEX(73), 65, 247, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: Thread Network Diagnostics (server) */ \ { \ - 0x0036, ZAP_ATTRIBUTE_INDEX(136), 15, 58, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0036, ZAP_ATTRIBUTE_INDEX(138), 15, 58, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: WiFi Network Diagnostics (server) */ \ { \ - 0x0037, ZAP_ATTRIBUTE_INDEX(151), 11, 57, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0037, ZAP_ATTRIBUTE_INDEX(153), 11, 57, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: Ethernet Network Diagnostics (server) */ \ { \ - 0x003C, ZAP_ATTRIBUTE_INDEX(162), 4, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x003C, ZAP_ATTRIBUTE_INDEX(164), 4, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: AdministratorCommissioning (server) */ \ { \ - 0x003E, ZAP_ATTRIBUTE_INDEX(166), 6, 4, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x003E, ZAP_ATTRIBUTE_INDEX(168), 6, 4, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: Operational Credentials (server) */ \ { \ - 0x003F, ZAP_ATTRIBUTE_INDEX(172), 5, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x003F, ZAP_ATTRIBUTE_INDEX(174), 5, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: Group Key Management (server) */ \ { \ - 0x0040, ZAP_ATTRIBUTE_INDEX(177), 2, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0040, ZAP_ATTRIBUTE_INDEX(179), 2, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: Fixed Label (server) */ \ { \ - 0x0041, ZAP_ATTRIBUTE_INDEX(179), 2, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0041, ZAP_ATTRIBUTE_INDEX(181), 2, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: User Label (server) */ \ { \ - 0x0405, ZAP_ATTRIBUTE_INDEX(181), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0405, ZAP_ATTRIBUTE_INDEX(183), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: Relative Humidity Measurement (server) */ \ { 0x0003, \ - ZAP_ATTRIBUTE_INDEX(185), \ + ZAP_ATTRIBUTE_INDEX(187), \ 3, \ 5, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ chipFuncArrayIdentifyServer }, /* Endpoint: 1, Cluster: Identify (server) */ \ { 0x0004, \ - ZAP_ATTRIBUTE_INDEX(188), \ + ZAP_ATTRIBUTE_INDEX(190), \ 2, \ 3, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayGroupsServer }, /* Endpoint: 1, Cluster: Groups (server) */ \ { 0x0005, \ - ZAP_ATTRIBUTE_INDEX(190), \ + ZAP_ATTRIBUTE_INDEX(192), \ 6, \ 8, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayScenesServer }, /* Endpoint: 1, Cluster: Scenes (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(196), \ + ZAP_ATTRIBUTE_INDEX(198), \ 7, \ 13, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayOnOffServer }, /* Endpoint: 1, Cluster: On/Off (server) */ \ { \ - 0x0007, ZAP_ATTRIBUTE_INDEX(203), 3, 4, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0007, ZAP_ATTRIBUTE_INDEX(205), 3, 4, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: On/off Switch Configuration (server) */ \ { 0x0008, \ - ZAP_ATTRIBUTE_INDEX(206), \ + ZAP_ATTRIBUTE_INDEX(208), \ 15, \ 23, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayLevelControlServer }, /* Endpoint: 1, Cluster: Level Control (server) */ \ { \ - 0x000F, ZAP_ATTRIBUTE_INDEX(221), 4, 5, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x000F, ZAP_ATTRIBUTE_INDEX(223), 4, 5, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Binary Input (Basic) (server) */ \ { \ - 0x001D, ZAP_ATTRIBUTE_INDEX(225), 5, 0, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x001D, ZAP_ATTRIBUTE_INDEX(227), 5, 0, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Descriptor (server) */ \ { \ - 0x001E, ZAP_ATTRIBUTE_INDEX(230), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x001E, ZAP_ATTRIBUTE_INDEX(232), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Binding (server) */ \ { \ - 0x0025, ZAP_ATTRIBUTE_INDEX(231), 4, 0, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0025, ZAP_ATTRIBUTE_INDEX(233), 4, 0, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Bridged Actions (server) */ \ { \ - 0x002F, ZAP_ATTRIBUTE_INDEX(235), 11, 88, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x002F, ZAP_ATTRIBUTE_INDEX(237), 11, 88, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Power Source (server) */ \ { \ - 0x0039, ZAP_ATTRIBUTE_INDEX(246), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0039, ZAP_ATTRIBUTE_INDEX(248), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Bridged Device Basic (server) */ \ { \ - 0x003B, ZAP_ATTRIBUTE_INDEX(247), 5, 9, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x003B, ZAP_ATTRIBUTE_INDEX(249), 5, 9, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Switch (server) */ \ { \ - 0x0040, ZAP_ATTRIBUTE_INDEX(252), 2, 256, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0040, ZAP_ATTRIBUTE_INDEX(254), 2, 256, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Fixed Label (server) */ \ { \ - 0x0041, ZAP_ATTRIBUTE_INDEX(254), 2, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0041, ZAP_ATTRIBUTE_INDEX(256), 2, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: User Label (server) */ \ { \ - 0x0045, ZAP_ATTRIBUTE_INDEX(256), 2, 3, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0045, ZAP_ATTRIBUTE_INDEX(258), 2, 3, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Boolean State (server) */ \ { \ - 0x0050, ZAP_ATTRIBUTE_INDEX(258), 6, 38, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0050, ZAP_ATTRIBUTE_INDEX(260), 6, 38, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Mode Select (server) */ \ { 0x0101, \ - ZAP_ATTRIBUTE_INDEX(264), \ + ZAP_ATTRIBUTE_INDEX(266), \ 19, \ 29, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ chipFuncArrayDoorLockServer }, /* Endpoint: 1, Cluster: Door Lock (server) */ \ { \ - 0x0102, ZAP_ATTRIBUTE_INDEX(283), 20, 35, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0102, ZAP_ATTRIBUTE_INDEX(285), 20, 35, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Window Covering (server) */ \ { \ - 0x0103, ZAP_ATTRIBUTE_INDEX(303), 5, 7, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0103, ZAP_ATTRIBUTE_INDEX(305), 5, 7, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Barrier Control (server) */ \ { \ 0x0200, \ - ZAP_ATTRIBUTE_INDEX(308), \ + ZAP_ATTRIBUTE_INDEX(310), \ 26, \ 54, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(ATTRIBUTE_CHANGED_FUNCTION), \ chipFuncArrayPumpConfigurationAndControlServer \ }, /* Endpoint: 1, Cluster: Pump Configuration and Control (server) */ \ { 0x0201, \ - ZAP_ATTRIBUTE_INDEX(334), \ + ZAP_ATTRIBUTE_INDEX(336), \ 19, \ 34, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayThermostatServer }, /* Endpoint: 1, Cluster: Thermostat (server) */ \ { \ 0x0204, \ - ZAP_ATTRIBUTE_INDEX(353), \ + ZAP_ATTRIBUTE_INDEX(355), \ 4, \ 5, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(PRE_ATTRIBUTE_CHANGED_FUNCTION), \ chipFuncArrayThermostatUserInterfaceConfigurationServer \ }, /* Endpoint: 1, Cluster: Thermostat User Interface Configuration (server) */ \ { 0x0300, \ - ZAP_ATTRIBUTE_INDEX(357), \ + ZAP_ATTRIBUTE_INDEX(359), \ 53, \ 341, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayColorControlServer }, /* Endpoint: 1, Cluster: Color Control (server) */ \ { \ - 0x0400, ZAP_ATTRIBUTE_INDEX(410), 6, 11, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0400, ZAP_ATTRIBUTE_INDEX(412), 6, 11, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Illuminance Measurement (server) */ \ { \ - 0x0402, ZAP_ATTRIBUTE_INDEX(416), 5, 10, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0402, ZAP_ATTRIBUTE_INDEX(418), 5, 10, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Temperature Measurement (server) */ \ { \ - 0x0403, ZAP_ATTRIBUTE_INDEX(421), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0403, ZAP_ATTRIBUTE_INDEX(423), 4, 8, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Pressure Measurement (server) */ \ { \ - 0x0404, ZAP_ATTRIBUTE_INDEX(425), 5, 10, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0404, ZAP_ATTRIBUTE_INDEX(427), 5, 10, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Flow Measurement (server) */ \ { \ - 0x0405, ZAP_ATTRIBUTE_INDEX(430), 5, 10, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0405, ZAP_ATTRIBUTE_INDEX(432), 5, 10, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Relative Humidity Measurement (server) */ \ { 0x0406, \ - ZAP_ATTRIBUTE_INDEX(435), \ + ZAP_ATTRIBUTE_INDEX(437), \ 4, \ 5, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayOccupancySensingServer }, /* Endpoint: 1, Cluster: Occupancy Sensing (server) */ \ { 0x0500, \ - ZAP_ATTRIBUTE_INDEX(439), \ + ZAP_ATTRIBUTE_INDEX(441), \ 6, \ 16, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION) | ZAP_CLUSTER_MASK(PRE_ATTRIBUTE_CHANGED_FUNCTION) | \ ZAP_CLUSTER_MASK(MESSAGE_SENT_FUNCTION), \ chipFuncArrayIasZoneServer }, /* Endpoint: 1, Cluster: IAS Zone (server) */ \ { \ - 0x0503, ZAP_ATTRIBUTE_INDEX(445), 2, 35, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0503, ZAP_ATTRIBUTE_INDEX(447), 2, 35, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Wake on LAN (server) */ \ { \ - 0x0504, ZAP_ATTRIBUTE_INDEX(447), 2, 256, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0504, ZAP_ATTRIBUTE_INDEX(449), 2, 256, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Channel (server) */ \ { \ - 0x0505, ZAP_ATTRIBUTE_INDEX(449), 3, 257, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0505, ZAP_ATTRIBUTE_INDEX(451), 3, 257, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Target Navigator (server) */ \ { \ - 0x0506, ZAP_ATTRIBUTE_INDEX(452), 7, 39, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0506, ZAP_ATTRIBUTE_INDEX(454), 7, 39, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Media Playback (server) */ \ { \ - 0x0507, ZAP_ATTRIBUTE_INDEX(459), 3, 257, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0507, ZAP_ATTRIBUTE_INDEX(461), 3, 257, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Media Input (server) */ \ { \ - 0x0508, ZAP_ATTRIBUTE_INDEX(462), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0508, ZAP_ATTRIBUTE_INDEX(464), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Low Power (server) */ \ { \ - 0x0509, ZAP_ATTRIBUTE_INDEX(463), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0509, ZAP_ATTRIBUTE_INDEX(465), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Keypad Input (server) */ \ { \ - 0x050A, ZAP_ATTRIBUTE_INDEX(464), 3, 260, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x050A, ZAP_ATTRIBUTE_INDEX(466), 3, 260, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Content Launcher (server) */ \ { \ - 0x050B, ZAP_ATTRIBUTE_INDEX(467), 3, 257, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x050B, ZAP_ATTRIBUTE_INDEX(469), 3, 257, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Audio Output (server) */ \ { \ - 0x050C, ZAP_ATTRIBUTE_INDEX(470), 2, 256, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x050C, ZAP_ATTRIBUTE_INDEX(472), 2, 256, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Application Launcher (server) */ \ { \ - 0x050D, ZAP_ATTRIBUTE_INDEX(472), 7, 106, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x050D, ZAP_ATTRIBUTE_INDEX(474), 7, 106, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Application Basic (server) */ \ { \ - 0x050E, ZAP_ATTRIBUTE_INDEX(479), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x050E, ZAP_ATTRIBUTE_INDEX(481), 1, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Account Login (server) */ \ { \ - 0x050F, ZAP_ATTRIBUTE_INDEX(480), 78, 3285, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x050F, ZAP_ATTRIBUTE_INDEX(482), 78, 3285, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Test Cluster (server) */ \ { \ - 0x0B04, ZAP_ATTRIBUTE_INDEX(558), 12, 28, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0B04, ZAP_ATTRIBUTE_INDEX(560), 12, 28, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 1, Cluster: Electrical Measurement (server) */ \ { 0x0004, \ - ZAP_ATTRIBUTE_INDEX(570), \ + ZAP_ATTRIBUTE_INDEX(572), \ 2, \ 3, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayGroupsServer }, /* Endpoint: 2, Cluster: Groups (server) */ \ { 0x0006, \ - ZAP_ATTRIBUTE_INDEX(572), \ + ZAP_ATTRIBUTE_INDEX(574), \ 7, \ 13, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ chipFuncArrayOnOffServer }, /* Endpoint: 2, Cluster: On/Off (server) */ \ { \ - 0x001D, ZAP_ATTRIBUTE_INDEX(579), 5, 0, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x001D, ZAP_ATTRIBUTE_INDEX(581), 5, 0, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 2, Cluster: Descriptor (server) */ \ { 0x0406, \ - ZAP_ATTRIBUTE_INDEX(584), \ + ZAP_ATTRIBUTE_INDEX(586), \ 4, \ 5, \ ZAP_CLUSTER_MASK(SERVER) | ZAP_CLUSTER_MASK(INIT_FUNCTION), \ @@ -2570,7 +2573,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 23, 1480 }, { ZAP_CLUSTER_INDEX(23), 45, 6078 }, { ZAP_CLUSTER_INDEX(68), 4, 21 }, \ + { ZAP_CLUSTER_INDEX(0), 23, 1465 }, { ZAP_CLUSTER_INDEX(23), 45, 6078 }, { ZAP_CLUSTER_INDEX(68), 4, 21 }, \ } // Largest attribute size is needed for various buffers @@ -2580,7 +2583,7 @@ #define ATTRIBUTE_SINGLETONS_SIZE (689) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (7579) +#define ATTRIBUTE_MAX_SIZE (7564) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (3) diff --git a/zzz_generated/app-common/app-common/zap-generated/af-structs.h b/zzz_generated/app-common/app-common/zap-generated/af-structs.h index e9b5a4b45140aa..f4537e7123e05a 100644 --- a/zzz_generated/app-common/app-common/zap-generated/af-structs.h +++ b/zzz_generated/app-common/app-common/zap-generated/af-structs.h @@ -416,6 +416,14 @@ typedef struct _PowerProfileRecord uint8_t powerProfileState; } PowerProfileRecord; +// Struct for ProviderLocation +typedef struct _ProviderLocation +{ + chip::FabricIndex FabricIndex; + chip::NodeId ProviderNodeID; + chip::EndpointId Endpoint; +} ProviderLocation; + // Struct for ReadAttributeStatusRecord typedef struct _ReadAttributeStatusRecord { diff --git a/zzz_generated/app-common/app-common/zap-generated/attribute-id.h b/zzz_generated/app-common/app-common/zap-generated/attribute-id.h index f7527dc3b39c80..9e3971d9122152 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attribute-id.h +++ b/zzz_generated/app-common/app-common/zap-generated/attribute-id.h @@ -317,8 +317,10 @@ // Client attributes // Server attributes -#define ZCL_DEFAULT_OTA_PROVIDER_ATTRIBUTE_ID (0x0001) -#define ZCL_UPDATE_POSSIBLE_ATTRIBUTE_ID (0x0002) +#define ZCL_DEFAULT_OTA_PROVIDERS_ATTRIBUTE_ID (0x0000) +#define ZCL_UPDATE_POSSIBLE_ATTRIBUTE_ID (0x0001) +#define ZCL_UPDATE_STATE_ATTRIBUTE_ID (0x0002) +#define ZCL_UPDATE_STATE_PROGRESS_ATTRIBUTE_ID (0x0003) // Attribute ids for cluster: Localization Configuration diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp index 2c1a723e093d3e..299f9b47a10ec6 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.cpp @@ -6241,43 +6241,44 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) namespace OtaSoftwareUpdateRequestor { namespace Attributes { -namespace DefaultOtaProvider { +namespace UpdatePossible { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value) +EmberAfStatus Get(chip::EndpointId endpoint, bool * value) { - uint8_t zclString[16 + 1]; + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = - emberAfReadServerAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, zclString, sizeof(zclString)); + emberAfReadServerAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - size_t length = emberAfStringLength(zclString); - if (length == NumericAttributeTraits::kNullValue) + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - - VerifyOrReturnError(value.size() == 16, EMBER_ZCL_STATUS_INVALID_DATA_TYPE); - memcpy(value.data(), &zclString[1], 16); - value.reduce_size(length); + *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value) +EmberAfStatus Set(chip::EndpointId endpoint, bool value) { - static_assert(16 < NumericAttributeTraits::kNullValue, "value.size() might be too big"); - VerifyOrReturnError(value.size() <= 16, EMBER_ZCL_STATUS_CONSTRAINT_ERROR); - uint8_t zclString[16 + 1]; - emberAfCopyInt8u(zclString, 0, static_cast(value.size())); - memcpy(&zclString[1], value.data(), value.size()); - return emberAfWriteServerAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, zclString, - ZCL_OCTET_STRING_ATTRIBUTE_TYPE); + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteServerAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, writable, + ZCL_BOOLEAN_ATTRIBUTE_TYPE); } -} // namespace DefaultOtaProvider +} // namespace UpdatePossible -namespace UpdatePossible { +namespace UpdateState { -EmberAfStatus Get(chip::EndpointId endpoint, bool * value) +EmberAfStatus Get(chip::EndpointId endpoint, chip::app::Clusters::OtaSoftwareUpdateRequestor::UpdateStateEnum * value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; Traits::StorageType temp; uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = @@ -6290,9 +6291,9 @@ EmberAfStatus Get(chip::EndpointId endpoint, bool * value) *value = Traits::StorageToWorking(temp); return status; } -EmberAfStatus Set(chip::EndpointId endpoint, bool value) +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::OtaSoftwareUpdateRequestor::UpdateStateEnum value) { - using Traits = NumericAttributeTraits; + using Traits = NumericAttributeTraits; if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; @@ -6300,11 +6301,64 @@ EmberAfStatus Set(chip::EndpointId endpoint, bool value) Traits::StorageType storageValue; Traits::WorkingToStorage(value, storageValue); uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); - return emberAfWriteServerAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, writable, - ZCL_BOOLEAN_ATTRIBUTE_TYPE); + return emberAfWriteServerAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, writable, ZCL_ENUM8_ATTRIBUTE_TYPE); } -} // namespace UpdatePossible +} // namespace UpdateState + +namespace UpdateStateProgress { + +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); + EmberAfStatus status = + emberAfReadServerAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, readable, sizeof(temp)); + VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); + if (Traits::IsNullValue(temp)) + { + value.SetNull(); + } + else + { + value.SetNonNull() = Traits::StorageToWorking(temp); + } + return status; +} +EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value) +{ + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ true, value)) + { + return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; + } + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); + return emberAfWriteServerAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); +} + +EmberAfStatus SetNull(chip::EndpointId endpoint) +{ + using Traits = NumericAttributeTraits; + Traits::StorageType value; + Traits::SetNull(value); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(value); + return emberAfWriteServerAttribute(endpoint, Clusters::OtaSoftwareUpdateRequestor::Id, Id, writable, ZCL_INT8U_ATTRIBUTE_TYPE); +} + +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value) +{ + if (value.IsNull()) + { + return SetNull(endpoint); + } + + return Set(endpoint, value.Value()); +} + +} // namespace UpdateStateProgress namespace FeatureMap { @@ -12239,26 +12293,28 @@ namespace MaxGroupsPerFabric { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - NumericAttributeTraits::StorageType temp; - uint8_t * readable = NumericAttributeTraits::ToAttributeStoreRepresentation(temp); + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::GroupKeyManagement::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - *value = NumericAttributeTraits::StorageToWorking(temp); + *value = Traits::StorageToWorking(temp); return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - NumericAttributeTraits::StorageType storageValue; - NumericAttributeTraits::WorkingToStorage(value, storageValue); - uint8_t * writable = NumericAttributeTraits::ToAttributeStoreRepresentation(storageValue); + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); return emberAfWriteServerAttribute(endpoint, Clusters::GroupKeyManagement::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } @@ -12268,26 +12324,28 @@ namespace MaxGroupKeysPerFabric { EmberAfStatus Get(chip::EndpointId endpoint, uint16_t * value) { - NumericAttributeTraits::StorageType temp; - uint8_t * readable = NumericAttributeTraits::ToAttributeStoreRepresentation(temp); + using Traits = NumericAttributeTraits; + Traits::StorageType temp; + uint8_t * readable = Traits::ToAttributeStoreRepresentation(temp); EmberAfStatus status = emberAfReadServerAttribute(endpoint, Clusters::GroupKeyManagement::Id, Id, readable, sizeof(temp)); VerifyOrReturnError(EMBER_ZCL_STATUS_SUCCESS == status, status); - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, temp)) + if (!Traits::CanRepresentValue(/* isNullable = */ false, temp)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - *value = NumericAttributeTraits::StorageToWorking(temp); + *value = Traits::StorageToWorking(temp); return status; } EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value) { - if (!NumericAttributeTraits::CanRepresentValue(/* isNullable = */ false, value)) + using Traits = NumericAttributeTraits; + if (!Traits::CanRepresentValue(/* isNullable = */ false, value)) { return EMBER_ZCL_STATUS_CONSTRAINT_ERROR; } - NumericAttributeTraits::StorageType storageValue; - NumericAttributeTraits::WorkingToStorage(value, storageValue); - uint8_t * writable = NumericAttributeTraits::ToAttributeStoreRepresentation(storageValue); + Traits::StorageType storageValue; + Traits::WorkingToStorage(value, storageValue); + uint8_t * writable = Traits::ToAttributeStoreRepresentation(storageValue); return emberAfWriteServerAttribute(endpoint, Clusters::GroupKeyManagement::Id, Id, writable, ZCL_INT16U_ATTRIBUTE_TYPE); } diff --git a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h index c754b35ef24ad8..aa147af6ffeb09 100644 --- a/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h +++ b/zzz_generated/app-common/app-common/zap-generated/attributes/Accessors.h @@ -1135,16 +1135,24 @@ EmberAfStatus Set(chip::EndpointId endpoint, uint16_t value); namespace OtaSoftwareUpdateRequestor { namespace Attributes { -namespace DefaultOtaProvider { -EmberAfStatus Get(chip::EndpointId endpoint, chip::MutableByteSpan value); // octet_string -EmberAfStatus Set(chip::EndpointId endpoint, chip::ByteSpan value); -} // namespace DefaultOtaProvider - namespace UpdatePossible { EmberAfStatus Get(chip::EndpointId endpoint, bool * value); // boolean EmberAfStatus Set(chip::EndpointId endpoint, bool value); } // namespace UpdatePossible +namespace UpdateState { +EmberAfStatus Get(chip::EndpointId endpoint, + chip::app::Clusters::OtaSoftwareUpdateRequestor::UpdateStateEnum * value); // UpdateStateEnum +EmberAfStatus Set(chip::EndpointId endpoint, chip::app::Clusters::OtaSoftwareUpdateRequestor::UpdateStateEnum value); +} // namespace UpdateState + +namespace UpdateStateProgress { +EmberAfStatus Get(chip::EndpointId endpoint, DataModel::Nullable & value); // int8u +EmberAfStatus Set(chip::EndpointId endpoint, uint8_t value); +EmberAfStatus SetNull(chip::EndpointId endpoint); +EmberAfStatus Set(chip::EndpointId endpoint, const chip::app::DataModel::Nullable & value); +} // namespace UpdateStateProgress + namespace FeatureMap { EmberAfStatus Get(chip::EndpointId endpoint, uint32_t * value); // bitmap32 EmberAfStatus Set(chip::EndpointId endpoint, uint32_t value); diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp index 884c2de49e2ad0..b51b15a0a1257a 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.cpp @@ -6042,6 +6042,52 @@ namespace Events { } // namespace OtaSoftwareUpdateProvider namespace OtaSoftwareUpdateRequestor { +namespace Structs { +namespace ProviderLocation { +CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const +{ + TLV::TLVType outer; + ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kFabricIndex)), fabricIndex)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kProviderNodeID)), providerNodeID)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kEndpoint)), endpoint)); + ReturnErrorOnFailure(writer.EndContainer(outer)); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + TLV::TLVType outer; + VerifyOrReturnError(TLV::kTLVType_Structure == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE); + err = reader.EnterContainer(outer); + ReturnErrorOnFailure(err); + while ((err = reader.Next()) == CHIP_NO_ERROR) + { + VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); + switch (TLV::TagNumFromTag(reader.GetTag())) + { + case to_underlying(Fields::kFabricIndex): + ReturnErrorOnFailure(DataModel::Decode(reader, fabricIndex)); + break; + case to_underlying(Fields::kProviderNodeID): + ReturnErrorOnFailure(DataModel::Decode(reader, providerNodeID)); + break; + case to_underlying(Fields::kEndpoint): + ReturnErrorOnFailure(DataModel::Decode(reader, endpoint)); + break; + default: + break; + } + } + + VerifyOrReturnError(err == CHIP_END_OF_TLV, err); + ReturnErrorOnFailure(reader.ExitContainer(outer)); + return CHIP_NO_ERROR; +} + +} // namespace ProviderLocation +} // namespace Structs namespace Commands { namespace AnnounceOtaProvider { @@ -6049,11 +6095,12 @@ CHIP_ERROR Type::Encode(TLV::TLVWriter & writer, TLV::Tag tag) const { TLV::TLVType outer; ReturnErrorOnFailure(writer.StartContainer(tag, TLV::kTLVType_Structure, outer)); - ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kProviderLocation)), providerLocation)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kProviderNodeId)), providerNodeId)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kVendorId)), vendorId)); ReturnErrorOnFailure( DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kAnnouncementReason)), announcementReason)); ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kMetadataForNode)), metadataForNode)); + ReturnErrorOnFailure(DataModel::Encode(writer, TLV::ContextTag(to_underlying(Fields::kEndpoint)), endpoint)); ReturnErrorOnFailure(writer.EndContainer(outer)); return CHIP_NO_ERROR; } @@ -6069,8 +6116,8 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) VerifyOrReturnError(TLV::IsContextTag(reader.GetTag()), CHIP_ERROR_INVALID_TLV_TAG); switch (TLV::TagNumFromTag(reader.GetTag())) { - case to_underlying(Fields::kProviderLocation): - ReturnErrorOnFailure(DataModel::Decode(reader, providerLocation)); + case to_underlying(Fields::kProviderNodeId): + ReturnErrorOnFailure(DataModel::Decode(reader, providerNodeId)); break; case to_underlying(Fields::kVendorId): ReturnErrorOnFailure(DataModel::Decode(reader, vendorId)); @@ -6081,6 +6128,9 @@ CHIP_ERROR DecodableType::Decode(TLV::TLVReader & reader) case to_underlying(Fields::kMetadataForNode): ReturnErrorOnFailure(DataModel::Decode(reader, metadataForNode)); break; + case to_underlying(Fields::kEndpoint): + ReturnErrorOnFailure(DataModel::Decode(reader, endpoint)); + break; default: break; } @@ -6098,12 +6148,18 @@ CHIP_ERROR TypeInfo::DecodableType::Decode(TLV::TLVReader & reader, const Concre { switch (path.mAttributeId) { - case Attributes::DefaultOtaProvider::TypeInfo::GetAttributeId(): - ReturnErrorOnFailure(DataModel::Decode(reader, defaultOtaProvider)); + case Attributes::DefaultOtaProviders::TypeInfo::GetAttributeId(): + ReturnErrorOnFailure(DataModel::Decode(reader, defaultOtaProviders)); break; case Attributes::UpdatePossible::TypeInfo::GetAttributeId(): ReturnErrorOnFailure(DataModel::Decode(reader, updatePossible)); break; + case Attributes::UpdateState::TypeInfo::GetAttributeId(): + ReturnErrorOnFailure(DataModel::Decode(reader, updateState)); + break; + case Attributes::UpdateStateProgress::TypeInfo::GetAttributeId(): + ReturnErrorOnFailure(DataModel::Decode(reader, updateStateProgress)); + break; case Attributes::AttributeList::TypeInfo::GetAttributeId(): ReturnErrorOnFailure(DataModel::Decode(reader, attributeList)); break; diff --git a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h index a8a926a3afcf5a..0754d9e47499a1 100644 --- a/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h +++ b/zzz_generated/app-common/app-common/zap-generated/cluster-objects.h @@ -8520,6 +8520,32 @@ enum class UpdateStateEnum : uint8_t using UpdateStateEnum = EmberAfUpdateStateEnum; #endif +namespace Structs { +namespace ProviderLocation { +enum class Fields +{ + kFabricIndex = 0, + kProviderNodeID = 1, + kEndpoint = 2, +}; + +struct Type +{ +public: + chip::FabricIndex fabricIndex; + chip::NodeId providerNodeID; + chip::EndpointId endpoint; + + CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; + CHIP_ERROR Decode(TLV::TLVReader & reader); + bool MatchesFabricIndex(FabricIndex fabricIndex_) const { return fabricIndex == fabricIndex_; } +}; + +using DecodableType = Type; + +} // namespace ProviderLocation +} // namespace Structs + namespace Commands { // Forward-declarations so we can reference these later. @@ -8534,10 +8560,11 @@ namespace Commands { namespace AnnounceOtaProvider { enum class Fields { - kProviderLocation = 0, + kProviderNodeId = 0, kVendorId = 1, kAnnouncementReason = 2, kMetadataForNode = 3, + kEndpoint = 4, }; struct Type @@ -8547,10 +8574,11 @@ struct Type static constexpr CommandId GetCommandId() { return Commands::AnnounceOtaProvider::Id; } static constexpr ClusterId GetClusterId() { return Clusters::OtaSoftwareUpdateRequestor::Id; } - chip::NodeId providerLocation; + chip::NodeId providerNodeId; chip::VendorId vendorId; OTAAnnouncementReason announcementReason; Optional metadataForNode; + chip::EndpointId endpoint; CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; @@ -8565,10 +8593,11 @@ struct DecodableType static constexpr CommandId GetCommandId() { return Commands::AnnounceOtaProvider::Id; } static constexpr ClusterId GetClusterId() { return Clusters::OtaSoftwareUpdateRequestor::Id; } - chip::NodeId providerLocation; + chip::NodeId providerNodeId; chip::VendorId vendorId; OTAAnnouncementReason announcementReason; Optional metadataForNode; + chip::EndpointId endpoint; CHIP_ERROR Decode(TLV::TLVReader & reader); }; }; // namespace AnnounceOtaProvider @@ -8576,18 +8605,20 @@ struct DecodableType namespace Attributes { -namespace DefaultOtaProvider { +namespace DefaultOtaProviders { struct TypeInfo { - using Type = chip::ByteSpan; - using DecodableType = chip::ByteSpan; - using DecodableArgType = chip::ByteSpan; + using Type = chip::app::DataModel::List; + using DecodableType = chip::app::DataModel::DecodableList< + chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType>; + using DecodableArgType = const chip::app::DataModel::DecodableList< + chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType> &; static constexpr ClusterId GetClusterId() { return Clusters::OtaSoftwareUpdateRequestor::Id; } - static constexpr AttributeId GetAttributeId() { return Attributes::DefaultOtaProvider::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::DefaultOtaProviders::Id; } static constexpr bool MustUseTimedWrite() { return false; } }; -} // namespace DefaultOtaProvider +} // namespace DefaultOtaProviders namespace UpdatePossible { struct TypeInfo { @@ -8600,6 +8631,30 @@ struct TypeInfo static constexpr bool MustUseTimedWrite() { return false; } }; } // namespace UpdatePossible +namespace UpdateState { +struct TypeInfo +{ + using Type = chip::app::Clusters::OtaSoftwareUpdateRequestor::UpdateStateEnum; + using DecodableType = chip::app::Clusters::OtaSoftwareUpdateRequestor::UpdateStateEnum; + using DecodableArgType = chip::app::Clusters::OtaSoftwareUpdateRequestor::UpdateStateEnum; + + static constexpr ClusterId GetClusterId() { return Clusters::OtaSoftwareUpdateRequestor::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::UpdateState::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace UpdateState +namespace UpdateStateProgress { +struct TypeInfo +{ + using Type = chip::app::DataModel::Nullable; + using DecodableType = chip::app::DataModel::Nullable; + using DecodableArgType = const chip::app::DataModel::Nullable &; + + static constexpr ClusterId GetClusterId() { return Clusters::OtaSoftwareUpdateRequestor::Id; } + static constexpr AttributeId GetAttributeId() { return Attributes::UpdateStateProgress::Id; } + static constexpr bool MustUseTimedWrite() { return false; } +}; +} // namespace UpdateStateProgress namespace AttributeList { struct TypeInfo { @@ -8645,8 +8700,10 @@ struct TypeInfo CHIP_ERROR Decode(TLV::TLVReader & reader, const ConcreteAttributePath & path); - Attributes::DefaultOtaProvider::TypeInfo::DecodableType defaultOtaProvider; + Attributes::DefaultOtaProviders::TypeInfo::DecodableType defaultOtaProviders; Attributes::UpdatePossible::TypeInfo::DecodableType updatePossible; + Attributes::UpdateState::TypeInfo::DecodableType updateState; + Attributes::UpdateStateProgress::TypeInfo::DecodableType updateStateProgress; Attributes::AttributeList::TypeInfo::DecodableType attributeList; Attributes::FeatureMap::TypeInfo::DecodableType featureMap; Attributes::ClusterRevision::TypeInfo::DecodableType clusterRevision; @@ -8673,10 +8730,10 @@ struct Type static constexpr EventId GetEventId() { return kEventId; } static constexpr ClusterId GetClusterId() { return Clusters::OtaSoftwareUpdateRequestor::Id; } - UpdateStateEnum previousState; + DataModel::Nullable previousState; UpdateStateEnum newState; ChangeReasonEnum reason; - uint32_t targetSoftwareVersion; + DataModel::Nullable targetSoftwareVersion; CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; @@ -8688,10 +8745,10 @@ struct DecodableType static constexpr EventId GetEventId() { return kEventId; } static constexpr ClusterId GetClusterId() { return Clusters::OtaSoftwareUpdateRequestor::Id; } - UpdateStateEnum previousState; + DataModel::Nullable previousState; UpdateStateEnum newState; ChangeReasonEnum reason; - uint32_t targetSoftwareVersion; + DataModel::Nullable targetSoftwareVersion; CHIP_ERROR Decode(TLV::TLVReader & reader); }; @@ -8754,7 +8811,7 @@ struct Type uint32_t softwareVersion; uint64_t bytesDownloaded; uint8_t progressPercent; - int64_t platformCode; + DataModel::Nullable platformCode; CHIP_ERROR Encode(TLV::TLVWriter & writer, TLV::Tag tag) const; }; @@ -8769,7 +8826,7 @@ struct DecodableType uint32_t softwareVersion; uint64_t bytesDownloaded; uint8_t progressPercent; - int64_t platformCode; + DataModel::Nullable platformCode; CHIP_ERROR Decode(TLV::TLVReader & reader); }; diff --git a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h index 83aed2424fd91a..7ec6eab6166808 100644 --- a/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h +++ b/zzz_generated/app-common/app-common/zap-generated/ids/Attributes.h @@ -1060,14 +1060,22 @@ static constexpr AttributeId Id = Globals::Attributes::ClusterRevision::Id; namespace OtaSoftwareUpdateRequestor { namespace Attributes { -namespace DefaultOtaProvider { -static constexpr AttributeId Id = 0x00000001; -} // namespace DefaultOtaProvider +namespace DefaultOtaProviders { +static constexpr AttributeId Id = 0x00000000; +} // namespace DefaultOtaProviders namespace UpdatePossible { -static constexpr AttributeId Id = 0x00000002; +static constexpr AttributeId Id = 0x00000001; } // namespace UpdatePossible +namespace UpdateState { +static constexpr AttributeId Id = 0x00000002; +} // namespace UpdateState + +namespace UpdateStateProgress { +static constexpr AttributeId Id = 0x00000003; +} // namespace UpdateStateProgress + namespace AttributeList { static constexpr AttributeId Id = Globals::Attributes::AttributeList::Id; } // namespace AttributeList diff --git a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h index 65d27f9fd1e237..d403a514804b18 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/Commands.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/Commands.h @@ -59,6 +59,8 @@ CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::BridgedActions::Structs::ActionStruct::DecodableType & value); CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::BridgedActions::Structs::EndpointListStruct::DecodableType & value); +CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType & value); CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfoType::DecodableType & value); CHIP_ERROR LogValue(const char * label, size_t indent, @@ -638,6 +640,38 @@ CHIP_ERROR LogValue(const char * label, size_t indent, ChipLogProgress(chipTool, "%s}", IndentStr(indent).c_str()); return CHIP_NO_ERROR; } +CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType & value) +{ + ChipLogProgress(chipTool, "%s%s: {", IndentStr(indent).c_str(), label); + { + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + if (err != CHIP_NO_ERROR) + { + ChipLogProgress(chipTool, "%sStruct truncated due to invalid value for 'FabricIndex'", IndentStr(indent + 1).c_str()); + return err; + } + } + { + CHIP_ERROR err = LogValue("ProviderNodeID", indent + 1, value.providerNodeID); + if (err != CHIP_NO_ERROR) + { + ChipLogProgress(chipTool, "%sStruct truncated due to invalid value for 'ProviderNodeID'", + IndentStr(indent + 1).c_str()); + return err; + } + } + { + CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); + if (err != CHIP_NO_ERROR) + { + ChipLogProgress(chipTool, "%sStruct truncated due to invalid value for 'Endpoint'", IndentStr(indent + 1).c_str()); + return err; + } + } + ChipLogProgress(chipTool, "%s}", IndentStr(indent).c_str()); + return CHIP_NO_ERROR; +} CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfoType::DecodableType & value) { @@ -25189,8 +25223,10 @@ class ReportOtaSoftwareUpdateProviderClusterRevision : public ModelCommand | * AnnounceOtaProvider | 0x00 | |------------------------------------------------------------------------------| | Attributes: | | -| * DefaultOtaProvider | 0x0001 | -| * UpdatePossible | 0x0002 | +| * DefaultOtaProviders | 0x0000 | +| * UpdatePossible | 0x0001 | +| * UpdateState | 0x0002 | +| * UpdateStateProgress | 0x0003 | | * AttributeList | 0xFFFB | | * ClusterRevision | 0xFFFD | \*----------------------------------------------------------------------------*/ @@ -25203,12 +25239,13 @@ class OtaSoftwareUpdateRequestorAnnounceOtaProvider : public ModelCommand public: OtaSoftwareUpdateRequestorAnnounceOtaProvider() : ModelCommand("announce-ota-provider") { - AddArgument("ProviderLocation", 0, UINT64_MAX, &mRequest.providerLocation); + AddArgument("ProviderNodeId", 0, UINT64_MAX, &mRequest.providerNodeId); AddArgument("VendorId", 0, UINT16_MAX, &mRequest.vendorId); AddArgument( "AnnouncementReason", 0, UINT8_MAX, reinterpret_cast *>(&mRequest.announcementReason)); AddArgument("MetadataForNode", &mRequest.metadataForNode); + AddArgument("Endpoint", 0, UINT16_MAX, &mRequest.endpoint); ModelCommand::AddArguments(); } @@ -25225,18 +25262,18 @@ class OtaSoftwareUpdateRequestorAnnounceOtaProvider : public ModelCommand }; /* - * Attribute DefaultOtaProvider + * Attribute DefaultOtaProviders */ -class ReadOtaSoftwareUpdateRequestorDefaultOtaProvider : public ModelCommand +class ReadOtaSoftwareUpdateRequestorDefaultOtaProviders : public ModelCommand { public: - ReadOtaSoftwareUpdateRequestorDefaultOtaProvider() : ModelCommand("read") + ReadOtaSoftwareUpdateRequestorDefaultOtaProviders() : ModelCommand("read") { - AddArgument("attr-name", "default-ota-provider"); + AddArgument("attr-name", "default-ota-providers"); ModelCommand::AddArguments(); } - ~ReadOtaSoftwareUpdateRequestorDefaultOtaProvider() {} + ~ReadOtaSoftwareUpdateRequestorDefaultOtaProviders() {} CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override { @@ -25244,55 +25281,32 @@ class ReadOtaSoftwareUpdateRequestorDefaultOtaProvider : public ModelCommand chip::Controller::OtaSoftwareUpdateRequestorCluster cluster; cluster.Associate(device, endpointId); - return cluster.ReadAttribute( + return cluster.ReadAttribute( this, OnAttributeResponse, OnDefaultFailure); } - static void OnAttributeResponse(void * context, chip::ByteSpan value) - { - OnGeneralAttributeResponse(context, "OtaSoftwareUpdateRequestor.DefaultOtaProvider response", value); - } -}; - -class WriteOtaSoftwareUpdateRequestorDefaultOtaProvider : public ModelCommand -{ -public: - WriteOtaSoftwareUpdateRequestorDefaultOtaProvider() : ModelCommand("write") - { - AddArgument("attr-name", "default-ota-provider"); - AddArgument("attr-value", &mValue); - ModelCommand::AddArguments(); - } - - ~WriteOtaSoftwareUpdateRequestorDefaultOtaProvider() {} - - CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + static void + OnAttributeResponse(void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType> & value) { - ChipLogProgress(chipTool, "Sending cluster (0x002A) command (0x01) on endpoint %" PRIu8, endpointId); - - chip::Controller::OtaSoftwareUpdateRequestorCluster cluster; - cluster.Associate(device, endpointId); - return cluster.WriteAttribute( - mValue, this, OnDefaultSuccessResponse, OnDefaultFailure, mTimedInteractionTimeoutMs); + OnGeneralAttributeResponse(context, "OtaSoftwareUpdateRequestor.DefaultOtaProviders response", value); } - -private: - chip::ByteSpan mValue; }; -class ReportOtaSoftwareUpdateRequestorDefaultOtaProvider : public ModelCommand +class ReportOtaSoftwareUpdateRequestorDefaultOtaProviders : public ModelCommand { public: - ReportOtaSoftwareUpdateRequestorDefaultOtaProvider() : ModelCommand("report") + ReportOtaSoftwareUpdateRequestorDefaultOtaProviders() : ModelCommand("report") { - AddArgument("attr-name", "default-ota-provider"); + AddArgument("attr-name", "default-ota-providers"); AddArgument("min-interval", 0, UINT16_MAX, &mMinInterval); AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval); AddArgument("wait", 0, 1, &mWait); ModelCommand::AddArguments(); } - ~ReportOtaSoftwareUpdateRequestorDefaultOtaProvider() {} + ~ReportOtaSoftwareUpdateRequestorDefaultOtaProviders() {} CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override { @@ -25303,7 +25317,7 @@ class ReportOtaSoftwareUpdateRequestorDefaultOtaProvider : public ModelCommand auto subscriptionEstablishedCallback = mWait ? OnDefaultSuccessResponseWithoutExit : OnDefaultSuccessResponse; return cluster - .SubscribeAttribute( + .SubscribeAttribute( this, OnValueReport, OnDefaultFailure, mMinInterval, mMaxInterval, subscriptionEstablishedCallback); } @@ -25312,9 +25326,12 @@ class ReportOtaSoftwareUpdateRequestorDefaultOtaProvider : public ModelCommand return chip::System::Clock::Seconds16(mWait ? UINT16_MAX : 10); } - static void OnValueReport(void * context, chip::ByteSpan value) + static void + OnValueReport(void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType> & value) { - LogValue("OtaSoftwareUpdateRequestor.DefaultOtaProvider report", 0, value); + LogValue("OtaSoftwareUpdateRequestor.DefaultOtaProviders report", 0, value); } private: @@ -25395,6 +25412,151 @@ class ReportOtaSoftwareUpdateRequestorUpdatePossible : public ModelCommand bool mWait; }; +/* + * Attribute UpdateState + */ +class ReadOtaSoftwareUpdateRequestorUpdateState : public ModelCommand +{ +public: + ReadOtaSoftwareUpdateRequestorUpdateState() : ModelCommand("read") + { + AddArgument("attr-name", "update-state"); + ModelCommand::AddArguments(); + } + + ~ReadOtaSoftwareUpdateRequestorUpdateState() {} + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x002A) command (0x00) on endpoint %" PRIu8, endpointId); + + chip::Controller::OtaSoftwareUpdateRequestorCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttribute( + this, OnAttributeResponse, OnDefaultFailure); + } + + static void OnAttributeResponse(void * context, chip::app::Clusters::OtaSoftwareUpdateRequestor::UpdateStateEnum value) + { + OnGeneralAttributeResponse(context, "OtaSoftwareUpdateRequestor.UpdateState response", value); + } +}; + +class ReportOtaSoftwareUpdateRequestorUpdateState : public ModelCommand +{ +public: + ReportOtaSoftwareUpdateRequestorUpdateState() : ModelCommand("report") + { + AddArgument("attr-name", "update-state"); + AddArgument("min-interval", 0, UINT16_MAX, &mMinInterval); + AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval); + AddArgument("wait", 0, 1, &mWait); + ModelCommand::AddArguments(); + } + + ~ReportOtaSoftwareUpdateRequestorUpdateState() {} + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x002A) command (0x06) on endpoint %" PRIu8, endpointId); + + chip::Controller::OtaSoftwareUpdateRequestorCluster cluster; + cluster.Associate(device, endpointId); + + auto subscriptionEstablishedCallback = mWait ? OnDefaultSuccessResponseWithoutExit : OnDefaultSuccessResponse; + return cluster.SubscribeAttribute( + this, OnValueReport, OnDefaultFailure, mMinInterval, mMaxInterval, subscriptionEstablishedCallback); + } + + chip::System::Clock::Timeout GetWaitDuration() const override + { + return chip::System::Clock::Seconds16(mWait ? UINT16_MAX : 10); + } + + static void OnValueReport(void * context, chip::app::Clusters::OtaSoftwareUpdateRequestor::UpdateStateEnum value) + { + LogValue("OtaSoftwareUpdateRequestor.UpdateState report", 0, value); + } + +private: + uint16_t mMinInterval; + uint16_t mMaxInterval; + bool mWait; +}; + +/* + * Attribute UpdateStateProgress + */ +class ReadOtaSoftwareUpdateRequestorUpdateStateProgress : public ModelCommand +{ +public: + ReadOtaSoftwareUpdateRequestorUpdateStateProgress() : ModelCommand("read") + { + AddArgument("attr-name", "update-state-progress"); + ModelCommand::AddArguments(); + } + + ~ReadOtaSoftwareUpdateRequestorUpdateStateProgress() {} + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x002A) command (0x00) on endpoint %" PRIu8, endpointId); + + chip::Controller::OtaSoftwareUpdateRequestorCluster cluster; + cluster.Associate(device, endpointId); + return cluster.ReadAttribute( + this, OnAttributeResponse, OnDefaultFailure); + } + + static void OnAttributeResponse(void * context, const chip::app::DataModel::Nullable & value) + { + OnGeneralAttributeResponse(context, "OtaSoftwareUpdateRequestor.UpdateStateProgress response", value); + } +}; + +class ReportOtaSoftwareUpdateRequestorUpdateStateProgress : public ModelCommand +{ +public: + ReportOtaSoftwareUpdateRequestorUpdateStateProgress() : ModelCommand("report") + { + AddArgument("attr-name", "update-state-progress"); + AddArgument("min-interval", 0, UINT16_MAX, &mMinInterval); + AddArgument("max-interval", 0, UINT16_MAX, &mMaxInterval); + AddArgument("wait", 0, 1, &mWait); + ModelCommand::AddArguments(); + } + + ~ReportOtaSoftwareUpdateRequestorUpdateStateProgress() {} + + CHIP_ERROR SendCommand(ChipDevice * device, uint8_t endpointId) override + { + ChipLogProgress(chipTool, "Sending cluster (0x002A) command (0x06) on endpoint %" PRIu8, endpointId); + + chip::Controller::OtaSoftwareUpdateRequestorCluster cluster; + cluster.Associate(device, endpointId); + + auto subscriptionEstablishedCallback = mWait ? OnDefaultSuccessResponseWithoutExit : OnDefaultSuccessResponse; + return cluster + .SubscribeAttribute( + this, OnValueReport, OnDefaultFailure, mMinInterval, mMaxInterval, subscriptionEstablishedCallback); + } + + chip::System::Clock::Timeout GetWaitDuration() const override + { + return chip::System::Clock::Seconds16(mWait ? UINT16_MAX : 10); + } + + static void OnValueReport(void * context, const chip::app::DataModel::Nullable & value) + { + LogValue("OtaSoftwareUpdateRequestor.UpdateStateProgress report", 0, value); + } + +private: + uint16_t mMinInterval; + uint16_t mMaxInterval; + bool mWait; +}; + /* * Attribute AttributeList */ @@ -51991,15 +52153,17 @@ void registerClusterOtaSoftwareUpdateRequestor(Commands & commands) const char * clusterName = "OtaSoftwareUpdateRequestor"; commands_list clusterCommands = { - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // - make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // + make_unique(), // }; commands.Register(clusterName, clusterCommands); diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp index 51d399b05a44e8..04eb97d3d5e9a3 100644 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp +++ b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.cpp @@ -1383,6 +1383,29 @@ void OtaSoftwareUpdateProviderClusterAttributeListListAttributeFilter(TLV::TLVRe cb->mCall(cb->mContext, list); } +void OtaSoftwareUpdateRequestorClusterDefaultOtaProvidersListAttributeFilter(TLV::TLVReader * tlvData, + Callback::Cancelable * onSuccessCallback, + Callback::Cancelable * onFailureCallback) +{ + chip::app::DataModel::DecodableList + list; + CHIP_ERROR err = Decode(*tlvData, list); + if (err != CHIP_NO_ERROR) + { + if (onFailureCallback != nullptr) + { + Callback::Callback * cb = + Callback::Callback::FromCancelable(onFailureCallback); + cb->mCall(cb->mContext, EMBER_ZCL_STATUS_INVALID_VALUE); + } + return; + } + + Callback::Callback * cb = + Callback::Callback::FromCancelable(onSuccessCallback); + cb->mCall(cb->mContext, list); +} + void OtaSoftwareUpdateRequestorClusterAttributeListListAttributeFilter(TLV::TLVReader * tlvData, Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback) diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h index 089cbd0b1b8c73..6535fa1fcb60ce 100644 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h +++ b/zzz_generated/controller-clusters/zap-generated/CHIPClientCallbacks.h @@ -420,6 +420,13 @@ void OtaSoftwareUpdateProviderClusterAttributeListListAttributeFilter(chip::TLV: chip::Callback::Cancelable * onFailureCallback); typedef void (*OtaSoftwareUpdateProviderAttributeListListAttributeCallback)( void * context, const chip::app::DataModel::DecodableList & data); +void OtaSoftwareUpdateRequestorClusterDefaultOtaProvidersListAttributeFilter(chip::TLV::TLVReader * data, + chip::Callback::Cancelable * onSuccessCallback, + chip::Callback::Cancelable * onFailureCallback); +typedef void (*OtaSoftwareUpdateRequestorDefaultOtaProvidersListAttributeCallback)( + void * context, + const chip::app::DataModel::DecodableList< + chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType> & data); void OtaSoftwareUpdateRequestorClusterAttributeListListAttributeFilter(chip::TLV::TLVReader * data, chip::Callback::Cancelable * onSuccessCallback, chip::Callback::Cancelable * onFailureCallback); diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp b/zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp index 0283851fb15355..0471685191652e 100644 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp +++ b/zzz_generated/controller-clusters/zap-generated/CHIPClusters.cpp @@ -5124,8 +5124,9 @@ CHIP_ERROR OtaSoftwareUpdateProviderCluster::QueryImage(Callback::Cancelable * o // OtaSoftwareUpdateRequestor Cluster Commands CHIP_ERROR OtaSoftwareUpdateRequestorCluster::AnnounceOtaProvider(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::NodeId providerLocation, chip::VendorId vendorId, - uint8_t announcementReason, chip::ByteSpan metadataForNode) + chip::NodeId providerNodeId, chip::VendorId vendorId, + uint8_t announcementReason, chip::ByteSpan metadataForNode, + chip::EndpointId endpoint) { CHIP_ERROR err = CHIP_NO_ERROR; TLV::TLVWriter * writer = nullptr; @@ -5149,14 +5150,16 @@ CHIP_ERROR OtaSoftwareUpdateRequestorCluster::AnnounceOtaProvider(Callback::Canc SuccessOrExit(err = sender->PrepareCommand(cmdParams)); VerifyOrExit((writer = sender->GetCommandDataIBTLVWriter()) != nullptr, err = CHIP_ERROR_INCORRECT_STATE); - // providerLocation: nodeId - SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), providerLocation)); + // providerNodeId: nodeId + SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), providerNodeId)); // vendorId: vendorId SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), vendorId)); // announcementReason: OTAAnnouncementReason SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), announcementReason)); // metadataForNode: octetString SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), metadataForNode)); + // endpoint: endpointNo + SuccessOrExit(err = writer->Put(TLV::ContextTag(argSeqNumber++), endpoint)); SuccessOrExit(err = sender->FinishCommand()); diff --git a/zzz_generated/controller-clusters/zap-generated/CHIPClusters.h b/zzz_generated/controller-clusters/zap-generated/CHIPClusters.h index fbf96bf18c5d53..a1803060bd700f 100644 --- a/zzz_generated/controller-clusters/zap-generated/CHIPClusters.h +++ b/zzz_generated/controller-clusters/zap-generated/CHIPClusters.h @@ -559,8 +559,8 @@ class DLL_EXPORT OtaSoftwareUpdateRequestorCluster : public ClusterBase // Cluster Commands CHIP_ERROR AnnounceOtaProvider(Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback, - chip::NodeId providerLocation, chip::VendorId vendorId, uint8_t announcementReason, - chip::ByteSpan metadataForNode); + chip::NodeId providerNodeId, chip::VendorId vendorId, uint8_t announcementReason, + chip::ByteSpan metadataForNode, chip::EndpointId endpoint); }; class DLL_EXPORT OccupancySensingCluster : public ClusterBase diff --git a/zzz_generated/ota-requestor-app/zap-generated/endpoint_config.h b/zzz_generated/ota-requestor-app/zap-generated/endpoint_config.h index 2b5c799c6d4cad..deacb6930d7e7a 100644 --- a/zzz_generated/ota-requestor-app/zap-generated/endpoint_config.h +++ b/zzz_generated/ota-requestor-app/zap-generated/endpoint_config.h @@ -143,7 +143,7 @@ #define ZAP_ATTRIBUTE_MASK(mask) ATTRIBUTE_MASK_##mask // This is an array of EmberAfAttributeMetadata structures. -#define GENERATED_ATTRIBUTE_COUNT 42 +#define GENERATED_ATTRIBUTE_COUNT 44 #define GENERATED_ATTRIBUTES \ { \ \ @@ -167,9 +167,12 @@ { 0xFFFD, ZAP_TYPE(INT16U), 2, ZAP_ATTRIBUTE_MASK(CLIENT), ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: OTA Software Update Requestor (server) */ \ - { 0x0001, ZAP_TYPE(OCTET_STRING), 17, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_EMPTY_DEFAULT() }, /* default ota provider */ \ - { 0x0002, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_EMPTY_DEFAULT() }, /* update possible */ \ - { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ + { 0x0000, ZAP_TYPE(ARRAY), 0, ZAP_ATTRIBUTE_MASK(EXTERNAL_STORAGE) | ZAP_ATTRIBUTE_MASK(WRITABLE), \ + ZAP_SIMPLE_DEFAULT(0) }, /* DefaultOtaProviders */ \ + { 0x0001, ZAP_TYPE(BOOLEAN), 1, 0, ZAP_SIMPLE_DEFAULT(1) }, /* UpdatePossible */ \ + { 0x0002, ZAP_TYPE(ENUM8), 1, 0, ZAP_SIMPLE_DEFAULT(0) }, /* UpdateState */ \ + { 0x0003, ZAP_TYPE(INT8U), 1, ZAP_ATTRIBUTE_MASK(NULLABLE), ZAP_SIMPLE_DEFAULT(0) }, /* UpdateStateProgress */ \ + { 0xFFFD, ZAP_TYPE(INT16U), 2, 0, ZAP_SIMPLE_DEFAULT(1) }, /* ClusterRevision */ \ \ /* Endpoint: 0, Cluster: General Commissioning (server) */ \ { 0x0000, ZAP_TYPE(INT64U), 8, ZAP_ATTRIBUTE_MASK(WRITABLE), ZAP_LONG_DEFAULTS_INDEX(4) }, /* Breadcrumb */ \ @@ -234,22 +237,22 @@ 0x0029, ZAP_ATTRIBUTE_INDEX(12), 1, 2, ZAP_CLUSTER_MASK(CLIENT), NULL \ }, /* Endpoint: 0, Cluster: OTA Software Update Provider (client) */ \ { \ - 0x002A, ZAP_ATTRIBUTE_INDEX(13), 3, 20, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x002A, ZAP_ATTRIBUTE_INDEX(13), 5, 5, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: OTA Software Update Requestor (server) */ \ { \ - 0x0030, ZAP_ATTRIBUTE_INDEX(16), 6, 270, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0030, ZAP_ATTRIBUTE_INDEX(18), 6, 270, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: General Commissioning (server) */ \ { \ - 0x0031, ZAP_ATTRIBUTE_INDEX(22), 10, 60, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0031, ZAP_ATTRIBUTE_INDEX(24), 10, 60, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: Network Commissioning (server) */ \ { \ - 0x003E, ZAP_ATTRIBUTE_INDEX(32), 6, 4, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x003E, ZAP_ATTRIBUTE_INDEX(34), 6, 4, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: Operational Credentials (server) */ \ { \ - 0x0040, ZAP_ATTRIBUTE_INDEX(38), 2, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0040, ZAP_ATTRIBUTE_INDEX(40), 2, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: Fixed Label (server) */ \ { \ - 0x0041, ZAP_ATTRIBUTE_INDEX(40), 2, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ + 0x0041, ZAP_ATTRIBUTE_INDEX(42), 2, 2, ZAP_CLUSTER_MASK(SERVER), NULL \ }, /* Endpoint: 0, Cluster: User Label (server) */ \ } @@ -258,7 +261,7 @@ // This is an array of EmberAfEndpointType structures. #define GENERATED_ENDPOINT_TYPES \ { \ - { ZAP_CLUSTER_INDEX(0), 8, 606 }, \ + { ZAP_CLUSTER_INDEX(0), 8, 591 }, \ } // Largest attribute size is needed for various buffers @@ -268,7 +271,7 @@ #define ATTRIBUTE_SINGLETONS_SIZE (246) // Total size of attribute storage -#define ATTRIBUTE_MAX_SIZE (606) +#define ATTRIBUTE_MAX_SIZE (591) // Number of fixed endpoints #define FIXED_ENDPOINT_COUNT (1)