Skip to content

Commit cfc9c38

Browse files
Log when MTRServerAttribute not bound to a controller has its value updated.
This should enable API consumers to more easily figure out why their attribute updates are not being published.
1 parent bb24d97 commit cfc9c38

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/darwin/Framework/CHIP/ServerEndpoint/MTRServerAttribute.mm

+12-2
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,19 @@ - (nullable instancetype)initWithAttributeID:(NSNumber *)attributeID value:(NSDi
7272
_parentCluster = app::ConcreteClusterPath(kInvalidEndpointId, kInvalidClusterId);
7373

7474
// Now call setValue to store the value and its serialization.
75-
if ([self setValue:value] == NO) {
75+
if ([self setValueInternal:value logIfNotAssociated:NO] == NO) {
7676
return nil;
7777
}
7878

7979
return self;
8080
}
8181

8282
- (BOOL)setValue:(NSDictionary<NSString *, id> *)value
83+
{
84+
return [self setValueInternal:value logIfNotAssociated:YES];
85+
}
86+
87+
- (BOOL)setValueInternal:(NSDictionary<NSString *, id> *)value logIfNotAssociated:(BOOL)logIfNotAssociated
8388
{
8489
id serializedValue;
8590
id dataType = value[MTRTypeKey];
@@ -121,7 +126,12 @@ - (BOOL)setValue:(NSDictionary<NSString *, id> *)value
121126

122127
MTRDeviceController * deviceController = _deviceController;
123128
if (deviceController == nil) {
124-
// We're not bound to a controller, so safe to directly update _serializedValue.
129+
// We're not bound to a controller, so safe to directly update
130+
// _serializedValue.
131+
if (logIfNotAssociated) {
132+
MTR_LOG_DEFAULT("Not publishing value for attribute " ChipLogFormatMEI "; not bound to a controller",
133+
ChipLogValueMEI(static_cast<AttributeId>(_attributeID.unsignedLongLongValue)));
134+
}
125135
_serializedValue = serializedValue;
126136
} else {
127137
[deviceController asyncDispatchToMatterQueue:^{

0 commit comments

Comments
 (0)