Skip to content

Commit

Permalink
Log the outgoing write values and command payloads in MTRBaseDevice.
Browse files Browse the repository at this point in the history
Note that this is the code MTRDevice_Concrete ends up calling into, so this logs
the MTRDevice_Concrete behavior as well.
  • Loading branch information
bzbarsky-apple committed Sep 20, 2024
1 parent 7b8467b commit 9d78909
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/darwin/Framework/CHIP/MTRBaseDevice.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1158,6 +1158,8 @@ - (void)writeAttributeWithEndpointID:(NSNumber *)endpointID
queue:(dispatch_queue_t)queue
completion:(MTRDeviceResponseHandler)completion
{
MTR_LOG("%@ write %@ 0x%llx 0x%llx: %@", self, endpointID, clusterID.unsignedLongLongValue, attributeID.unsignedLongLongValue, value);

auto * bridge = new MTRDataValueDictionaryCallbackBridge(queue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session, MTRDataValueDictionaryCallback successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
Expand Down Expand Up @@ -1367,6 +1369,8 @@ - (void)_invokeCommandWithEndpointID:(NSNumber *)endpointID
timeoutMs = MTRClampedNumber(timeoutMs, @(1), @(UINT16_MAX));
}

MTR_LOG("%@ invoke %@ 0x%llx 0x%llx: %@", self, endpointID, clusterID.unsignedLongLongValue, commandID.unsignedLongLongValue, commandFields);

auto * bridge = new MTRDataValueDictionaryCallbackBridge(queue, completion,
^(ExchangeManager & exchangeManager, const SessionHandle & session, MTRDataValueDictionaryCallback successCb,
MTRErrorCallback failureCb, MTRCallbackBridgeBase * bridge) {
Expand Down Expand Up @@ -2148,6 +2152,12 @@ - (void)downloadLogOfType:(MTRDiagnosticLogType)type
completion:completion];
}

- (NSString *)description
{
return [NSString
stringWithFormat:@"<%@: %p, node: %016llX-%016llX (%llu)>", NSStringFromClass(self.class), self, _deviceController.compressedFabricID.unsignedLongLongValue, _nodeID, _nodeID];
}

@end

@implementation MTRBaseDevice (Deprecated)
Expand Down

0 comments on commit 9d78909

Please sign in to comment.