Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding logging to Darwin #34241

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class CHIPCommandBridge : public Command {
{
AddArgument("commissioner-name", &mCommissionerName);
AddArgument("commissioner-nodeId", 0, UINT64_MAX, &mCommissionerNodeId,
"Sets the commisser node ID of the given "
"Sets the commissioner node ID of the given "
"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("paa-trust-store-path", &mPaaTrustStorePath,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ - (void)controller:(MTRDeviceController *)controller statusUpdate:(MTRCommission
ChipLogError(chipTool, "MTRCommissioningStatusDiscoveringMoreDevices: This should not happen.");
break;
case MTRCommissioningStatusUnknown:
ChipLogError(chipTool, "Uknown Pairing Status");
ChipLogError(chipTool, "Unknown Pairing Status");
break;
}
}
Expand Down
6 changes: 5 additions & 1 deletion src/darwin/Framework/CHIP/MTRDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -844,11 +844,13 @@ - (void)_addDelegate:(id<MTRDeviceDelegate>)delegate queue:(dispatch_queue_t)que
#endif

if (shouldSetUpSubscription) {
MTR_LOG("%@ - starting subscription setup", self);
// Record the time of first addDelegate call that triggers initial subscribe, and do not reset this value on subsequent addDelegate calls
if (!_initialSubscribeStart) {
_initialSubscribeStart = [NSDate now];
}
if ([self _deviceUsesThread]) {
MTR_LOG(" => %@ - device is a thread device, scheduling in pool", self);
[self _scheduleSubscriptionPoolWork:^{
std::lock_guard lock(self->_lock);
[self _setupSubscriptionWithReason:@"delegate is set and scheduled subscription is happening"];
Expand Down Expand Up @@ -1301,7 +1303,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:

// Sanity check we are not scheduling for this device multiple times in the pool
if (_subscriptionPoolWorkCompletionBlock) {
MTR_LOG_ERROR("%@ already scheduled in subscription pool for this device - ignoring: %@", self, description);
MTR_LOG("%@ already scheduled in subscription pool for this device - ignoring: %@", self, description);
return;
}

Expand All @@ -1310,6 +1312,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:
// In the case where a resubscription triggering event happened and already established, running the work block should result in a no-op
MTRAsyncWorkItem * workItem = [[MTRAsyncWorkItem alloc] initWithQueue:self.queue];
[workItem setReadyHandler:^(id _Nonnull context, NSInteger retryCount, MTRAsyncWorkCompletionBlock _Nonnull completion) {
MTR_LOG("%@ - work item is ready to attempt pooled subscription", self);
os_unfair_lock_lock(&self->_lock);
#ifdef DEBUG
[self _callDelegatesWithBlock:^(id testDelegate) {
Expand All @@ -1335,6 +1338,7 @@ - (void)_scheduleSubscriptionPoolWork:(dispatch_block_t)workBlock inNanoseconds:
workBlock();
}];
[self->_deviceController.concurrentSubscriptionPool enqueueWorkItem:workItem description:description];
MTR_LOG("%@ - enqueued in the subscription pool", self);
});
}

Expand Down
4 changes: 4 additions & 0 deletions src/darwin/Framework/CHIP/MTRError_Internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@

NS_ASSUME_NONNULL_BEGIN

#ifndef YES_NO
#define YES_NO(x) ((x) ? @"YES" : @"NO")
kiel-apple marked this conversation as resolved.
Show resolved Hide resolved
#endif

MTR_DIRECT_MEMBERS
@interface MTRError : NSObject
+ (NSError *)errorWithCode:(MTRErrorCode)code;
Expand Down
Loading