Skip to content

Commit

Permalink
Merge branch 'master' into increase_acls_and_groups
Browse files Browse the repository at this point in the history
  • Loading branch information
cletnick authored Jan 10, 2023
2 parents ecb0176 + 6a0fb2e commit 3634df2
Show file tree
Hide file tree
Showing 25 changed files with 3,217 additions and 2,781 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/examples-nrfconnect.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ jobs:
examples/all-clusters-app/nrfconnect/build/zephyr/zephyr.elf \
/tmp/bloat_reports/
- name: Run unit tests for Zephyr native_posix_64 platform
if: github.event_name == 'push' || steps.changed_paths.outputs.tests == 'true'
if: github.event_name == 'push' || steps.changed_paths.outputs.tests == 'true' || steps.changed_paths.outputs.nrfconnect == 'true'
timeout-minutes: 15
run: |
scripts/run_in_build_env.sh "./scripts/build/build_examples.py --target nrf-native-posix-64-tests build"
Expand Down
5 changes: 3 additions & 2 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Sphinx
docutils==0.17.1
Sphinx>=4.5
sphinx-book-theme
myst-parser
breathe
breathe>=4.34
1 change: 1 addition & 0 deletions examples/chip-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ static_library("chip-tool-utils") {
"commands/common/CredentialIssuerCommands.h",
"commands/common/HexConversion.h",
"commands/delay/SleepCommand.cpp",
"commands/delay/WaitForCommissioneeCommand.cpp",
"commands/discover/DiscoverCommand.cpp",
"commands/discover/DiscoverCommissionablesCommand.cpp",
"commands/discover/DiscoverCommissionersCommand.cpp",
Expand Down
4 changes: 3 additions & 1 deletion examples/chip-tool/commands/delay/Commands.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@

#include "commands/common/Commands.h"
#include "commands/delay/SleepCommand.h"
#include "commands/delay/WaitForCommissioneeCommand.h"

void registerCommandsDelay(Commands & commands, CredentialIssuerCommands * credsIssuerConfig)
{
const char * clusterName = "Delay";
commands_list clusterCommands = {
make_unique<SleepCommand>(credsIssuerConfig), //
make_unique<SleepCommand>(credsIssuerConfig), //
make_unique<WaitForCommissioneeCommand>(credsIssuerConfig), //
};

commands.Register(clusterName, clusterCommands);
Expand Down
51 changes: 51 additions & 0 deletions examples/chip-tool/commands/delay/WaitForCommissioneeCommand.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2023 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 "WaitForCommissioneeCommand.h"

using namespace chip;

CHIP_ERROR WaitForCommissioneeCommand::RunCommand()
{
chip::FabricIndex fabricIndex = CurrentCommissioner().GetFabricIndex();
ReturnErrorCodeIf(fabricIndex == chip::kUndefinedFabricIndex, CHIP_ERROR_INCORRECT_STATE);

if (mExpireExistingSession.ValueOr(true))
{
CurrentCommissioner().SessionMgr()->ExpireAllSessions(chip::ScopedNodeId(mNodeId, fabricIndex));
}

return CurrentCommissioner().GetConnectedDevice(mNodeId, &mOnDeviceConnectedCallback, &mOnDeviceConnectionFailureCallback);
}

void WaitForCommissioneeCommand::OnDeviceConnectedFn(void * context, Messaging::ExchangeManager & exchangeMgr,
SessionHandle & sessionHandle)
{
auto * command = reinterpret_cast<WaitForCommissioneeCommand *>(context);
VerifyOrReturn(command != nullptr, ChipLogError(chipTool, "OnDeviceConnectedFn: context is null"));
command->SetCommandExitStatus(CHIP_NO_ERROR);
}

void WaitForCommissioneeCommand::OnDeviceConnectionFailureFn(void * context, const chip::ScopedNodeId & peerId, CHIP_ERROR err)
{
LogErrorOnFailure(err);

auto * command = reinterpret_cast<WaitForCommissioneeCommand *>(context);
VerifyOrReturn(command != nullptr, ChipLogError(chipTool, "OnDeviceConnectionFailureFn: context is null"));
command->SetCommandExitStatus(err);
}
56 changes: 56 additions & 0 deletions examples/chip-tool/commands/delay/WaitForCommissioneeCommand.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2023 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 "../common/CHIPCommand.h"
#include <app/OperationalSessionSetup.h>
#include <lib/core/CHIPCallback.h>

class WaitForCommissioneeCommand : public CHIPCommand
{
public:
WaitForCommissioneeCommand(CredentialIssuerCommands * credIssuerCommands) :
CHIPCommand("wait-for-commissionee", credIssuerCommands), mOnDeviceConnectedCallback(OnDeviceConnectedFn, this),
mOnDeviceConnectionFailureCallback(OnDeviceConnectionFailureFn, this)
{
AddArgument("nodeId", 0, UINT64_MAX, &mNodeId);
AddArgument("expire-existing-session", 0, 1, &mExpireExistingSession);
AddArgument("timeout", 0, UINT64_MAX, &mTimeoutSecs,
"Time, in seconds, before this command is considered to have timed out.");
}

/////////// CHIPCommand Interface /////////
CHIP_ERROR RunCommand() override;
chip::System::Clock::Timeout GetWaitDuration() const override
{
return chip::System::Clock::Seconds16(mTimeoutSecs.ValueOr(10));
}

private:
chip::NodeId mNodeId;
chip::Optional<uint16_t> mTimeoutSecs;
chip::Optional<bool> mExpireExistingSession;

static void OnDeviceConnectedFn(void * context, chip::Messaging::ExchangeManager & exchangeMgr,
chip::SessionHandle & sessionHandle);
static void OnDeviceConnectionFailureFn(void * context, const chip::ScopedNodeId & peerId, CHIP_ERROR error);

chip::Callback::Callback<chip::OnDeviceConnected> mOnDeviceConnectedCallback;
chip::Callback::Callback<chip::OnDeviceConnectionFailure> mOnDeviceConnectionFailureCallback;
};
2 changes: 1 addition & 1 deletion examples/thermostat/silabs/efr32/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ tracking code inside the `trackAlloc` and `trackFree` function
For the description of Software Update process with EFR32 example applications
see
[EFR32 OTA Software Update](../../../docs/guides/silabs_efr32_software_update.md)
[EFR32 OTA Software Update](../../../../docs/guides/silabs_efr32_software_update.md)
## Building options
Expand Down
23 changes: 23 additions & 0 deletions src/darwin/Darwin.xcworkspace/xcshareddata/IDETemplateMacros.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>FILEHEADER</key>
<string>
/**
* Copyright (c) 2023 Project CHIP Authors
*
* 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.
*/</string>
</dict>
</plist>
35 changes: 35 additions & 0 deletions src/darwin/Framework/CHIP/MTRConversion.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/**
* Copyright (c) 2023 Project CHIP Authors
*
* 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.
*/

#import "NSDataSpanConversion.h"
#import "NSStringSpanConversion.h"

#import <Foundation/Foundation.h>

#include <lib/core/Optional.h>
#include <type_traits>

NS_ASSUME_NONNULL_BEGIN

template <typename T>
inline std::enable_if_t<std::is_integral<T>::value || std::is_floating_point<T>::value || std::is_enum<T>::value,
NSNumber * _Nullable>
AsNumber(chip::Optional<T> optional)
{
return (optional.HasValue()) ? @(optional.Value()) : nil;
}

NS_ASSUME_NONNULL_END
18 changes: 16 additions & 2 deletions src/darwin/Framework/CHIP/MTRDeviceAttestationDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,31 @@
*/

#import <Foundation/Foundation.h>
#import <Matter/MTRCertificates.h>

NS_ASSUME_NONNULL_BEGIN

@class MTRDeviceController;

@interface MTRDeviceAttestationDeviceInfo : NSObject

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;
@property (nonatomic, readonly) NSData * dacCertificate;
@property (nonatomic, readonly) NSData * dacPAICertificate;

/**
* The vendor ID for the device from the Device Attestation Certificate. May be nil only if attestation was unsucessful.
*/
@property (nonatomic, readonly, nullable) NSNumber * vendorID;

/**
* The product ID for the device from the Device Attestation Certificate. May be nil only if attestation was unsucessful.
*/
@property (nonatomic, readonly, nullable) NSNumber * productID;

@property (nonatomic, readonly) MTRCertificateDERBytes dacCertificate;
@property (nonatomic, readonly) MTRCertificateDERBytes dacPAICertificate;
@property (nonatomic, readonly, nullable) NSData * certificateDeclaration;

@end

/**
Expand Down
21 changes: 17 additions & 4 deletions src/darwin/Framework/CHIP/MTRDeviceAttestationDelegate.mm
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,32 @@
* limitations under the License.
*/

#import <Foundation/Foundation.h>
#import <MTRDeviceAttestationDelegate_Internal.h>
#import "MTRDeviceAttestationDelegate_Internal.h"

#import "MTRConversion.h"

#include <crypto/CHIPCryptoPAL.h>

using namespace chip::Crypto;

@implementation MTRDeviceAttestationDeviceInfo
- (instancetype)initWithDACCertificate:(NSData *)dacCertificate
dacPAICertificate:(NSData *)dacPAICertificate

- (instancetype)initWithDACCertificate:(MTRCertificateDERBytes)dacCertificate
dacPAICertificate:(MTRCertificateDERBytes)dacPAICertificate
certificateDeclaration:(NSData *)certificateDeclaration
{
if (self = [super init]) {
_dacCertificate = [dacCertificate copy];
_dacPAICertificate = [dacPAICertificate copy];
_certificateDeclaration = [certificateDeclaration copy];

struct AttestationCertVidPid dacVidPid;
if (ExtractVIDPIDFromX509Cert(AsByteSpan(_dacCertificate), dacVidPid) == CHIP_NO_ERROR) {
_vendorID = AsNumber(dacVidPid.mVendorId);
_productID = AsNumber(dacVidPid.mProductId);
}
}
return self;
}

@end
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
* limitations under the License.
*/

#import <MTRDeviceAttestationDelegate.h>
#import "MTRDeviceAttestationDelegate.h"

NS_ASSUME_NONNULL_BEGIN

@interface MTRDeviceAttestationDeviceInfo ()
- (instancetype)initWithDACCertificate:(NSData *)dacCertificate
dacPAICertificate:(NSData *)dacPAICertificate

- (instancetype)initWithDACCertificate:(MTRCertificateDERBytes)dacCertificate
dacPAICertificate:(MTRCertificateDERBytes)dacPAICertificate
certificateDeclaration:(NSData *)certificateDeclaration;

@end

NS_ASSUME_NONNULL_END
2 changes: 1 addition & 1 deletion src/darwin/Framework/CHIP/NSDataSpanConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#pragma once

#import "Foundation/Foundation.h"
#import <Foundation/Foundation.h>

#include <lib/support/Span.h>

Expand Down
2 changes: 1 addition & 1 deletion src/darwin/Framework/CHIP/NSStringSpanConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

#pragma once

#import "Foundation/Foundation.h"
#import <Foundation/Foundation.h>

#include <lib/support/Span.h>

Expand Down
4 changes: 4 additions & 0 deletions src/darwin/Framework/Matter.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
3DECCB702934AECD00585AEC /* MTRLogging.h in Headers */ = {isa = PBXBuildFile; fileRef = 3DECCB6F2934AC1C00585AEC /* MTRLogging.h */; settings = {ATTRIBUTES = (Public, ); }; };
3DECCB722934AFE200585AEC /* MTRLogging.mm in Sources */ = {isa = PBXBuildFile; fileRef = 3DECCB712934AFE200585AEC /* MTRLogging.mm */; };
3DECCB742934C21B00585AEC /* MTRDefines.h in Headers */ = {isa = PBXBuildFile; fileRef = 3DECCB732934C21B00585AEC /* MTRDefines.h */; settings = {ATTRIBUTES = (Public, ); }; };
3DFCB32C29678C9500332B35 /* MTRConversion.h in Headers */ = {isa = PBXBuildFile; fileRef = 3DFCB32B29678C9500332B35 /* MTRConversion.h */; };
51029DF6293AA6100087AFB0 /* MTROperationalCertificateIssuer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 51029DF5293AA6100087AFB0 /* MTROperationalCertificateIssuer.mm */; };
511913FB28C100EF009235E9 /* MTRBaseSubscriptionCallback.mm in Sources */ = {isa = PBXBuildFile; fileRef = 511913F928C100EF009235E9 /* MTRBaseSubscriptionCallback.mm */; };
511913FC28C100EF009235E9 /* MTRBaseSubscriptionCallback.h in Headers */ = {isa = PBXBuildFile; fileRef = 511913FA28C100EF009235E9 /* MTRBaseSubscriptionCallback.h */; };
Expand Down Expand Up @@ -236,6 +237,7 @@
3DECCB6F2934AC1C00585AEC /* MTRLogging.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRLogging.h; sourceTree = "<group>"; };
3DECCB712934AFE200585AEC /* MTRLogging.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRLogging.mm; sourceTree = "<group>"; };
3DECCB732934C21B00585AEC /* MTRDefines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRDefines.h; sourceTree = "<group>"; };
3DFCB32B29678C9500332B35 /* MTRConversion.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MTRConversion.h; sourceTree = "<group>"; };
51029DF5293AA6100087AFB0 /* MTROperationalCertificateIssuer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTROperationalCertificateIssuer.mm; sourceTree = "<group>"; };
511913F928C100EF009235E9 /* MTRBaseSubscriptionCallback.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = MTRBaseSubscriptionCallback.mm; sourceTree = "<group>"; };
511913FA28C100EF009235E9 /* MTRBaseSubscriptionCallback.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MTRBaseSubscriptionCallback.h; sourceTree = "<group>"; };
Expand Down Expand Up @@ -507,6 +509,7 @@
99AECC7F2798A57E00B6355B /* MTRCommissioningParameters.mm */,
51E030FE27EA20D20083DC9C /* MTRControllerAccessControl.h */,
51E030FF27EA20D20083DC9C /* MTRControllerAccessControl.mm */,
3DFCB32B29678C9500332B35 /* MTRConversion.h */,
3CF134A6289D8AD90017A19E /* MTRCSRInfo.h */,
3CF134A8289D8D800017A19E /* MTRCSRInfo.mm */,
3DECCB732934C21B00585AEC /* MTRDefines.h */,
Expand Down Expand Up @@ -667,6 +670,7 @@
27A53C1727FBC6920053F131 /* MTRAttestationTrustStoreBridge.h in Headers */,
5A830D6C27CFCF590053B85D /* MTRDeviceControllerOverXPC_Internal.h in Headers */,
88EBF8D027FABDD500686BC1 /* MTRDeviceAttestationDelegateBridge.h in Headers */,
3DFCB32C29678C9500332B35 /* MTRConversion.h in Headers */,
5A60370827EA1FF60020DB79 /* MTRClusterStateCacheContainer+XPC.h in Headers */,
5ACDDD7E27CD3F3A00EFD68A /* MTRClusterStateCacheContainer_Internal.h in Headers */,
5136661328067D550025EDAE /* MTRDeviceController_Internal.h in Headers */,
Expand Down
Loading

0 comments on commit 3634df2

Please sign in to comment.