Skip to content

Commit

Permalink
Merge branch 'master' into feature/thermostat-events-xml
Browse files Browse the repository at this point in the history
  • Loading branch information
drempelg committed Feb 19, 2025
2 parents 4ee024e + 40979b4 commit 7d32a69
Show file tree
Hide file tree
Showing 45 changed files with 1,944 additions and 62 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/util/config.h>
#include <chef-dishwasher-mode-delegate-impl.h>

using namespace chip;
using namespace chip::app;
Expand Down
1 change: 1 addition & 0 deletions examples/chef/common/chef-rvc-mode-delegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
#include <app-common/zap-generated/attributes/Accessors.h>
#include <app/util/config.h>
#include <chef-rvc-mode-delegate.h>

using namespace chip;
using namespace chip::app;
Expand Down
3 changes: 3 additions & 0 deletions examples/darwin-framework-tool/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ executable("darwin-framework-tool") {
"commands/common/PreferencesStorage.mm",
"commands/common/RemoteDataModelLogger.h",
"commands/common/RemoteDataModelLogger.mm",
"commands/common/xpc/DeviceControllerServer.mm",
"commands/common/xpc/XPCServer.mm",
"commands/common/xpc/XPCServerRegistry.mm",
"commands/configuration/Commands.h",
"commands/configuration/ResetMRPParametersCommand.h",
"commands/configuration/ResetMRPParametersCommand.mm",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class CHIPCommandBridge : public Command {
AddArgument("commissioner-vendor-id", 0, UINT16_MAX, &mCommissionerVendorId,
"The vendor id to use for darwin-framework-tool. If not provided, chip::VendorId::TestVendor1 (65521, 0xFFF1) will be "
"used.");
AddArgument("use-xpc", &mUseXPC, "Use a controller that will connect to an XPC endpoint instead of talking to devices directly. If a string argument is provided, it must identify a Mach service name that can be used to connect to a remote endpoint. If no argument is provided, a local endpoint will be used.");
}

/////////// Command Interface /////////
Expand Down Expand Up @@ -168,4 +169,5 @@ class CHIPCommandBridge : public Command {
chip::Optional<char *> mPaaTrustStorePath;
chip::Optional<chip::VendorId> mCommissionerVendorId;
std::string mCurrentIdentity;
chip::Optional<chip::app::DataModel::Nullable<char *>> mUseXPC;
};
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
#import "DeviceDelegate.h"
#include "MTRError_Utils.h"

#include "xpc/XPCServerRegistry.h"

#include <map>
#include <string>

Expand All @@ -45,6 +47,17 @@
bool CHIPCommandBridge::sUseSharedStorage = true;
constexpr char kTrustStorePathVariable[] = "PAA_TRUST_STORE_PATH";

namespace {
NSString * ToNSString(const chip::Optional<chip::app::DataModel::Nullable<char *>> & string)
{
if (!string.HasValue() && string.Value().IsNull()) {
return nil;
}

return @(string.Value().Value());
}
}

CHIP_ERROR CHIPCommandBridge::Run()
{
// In interactive mode, we want to avoid memory accumulating in the main autorelease pool,
Expand Down Expand Up @@ -143,6 +156,8 @@
productAttestationAuthorityCertificates = nil;
}

[[XPCServerRegistry sharedInstance] start];

sUseSharedStorage = mCommissionerSharedStorage.ValueOr(false);
if (sUseSharedStorage) {
return SetUpStackWithSharedStorage(productAttestationAuthorityCertificates);
Expand Down Expand Up @@ -202,7 +217,13 @@

params.productAttestationAuthorityCertificates = productAttestationAuthorityCertificates;

__auto_type * controller = [[MTRDeviceController alloc] initWithParameters:params error:&error];
MTRDeviceController * controller = nil;
if (mUseXPC.HasValue()) {
__auto_type * identifier = uuidString;
controller = [[XPCServerRegistry sharedInstance] createController:identifier serviceName:ToNSString(mUseXPC) params:params error:&error];
} else {
controller = [[MTRDeviceController alloc] initWithParameters:params error:&error];
}
VerifyOrReturnError(nil != controller, MTRErrorToCHIPErrorCode(error), ChipLogError(chipTool, "Controller startup failure: %@", error));
mControllers[identities[i]] = controller;
}
Expand Down Expand Up @@ -237,12 +258,18 @@
params.nodeId = @(mCommissionerNodeId.Value());
}

// We're not sure whether we're creating a new fabric or using an existing one, so just try both.
auto controller = [factory createControllerOnExistingFabric:params error:&error];
if (controller == nil) {
// Maybe we didn't have this fabric yet.
params.vendorID = @(mCommissionerVendorId.ValueOr(chip::VendorId::TestVendor1));
controller = [factory createControllerOnNewFabric:params error:&error];
MTRDeviceController * controller = nil;
if (mUseXPC.HasValue()) {
__auto_type * identifier = @(identities[i]);
controller = [[XPCServerRegistry sharedInstance] createController:identifier serviceName:ToNSString(mUseXPC) params:params error:&error];
} else {
// We're not sure whether we're creating a new fabric or using an existing one, so just try both.
controller = [factory createControllerOnExistingFabric:params error:&error];
if (controller == nil) {
// Maybe we didn't have this fabric yet.
params.vendorID = @(mCommissionerVendorId.ValueOr(chip::VendorId::TestVendor1));
controller = [factory createControllerOnNewFabric:params error:&error];
}
}
VerifyOrReturnError(nil != controller, MTRErrorToCHIPErrorCode(error), ChipLogError(chipTool, "Controller startup failure: %@", error));
mControllers[identities[i]] = controller;
Expand All @@ -256,6 +283,8 @@
if (IsInteractive()) {
return;
}

[[XPCServerRegistry sharedInstance] stop];
ShutdownCommissioner();
}

Expand Down
Loading

0 comments on commit 7d32a69

Please sign in to comment.