diff --git a/examples/all-clusters-app/esp32/main/CMakeLists.txt b/examples/all-clusters-app/esp32/main/CMakeLists.txt index 5858a671cd77eb..6fec09e6489abe 100644 --- a/examples/all-clusters-app/esp32/main/CMakeLists.txt +++ b/examples/all-clusters-app/esp32/main/CMakeLists.txt @@ -48,7 +48,6 @@ set(SRC_DIRS_LIST "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/barrier-control-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/window-covering-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-commissioning-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning-old" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/groups-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/color-control-server" diff --git a/examples/all-clusters-app/linux/main-common.cpp b/examples/all-clusters-app/linux/main-common.cpp index 7e672648e8048e..a9b09291304849 100644 --- a/examples/all-clusters-app/linux/main-common.cpp +++ b/examples/all-clusters-app/linux/main-common.cpp @@ -107,11 +107,10 @@ NetworkCommissioning::LinuxWiFiDriver sLinuxWiFiDriver; Clusters::NetworkCommissioning::Instance sWiFiNetworkCommissioningInstance(kNetworkCommissioningEndpointSecondary, &sLinuxWiFiDriver); #endif +#endif // CHIP_DEVICE_LAYER_TARGET_LINUX Clusters::NetworkCommissioning::NullNetworkDriver sNullNetworkDriver; Clusters::NetworkCommissioning::Instance sNullNetworkCommissioningInstance(kNetworkCommissioningEndpointMain, &sNullNetworkDriver); - -#endif // CHIP_DEVICE_LAYER_TARGET_LINUX } // namespace void ApplicationInit() @@ -165,11 +164,11 @@ void ApplicationInit() #endif } else +#endif // CHIP_DEVICE_LAYER_TARGET_LINUX { // Use NullNetworkCommissioningInstance to disable the network commissioning functions. sNullNetworkCommissioningInstance.Init(); } -#endif // CHIP_DEVICE_LAYER_TARGET_LINUX } void emberAfLowPowerClusterInitCallback(EndpointId endpoint) diff --git a/examples/bridge-app/esp32/main/CMakeLists.txt b/examples/bridge-app/esp32/main/CMakeLists.txt index ad9ef0b548d8e6..a2af85946b9b1f 100644 --- a/examples/bridge-app/esp32/main/CMakeLists.txt +++ b/examples/bridge-app/esp32/main/CMakeLists.txt @@ -43,7 +43,6 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/descriptor" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning-old" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/on-off-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server" diff --git a/examples/lighting-app/esp32/main/CMakeLists.txt b/examples/lighting-app/esp32/main/CMakeLists.txt index b2a748452b8208..0190a95d18078c 100644 --- a/examples/lighting-app/esp32/main/CMakeLists.txt +++ b/examples/lighting-app/esp32/main/CMakeLists.txt @@ -46,7 +46,6 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/localization-configuration-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/time-format-localization-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/level-control" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning-old" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/occupancy-sensor-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/on-off-server" diff --git a/examples/lighting-app/telink/CMakeLists.txt b/examples/lighting-app/telink/CMakeLists.txt index 3d1e3699383a8d..d30ce4bec977e1 100644 --- a/examples/lighting-app/telink/CMakeLists.txt +++ b/examples/lighting-app/telink/CMakeLists.txt @@ -96,8 +96,6 @@ target_sources(app PRIVATE ${CHIP_ROOT}/src/app/clusters/color-control-server/color-control-server.cpp ${CHIP_ROOT}/src/app/clusters/occupancy-sensor-server/occupancy-sensor-server.cpp ${CHIP_ROOT}/src/app/clusters/network-commissioning/network-commissioning.cpp - ${CHIP_ROOT}/src/app/clusters/network-commissioning-old/network-commissioning-ember.cpp - ${CHIP_ROOT}/src/app/clusters/network-commissioning-old/network-commissioning-old.cpp ${CHIP_ROOT}/src/app/clusters/ota-requestor/ota-requestor-server.cpp ${CHIP_ROOT}/src/app/clusters/ota-requestor/BDXDownloader.cpp ${CHIP_ROOT}/src/app/clusters/ota-requestor/OTARequestor.cpp diff --git a/examples/lock-app/esp32/main/CMakeLists.txt b/examples/lock-app/esp32/main/CMakeLists.txt index ffa3db3ff25571..cf37ab00284559 100644 --- a/examples/lock-app/esp32/main/CMakeLists.txt +++ b/examples/lock-app/esp32/main/CMakeLists.txt @@ -45,7 +45,6 @@ idf_component_register(INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/bindings" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/descriptor" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/fixed-label-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning-old" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/on-off-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor" @@ -153,7 +152,6 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning-old" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/on-off-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor" diff --git a/examples/ota-provider-app/esp32/main/CMakeLists.txt b/examples/ota-provider-app/esp32/main/CMakeLists.txt index 4b7fdf20a263cf..34353da1390aee 100644 --- a/examples/ota-provider-app/esp32/main/CMakeLists.txt +++ b/examples/ota-provider-app/esp32/main/CMakeLists.txt @@ -46,7 +46,6 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-commissioning-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning-old" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-provider" diff --git a/examples/ota-requestor-app/esp32/main/CMakeLists.txt b/examples/ota-requestor-app/esp32/main/CMakeLists.txt index e634ab659eca5c..05ddfa4e6afabc 100644 --- a/examples/ota-requestor-app/esp32/main/CMakeLists.txt +++ b/examples/ota-requestor-app/esp32/main/CMakeLists.txt @@ -46,7 +46,6 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-commissioning-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning-old" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/ota-requestor" diff --git a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt index ba5b2c41c3c89e..9856a68640e346 100644 --- a/examples/temperature-measurement-app/esp32/main/CMakeLists.txt +++ b/examples/temperature-measurement-app/esp32/main/CMakeLists.txt @@ -46,7 +46,6 @@ idf_component_register(PRIV_INCLUDE_DIRS "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-diagnostics-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/group-key-mgmt-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/general-commissioning-server" - "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning-old" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/network-commissioning" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/src/app/clusters/operational-credentials-server" "${CMAKE_SOURCE_DIR}/third_party/connectedhomeip/examples/platform/esp32/route_hook" diff --git a/src/app/chip_data_model.gni b/src/app/chip_data_model.gni index 7ce8594a8c5145..a8cff820c5717a 100644 --- a/src/app/chip_data_model.gni +++ b/src/app/chip_data_model.gni @@ -80,7 +80,6 @@ template("chip_data_model") { "${_app_root}/clusters/level-control/level-control.h", "${_app_root}/clusters/messaging-client/messaging-client.h", "${_app_root}/clusters/messaging-server/messaging-server.h", - "${_app_root}/clusters/network-commissioning-old/network-commissioning.h", "${_app_root}/clusters/on-off-server/on-off-server.h", "${_app_root}/clusters/scenes/scenes-tokens.h", "${_app_root}/clusters/scenes/scenes.h", @@ -120,11 +119,6 @@ template("chip_data_model") { foreach(cluster, _cluster_sources) { if (cluster == "door-lock-server") { sources += [ "${_app_root}/clusters/${cluster}/door-lock-server.cpp" ] - } else if (cluster == "network-commissioning-old") { - sources += [ - "${_app_root}/clusters/${cluster}/network-commissioning-ember.cpp", - "${_app_root}/clusters/${cluster}/network-commissioning-old.cpp", - ] } else if (cluster == "mode-select-server") { sources += [ "${_app_root}/clusters/${cluster}/${cluster}.cpp", diff --git a/src/app/clusters/network-commissioning-old/network-commissioning-ember.cpp b/src/app/clusters/network-commissioning-old/network-commissioning-ember.cpp deleted file mode 100644 index 3904b7e0130e5a..00000000000000 --- a/src/app/clusters/network-commissioning-old/network-commissioning-ember.cpp +++ /dev/null @@ -1,154 +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 "network-commissioning.h" - -#include - -#include -#include -#include -#include -#include -#include -#include - -using namespace chip; -using namespace chip::app; -using namespace chip::app::Clusters::NetworkCommissioning; - -// TODO: this is a TEMPORARY solution for enabling tests. The all-zero version -// is not spec compliang and will generally not even commission on thread/wifi -// because of a missing feature map -// -// Instead of this, the app::Clusters::NetworkCommissioning::Instance class -// from the "network-commissioning" cluster (note no "-old" suffix) should -// be used. -#ifdef __APPLE__ -#define FAKE_NETWORK_COMMISSIONING_ATTRIBUTES -#else -#undef FAKE_NETWORK_COMMISSIONING_ATTRIBUTES -#endif - -namespace { - -#ifdef FAKE_NETWORK_COMMISSIONING_ATTRIBUTES -class NetworkCommissioningAttributeAccess : public AttributeAccessInterface -{ -public: - NetworkCommissioningAttributeAccess() : AttributeAccessInterface(Optional::Missing(), Id) {} - - CHIP_ERROR Read(const ConcreteReadAttributePath & aPath, AttributeValueEncoder & aEncoder) override - { - switch (aPath.mAttributeId) - { - case Attributes::MaxNetworks::Id: - return aEncoder.Encode(static_cast(0)); - case Attributes::Networks::Id: - return aEncoder.EncodeEmptyList(); - case Attributes::ScanMaxTimeSeconds::Id: - return aEncoder.Encode(static_cast(0)); - case Attributes::ConnectMaxTimeSeconds::Id: - return aEncoder.Encode(static_cast(0)); - case Attributes::InterfaceEnabled::Id: - return aEncoder.Encode(static_cast(false)); - case Attributes::LastNetworkingStatus::Id: - return aEncoder.Encode(NetworkCommissioningStatus::kSuccess); - case Attributes::LastNetworkID::Id: - return aEncoder.Encode(ByteSpan()); - case Attributes::LastConnectErrorValue::Id: - return aEncoder.Encode(Attributes::LastConnectErrorValue::TypeInfo::Type(static_cast(0))); - case Attributes::FeatureMap::Id: - return aEncoder.Encode(static_cast(0)); - default: - return CHIP_NO_ERROR; - } - } -}; -#endif // FAKE_NETWORK_COMMISSIONING_ATTRIBUTES -} // namespace - -bool emberAfNetworkCommissioningClusterAddOrUpdateThreadNetworkCallback( - app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, - const Commands::AddOrUpdateThreadNetwork::DecodableType & commandData) -{ - auto & operationalDataset = commandData.operationalDataset; - auto & breadcrumb = commandData.breadcrumb; - - app::Clusters::NetworkCommissioning::OnAddOrUpdateThreadNetworkCommandCallbackInternal( - commandObj, commandPath, operationalDataset, breadcrumb, 0 /* ignored timeout ms */); - return true; -} - -bool emberAfNetworkCommissioningClusterAddOrUpdateWiFiNetworkCallback( - app::CommandHandler * commandObj, const app::ConcreteCommandPath & commandPath, - const Commands::AddOrUpdateWiFiNetwork::DecodableType & commandData) -{ - auto & ssid = commandData.ssid; - auto & credentials = commandData.credentials; - auto & breadcrumb = commandData.breadcrumb; - - app::Clusters::NetworkCommissioning::OnAddOrUpdateWiFiNetworkCommandCallbackInternal(commandObj, commandPath, ssid, credentials, - breadcrumb, 0 /* ignored timeout ms */); - return true; -} - -bool emberAfNetworkCommissioningClusterConnectNetworkCallback(app::CommandHandler * commandObj, - const app::ConcreteCommandPath & commandPath, - const Commands::ConnectNetwork::DecodableType & commandData) -{ - auto & networkID = commandData.networkID; - auto & breadcrumb = commandData.breadcrumb; - - app::Clusters::NetworkCommissioning::OnConnectNetworkCommandCallbackInternal(commandObj, commandPath, networkID, breadcrumb, - 0 /* ignored timeout ms */); - return true; -} - -// TODO: The following commands needed to be implemented. -// These commands are not implemented thus not handled yet, return false so ember will return a error. - -bool emberAfNetworkCommissioningClusterRemoveNetworkCallback(app::CommandHandler * commandObj, - const app::ConcreteCommandPath & commandPath, - const Commands::RemoveNetwork::DecodableType & commandData) -{ - return false; -} - -bool emberAfNetworkCommissioningClusterScanNetworksCallback(app::CommandHandler * commandObj, - const app::ConcreteCommandPath & commandPath, - const Commands::ScanNetworks::DecodableType & commandData) -{ - return false; -} - -bool emberAfNetworkCommissioningClusterReorderNetworkCallback(app::CommandHandler * commandObj, - const app::ConcreteCommandPath & commandPath, - const Commands::ReorderNetwork::DecodableType & commandData) -{ - return false; -} - -void MatterNetworkCommissioningPluginServerInitCallback() -{ - -#ifdef FAKE_NETWORK_COMMISSIONING_ATTRIBUTES - static NetworkCommissioningAttributeAccess gAttrAccess; - registerAttributeAccessOverride(&gAttrAccess); -#endif // FAKE_NETWORK_COMMISSIONING_ATTRIBUTES -} diff --git a/src/app/clusters/network-commissioning-old/network-commissioning-old.cpp b/src/app/clusters/network-commissioning-old/network-commissioning-old.cpp deleted file mode 100644 index 886886c27ff7a7..00000000000000 --- a/src/app/clusters/network-commissioning-old/network-commissioning-old.cpp +++ /dev/null @@ -1,295 +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 "network-commissioning.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD -#include -#endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD - -// Include DeviceNetworkProvisioningDelegateImpl for WiFi provisioning. -// TODO: Enable wifi network should be done by ConnectivityManager. (Or other platform neutral interfaces) -#if defined(CHIP_DEVICE_LAYER_TARGET) -#define DEVICENETWORKPROVISIONING_HEADER -#include DEVICENETWORKPROVISIONING_HEADER -#endif - -// TODO: Configuration should move to build-time configuration -#ifndef CHIP_CLUSTER_NETWORK_COMMISSIONING_MAX_NETWORKS -#define CHIP_CLUSTER_NETWORK_COMMISSIONING_MAX_NETWORKS 4 -#endif // CHIP_CLUSTER_NETWORK_COMMISSIONING_MAX_NETWORKS - -using namespace chip; -using namespace chip::app; - -namespace chip { -namespace app { -namespace Clusters { -namespace NetworkCommissioning { - -constexpr uint8_t kMaxNetworkIDLen = 32; -constexpr uint8_t kMaxThreadDatasetLen = 254; // As defined in Thread spec. -constexpr uint8_t kMaxWiFiSSIDLen = 32; -constexpr uint8_t kMaxWiFiCredentialsLen = 64; -constexpr uint8_t kMaxNetworks = CHIP_CLUSTER_NETWORK_COMMISSIONING_MAX_NETWORKS; - -enum class NetworkType : uint8_t -{ - kUndefined = 0, - kWiFi = 1, - kThread = 2, - kEthernet = 3, -}; - -struct ThreadNetworkInfo -{ - uint8_t mDataset[kMaxThreadDatasetLen]; - uint8_t mDatasetLen; -}; - -struct WiFiNetworkInfo -{ - uint8_t mSSID[kMaxWiFiSSIDLen + 1]; - uint8_t mSSIDLen; - uint8_t mCredentials[kMaxWiFiCredentialsLen]; - uint8_t mCredentialsLen; -}; - -struct NetworkInfo -{ - uint8_t mNetworkID[kMaxNetworkIDLen]; - uint8_t mNetworkIDLen; - uint8_t mEnabled; - NetworkType mNetworkType; - union NetworkData - { -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - Thread::OperationalDataset mThread; -#endif -#if defined(CHIP_DEVICE_LAYER_TARGET) - WiFiNetworkInfo mWiFi; -#endif - } mData; -}; - -namespace { -// The internal network info containing credentials. Need to find some better place to save these info. -NetworkInfo sNetworks[kMaxNetworks]; -} // namespace - -void OnAddOrUpdateThreadNetworkCommandCallbackInternal(app::CommandHandler * apCommandHandler, - const app::ConcreteCommandPath & commandPath, ByteSpan operationalDataset, - uint64_t breadcrumb, uint32_t timeoutMs) -{ - Commands::NetworkConfigResponse::Type response; -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD - NetworkCommissioningStatus err = NetworkCommissioningStatus::kBoundsExceeded; - - for (size_t i = 0; i < kMaxNetworks; i++) - { - if (sNetworks[i].mNetworkType == NetworkType::kUndefined) - { - Thread::OperationalDataset & dataset = sNetworks[i].mData.mThread; - CHIP_ERROR error = dataset.Init(operationalDataset); - - if (error != CHIP_NO_ERROR) - { - ChipLogDetail(Zcl, "Failed to parse Thread operational dataset: %s", ErrorStr(error)); - err = NetworkCommissioningStatus::kUnknownError; - break; - } - - uint8_t extendedPanId[Thread::kSizeExtendedPanId]; - - static_assert(sizeof(sNetworks[i].mNetworkID) >= sizeof(extendedPanId), - "Network ID must be larger than Thread extended PAN ID!"); - SuccessOrExit(dataset.GetExtendedPanId(extendedPanId)); - memcpy(sNetworks[i].mNetworkID, extendedPanId, sizeof(extendedPanId)); - sNetworks[i].mNetworkIDLen = sizeof(extendedPanId); - - sNetworks[i].mNetworkType = NetworkType::kThread; - sNetworks[i].mEnabled = false; - - err = NetworkCommissioningStatus::kSuccess; - break; - } - } - -exit: - // TODO: We should encode response command here. - - ChipLogDetail(Zcl, "AddOrUpdateThreadNetwork: %u", to_underlying(err)); - response.networkingStatus = err; -#else - // The target does not supports ThreadNetwork. We should not add AddOrUpdateThreadNetwork command in that case then the upper - // layer will return "Command not found" error. - response.networkingStatus = NetworkCommissioningStatus::kUnknownError; -#endif - apCommandHandler->AddResponseData(commandPath, response); -} - -void OnAddOrUpdateWiFiNetworkCommandCallbackInternal(app::CommandHandler * apCommandHandler, - const app::ConcreteCommandPath & commandPath, ByteSpan ssid, - ByteSpan credentials, uint64_t breadcrumb, uint32_t timeoutMs) -{ - Commands::NetworkConfigResponse::Type response; -#if defined(CHIP_DEVICE_LAYER_TARGET) - NetworkCommissioningStatus err = NetworkCommissioningStatus::kBoundsExceeded; - - for (size_t i = 0; i < kMaxNetworks; i++) - { - if (sNetworks[i].mNetworkType == NetworkType::kUndefined) - { - VerifyOrExit(ssid.size() <= sizeof(sNetworks[i].mData.mWiFi.mSSID), err = NetworkCommissioningStatus::kOutOfRange); - memcpy(sNetworks[i].mData.mWiFi.mSSID, ssid.data(), ssid.size()); - - using WiFiSSIDLenType = decltype(sNetworks[i].mData.mWiFi.mSSIDLen); - VerifyOrExit(CanCastTo(ssid.size()), err = NetworkCommissioningStatus::kOutOfRange); - sNetworks[i].mData.mWiFi.mSSIDLen = static_cast(ssid.size()); - - VerifyOrExit(credentials.size() <= sizeof(sNetworks[i].mData.mWiFi.mCredentials), - err = NetworkCommissioningStatus::kOutOfRange); - memcpy(sNetworks[i].mData.mWiFi.mCredentials, credentials.data(), credentials.size()); - - using WiFiCredentialsLenType = decltype(sNetworks[i].mData.mWiFi.mCredentialsLen); - VerifyOrExit(CanCastTo(ssid.size()), err = NetworkCommissioningStatus::kOutOfRange); - sNetworks[i].mData.mWiFi.mCredentialsLen = static_cast(credentials.size()); - - VerifyOrExit(ssid.size() <= sizeof(sNetworks[i].mNetworkID), err = NetworkCommissioningStatus::kOutOfRange); - memcpy(sNetworks[i].mNetworkID, sNetworks[i].mData.mWiFi.mSSID, ssid.size()); - - using NetworkIDLenType = decltype(sNetworks[i].mNetworkIDLen); - VerifyOrExit(CanCastTo(ssid.size()), err = NetworkCommissioningStatus::kOutOfRange); - sNetworks[i].mNetworkIDLen = static_cast(ssid.size()); - - sNetworks[i].mNetworkType = NetworkType::kWiFi; - sNetworks[i].mEnabled = false; - - err = NetworkCommissioningStatus::kSuccess; - break; - } - } - - VerifyOrExit(err == NetworkCommissioningStatus::kSuccess, ); - - ChipLogDetail(Zcl, "WiFi provisioning data: SSID: %.*s", static_cast(ssid.size()), ssid.data()); -exit: - // TODO: We should encode response command here. - - ChipLogDetail(Zcl, "AddOrUpdateWiFiNetwork: %u", to_underlying(err)); - response.networkingStatus = err; -#else - // The target does not supports WiFiNetwork. - // return "Command not found" error. - response.networkingStatus = NetworkCommissioningStatus::kUnknownError; -#endif - apCommandHandler->AddResponseData(commandPath, response); -} - -namespace { -CHIP_ERROR DoConnectNetwork(NetworkInfo * network) -{ - switch (network->mNetworkType) - { - case NetworkType::kThread: -#if CHIP_DEVICE_CONFIG_ENABLE_THREAD -// TODO: On linux, we are using Reset() instead of Detach() to disable thread network, which is not expected. -// Upstream issue: https://github.com/openthread/ot-br-posix/issues/755 -#if !CHIP_DEVICE_LAYER_TARGET_LINUX - ReturnErrorOnFailure(DeviceLayer::ThreadStackMgr().SetThreadEnabled(false)); -#endif - ReturnErrorOnFailure(DeviceLayer::ThreadStackMgr().SetThreadProvision(network->mData.mThread.AsByteSpan())); - ReturnErrorOnFailure(DeviceLayer::ThreadStackMgr().SetThreadEnabled(true)); -#else - return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; -#endif - break; - case NetworkType::kWiFi: -#if defined(CHIP_DEVICE_LAYER_TARGET) - { - // TODO: Currently, DeviceNetworkProvisioningDelegateImpl assumes that ssid and credentials are null terminated strings, - // which is not correct, this should be changed once we have better method for commissioning wifi networks. - DeviceLayer::DeviceNetworkProvisioningDelegateImpl deviceDelegate; - ReturnErrorOnFailure(deviceDelegate.ProvisionWiFi(reinterpret_cast(network->mData.mWiFi.mSSID), - reinterpret_cast(network->mData.mWiFi.mCredentials))); - break; - } -#else - return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE; -#endif - break; - case NetworkType::kEthernet: - case NetworkType::kUndefined: - default: - return CHIP_ERROR_NOT_IMPLEMENTED; - } - network->mEnabled = true; - return CHIP_NO_ERROR; -} -} // namespace - -void OnConnectNetworkCommandCallbackInternal(app::CommandHandler * apCommandHandler, const app::ConcreteCommandPath & commandPath, - ByteSpan networkID, uint64_t breadcrumb, uint32_t timeoutMs) -{ - Commands::ConnectNetworkResponse::Type response; - size_t networkSeq; - NetworkCommissioningStatus err = NetworkCommissioningStatus::kNetworkIDNotFound; - - for (networkSeq = 0; networkSeq < kMaxNetworks; networkSeq++) - { - if (sNetworks[networkSeq].mNetworkIDLen == networkID.size() && - sNetworks[networkSeq].mNetworkType != NetworkType::kUndefined && - memcmp(sNetworks[networkSeq].mNetworkID, networkID.data(), networkID.size()) == 0) - { - // TODO: Currently, we cannot figure out the detailed error from network provisioning on DeviceLayer, we should - // implement this in device layer. - VerifyOrExit(DoConnectNetwork(&sNetworks[networkSeq]) == CHIP_NO_ERROR, - err = NetworkCommissioningStatus::kUnknownError); - ExitNow(err = NetworkCommissioningStatus::kSuccess); - } - } - // TODO: We should encode response command here. -exit: - if (err == NetworkCommissioningStatus::kSuccess) - { - DeviceLayer::DeviceControlServer::DeviceControlSvr().ConnectNetworkForOperational(networkID); - } - response.networkingStatus = err; - apCommandHandler->AddResponseData(commandPath, response); -} - -} // namespace NetworkCommissioning -} // namespace Clusters -} // namespace app -} // namespace chip diff --git a/src/app/clusters/network-commissioning-old/network-commissioning.h b/src/app/clusters/network-commissioning-old/network-commissioning.h deleted file mode 100644 index 6b389d8324c724..00000000000000 --- a/src/app/clusters/network-commissioning-old/network-commissioning.h +++ /dev/null @@ -1,40 +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. - */ - -#pragma once - -#include -#include -#include -#include - -namespace chip { -namespace app { -namespace Clusters { -namespace NetworkCommissioning { -void OnAddOrUpdateThreadNetworkCommandCallbackInternal(app::CommandHandler *, const app::ConcreteCommandPath & commandPath, - ByteSpan operationalDataset, uint64_t breadcrumb, uint32_t timeoutMs); -void OnAddOrUpdateWiFiNetworkCommandCallbackInternal(app::CommandHandler *, const app::ConcreteCommandPath & commandPath, - ByteSpan ssid, ByteSpan credentials, uint64_t breadcrumb, uint32_t timeoutMs); -void OnConnectNetworkCommandCallbackInternal(app::CommandHandler *, const app::ConcreteCommandPath & commandPath, - ByteSpan networkID, uint64_t breadcrumb, uint32_t timeoutMs); -} // namespace NetworkCommissioning - -} // namespace Clusters -} // namespace app -} // namespace chip diff --git a/src/app/clusters/network-commissioning/network-commissioning.cpp b/src/app/clusters/network-commissioning/network-commissioning.cpp index 52ef8190fe78a7..6c32c0c6996002 100644 --- a/src/app/clusters/network-commissioning/network-commissioning.cpp +++ b/src/app/clusters/network-commissioning/network-commissioning.cpp @@ -28,6 +28,11 @@ #include #include +using namespace chip; +using namespace chip::app; +using namespace chip::app::Clusters; +using namespace chip::app::Clusters::NetworkCommissioning; + namespace chip { namespace app { namespace Clusters { @@ -239,12 +244,12 @@ void Instance::HandleScanNetworks(HandlerContext & ctx, const Commands::ScanNetw if (mFeatureFlags.Has(NetworkCommissioningFeature::kWiFiNetworkInterface)) { - mAsyncCommandHandle = app::CommandHandler::Handle(&ctx.mCommandHandler); + mAsyncCommandHandle = CommandHandler::Handle(&ctx.mCommandHandler); mpDriver.Get()->ScanNetworks(req.ssid, this); } else if (mFeatureFlags.Has(NetworkCommissioningFeature::kThreadNetworkInterface)) { - mAsyncCommandHandle = app::CommandHandler::Handle(&ctx.mCommandHandler); + mAsyncCommandHandle = CommandHandler::Handle(&ctx.mCommandHandler); mpDriver.Get()->ScanNetworks(this); } else @@ -285,7 +290,7 @@ void Instance::HandleConnectNetwork(HandlerContext & ctx, const Commands::Connec mConnectingNetworkIDLen = static_cast(req.networkID.size()); memcpy(mConnectingNetworkID, req.networkID.data(), mConnectingNetworkIDLen); - mAsyncCommandHandle = app::CommandHandler::Handle(&ctx.mCommandHandler); + mAsyncCommandHandle = CommandHandler::Handle(&ctx.mCommandHandler); mpWirelessDriver->ConnectNetwork(req.networkID, this); } @@ -487,3 +492,48 @@ DeviceLayer::NetworkCommissioning::NetworkIterator * NullNetworkDriver::GetNetwo } // namespace Clusters } // namespace app } // namespace chip + +// These functions are ember interfaces, they should never be implemented since all network commissioning cluster functions are +// implemented in NetworkCommissioning::Instance. +bool emberAfNetworkCommissioningClusterAddOrUpdateThreadNetworkCallback( + CommandHandler * commandObj, const ConcreteCommandPath & commandPath, + const Commands::AddOrUpdateThreadNetwork::DecodableType & commandData) +{ + return false; +} + +bool emberAfNetworkCommissioningClusterAddOrUpdateWiFiNetworkCallback( + CommandHandler * commandObj, const ConcreteCommandPath & commandPath, + const Commands::AddOrUpdateWiFiNetwork::DecodableType & commandData) +{ + return false; +} + +bool emberAfNetworkCommissioningClusterConnectNetworkCallback(CommandHandler * commandObj, const ConcreteCommandPath & commandPath, + const Commands::ConnectNetwork::DecodableType & commandData) +{ + return false; +} + +bool emberAfNetworkCommissioningClusterRemoveNetworkCallback(CommandHandler * commandObj, const ConcreteCommandPath & commandPath, + const Commands::RemoveNetwork::DecodableType & commandData) +{ + return false; +} + +bool emberAfNetworkCommissioningClusterScanNetworksCallback(CommandHandler * commandObj, const ConcreteCommandPath & commandPath, + const Commands::ScanNetworks::DecodableType & commandData) +{ + return false; +} + +bool emberAfNetworkCommissioningClusterReorderNetworkCallback(CommandHandler * commandObj, const ConcreteCommandPath & commandPath, + const Commands::ReorderNetwork::DecodableType & commandData) +{ + return false; +} + +void MatterNetworkCommissioningPluginServerInitCallback() +{ + // Nothing to do, the server init routine will be done in Instance::Init() +} diff --git a/src/app/zap_cluster_list.py b/src/app/zap_cluster_list.py index 9f2e4aa69e587b..fb0098b8b82f9d 100755 --- a/src/app/zap_cluster_list.py +++ b/src/app/zap_cluster_list.py @@ -49,8 +49,7 @@ 'MEDIA_INPUT_CLUSTER': ['media-input-server'], 'MEDIA_PLAYBACK_CLUSTER': ['media-playback-server'], 'MODE_SELECT_CLUSTER': ['mode-select-server'], - # network-commissioning-old is the old, not spec compliant implementation. - 'NETWORK_COMMISSIONING_CLUSTER': ['network-commissioning', 'network-commissioning-old'], + 'NETWORK_COMMISSIONING_CLUSTER': ['network-commissioning'], 'OCCUPANCY_SENSING_CLUSTER': ['occupancy-sensor-server'], 'ON_OFF_CLUSTER': ['on-off-server'], 'ON_OFF_SWITCH_CONFIG_CLUSTER': [],