Skip to content

Commit

Permalink
Log attempts to commission a device in Matter.framework. (project-chi…
Browse files Browse the repository at this point in the history
…p#37502)

Also logs the SSID when doing commmissioning onto a Wi-Fi network.
  • Loading branch information
bzbarsky-apple authored Feb 11, 2025
1 parent cbfa554 commit c0f11e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/darwin/Framework/CHIP/MTRCommissioningParameters.mm
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,18 @@ - (void)setFailSafeExpiryTimeoutSecs:(NSNumber * _Nullable)failSafeExpiryTimeout
self.failSafeTimeout = failSafeExpiryTimeoutSecs;
}

- (NSString *)description
{
// SSID is not required to be UTF-8, but almost always is.
NSString * ssidString;
if (self.wifiSSID) {
ssidString = [[NSString alloc] initWithData:self.wifiSSID encoding:NSUTF8StringEncoding];
} else {
ssidString = nil;
}
return [NSString stringWithFormat:@"<MTRCommissioningParameters: %p ssid: %@>", self, ssidString];
}

@end

NS_ASSUME_NONNULL_END
2 changes: 2 additions & 0 deletions src/darwin/Framework/CHIP/MTRDeviceController_Concrete.mm
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,8 @@ - (BOOL)commissionNodeWithID:(NSNumber *)nodeID
commissioningParams:(MTRCommissioningParameters *)commissioningParams
error:(NSError * __autoreleasing *)error
{
MTR_LOG("%@ trying to commission node with ID 0x%016llX parameters %@", self, nodeID.unsignedLongLongValue, commissioningParams);

if (self.suspended) {
MTR_LOG_ERROR("%@ suspended: can't commission device ID 0x%016llX with parameters %@", self, nodeID.unsignedLongLongValue, commissioningParams);
// TODO: Can we do a better error here?
Expand Down

0 comments on commit c0f11e7

Please sign in to comment.