From 9d78909ad9b8e66360f506b6dd9be7f585c853bd Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 20 Sep 2024 12:18:24 -0400 Subject: [PATCH] Log the outgoing write values and command payloads in MTRBaseDevice. Note that this is the code MTRDevice_Concrete ends up calling into, so this logs the MTRDevice_Concrete behavior as well. --- src/darwin/Framework/CHIP/MTRBaseDevice.mm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice.mm b/src/darwin/Framework/CHIP/MTRBaseDevice.mm index 8a1feefea20607..ca291b8a4f1b56 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice.mm +++ b/src/darwin/Framework/CHIP/MTRBaseDevice.mm @@ -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) { @@ -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) { @@ -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)