Skip to content

Commit

Permalink
foo debug
Browse files Browse the repository at this point in the history
  • Loading branch information
vivien-apple committed Sep 26, 2024
1 parent 19c401a commit ae8968a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ class ClusterCommand : public ModelCommand {
queue:callbackQueue
completion:^(
NSArray<NSDictionary<NSString *, id> *> * _Nullable values, NSError * _Nullable error) {
ChipLogError(chipTool, "Main: Received a invoke response");
responsesNeeded--;
if (error != nil) {
mError = error;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class SubscribeAttribute : public ModelCommand {
params:params
queue:callbackQueue
reportHandler:^(NSArray<NSDictionary<NSString *, id> *> * _Nullable values, NSError * _Nullable error) {
ChipLogError(chipTool, "Main: Received a ReportData");
if (error != nil) {
RemoteDataModelLogger::LogAttributeErrorAsJSON(endpoint, cluster, attribute, error);
}
Expand Down
14 changes: 13 additions & 1 deletion examples/darwin-framework-tool/commands/common/CHIPXPCServer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

#include "CHIPCommandBridge.h"

#include <chrono>
#include <thread>

MTRBaseDevice * GetDevice(id controller, uint64_t nodeId)
{
if (![controller isKindOfClass:[NSString class]]) {
Expand Down Expand Up @@ -128,7 +131,10 @@ - (void)invokeCommandWithController:(id _Nullable)controller
timedInvokeTimeout:timeoutMs
queue:_callbackQueue
completion:^(NSArray<NSDictionary<NSString *, id> *> * _Nullable values, NSError * _Nullable error) {
ChipLogError(chipTool, "XPC: Received a invoke response.");
std::this_thread::sleep_for(std::chrono::microseconds(2500));
completion([MTRDeviceController encodeXPCResponseValues:values], error);
ChipLogError(chipTool, "XPC: Invoke response has been dispatched.");
}];
}

Expand Down Expand Up @@ -172,11 +178,13 @@ - (void)subscribeAttributeWithController:(id _Nullable)controller
queue:_callbackQueue
reportHandler:^(
NSArray<NSDictionary<NSString *, id> *> * _Nullable values, NSError * _Nullable error) {
ChipLogError(chipTool, "XPC: Received a report.");
[self.clientProxy
handleReportWithController:controller
nodeId:nodeId
values:[MTRDeviceController encodeXPCResponseValues:values]
error:error];
ChipLogError(chipTool, "XPC: ReportData has been dispatched.");
}
subscriptionEstablished:establishedHandler];
}
Expand Down Expand Up @@ -238,8 +246,12 @@ - (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConne
auto server = [[AppDeviceControllerServerProtocol alloc] initWithClientProxy:[newConnection remoteObjectProxy]];
newConnection.exportedObject = server;

newConnection.interruptionHandler = ^{
ChipLogProgress(chipTool, "XPC connection interrupted");
};

newConnection.invalidationHandler = ^{
ChipLogProgress(chipTool, "XPC connection disconnected");
ChipLogProgress(chipTool, "XPC connection invalidated");
};

[newConnection resume];
Expand Down

0 comments on commit ae8968a

Please sign in to comment.