Skip to content

Commit 7d32a69

Browse files
committed
Merge branch 'master' into feature/thermostat-events-xml
2 parents 4ee024e + 40979b4 commit 7d32a69

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+1944
-62
lines changed

examples/chef/common/chef-dishwasher-mode-delegate-impl.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
#include <app-common/zap-generated/attributes/Accessors.h>
1919
#include <app/util/config.h>
20+
#include <chef-dishwasher-mode-delegate-impl.h>
2021

2122
using namespace chip;
2223
using namespace chip::app;

examples/chef/common/chef-rvc-mode-delegate.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818
#include <app-common/zap-generated/attributes/Accessors.h>
1919
#include <app/util/config.h>
20+
#include <chef-rvc-mode-delegate.h>
2021

2122
using namespace chip;
2223
using namespace chip::app;

examples/darwin-framework-tool/BUILD.gn

+3
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,9 @@ executable("darwin-framework-tool") {
218218
"commands/common/PreferencesStorage.mm",
219219
"commands/common/RemoteDataModelLogger.h",
220220
"commands/common/RemoteDataModelLogger.mm",
221+
"commands/common/xpc/DeviceControllerServer.mm",
222+
"commands/common/xpc/XPCServer.mm",
223+
"commands/common/xpc/XPCServerRegistry.mm",
221224
"commands/configuration/Commands.h",
222225
"commands/configuration/ResetMRPParametersCommand.h",
223226
"commands/configuration/ResetMRPParametersCommand.mm",

examples/darwin-framework-tool/commands/common/CHIPCommandBridge.h

+2
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class CHIPCommandBridge : public Command {
5252
AddArgument("commissioner-vendor-id", 0, UINT16_MAX, &mCommissionerVendorId,
5353
"The vendor id to use for darwin-framework-tool. If not provided, chip::VendorId::TestVendor1 (65521, 0xFFF1) will be "
5454
"used.");
55+
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.");
5556
}
5657

5758
/////////// Command Interface /////////
@@ -168,4 +169,5 @@ class CHIPCommandBridge : public Command {
168169
chip::Optional<char *> mPaaTrustStorePath;
169170
chip::Optional<chip::VendorId> mCommissionerVendorId;
170171
std::string mCurrentIdentity;
172+
chip::Optional<chip::app::DataModel::Nullable<char *>> mUseXPC;
171173
};

examples/darwin-framework-tool/commands/common/CHIPCommandBridge.mm

+36-7
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#import "DeviceDelegate.h"
3232
#include "MTRError_Utils.h"
3333

34+
#include "xpc/XPCServerRegistry.h"
35+
3436
#include <map>
3537
#include <string>
3638

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

50+
namespace {
51+
NSString * ToNSString(const chip::Optional<chip::app::DataModel::Nullable<char *>> & string)
52+
{
53+
if (!string.HasValue() && string.Value().IsNull()) {
54+
return nil;
55+
}
56+
57+
return @(string.Value().Value());
58+
}
59+
}
60+
4861
CHIP_ERROR CHIPCommandBridge::Run()
4962
{
5063
// In interactive mode, we want to avoid memory accumulating in the main autorelease pool,
@@ -143,6 +156,8 @@
143156
productAttestationAuthorityCertificates = nil;
144157
}
145158

159+
[[XPCServerRegistry sharedInstance] start];
160+
146161
sUseSharedStorage = mCommissionerSharedStorage.ValueOr(false);
147162
if (sUseSharedStorage) {
148163
return SetUpStackWithSharedStorage(productAttestationAuthorityCertificates);
@@ -202,7 +217,13 @@
202217

203218
params.productAttestationAuthorityCertificates = productAttestationAuthorityCertificates;
204219

205-
__auto_type * controller = [[MTRDeviceController alloc] initWithParameters:params error:&error];
220+
MTRDeviceController * controller = nil;
221+
if (mUseXPC.HasValue()) {
222+
__auto_type * identifier = uuidString;
223+
controller = [[XPCServerRegistry sharedInstance] createController:identifier serviceName:ToNSString(mUseXPC) params:params error:&error];
224+
} else {
225+
controller = [[MTRDeviceController alloc] initWithParameters:params error:&error];
226+
}
206227
VerifyOrReturnError(nil != controller, MTRErrorToCHIPErrorCode(error), ChipLogError(chipTool, "Controller startup failure: %@", error));
207228
mControllers[identities[i]] = controller;
208229
}
@@ -237,12 +258,18 @@
237258
params.nodeId = @(mCommissionerNodeId.Value());
238259
}
239260

240-
// We're not sure whether we're creating a new fabric or using an existing one, so just try both.
241-
auto controller = [factory createControllerOnExistingFabric:params error:&error];
242-
if (controller == nil) {
243-
// Maybe we didn't have this fabric yet.
244-
params.vendorID = @(mCommissionerVendorId.ValueOr(chip::VendorId::TestVendor1));
245-
controller = [factory createControllerOnNewFabric:params error:&error];
261+
MTRDeviceController * controller = nil;
262+
if (mUseXPC.HasValue()) {
263+
__auto_type * identifier = @(identities[i]);
264+
controller = [[XPCServerRegistry sharedInstance] createController:identifier serviceName:ToNSString(mUseXPC) params:params error:&error];
265+
} else {
266+
// We're not sure whether we're creating a new fabric or using an existing one, so just try both.
267+
controller = [factory createControllerOnExistingFabric:params error:&error];
268+
if (controller == nil) {
269+
// Maybe we didn't have this fabric yet.
270+
params.vendorID = @(mCommissionerVendorId.ValueOr(chip::VendorId::TestVendor1));
271+
controller = [factory createControllerOnNewFabric:params error:&error];
272+
}
246273
}
247274
VerifyOrReturnError(nil != controller, MTRErrorToCHIPErrorCode(error), ChipLogError(chipTool, "Controller startup failure: %@", error));
248275
mControllers[identities[i]] = controller;
@@ -256,6 +283,8 @@
256283
if (IsInteractive()) {
257284
return;
258285
}
286+
287+
[[XPCServerRegistry sharedInstance] stop];
259288
ShutdownCommissioner();
260289
}
261290

0 commit comments

Comments
 (0)