Skip to content

Commit

Permalink
Merge branch 'master' into accountlogin-login-logout-support
Browse files Browse the repository at this point in the history
  • Loading branch information
lazarkov authored Aug 21, 2024
2 parents ac49ea3 + 8b97b28 commit 3b70d26
Show file tree
Hide file tree
Showing 50 changed files with 766 additions and 666 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/examples-efr32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
if: github.actor != 'restyled-io[bot]'

container:
image: ghcr.io/project-chip/chip-build-efr32:73
image: ghcr.io/project-chip/chip-build-efr32:74
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
steps:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -514,6 +514,7 @@ jobs:
scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestIdChecks.py'
scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestSpecParsingDeviceType.py'
scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestConformanceSupport.py'
scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestConformanceTest.py'
scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/TestChoiceConformanceSupport.py'
scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/test_testing/test_IDM_10_4.py'
scripts/run_in_python_env.sh out/venv 'python3 ./src/python_testing/test_testing/test_TC_SC_7_1.py'
Expand Down
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -213,17 +213,17 @@
[submodule "third_party/silabs/simplicity_sdk"]
path = third_party/silabs/simplicity_sdk
url = https://github.com/SiliconLabs/simplicity_sdk.git
branch = v2024.6.0
branch = v2024.6.1-0
platforms = silabs
[submodule "third_party/silabs/wiseconnect-wifi-bt-sdk"]
path = third_party/silabs/wiseconnect-wifi-bt-sdk
url = https://github.com/SiliconLabs/wiseconnect-wifi-bt-sdk.git
branch = 2.8.2
branch = 2.10.0
platforms = silabs
[submodule "third_party/silabs/wifi_sdk"]
path = third_party/silabs/wifi_sdk
url = https://github.com/SiliconLabs/wiseconnect.git
branch = v3.3.0
branch = v3.3.1
platforms = silabs
[submodule "editline"]
path = third_party/editline/repo
Expand Down
5 changes: 0 additions & 5 deletions config/telink/chip-module/Kconfig.defaults
Original file line number Diff line number Diff line change
Expand Up @@ -219,12 +219,7 @@ config NVS_LOOKUP_CACHE_SIZE
config SETTINGS_NVS_SECTOR_SIZE_MULT
default 1

# Set sector counter of NVS
config SETTINGS_NVS_SECTOR_COUNT
default 12

# Enable OpenThread

config NET_L2_OPENTHREAD
default y if !WIFI

Expand Down
2 changes: 1 addition & 1 deletion examples/fabric-admin/commands/clusters/ClusterCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ class ClusterCommand : public InteractionModelCommands, public ModelCommand, pub
if (data != nullptr)
{
LogErrorOnFailure(RemoteDataModelLogger::LogCommandAsJSON(path, data));
DeviceMgr().HandleCommandResponse(path, data);
DeviceMgr().HandleCommandResponse(path, *data);
}
}

Expand Down
4 changes: 2 additions & 2 deletions examples/fabric-admin/commands/clusters/ReportCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void ReportCommand::OnAttributeData(const app::ConcreteDataAttributePath & path,

LogErrorOnFailure(RemoteDataModelLogger::LogAttributeAsJSON(path, data));

DeviceMgr().HandleAttributeData(path, data);
DeviceMgr().HandleAttributeData(path, *data);
}

void ReportCommand::OnEventData(const app::EventHeader & eventHeader, TLV::TLVReader * data, const app::StatusIB * status)
Expand All @@ -73,5 +73,5 @@ void ReportCommand::OnEventData(const app::EventHeader & eventHeader, TLV::TLVRe

LogErrorOnFailure(RemoteDataModelLogger::LogEventAsJSON(eventHeader, data));

DeviceMgr().HandleEventData(eventHeader, data);
DeviceMgr().HandleEventData(eventHeader, *data);
}
159 changes: 82 additions & 77 deletions examples/fabric-admin/device_manager/DeviceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,25 @@ void DeviceManager::ReadSupportedDeviceCategories()
PushCommand(commandBuilder.c_str());
}

void DeviceManager::HandleReadSupportedDeviceCategories(chip::TLV::TLVReader & data)
{
ChipLogProgress(NotSpecified, "Attribute SupportedDeviceCategories detected.");

BitMask<CommissionerControl::SupportedDeviceCategoryBitmap> value;
CHIP_ERROR error = app::DataModel::Decode(data, value);
if (error != CHIP_NO_ERROR)
{
ChipLogError(NotSpecified, "Failed to decode attribute value. Error: %" CHIP_ERROR_FORMAT, error.Format());
return;
}

if (value.Has(CommissionerControl::SupportedDeviceCategoryBitmap::kFabricSynchronization))
{
ChipLogProgress(NotSpecified, "Remote Fabric-Bridge supports Fabric Synchronization, start reverse commissioning.");
RequestCommissioningApproval();
}
}

void DeviceManager::RequestCommissioningApproval()
{
ChipLogProgress(NotSpecified, "Starting reverse commissioning for bridge device: NodeId: " ChipLogFormatX64,
Expand All @@ -254,12 +273,12 @@ void DeviceManager::RequestCommissioningApproval()
PushCommand(commandBuilder.c_str());
}

void DeviceManager::HandleCommissioningRequestResult(TLV::TLVReader * data)
void DeviceManager::HandleCommissioningRequestResult(TLV::TLVReader & data)
{
ChipLogProgress(NotSpecified, "CommissioningRequestResult event received.");

CommissionerControl::Events::CommissioningRequestResult::DecodableType value;
CHIP_ERROR error = app::DataModel::Decode(*data, value);
CHIP_ERROR error = app::DataModel::Decode(data, value);
if (error != CHIP_NO_ERROR)
{
ChipLogError(NotSpecified, "Failed to decode event value. Error: %" CHIP_ERROR_FORMAT, error.Format());
Expand All @@ -283,82 +302,12 @@ void DeviceManager::HandleCommissioningRequestResult(TLV::TLVReader * data)
SendCommissionNodeRequest(value.requestId, kResponseTimeoutSeconds);
}

void DeviceManager::SendCommissionNodeRequest(uint64_t requestId, uint16_t responseTimeoutSeconds)
{
ChipLogProgress(NotSpecified, "Request the Commissioner Control Server to begin commissioning a previously approved request.");

StringBuilder<kMaxCommandSize> commandBuilder;
commandBuilder.Add("commissionercontrol commission-node ");
commandBuilder.AddFormat("%lu %u %lu %d", requestId, responseTimeoutSeconds, mRemoteBridgeNodeId, kRootEndpointId);

PushCommand(commandBuilder.c_str());
}

void DeviceManager::HandleReverseOpenCommissioningWindow(TLV::TLVReader * data)
void DeviceManager::HandleAttributePartsListUpdate(chip::TLV::TLVReader & data)
{
CommissionerControl::Commands::ReverseOpenCommissioningWindow::DecodableType value;
CHIP_ERROR error = app::DataModel::Decode(*data, value);
if (error != CHIP_NO_ERROR)
{
ChipLogError(NotSpecified, "Failed to decode command response value. Error: %" CHIP_ERROR_FORMAT, error.Format());
return;
}

// Log all fields
ChipLogProgress(NotSpecified, "DecodableType fields:");
ChipLogProgress(NotSpecified, " commissioningTimeout: %u", value.commissioningTimeout);
ChipLogProgress(NotSpecified, " discriminator: %u", value.discriminator);
ChipLogProgress(NotSpecified, " iterations: %u", value.iterations);

char verifierHex[Crypto::kSpake2p_VerifierSerialized_Length * 2 + 1];
Encoding::BytesToHex(value.PAKEPasscodeVerifier.data(), value.PAKEPasscodeVerifier.size(), verifierHex, sizeof(verifierHex),
Encoding::HexFlags::kNullTerminate);
ChipLogProgress(NotSpecified, " PAKEPasscodeVerifier: %s", verifierHex);

char saltHex[Crypto::kSpake2p_Max_PBKDF_Salt_Length * 2 + 1];
Encoding::BytesToHex(value.salt.data(), value.salt.size(), saltHex, sizeof(saltHex), Encoding::HexFlags::kNullTerminate);
ChipLogProgress(NotSpecified, " salt: %s", saltHex);

OpenDeviceCommissioningWindow(mLocalBridgeNodeId, value.commissioningTimeout, value.iterations, value.discriminator, saltHex,
verifierHex);
}

void DeviceManager::HandleAttributeData(const app::ConcreteDataAttributePath & path, TLV::TLVReader * data)
{
if (path.mClusterId == CommissionerControl::Id &&
path.mAttributeId == CommissionerControl::Attributes::SupportedDeviceCategories::Id)
{
ChipLogProgress(NotSpecified, "Attribute SupportedDeviceCategories detected.");

BitMask<CommissionerControl::SupportedDeviceCategoryBitmap> value;
CHIP_ERROR error = app::DataModel::Decode(*data, value);
if (error != CHIP_NO_ERROR)
{
ChipLogError(NotSpecified, "Failed to decode attribute value. Error: %" CHIP_ERROR_FORMAT, error.Format());
return;
}

if (value.Has(CommissionerControl::SupportedDeviceCategoryBitmap::kFabricSynchronization))
{
ChipLogProgress(NotSpecified, "Remote Fabric-Bridge supports Fabric Synchronization, start reverse commissioning.");
RequestCommissioningApproval();
}

return;
}

if (path.mClusterId != Descriptor::Id || path.mAttributeId != Descriptor::Attributes::PartsList::Id)
{
return;
}

ChipLogProgress(NotSpecified, "Attribute change detected:");
ChipLogProgress(
NotSpecified, "Endpoint: %u, Cluster: " ChipLogFormatMEI ", Attribute: " ChipLogFormatMEI ", DataVersion: %" PRIu32,
path.mEndpointId, ChipLogValueMEI(path.mClusterId), ChipLogValueMEI(path.mAttributeId), path.mDataVersion.ValueOr(0));
ChipLogProgress(NotSpecified, "Attribute PartsList change detected:");

app::DataModel::DecodableList<EndpointId> value;
CHIP_ERROR error = app::DataModel::Decode(*data, value);
CHIP_ERROR error = app::DataModel::Decode(data, value);
if (error != CHIP_NO_ERROR)
{
ChipLogError(NotSpecified, "Failed to decode attribute value. Error: %" CHIP_ERROR_FORMAT, error.Format());
Expand Down Expand Up @@ -456,7 +405,63 @@ void DeviceManager::HandleAttributeData(const app::ConcreteDataAttributePath & p
}
}

void DeviceManager::HandleEventData(const app::EventHeader & header, TLV::TLVReader * data)
void DeviceManager::SendCommissionNodeRequest(uint64_t requestId, uint16_t responseTimeoutSeconds)
{
ChipLogProgress(NotSpecified, "Request the Commissioner Control Server to begin commissioning a previously approved request.");

StringBuilder<kMaxCommandSize> commandBuilder;
commandBuilder.Add("commissionercontrol commission-node ");
commandBuilder.AddFormat("%lu %u %lu %d", requestId, responseTimeoutSeconds, mRemoteBridgeNodeId, kRootEndpointId);

PushCommand(commandBuilder.c_str());
}

void DeviceManager::HandleReverseOpenCommissioningWindow(TLV::TLVReader & data)
{
CommissionerControl::Commands::ReverseOpenCommissioningWindow::DecodableType value;
CHIP_ERROR error = app::DataModel::Decode(data, value);
if (error != CHIP_NO_ERROR)
{
ChipLogError(NotSpecified, "Failed to decode command response value. Error: %" CHIP_ERROR_FORMAT, error.Format());
return;
}

// Log all fields
ChipLogProgress(NotSpecified, "DecodableType fields:");
ChipLogProgress(NotSpecified, " commissioningTimeout: %u", value.commissioningTimeout);
ChipLogProgress(NotSpecified, " discriminator: %u", value.discriminator);
ChipLogProgress(NotSpecified, " iterations: %u", value.iterations);

char verifierHex[Crypto::kSpake2p_VerifierSerialized_Length * 2 + 1];
Encoding::BytesToHex(value.PAKEPasscodeVerifier.data(), value.PAKEPasscodeVerifier.size(), verifierHex, sizeof(verifierHex),
Encoding::HexFlags::kNullTerminate);
ChipLogProgress(NotSpecified, " PAKEPasscodeVerifier: %s", verifierHex);

char saltHex[Crypto::kSpake2p_Max_PBKDF_Salt_Length * 2 + 1];
Encoding::BytesToHex(value.salt.data(), value.salt.size(), saltHex, sizeof(saltHex), Encoding::HexFlags::kNullTerminate);
ChipLogProgress(NotSpecified, " salt: %s", saltHex);

OpenDeviceCommissioningWindow(mLocalBridgeNodeId, value.commissioningTimeout, value.iterations, value.discriminator, saltHex,
verifierHex);
}

void DeviceManager::HandleAttributeData(const app::ConcreteDataAttributePath & path, TLV::TLVReader & data)
{
if (path.mClusterId == CommissionerControl::Id &&
path.mAttributeId == CommissionerControl::Attributes::SupportedDeviceCategories::Id)
{
HandleReadSupportedDeviceCategories(data);
return;
}

if (path.mClusterId == Descriptor::Id && path.mAttributeId == Descriptor::Attributes::PartsList::Id)
{
HandleAttributePartsListUpdate(data);
return;
}
}

void DeviceManager::HandleEventData(const app::EventHeader & header, TLV::TLVReader & data)
{
if (header.mPath.mClusterId == CommissionerControl::Id &&
header.mPath.mEventId == CommissionerControl::Events::CommissioningRequestResult::Id)
Expand All @@ -465,7 +470,7 @@ void DeviceManager::HandleEventData(const app::EventHeader & header, TLV::TLVRea
}
}

void DeviceManager::HandleCommandResponse(const app::ConcreteCommandPath & path, TLV::TLVReader * data)
void DeviceManager::HandleCommandResponse(const app::ConcreteCommandPath & path, TLV::TLVReader & data)
{
ChipLogProgress(NotSpecified, "Command Response received.");

Expand Down
14 changes: 9 additions & 5 deletions examples/fabric-admin/device_manager/DeviceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ class DeviceManager : public PairingDelegate

void ReadSupportedDeviceCategories();

void HandleAttributeData(const chip::app::ConcreteDataAttributePath & path, chip::TLV::TLVReader * data);
void HandleAttributeData(const chip::app::ConcreteDataAttributePath & path, chip::TLV::TLVReader & data);

void HandleEventData(const chip::app::EventHeader & header, chip::TLV::TLVReader * data);
void HandleEventData(const chip::app::EventHeader & header, chip::TLV::TLVReader & data);

void HandleCommandResponse(const chip::app::ConcreteCommandPath & path, chip::TLV::TLVReader * data);
void HandleCommandResponse(const chip::app::ConcreteCommandPath & path, chip::TLV::TLVReader & data);

void OnDeviceRemoved(chip::NodeId deviceId, CHIP_ERROR err) override;

Expand All @@ -163,11 +163,15 @@ class DeviceManager : public PairingDelegate

void RequestCommissioningApproval();

void HandleCommissioningRequestResult(chip::TLV::TLVReader * data);
void HandleReadSupportedDeviceCategories(chip::TLV::TLVReader & data);

void HandleCommissioningRequestResult(chip::TLV::TLVReader & data);

void HandleAttributePartsListUpdate(chip::TLV::TLVReader & data);

void SendCommissionNodeRequest(uint64_t requestId, uint16_t responseTimeoutSeconds);

void HandleReverseOpenCommissioningWindow(chip::TLV::TLVReader * data);
void HandleReverseOpenCommissioningWindow(chip::TLV::TLVReader & data);

static DeviceManager sInstance;

Expand Down
2 changes: 2 additions & 0 deletions examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,12 @@ source_set("fabric-bridge-lib") {
public_configs = [ ":config" ]

sources = [
"include/BridgedAdministratorCommissioning.h",
"include/BridgedDevice.h",
"include/BridgedDeviceBasicInformationImpl.h",
"include/BridgedDeviceManager.h",
"include/CHIPProjectAppConfig.h",
"src/BridgedAdministratorCommissioning.cpp",
"src/BridgedDevice.cpp",
"src/BridgedDeviceBasicInformationImpl.cpp",
"src/BridgedDeviceManager.cpp",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* 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.
*/

#pragma once

#include <app-common/zap-generated/cluster-objects.h>
#include <app/AttributeAccessInterfaceRegistry.h>

/**
* @brief CADMIN cluster implementation for handling attribute interactions of bridged device endpoints.
*
* The current Administrator Commissioning Cluster server's zap generated code will automatically
* register an Attribute Access Interface for the root node endpoint implementation. In order to
* properly respond to a read attribute for bridged devices we are representing, we override the
* currently registered Attribute Interface such that we are first to receive any read attribute
* request on Administrator Commissioning Cluster, and if it is not an endpoint for a device we
* are a bridge for we redirect to the default cluster server implementation of Administrator
* Commissioning Cluster.
*/
class BridgedAdministratorCommissioning : public chip::app::AttributeAccessInterface
{
public:
// Register for the AdministratorCommissioning cluster on all endpoints.
BridgedAdministratorCommissioning() :
AttributeAccessInterface(chip::NullOptional, chip::app::Clusters::AdministratorCommissioning::Id)
{}

CHIP_ERROR Init();

CHIP_ERROR Read(const chip::app::ConcreteReadAttributePath & aPath, chip::app::AttributeValueEncoder & aEncoder) override;

// We do not allow writing to CADMIN attributes of a bridged device endpoint. We simply redirect
// write requests to the original attribute interface.
CHIP_ERROR Write(const chip::app::ConcreteDataAttributePath & aPath, chip::app::AttributeValueDecoder & aDecoder) override
{
VerifyOrDie(mOriginalAttributeInterface);
return mOriginalAttributeInterface->Write(aPath, aDecoder);
}

private:
// If mOriginalAttributeInterface is removed from here, the class description needs to be updated
// to reflect this change.
chip::app::AttributeAccessInterface * mOriginalAttributeInterface = nullptr;
};
Loading

0 comments on commit 3b70d26

Please sign in to comment.