Skip to content

Commit

Permalink
Merge branch 'master' into fix-chef-fan-app
Browse files Browse the repository at this point in the history
  • Loading branch information
soares-sergio authored Oct 28, 2024
2 parents f119c9a + 928efd7 commit 5ac4256
Show file tree
Hide file tree
Showing 57 changed files with 1,588 additions and 967 deletions.
1 change: 1 addition & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,7 @@
[submodule "third_party/lwip/repo"]
path = third_party/lwip/repo
url = https://github.com/lwip-tcpip/lwip.git
excluded-platforms = darwin
[submodule "third_party/abseil-cpp/src"]
path = third_party/abseil-cpp/src
url = https://github.com/abseil/abseil-cpp.git
Expand Down
2 changes: 1 addition & 1 deletion examples/common/pigweed/rpc_services/Attributes.h
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class Attributes : public pw_rpc::nanopb::Attributes::Service<Attributes>
app::DataModel::ReadAttributeRequest request;
request.path = path;
request.operationFlags.Set(app::DataModel::OperationFlags::kInternal);
request.subjectDescriptor = subjectDescriptor;
request.subjectDescriptor = &subjectDescriptor;

std::optional<app::DataModel::ClusterInfo> info = provider->GetClusterInfo(path);
if (!info.has_value())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class CHIPCommandBridge : public Command {
"commissioner-name. Interactive mode will only set a single commissioner on the inital command. "
"The commissioner node ID will be persisted until a different one is specified.");
AddArgument("commissioner-shared-storage", 0, 1, &mCommissionerSharedStorage,
"Use a shared storage instance instead of individual storage for each commissioner. Default is true.");
"Use a shared storage instance instead of individual storage for each commissioner. Default is false.");
AddArgument("paa-trust-store-path", &mPaaTrustStorePath,
"Path to directory holding PAA certificate information. Can be absolute or relative to the current working "
"directory.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
productAttestationAuthorityCertificates = nil;
}

sUseSharedStorage = mCommissionerSharedStorage.ValueOr(true);
sUseSharedStorage = mCommissionerSharedStorage.ValueOr(false);
if (sUseSharedStorage) {
return SetUpStackWithSharedStorage(productAttestationAuthorityCertificates);
}
Expand Down Expand Up @@ -185,6 +185,10 @@
intermediateCertificate:nil
rootCertificate:certificateIssuer.rootCertificate];
[params setOperationalCertificateIssuer:certificateIssuer queue:controllerStorageQueue];

__auto_type * otaDelegateQueue = dispatch_queue_create("com.chip.ota", DISPATCH_QUEUE_SERIAL_WITH_AUTORELEASE_POOL);
[params setOTAProviderDelegate:mOTADelegate queue:otaDelegateQueue];

params.productAttestationAuthorityCertificates = productAttestationAuthorityCertificates;

__auto_type * controller = [[MTRDeviceController alloc] initWithParameters:params error:&error];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

#include <lib/support/logging/CHIPLogging.h>

constexpr const uint32_t kIssuerId = 12345678;

@interface CertificateIssuer ()
- (MTRCertificateDERBytes _Nullable)issueOperationalCertificateForNodeID:(NSNumber *)nodeID
fabricID:(NSNumber *)fabricID
Expand Down Expand Up @@ -67,7 +69,7 @@ - (void)startWithStorage:(id<MTRStorage>)storage
return;
}

__auto_type * rootCertificate = [MTRCertificates createRootCertificate:signingKey issuerID:nil fabricID:nil error:error];
__auto_type * rootCertificate = [MTRCertificates createRootCertificate:signingKey issuerID:@(kIssuerId) fabricID:nil error:error];
if (nil == rootCertificate) {
*error = [NSError errorWithDomain:@"Error" code:0 userInfo:@{ @"reason" : @"Error creating root certificate" }];
return;
Expand Down
6 changes: 2 additions & 4 deletions examples/fabric-admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ For Raspberry Pi 4 example:
### Pull Docker Images

```
docker pull connectedhomeip/chip-build-vscode:latest
docker pull ghcr.io/project-chip/chip-build-crosscompile:81
```

### Run docker

```
docker run -it -v ~/connectedhomeip:/var/connectedhomeip connectedhomeip/chip-build-vscode:latest /bin/bash
docker run -it -v ~/connectedhomeip:/var/connectedhomeip ghcr.io/project-chip/chip-build-crosscompile:81 /bin/bash
```

### Build
Expand All @@ -38,8 +38,6 @@ docker run -it -v ~/connectedhomeip:/var/connectedhomeip connectedhomeip/chip-bu
cd /var/connectedhomeip
git config --global --add safe.directory /var/connectedhomeip
git config --global --add safe.directory /var/connectedhomeip/third_party/pigweed/repo
git config --global --add safe.directory /var/connectedhomeip/examples/common/QRCode/repo
./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
Expand Down
6 changes: 2 additions & 4 deletions examples/fabric-bridge-app/linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ defined:
Pull Docker Images

```
docker pull connectedhomeip/chip-build-vscode:latest
docker pull ghcr.io/project-chip/chip-build-crosscompile:81
```

Run docker

```
docker run -it -v ~/connectedhomeip:/var/connectedhomeip connectedhomeip/chip-build-vscode:latest /bin/bash
docker run -it -v ~/connectedhomeip:/var/connectedhomeip ghcr.io/project-chip/chip-build-crosscompile:81 /bin/bash
```

Build
Expand All @@ -115,8 +115,6 @@ defined:
cd /var/connectedhomeip

git config --global --add safe.directory /var/connectedhomeip
git config --global --add safe.directory /var/connectedhomeip/third_party/pigweed/repo
git config --global --add safe.directory /var/connectedhomeip/examples/common/QRCode/repo

./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
Expand Down
6 changes: 2 additions & 4 deletions examples/fabric-sync/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ defined:
Pull Docker Images

```
docker pull connectedhomeip/chip-build-vscode:latest
docker pull ghcr.io/project-chip/chip-build-crosscompile:81
```

Run docker

```
docker run -it -v ~/connectedhomeip:/var/connectedhomeip connectedhomeip/chip-build-vscode:latest /bin/bash
docker run -it -v ~/connectedhomeip:/var/connectedhomeip ghcr.io/project-chip/chip-build-crosscompile:81 /bin/bash
```

Build
Expand All @@ -107,8 +107,6 @@ defined:
cd /var/connectedhomeip

git config --global --add safe.directory /var/connectedhomeip
git config --global --add safe.directory /var/connectedhomeip/third_party/pigweed/repo
git config --global --add safe.directory /var/connectedhomeip/examples/common/QRCode/repo

./scripts/run_in_build_env.sh \
"./scripts/build/build_examples.py \
Expand Down
55 changes: 55 additions & 0 deletions examples/fabric-sync/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,69 @@

using namespace chip;

namespace {

constexpr char kFabricSyncLogFilePath[] = "/tmp/fabric_sync.log";

// File pointer for the log file
FILE * sLogFile = nullptr;

void OpenLogFile(const char * filePath)
{
sLogFile = fopen(filePath, "a");
if (sLogFile == nullptr)
{
perror("Failed to open log file");
}
}

void CloseLogFile()
{
if (sLogFile != nullptr)
{
fclose(sLogFile);
sLogFile = nullptr;
}
}

void ENFORCE_FORMAT(3, 0) LoggingCallback(const char * module, uint8_t category, const char * msg, va_list args)
{
if (sLogFile == nullptr)
{
return;
}

uint64_t timeMs = System::SystemClock().GetMonotonicMilliseconds64().count();
uint64_t seconds = timeMs / 1000;
uint64_t milliseconds = timeMs % 1000;

flockfile(sLogFile);

fprintf(sLogFile, "[%llu.%06llu] CHIP:%s: ", static_cast<unsigned long long>(seconds),
static_cast<unsigned long long>(milliseconds), module);
vfprintf(sLogFile, msg, args);
fprintf(sLogFile, "\n");
fflush(sLogFile);

funlockfile(sLogFile);
}

} // namespace

void ApplicationInit()
{
ChipLogProgress(NotSpecified, "Fabric-Sync: ApplicationInit()");

OpenLogFile(kFabricSyncLogFilePath);

// Redirect logs to the custom logging callback
Logging::SetLogRedirectCallback(LoggingCallback);
}

void ApplicationShutdown()
{
ChipLogDetail(NotSpecified, "Fabric-Sync: ApplicationShutdown()");
CloseLogFile();
}

int main(int argc, char * argv[])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
#include <platform/silabs/MigrationManager.h>
#include <platform/silabs/SilabsConfig.h>
#include <silabs_creds.h>
#ifndef NDEBUG
#if defined(SL_MATTER_TEST_EVENT_TRIGGER_ENABLED) && (SL_MATTER_GN_BUILD == 0)
#include <sl_matter_test_event_trigger_config.h>
#endif // defined(SL_MATTER_TEST_EVENT_TRIGGER_ENABLED) && (SL_MATTER_GN_BUILD == 0)
#endif // NDEBUG
#ifdef OTA_ENCRYPTION_ENABLE
#include <platform/silabs/multi-ota/OtaTlvEncryptionKey.h>
#endif // OTA_ENCRYPTION_ENABLE
Expand Down
12 changes: 12 additions & 0 deletions scripts/checkout_submodules.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,18 @@ def load_module_info() -> None:
platforms = set(filter(None, platforms))
assert not (
platforms - ALL_PLATFORMS), "Submodule's platform not contained in ALL_PLATFORMS"

# Check for explicitly excluded platforms
excluded_platforms = module.get('excluded-platforms', '').split(',')
excluded_platforms = set(filter(None, excluded_platforms))
assert not (
excluded_platforms - ALL_PLATFORMS), "Submodule excluded on platforms not contained in ALL_PLATFORMS"

if len(excluded_platforms) != 0:
if len(platforms) == 0:
platforms = ALL_PLATFORMS
platforms = platforms - excluded_platforms

recursive = module.getboolean('recursive', False)
name = name.replace('submodule "', '').replace('"', '')
yield Module(name=name, path=module['path'], platforms=platforms, recursive=recursive)
Expand Down
1 change: 1 addition & 0 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ buildconfig_header("app_buildconfig") {
"CHIP_DEVICE_CONFIG_DYNAMIC_SERVER=${chip_build_controller_dynamic_server}",
"CHIP_CONFIG_ENABLE_BUSY_HANDLING_FOR_OPERATIONAL_SESSION_SETUP=${chip_enable_busy_handling_for_operational_session_setup}",
"CHIP_CONFIG_DATA_MODEL_CHECK_DIE_ON_FAILURE=${chip_data_model_check_die_on_failure}",
"CHIP_CONFIG_DATA_MODEL_EXTRA_LOGGING=${chip_data_model_extra_logging}",
]

if (chip_use_data_model_interface == "disabled") {
Expand Down
7 changes: 5 additions & 2 deletions src/app/CommandHandlerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <app/CommandHandlerImpl.h>

#include <access/AccessControl.h>
#include <access/SubjectDescriptor.h>
#include <app-common/zap-generated/cluster-objects.h>
#include <app/MessageDef/StatusIB.h>
#include <app/RequiredPrivilege.h>
Expand Down Expand Up @@ -391,10 +392,11 @@ Status CommandHandlerImpl::ProcessCommandDataIB(CommandDataIB::Parser & aCommand
VerifyOrReturnError(err == CHIP_NO_ERROR, Status::InvalidAction);

{
Access::SubjectDescriptor subjectDescriptor = GetSubjectDescriptor();
DataModel::InvokeRequest request;

request.path = concretePath;
request.subjectDescriptor = GetSubjectDescriptor();
request.subjectDescriptor = &subjectDescriptor;
request.invokeFlags.Set(DataModel::InvokeFlags::kTimed, IsTimedInvoke());

Status preCheckStatus = mpCallback->ValidateCommandCanBeDispatched(request);
Expand Down Expand Up @@ -513,10 +515,11 @@ Status CommandHandlerImpl::ProcessGroupCommandDataIB(CommandDataIB::Parser & aCo
const ConcreteCommandPath concretePath(mapping.endpoint_id, clusterId, commandId);

{
Access::SubjectDescriptor subjectDescriptor = GetSubjectDescriptor();
DataModel::InvokeRequest request;

request.path = concretePath;
request.subjectDescriptor = GetSubjectDescriptor();
request.subjectDescriptor = &subjectDescriptor;
request.invokeFlags.Set(DataModel::InvokeFlags::kTimed, IsTimedInvoke());

Status preCheckStatus = mpCallback->ValidateCommandCanBeDispatched(request);
Expand Down
6 changes: 4 additions & 2 deletions src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1646,10 +1646,12 @@ void InteractionModelEngine::DispatchCommand(CommandHandlerImpl & apCommandObj,
{
#if CHIP_CONFIG_USE_DATA_MODEL_INTERFACE

Access::SubjectDescriptor subjectDescriptor = apCommandObj.GetSubjectDescriptor();

DataModel::InvokeRequest request;
request.path = aCommandPath;
request.invokeFlags.Set(DataModel::InvokeFlags::kTimed, apCommandObj.IsTimedInvoke());
request.subjectDescriptor = apCommandObj.GetSubjectDescriptor();
request.subjectDescriptor = &subjectDescriptor;

std::optional<DataModel::ActionReturnStatus> status = GetDataModelProvider()->Invoke(request, apPayload, &apCommandObj);

Expand Down Expand Up @@ -1702,7 +1704,7 @@ Protocols::InteractionModel::Status InteractionModelEngine::ValidateCommandCanBe

Protocols::InteractionModel::Status InteractionModelEngine::CheckCommandAccess(const DataModel::InvokeRequest & aRequest)
{
if (!aRequest.subjectDescriptor.has_value())
if (aRequest.subjectDescriptor == nullptr)
{
return Status::UnsupportedAccess; // we require a subject for invoke
}
Expand Down
11 changes: 8 additions & 3 deletions src/app/WriteHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,13 @@ void WriteHandler::Close()
std::optional<bool> WriteHandler::IsListAttributePath(const ConcreteAttributePath & path)
{
#if CHIP_CONFIG_USE_DATA_MODEL_INTERFACE
VerifyOrReturnValue(mDataModelProvider != nullptr, std::nullopt,
ChipLogError(DataManagement, "Null data model while checking attribute properties."));
if (mDataModelProvider == nullptr)
{
#if CHIP_CONFIG_DATA_MODEL_EXTRA_LOGGING
ChipLogError(DataManagement, "Null data model while checking attribute properties.");
#endif
return std::nullopt;
}

auto info = mDataModelProvider->GetAttributeInfo(path);
if (!info.has_value())
Expand Down Expand Up @@ -774,7 +779,7 @@ CHIP_ERROR WriteHandler::WriteClusterData(const Access::SubjectDescriptor & aSub
DataModel::WriteAttributeRequest request;

request.path = aPath;
request.subjectDescriptor = aSubject;
request.subjectDescriptor = &aSubject;
request.previousSuccessPath = mLastSuccessfullyWrittenPath;
request.writeFlags.Set(DataModel::WriteFlags::kTimed, IsTimedWrite());

Expand Down
Loading

0 comments on commit 5ac4256

Please sign in to comment.