diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index 3b0211d9d45129..d8b4fb30eb602a 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -1627,7 +1627,9 @@ static BOOL AttributeHasChangesOmittedQuality(MTRAttributePath * attributePath) // Send read request to device if any of the following are true: // 1. Subscription not in a state we can expect reports - // 2. The attribute has (or is assumed to have) the Changes Omitted quality, so we won't get reports for it. + // 2. The attribute has the Changes Omitted quality, so we won't get reports for it. + // 3. The attribute is not in the spec, and the read params asks to assume + // an unknown attribute has the Changes Omitted quality. if (![self _subscriptionAbleToReport] || hasChangesOmittedQuality) { // Read requests container will be a mutable array of items, each being an array containing: // [attribute request path, params] diff --git a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m index 06d06404ffeaad..4f97026ed6644f 100644 --- a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m +++ b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m @@ -1518,6 +1518,10 @@ - (void)test017_TestMTRDeviceBasics [self waitForExpectations:@[ onTimeWriteSuccess, onTimePreviousValue ] timeout:10]; // Test if errors are properly received + // TODO: We might stop reporting these altogether from MTRDevice, and then + // this test will need updating. + __auto_type * readThroughForUnknownAttributesParams = [[MTRReadParams alloc] init]; + readThroughForUnknownAttributesParams.assumeUnknownAttributesReportable = NO; XCTestExpectation * attributeReportErrorExpectation = [self expectationWithDescription:@"Attribute read error"]; delegate.onAttributeDataReceived = ^(NSArray *> * data) { for (NSDictionary * attributeReponseValue in data) { @@ -1526,8 +1530,9 @@ - (void)test017_TestMTRDeviceBasics } } }; + // use the nonexistent attribute and expect read error - [device readAttributeWithEndpointID:testEndpointID clusterID:testClusterID attributeID:testAttributeID params:nil]; + [device readAttributeWithEndpointID:testEndpointID clusterID:testClusterID attributeID:testAttributeID params:readThroughForUnknownAttributesParams]; [self waitForExpectations:@[ attributeReportErrorExpectation ] timeout:10]; // Resubscription test setup diff --git a/src/darwin/Framework/CHIPTests/MTRSwiftDeviceTests.swift b/src/darwin/Framework/CHIPTests/MTRSwiftDeviceTests.swift index 1276868a14c5fa..21d61cb0360ac1 100644 --- a/src/darwin/Framework/CHIPTests/MTRSwiftDeviceTests.swift +++ b/src/darwin/Framework/CHIPTests/MTRSwiftDeviceTests.swift @@ -287,6 +287,10 @@ class MTRSwiftDeviceTests : XCTestCase { wait(for: [ expectedValueReportedExpectation, expectedValueRemovedExpectation ], timeout: 5, enforceOrder: true) // Test if errors are properly received + // TODO: We might stop reporting these altogether from MTRDevice, and then + // this test will need updating. + let readThroughForUnknownAttributesParams = MTRReadParams() + readThroughForUnknownAttributesParams.shouldAssumeUnknownAttributesReportable = false; let attributeReportErrorExpectation = expectation(description: "Attribute read error") delegate.onAttributeDataReceived = { (data: [[ String: Any ]]) -> Void in for attributeReponseValue in data { @@ -296,7 +300,7 @@ class MTRSwiftDeviceTests : XCTestCase { } } // use the nonexistent attribute and expect read error - device.readAttribute(withEndpointID: testEndpointID, clusterID: testClusterID, attributeID: testAttributeID, params: nil) + device.readAttribute(withEndpointID: testEndpointID, clusterID: testClusterID, attributeID: testAttributeID, params: readThroughForUnknownAttributesParams) wait(for: [ attributeReportErrorExpectation ], timeout: 10) // Resubscription test setup