From 5873937407e55114fd36fcbeb12e4a272b2d5d23 Mon Sep 17 00:00:00 2001 From: Timothy Maes Date: Wed, 12 Jan 2022 18:38:44 +0100 Subject: [PATCH] * [OTA] enable ota-requestor cluster in chip data model build (#13256) * Adjust apps with a stub (all-clusters-app, ota-requestor-app, shell) --- .../src/ota-requestor-stub.cpp | 87 ------------------- .../all-clusters-app/ameba/chip_main.cmake | 1 - examples/all-clusters-app/linux/BUILD.gn | 1 - examples/all-clusters-app/mbed/CMakeLists.txt | 4 +- examples/all-clusters-app/p6/BUILD.gn | 1 - .../ota-requestor-common/BUILD.gn | 9 -- examples/shell/shell_common/BUILD.gn | 1 - src/app/chip_data_model.gni | 8 ++ .../clusters/ota-requestor/OTARequestor.cpp | 4 +- src/app/zap_cluster_list.py | 2 +- third_party/qpg_sdk/repo | 2 +- 11 files changed, 15 insertions(+), 105 deletions(-) delete mode 100644 examples/all-clusters-app/all-clusters-common/src/ota-requestor-stub.cpp 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 deleted file mode 100644 index ceff034374f750..00000000000000 --- a/examples/all-clusters-app/all-clusters-common/src/ota-requestor-stub.cpp +++ /dev/null @@ -1,87 +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. - */ - -#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 fa03acfbd1673c..cb86b9f8b23d34 100755 --- a/examples/all-clusters-app/ameba/chip_main.cmake +++ b/examples/all-clusters-app/ameba/chip_main.cmake @@ -121,7 +121,6 @@ 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 9f2870d976d65b..3e700fd1af5b5e 100644 --- a/examples/all-clusters-app/linux/BUILD.gn +++ b/examples/all-clusters-app/linux/BUILD.gn @@ -18,7 +18,6 @@ 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", "include/tv-callbacks.h", diff --git a/examples/all-clusters-app/mbed/CMakeLists.txt b/examples/all-clusters-app/mbed/CMakeLists.txt index e5611b5dc0c14c..809b98c0b5e5d5 100644 --- a/examples/all-clusters-app/mbed/CMakeLists.txt +++ b/examples/all-clusters-app/mbed/CMakeLists.txt @@ -67,7 +67,6 @@ 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 @@ -139,6 +138,9 @@ target_sources(${APP_TARGET} PRIVATE ${APP_CLUSTERS}/general-diagnostics-server/general-diagnostics-server.cpp ${APP_CLUSTERS}/group-key-mgmt-server/group-key-mgmt-server.cpp ${APP_CLUSTERS}/power-source-configuration-server/power-source-configuration-server.cpp + ${APP_CLUSTERS}/ota-requestor/ota-requestor-server.cpp + ${APP_CLUSTERS}/ota-requestor/BDXDownloader.cpp + ${APP_CLUSTERS}/ota-requestor/OTARequestor.cpp ) target_link_libraries(${APP_TARGET} mbed-os-posix-socket mbed-os mbed-ble mbed-events mbed-netsocket mbed-storage mbed-storage-kv-global-api mbed-mbedtls mbed-emac chip) diff --git a/examples/all-clusters-app/p6/BUILD.gn b/examples/all-clusters-app/p6/BUILD.gn index ccd4ac152789de..5b99c3f3b3b6f6 100644 --- a/examples/all-clusters-app/p6/BUILD.gn +++ b/examples/all-clusters-app/p6/BUILD.gn @@ -61,7 +61,6 @@ 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 1d5d7bf413cd30..4ba7b05ddb2b2e 100644 --- a/examples/ota-requestor-app/ota-requestor-common/BUILD.gn +++ b/examples/ota-requestor-app/ota-requestor-common/BUILD.gn @@ -30,15 +30,6 @@ chip_data_model("ota-requestor-common") { deps = [ "${chip_root}/src/lib" ] - 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/OTARequestor.cpp", - "${chip_root}/src/app/clusters/ota-requestor/ota-requestor-server.cpp", - ] - - is_server = true - public_configs = [ ":config" ] is_server = true diff --git a/examples/shell/shell_common/BUILD.gn b/examples/shell/shell_common/BUILD.gn index efd1a154fedabc..484c3dbbbde058 100644 --- a/examples/shell/shell_common/BUILD.gn +++ b/examples/shell/shell_common/BUILD.gn @@ -74,7 +74,6 @@ static_library("shell_common") { 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", ] diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index a19f120daa9660..c8134caba0f0f0 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -148,6 +148,14 @@ template("chip_data_model") { "${_app_root}/util/ContentApp.cpp", "${_app_root}/util/ContentAppPlatform.cpp", ] + } else if (cluster == "ota-requestor") { + sources += [ + # TODO - align name of folder ? + "${_app_root}/clusters/${cluster}/${cluster}-server.cpp", + "${_app_root}/clusters/${cluster}/BDXDownloader.cpp", + "${_app_root}/clusters/${cluster}/BDXDownloader.h", + "${_app_root}/clusters/${cluster}/OTARequestor.cpp", + ] } else { sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp" ] } diff --git a/src/app/clusters/ota-requestor/OTARequestor.cpp b/src/app/clusters/ota-requestor/OTARequestor.cpp index d8e4033d9057ae..93961cf7c3de23 100644 --- a/src/app/clusters/ota-requestor/OTARequestor.cpp +++ b/src/app/clusters/ota-requestor/OTARequestor.cpp @@ -323,8 +323,8 @@ void OTARequestor::OnConnectionFailure(void * context, PeerId peerId, CHIP_ERROR OTARequestor * requestorCore = static_cast(context); VerifyOrDie(requestorCore != nullptr); - ChipLogError(SoftwareUpdate, "Failed to connect to node 0x%" PRIX64 ": %" CHIP_ERROR_FORMAT, peerId.GetNodeId(), - error.Format()); + ChipLogError(SoftwareUpdate, "Failed to connect to node 0x" ChipLogFormatX64 ": %" CHIP_ERROR_FORMAT, + ChipLogValueX64(peerId.GetNodeId()), error.Format()); switch (requestorCore->mOnConnectedAction) { diff --git a/src/app/zap_cluster_list.py b/src/app/zap_cluster_list.py index dd763a17eea499..212852d351d5b0 100755 --- a/src/app/zap_cluster_list.py +++ b/src/app/zap_cluster_list.py @@ -59,7 +59,7 @@ 'OPERATIONAL_CREDENTIALS_CLUSTER': ['operational-credentials-server'], 'OTA_BOOTLOAD_CLUSTER': [], 'OTA_PROVIDER_CLUSTER': ['ota-provider'], - 'OTA_REQUESTOR_CLUSTER': [], + 'OTA_REQUESTOR_CLUSTER': ['ota-requestor'], 'POWER_SOURCE_CLUSTER': [], 'POWER_SOURCE_CONFIGURATION_CLUSTER': ['power-source-configuration-server'], 'POLL_CONTROL_CLUSTER': [], diff --git a/third_party/qpg_sdk/repo b/third_party/qpg_sdk/repo index edb134291c9f0c..6bce6f11208c77 160000 --- a/third_party/qpg_sdk/repo +++ b/third_party/qpg_sdk/repo @@ -1 +1 @@ -Subproject commit edb134291c9f0cb661c2e95dcf643cd334dca810 +Subproject commit 6bce6f11208c77dfc6bb1b9256bf01248ff002ab