Skip to content

Commit

Permalink
Merge branch 'project-chip:master' into issue_226_temp_2
Browse files Browse the repository at this point in the history
  • Loading branch information
austina-csa authored Dec 4, 2024
2 parents 41bdc70 + e0fc29a commit 733c081
Show file tree
Hide file tree
Showing 27 changed files with 276 additions and 150 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ CHIP_ERROR DataModelLogger::LogAttribute(const chip::app::ConcreteDataAttributeP
default:
break;
}
ChipLogProgress(chipTool, " Don't know how to log atribute value");
ChipLogProgress(chipTool, " Don't know how to log attribute value");
return CHIP_NO_ERROR;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ CHIP_ERROR CommissionerControlDelegate::HandleCommissioningApprovalRequest(const
mLabel.ClearValue();
}

CHIP_ERROR err = CommissionerControlServer::Instance().GenerateCommissioningRequestResultEvent(kAggregatorEndpointId, result);
CHIP_ERROR err = mCommissionerControlServer.GenerateCommissioningRequestResultEvent(kAggregatorEndpointId, result);

if (err == CHIP_NO_ERROR)
{
Expand Down Expand Up @@ -228,7 +228,7 @@ CHIP_ERROR CommissionerControlInit()
return CHIP_ERROR_NO_MEMORY;
}

err = Clusters::CommissionerControl::CommissionerControlServer::Instance().Init(*sCommissionerControlDelegate);
err = sCommissionerControlDelegate->GetCommissionerControlServer().Init();
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "Initialization failed on Commissioner Control Delegate.");
Expand All @@ -242,7 +242,7 @@ CHIP_ERROR CommissionerControlInit()
supportedDeviceCategories.SetField(Clusters::CommissionerControl::SupportedDeviceCategoryBitmap::kFabricSynchronization, 1);

Protocols::InteractionModel::Status status =
Clusters::CommissionerControl::CommissionerControlServer::Instance().SetSupportedDeviceCategoriesValue(
sCommissionerControlDelegate->GetCommissionerControlServer().SetSupportedDeviceCategoriesValue(
Clusters::CommissionerControl::kAggregatorEndpointId, supportedDeviceCategories);

if (status != Protocols::InteractionModel::Status::Success)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ inline constexpr EndpointId kAggregatorEndpointId = 1;
class CommissionerControlDelegate : public Delegate
{
public:
CommissionerControlDelegate() : mCommissionerControlServer(this, kAggregatorEndpointId, CommissionerControl::Id) {}

CHIP_ERROR HandleCommissioningApprovalRequest(const CommissioningApprovalRequest & request) override;
// TODO(#35627) clientNodeId should move towards ScopedNodeId.
CHIP_ERROR ValidateCommissionNodeCommand(NodeId clientNodeId, uint64_t requestId) override;
Expand All @@ -39,6 +41,8 @@ class CommissionerControlDelegate : public Delegate

~CommissionerControlDelegate() = default;

CommissionerControlServer & GetCommissionerControlServer() { return mCommissionerControlServer; }

private:
enum class Step : uint8_t
{
Expand Down Expand Up @@ -82,6 +86,8 @@ class CommissionerControlDelegate : public Delegate
ByteSpan mPBKDFSalt;
Crypto::Spake2pVerifierSerialized mPAKEPasscodeVerifierBuffer;
ByteSpan mPAKEPasscodeVerifier;

CommissionerControlServer mCommissionerControlServer;
};

} // namespace CommissionerControl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ inline constexpr EndpointId kAggregatorEndpointId = 1;
class CommissionerControlDelegate : public Delegate
{
public:
CommissionerControlDelegate(bridge::FabricAdminDelegate * fabricAdmin) : mFabricAdmin(fabricAdmin) {}
CommissionerControlDelegate(bridge::FabricAdminDelegate * fabricAdmin) :
mFabricAdmin(fabricAdmin), mCommissionerControlServer(this, kAggregatorEndpointId, CommissionerControl::Id)
{}

CHIP_ERROR HandleCommissioningApprovalRequest(const CommissioningApprovalRequest & request) override;
// TODO(#35627) clientNodeId should move towards ScopedNodeId.
Expand All @@ -42,6 +44,8 @@ class CommissionerControlDelegate : public Delegate

~CommissionerControlDelegate() = default;

CommissionerControlServer & GetCommissionerControlServer() { return mCommissionerControlServer; }

private:
enum class Step : uint8_t
{
Expand Down Expand Up @@ -87,6 +91,7 @@ class CommissionerControlDelegate : public Delegate
ByteSpan mPAKEPasscodeVerifier;

bridge::FabricAdminDelegate * mFabricAdmin;
CommissionerControlServer mCommissionerControlServer;
};

} // namespace CommissionerControl
Expand Down
12 changes: 10 additions & 2 deletions examples/fabric-sync/bridge/src/BridgedDeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,13 @@ std::optional<uint16_t> BridgedDeviceManager::AddDeviceEndpoint(std::unique_ptr<

int BridgedDeviceManager::RemoveDeviceEndpoint(BridgedDevice * dev)
{
assertChipStackLockedByCurrentThread();

uint8_t index = 0;
while (index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT)
{
if (mDevices[index].get() == dev)
{
DeviceLayer::StackLock lock;
// Silence complaints about unused ep when progress logging
// disabled.
[[maybe_unused]] EndpointId ep = emberAfClearDynamicEndpoint(index);
Expand All @@ -266,6 +267,8 @@ int BridgedDeviceManager::RemoveDeviceEndpoint(BridgedDevice * dev)

BridgedDevice * BridgedDeviceManager::GetDevice(chip::EndpointId endpointId) const
{
assertChipStackLockedByCurrentThread();

for (uint8_t index = 0; index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; ++index)
{
if (mDevices[index] && mDevices[index]->GetEndpointId() == endpointId)
Expand Down Expand Up @@ -304,6 +307,8 @@ std::string BridgedDeviceManager::GenerateUniqueId()

BridgedDevice * BridgedDeviceManager::GetDeviceByUniqueId(const std::string & id)
{
assertChipStackLockedByCurrentThread();

for (uint8_t index = 0; index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; ++index)
{
if (mDevices[index] && mDevices[index]->GetBridgedAttributes().uniqueId == id)
Expand All @@ -316,6 +321,8 @@ BridgedDevice * BridgedDeviceManager::GetDeviceByUniqueId(const std::string & id

BridgedDevice * BridgedDeviceManager::GetDeviceByScopedNodeId(chip::ScopedNodeId scopedNodeId) const
{
assertChipStackLockedByCurrentThread();

for (uint8_t index = 0; index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; ++index)
{
if (mDevices[index] && mDevices[index]->GetScopedNodeId() == scopedNodeId)
Expand All @@ -328,11 +335,12 @@ BridgedDevice * BridgedDeviceManager::GetDeviceByScopedNodeId(chip::ScopedNodeId

std::optional<uint16_t> BridgedDeviceManager::RemoveDeviceByScopedNodeId(chip::ScopedNodeId scopedNodeId)
{
assertChipStackLockedByCurrentThread();

for (uint16_t index = 0; index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; ++index)
{
if (mDevices[index] && mDevices[index]->GetScopedNodeId() == scopedNodeId)
{
DeviceLayer::StackLock lock;
EndpointId ep = emberAfClearDynamicEndpoint(index);
mDevices[index] = nullptr;
ChipLogProgress(NotSpecified, "Removed device with Id=[%d:0x" ChipLogFormatX64 "] from dynamic endpoint %d (index=%d)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ CHIP_ERROR CommissionerControlDelegate::HandleCommissioningApprovalRequest(const
mLabel.ClearValue();
}

CHIP_ERROR err = CommissionerControlServer::Instance().GenerateCommissioningRequestResultEvent(kAggregatorEndpointId, result);
CHIP_ERROR err = mCommissionerControlServer.GenerateCommissioningRequestResultEvent(kAggregatorEndpointId, result);

if (err == CHIP_NO_ERROR)
{
Expand Down Expand Up @@ -227,7 +227,7 @@ CHIP_ERROR CommissionerControlInit(bridge::FabricAdminDelegate * fabricAdmin)
return CHIP_ERROR_NO_MEMORY;
}

err = Clusters::CommissionerControl::CommissionerControlServer::Instance().Init(*sCommissionerControlDelegate);
err = sCommissionerControlDelegate->GetCommissionerControlServer().Init();
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer, "Initialization failed on Commissioner Control Delegate.");
Expand All @@ -241,7 +241,7 @@ CHIP_ERROR CommissionerControlInit(bridge::FabricAdminDelegate * fabricAdmin)
supportedDeviceCategories.SetField(Clusters::CommissionerControl::SupportedDeviceCategoryBitmap::kFabricSynchronization, 1);

Protocols::InteractionModel::Status status =
Clusters::CommissionerControl::CommissionerControlServer::Instance().SetSupportedDeviceCategoriesValue(
sCommissionerControlDelegate->GetCommissionerControlServer().SetSupportedDeviceCategoriesValue(
Clusters::CommissionerControl::kAggregatorEndpointId, supportedDeviceCategories);

if (status != Protocols::InteractionModel::Status::Success)
Expand Down
Loading

0 comments on commit 733c081

Please sign in to comment.