Skip to content

Commit

Permalink
Merge branch 'master' into DFT_AddDeviceDelegate
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple authored Oct 28, 2024
2 parents bf85f86 + 928efd7 commit 50e98d7
Show file tree
Hide file tree
Showing 22 changed files with 343 additions and 238 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 @@ -142,7 +142,7 @@
productAttestationAuthorityCertificates = nil;
}

sUseSharedStorage = mCommissionerSharedStorage.ValueOr(true);
sUseSharedStorage = mCommissionerSharedStorage.ValueOr(false);
if (sUseSharedStorage) {
return SetUpStackWithSharedStorage(productAttestationAuthorityCertificates);
}
Expand Down Expand Up @@ -188,6 +188,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
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
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
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
2 changes: 1 addition & 1 deletion src/app/WriteHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,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 50e98d7

Please sign in to comment.