Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca committed Nov 12, 2024
1 parent 5da2dda commit 641726e
Show file tree
Hide file tree
Showing 25 changed files with 62 additions and 39 deletions.
18 changes: 18 additions & 0 deletions examples/fabric-admin/device_manager/CommissionerControl.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#include "CommissionerControl.h"
#include "DeviceManager.h"

Expand Down
18 changes: 18 additions & 0 deletions examples/fabric-sync/admin/CommissionerControl.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
/*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

#include "CommissionerControl.h"
#include "DeviceManager.h"

Expand Down
1 change: 0 additions & 1 deletion examples/fabric-sync/admin/DeviceManager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-sync/admin/DeviceManager.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down
4 changes: 2 additions & 2 deletions examples/fabric-sync/admin/DeviceSubscription.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ void DeviceSubscription::OnAttributeData(const ConcreteDataAttributePath & path,
CHIP_ERROR err = data->Get(windowStatus);
VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(NotSpecified, "Failed to read WindowStatus"));
VerifyOrReturn(windowStatus != Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum::kUnknownEnumValue);
mCurrentAdministratorCommissioningAttributes.windowStatus = static_cast<uint8_t>(windowStatus);
mCurrentAdministratorCommissioningAttributes.windowStatus = windowStatus;
mChangeDetected = true;
break;
}
Expand Down Expand Up @@ -236,7 +236,7 @@ CHIP_ERROR DeviceSubscription::StartSubscription(OnDoneCallback onDoneCallback,
mCurrentAdministratorCommissioningAttributes = AdministratorCommissioningChanged_init_default;
mCurrentAdministratorCommissioningAttributes.id = scopedNodeId;
mCurrentAdministratorCommissioningAttributes.windowStatus =
static_cast<uint8_t>(Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum::kWindowNotOpen);
Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum::kWindowNotOpen;

mOnDoneCallback = onDoneCallback;
MoveToState(State::Connecting);
Expand Down
14 changes: 8 additions & 6 deletions examples/fabric-sync/admin/DeviceSynchronization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ namespace admin {

namespace {

constexpr uint16_t kBasicInformationAttributeBufSize = 128;

void OnDeviceConnectedWrapper(void * context, Messaging::ExchangeManager & exchangeMgr, const SessionHandle & sessionHandle)
{
reinterpret_cast<DeviceSynchronizer *>(context)->OnDeviceConnected(exchangeMgr, sessionHandle);
Expand Down Expand Up @@ -82,39 +84,39 @@ void DeviceSynchronizer::OnAttributeData(const ConcreteDataAttributePath & path,
switch (path.mAttributeId)
{
case Clusters::BasicInformation::Attributes::UniqueID::Id: {
char uniqueIdBuffer[128]; // Adjust size as needed
char uniqueIdBuffer[kBasicInformationAttributeBufSize];
if (SuccessOrLog(data->GetString(uniqueIdBuffer, sizeof(uniqueIdBuffer)), "UniqueId"))
{
mCurrentDeviceData.uniqueId = std::string(uniqueIdBuffer);
}
}
break;
case Clusters::BasicInformation::Attributes::VendorName::Id: {
char vendorNameBuffer[128]; // Adjust size as needed
char vendorNameBuffer[kBasicInformationAttributeBufSize];
if (SuccessOrLog(data->GetString(vendorNameBuffer, sizeof(vendorNameBuffer)), "VendorName"))
{
mCurrentDeviceData.vendorName = std::string(vendorNameBuffer);
}
}
break;
case Clusters::BasicInformation::Attributes::ProductName::Id: {
char productNameBuffer[128]; // Adjust size as needed
char productNameBuffer[kBasicInformationAttributeBufSize];
if (SuccessOrLog(data->GetString(productNameBuffer, sizeof(productNameBuffer)), "ProductName"))
{
mCurrentDeviceData.productName = std::string(productNameBuffer);
}
}
break;
case Clusters::BasicInformation::Attributes::NodeLabel::Id: {
char nodeLabelBuffer[128]; // Adjust size as needed
char nodeLabelBuffer[kBasicInformationAttributeBufSize];
if (SuccessOrLog(data->GetString(nodeLabelBuffer, sizeof(nodeLabelBuffer)), "NodeLabel"))
{
mCurrentDeviceData.nodeLabel = std::string(nodeLabelBuffer);
}
}
break;
case Clusters::BasicInformation::Attributes::HardwareVersionString::Id: {
char hardwareVersionStringBuffer[128]; // Adjust size as needed
char hardwareVersionStringBuffer[kBasicInformationAttributeBufSize];
if (SuccessOrLog(data->GetString(hardwareVersionStringBuffer, sizeof(hardwareVersionStringBuffer)),
"HardwareVersionString"))
{
Expand All @@ -123,7 +125,7 @@ void DeviceSynchronizer::OnAttributeData(const ConcreteDataAttributePath & path,
}
break;
case Clusters::BasicInformation::Attributes::SoftwareVersionString::Id: {
char softwareVersionStringBuffer[128]; // Adjust size as needed
char softwareVersionStringBuffer[kBasicInformationAttributeBufSize];
if (SuccessOrLog(data->GetString(softwareVersionStringBuffer, sizeof(softwareVersionStringBuffer)),
"SoftwareVersionString"))
{
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-sync/admin/FabricAdmin.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-sync/admin/FabricAdmin.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-sync/admin/PairingManager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-sync/admin/PairingManager.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-sync/bridge/include/Bridge.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-sync/bridge/include/BridgedDevice.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-sync/bridge/include/BridgedDeviceManager.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-sync/bridge/include/CHIPProjectAppConfig.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-sync/bridge/include/FabricAdminDelegate.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down
12 changes: 6 additions & 6 deletions examples/fabric-sync/bridge/include/FabricBridge.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand All @@ -20,6 +19,7 @@

#include "FabricAdminDelegate.h"

#include <app-common/zap-generated/cluster-objects.h>
#include <lib/core/CHIPError.h>
#include <lib/core/ScopedNodeId.h>
#include <optional>
Expand All @@ -46,10 +46,10 @@ namespace bridge {

#define AdministratorCommissioningChanged_init_default \
{ \
ScopedNodeId_init_default, /* id */ \
0, /* windowStatus */ \
std::nullopt, /* openerFabricIndex */ \
std::nullopt /* openerVendorId */ \
ScopedNodeId_init_default, /* id */ \
chip::app::Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum::kWindowNotOpen, /* windowStatus */ \
std::nullopt, /* openerFabricIndex */ \
std::nullopt /* openerVendorId */ \
}

struct SynchronizedDevice
Expand All @@ -72,7 +72,7 @@ struct SynchronizedDevice
struct AdministratorCommissioningChanged
{
chip::ScopedNodeId id;
uint8_t windowStatus;
chip::app::Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum windowStatus;
std::optional<chip::FabricIndex> openerFabricIndex;
std::optional<chip::VendorId> openerVendorId;
};
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-sync/bridge/src/Bridge.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-sync/bridge/src/BridgedDevice.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-sync/bridge/src/BridgedDeviceManager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down
16 changes: 10 additions & 6 deletions examples/fabric-sync/bridge/src/FabricBridge.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down Expand Up @@ -124,6 +123,12 @@ CHIP_ERROR FabricBridge::AddSynchronizedDevice(const SynchronizedDevice & data)
app::Clusters::EcosystemInformation::EcosystemInformationServer::Instance().AddEcosystemInformationClusterToEndpoint(
addedDevice->GetEndpointId());

if (err != CHIP_NO_ERROR)
{
ChipLogError(NotSpecified, "Failed to add Ecosystem Information Cluster to endpoint %u: %" CHIP_ERROR_FORMAT,
addedDevice->GetEndpointId(), err.Format());
}

return err;
}

Expand Down Expand Up @@ -175,12 +180,11 @@ CHIP_ERROR FabricBridge::AdminCommissioningAttributeChanged(const AdministratorC

BridgedDevice::AdminCommissioningAttributes adminCommissioningAttributes;

uint32_t maxWindowStatusValue =
static_cast<uint32_t>(app::Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum::kUnknownEnumValue);
VerifyOrReturnError(data.windowStatus < maxWindowStatusValue, CHIP_ERROR_INVALID_ARGUMENT);
VerifyOrReturnError(data.windowStatus <
app::Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum::kUnknownEnumValue,
CHIP_ERROR_INVALID_ARGUMENT);

adminCommissioningAttributes.commissioningWindowStatus =
static_cast<app::Clusters::AdministratorCommissioning::CommissioningWindowStatusEnum>(data.windowStatus);
adminCommissioningAttributes.commissioningWindowStatus = data.windowStatus;
if (data.openerFabricIndex.has_value())
{
VerifyOrReturnError(data.openerFabricIndex >= kMinValidFabricIndex, CHIP_ERROR_INVALID_ARGUMENT);
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-sync/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-sync/shell/ShellCommands.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
1 change: 0 additions & 1 deletion examples/fabric-sync/shell/ShellCommands.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/*
*
* Copyright (c) 2024 Project CHIP Authors
* All rights reserved.
*
Expand Down

0 comments on commit 641726e

Please sign in to comment.