From 4766142b505904d99ae5ee9bc00cec315ae05992 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 19 Apr 2023 19:28:10 -0400 Subject: [PATCH 01/54] Improve the readAttributePaths tests a bit. (#26166) * Improve the readAttributePaths tests a bit. More stringent result checking, somewhat more readable code. Fixes https://github.com/project-chip/connectedhomeip/issues/26077 * Address review comments --- .../Framework/CHIPTests/MTRDeviceTests.m | 216 +++++++++++++----- 1 file changed, 154 insertions(+), 62 deletions(-) diff --git a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m index f649a04dff13e8..cf2757097c1ca4 100644 --- a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m +++ b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m @@ -1625,15 +1625,16 @@ - (void)test020_ReadMultipleAttributes MTRBaseDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); - NSArray * attributePaths = - [NSArray arrayWithObjects:[MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@29 attributeID:@0], - [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@29 attributeID:@1], - [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@29 attributeID:@2], - [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@29 attributeID:@3], - [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@29 attributeID:@4], - [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@5], - [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@6], - [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@7], nil]; + NSArray * attributePaths = @[ + [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@29 attributeID:@0], + [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@29 attributeID:@1], + [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@29 attributeID:@2], + [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@29 attributeID:@3], + [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@4], + [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@5], + [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@6], + [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@7] + ]; NSArray * eventPaths = [NSArray arrayWithObjects:[MTREventRequestPath requestPathWithEndpointID:nil clusterID:@40 eventID:@0], nil]; @@ -1648,34 +1649,43 @@ - (void)test020_ReadMultipleAttributes XCTAssertNil(error); XCTAssertEqual([MTRErrorTestUtils errorToZCLErrorCode:error], 0); - { - XCTAssertTrue([values isKindOfClass:[NSArray class]]); - NSArray * resultArray = values; - BOOL includeEventPath = NO; - for (NSDictionary * result in resultArray) { - if ([result objectForKey:@"eventPath"]) { - MTREventPath * path = result[@"eventPath"]; - XCTAssertEqual([path.cluster unsignedIntegerValue], 40); - XCTAssertEqual([path.event unsignedIntegerValue], 0); - XCTAssertNotNil(result[@"data"]); - XCTAssertNil(result[@"error"]); - XCTAssertTrue([result[@"data"] isKindOfClass:[NSDictionary class]]); - includeEventPath = YES; - } else if ([result objectForKey:@"attributePath"]) { - MTRAttributePath * path = result[@"attributePath"]; - if ([path.attribute unsignedIntegerValue] < 5) { - XCTAssertEqual([path.cluster unsignedIntegerValue], 29); - } else { - XCTAssertEqual([path.cluster unsignedIntegerValue], 40); - } - XCTAssertNotNil(result[@"data"]); - XCTAssertNil(result[@"error"]); - XCTAssertTrue([result[@"data"] isKindOfClass:[NSDictionary class]]); + XCTAssertTrue([values isKindOfClass:[NSArray class]]); + NSArray * resultArray = values; + size_t attributeResultCount = 0; + size_t eventResultCount = 0; + for (NSDictionary * result in resultArray) { + if ([result objectForKey:@"eventPath"]) { + ++eventResultCount; + MTREventPath * path = result[@"eventPath"]; + XCTAssertEqualObjects(path.endpoint, @0); + XCTAssertEqualObjects(path.cluster, @40); + XCTAssertEqualObjects(path.event, @0); + XCTAssertNotNil(result[@"data"]); + XCTAssertNil(result[@"error"]); + XCTAssertTrue([result[@"data"] isKindOfClass:[NSDictionary class]]); + } else if ([result objectForKey:@"attributePath"]) { + ++attributeResultCount; + MTRAttributePath * path = result[@"attributePath"]; + if ([path.attribute unsignedIntegerValue] < 4) { + XCTAssertEqualObjects(path.cluster, @29); + __auto_type endpoint = [path.endpoint unsignedShortValue]; + XCTAssertTrue(endpoint == 0 || endpoint == 1 || endpoint == 2); + } else { + XCTAssertEqualObjects(path.cluster, @40); + XCTAssertEqualObjects(path.endpoint, @0); } + XCTAssertNotNil(result[@"data"]); + XCTAssertNil(result[@"error"]); + XCTAssertTrue([result[@"data"] isKindOfClass:[NSDictionary class]]); + } else { + XCTFail("Unexpected result dictionary %@", result); } - XCTAssertTrue(includeEventPath); - XCTAssertTrue([resultArray count] > 0); } + // Our test application has 3 endpoints. We have a descriptor on each one, + // so that's 4 results per endpoint, and we only have Basic Information on + // endpoint 0, so that's 4 more results. + XCTAssertEqual(attributeResultCount, 3 * 4 + 4); + XCTAssertEqual(eventResultCount, [eventPaths count]); [expectation fulfill]; }]; @@ -1683,7 +1693,82 @@ - (void)test020_ReadMultipleAttributes [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)test021_ReadMultipleAttributesIncludeUnsupportedAttribute +- (void)test021_ReadMultipleWildcardPathsIncludeUnsupportedAttribute +{ + MTRBaseDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + + // Read the PartList of descriptor on endpoint 0 to find out how many endpoints there are. + XCTestExpectation * descriptorReadExpectation = [self expectationWithDescription:@"read PartsList from endpoint 0"]; + __auto_type * descriptorCluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:queue]; + __block size_t endpointCount = 0; + [descriptorCluster readAttributePartsListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable error) { + XCTAssertNil(error); + XCTAssertNotNil(value); + endpointCount = value.count + 1; // Include endpoint 0 + [descriptorReadExpectation fulfill]; + }]; + + [self waitForExpectations:@[ descriptorReadExpectation ] timeout:kTimeoutInSeconds]; + + XCTestExpectation * expectation = + [self expectationWithDescription:@"read Basic Information Cluster's attributes and include 1 unsupported attribute"]; + + NSNumber * failAttributeID = @10000; + + NSArray * attributePaths = @[ + [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@29 attributeID:@0], + [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@29 attributeID:@1], + [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@29 attributeID:@2], + [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@29 attributeID:@3], + [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@29 attributeID:failAttributeID], // Fail Case + [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@4], + [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@5], + [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@6], + [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@7] + ]; + + [device readAttributePaths:attributePaths + eventPaths:nil + params:nil + queue:queue + completion:^(id _Nullable values, NSError * _Nullable error) { + NSLog(@"read attribute: DeviceType values: %@, error: %@", values, error); + + XCTAssertNil(error); + XCTAssertEqual([MTRErrorTestUtils errorToZCLErrorCode:error], 0); + + XCTAssertTrue([values isKindOfClass:[NSArray class]]); + NSArray * resultArray = values; + // We have a descriptor on each endpoint, so that's 4 results per endpoint, + // and we only have Basic Information on endpoint 0, so that's 4 more + // results. Note that there are no results for failAttributeID, because we + // used a wildcard path and hence it got ignored. + XCTAssertEqual(resultArray.count, endpointCount * 4 + 4); + + for (NSDictionary * result in resultArray) { + MTRAttributePath * path = result[@"attributePath"]; + if ([path.attribute unsignedIntegerValue] < 4) { + XCTAssertEqualObjects(path.cluster, @29); + __auto_type endpoint = [path.endpoint unsignedShortValue]; + XCTAssertTrue(endpoint == 0 || endpoint == 1 || endpoint == 2); + } else { + XCTAssertEqualObjects(path.cluster, @40); + XCTAssertEqualObjects(path.endpoint, @0); + } + + XCTAssertNotNil(result[@"data"]); + XCTAssertNil(result[@"error"]); + XCTAssertTrue([result[@"data"] isKindOfClass:[NSDictionary class]]); + } + + [expectation fulfill]; + }]; + + [self waitForExpectations:@[ expectation ] timeout:kTimeoutInSeconds]; +} + +- (void)test022_ReadMultipleConcretePathsIncludeUnsupportedAttribute { XCTestExpectation * expectation = [self expectationWithDescription:@"read Basic Information Cluster's attributes and include 1 unsupported attribute"]; @@ -1693,17 +1778,17 @@ - (void)test021_ReadMultipleAttributesIncludeUnsupportedAttribute NSNumber * failAttributeID = @10000; - NSArray * attributePaths = - [NSArray arrayWithObjects:[MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@0], - [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@1], - [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@2], - [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@3], - [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@4], - [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:failAttributeID] // Fail Case - , - [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@5], - [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@6], - [MTRAttributeRequestPath requestPathWithEndpointID:nil clusterID:@40 attributeID:@7], nil]; + NSArray * attributePaths = @[ + [MTRAttributeRequestPath requestPathWithEndpointID:@0 clusterID:@29 attributeID:@0], + [MTRAttributeRequestPath requestPathWithEndpointID:@0 clusterID:@29 attributeID:@1], + [MTRAttributeRequestPath requestPathWithEndpointID:@0 clusterID:@29 attributeID:@2], + [MTRAttributeRequestPath requestPathWithEndpointID:@0 clusterID:@29 attributeID:@3], + [MTRAttributeRequestPath requestPathWithEndpointID:@0 clusterID:@29 attributeID:failAttributeID], // Fail Case + [MTRAttributeRequestPath requestPathWithEndpointID:@0 clusterID:@40 attributeID:@4], + [MTRAttributeRequestPath requestPathWithEndpointID:@0 clusterID:@40 attributeID:@5], + [MTRAttributeRequestPath requestPathWithEndpointID:@0 clusterID:@40 attributeID:@6], + [MTRAttributeRequestPath requestPathWithEndpointID:@0 clusterID:@40 attributeID:@7] + ]; [device readAttributePaths:attributePaths eventPaths:nil @@ -1715,22 +1800,29 @@ - (void)test021_ReadMultipleAttributesIncludeUnsupportedAttribute XCTAssertNil(error); XCTAssertEqual([MTRErrorTestUtils errorToZCLErrorCode:error], 0); - { - XCTAssertTrue([values isKindOfClass:[NSArray class]]); - NSArray * resultArray = values; - for (NSDictionary * result in resultArray) { - MTRAttributePath * path = result[@"attributePath"]; - XCTAssertEqual([path.cluster unsignedIntegerValue], 40); - if (path.attribute.unsignedIntegerValue != failAttributeID.unsignedIntegerValue) { - XCTAssertNotNil(result[@"data"]); - XCTAssertNil(result[@"error"]); - XCTAssertTrue([result[@"data"] isKindOfClass:[NSDictionary class]]); - } else { - XCTAssertNil(result[@"data"]); - XCTAssertNotNil(result[@"error"]); - } + XCTAssertTrue([values isKindOfClass:[NSArray class]]); + NSArray * resultArray = values; + XCTAssertEqual(resultArray.count, attributePaths.count); + + for (NSDictionary * result in resultArray) { + MTRAttributePath * path = result[@"attributePath"]; + XCTAssertEqualObjects(path.endpoint, @0); + if ([path.attribute unsignedIntegerValue] < 4 || [path.attribute isEqualToNumber:failAttributeID]) { + XCTAssertEqualObjects(path.cluster, @29); + } else { + XCTAssertEqualObjects(path.cluster, @40); + } + + if ([path.attribute isEqualToNumber:failAttributeID]) { + XCTAssertNil(result[@"data"]); + XCTAssertNotNil(result[@"error"]); + XCTAssertEqual([MTRErrorTestUtils errorToZCLErrorCode:result[@"error"]], + MTRInteractionErrorCodeUnsupportedAttribute); + } else { + XCTAssertNotNil(result[@"data"]); + XCTAssertNil(result[@"error"]); + XCTAssertTrue([result[@"data"] isKindOfClass:[NSDictionary class]]); } - XCTAssertTrue([resultArray count] > 0); } [expectation fulfill]; @@ -1739,7 +1831,7 @@ - (void)test021_ReadMultipleAttributesIncludeUnsupportedAttribute [self waitForExpectationsWithTimeout:kTimeoutInSeconds handler:nil]; } -- (void)test022_SubscribeMultipleAttributes +- (void)test023_SubscribeMultipleAttributes { MTRBaseDevice * device = GetConnectedDevice(); dispatch_queue_t queue = dispatch_get_main_queue(); From e2341d8c82578fc6649ba380399ece85848fc2bc Mon Sep 17 00:00:00 2001 From: Andrii Bilynskyi Date: Thu, 20 Apr 2023 03:11:26 +0300 Subject: [PATCH 02/54] [Telink] Fix crash during boot (#26163) --- src/platform/telink/BLEManagerImpl.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/src/platform/telink/BLEManagerImpl.cpp b/src/platform/telink/BLEManagerImpl.cpp index d072b38b1a063b..91711842726acf 100644 --- a/src/platform/telink/BLEManagerImpl.cpp +++ b/src/platform/telink/BLEManagerImpl.cpp @@ -273,17 +273,6 @@ inline CHIP_ERROR BLEManagerImpl::PrepareAdvertisingRequest(void) mAdvertisingRequest.advertisingData = Span(advertisingData); mAdvertisingRequest.scanResponseData = nameSize ? Span(scanResponseData) : Span{}; - mAdvertisingRequest.onStarted = [](int rc) { - if (rc == 0) - { - ChipLogProgress(DeviceLayer, "CHIPoBLE advertising started"); - } - else - { - ChipLogError(DeviceLayer, "Failed to start CHIPoBLE advertising: %d", rc); - } - }; - return CHIP_NO_ERROR; } @@ -339,7 +328,13 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) #endif // Request advertising - ReturnErrorOnFailure(BLEAdvertisingArbiter::InsertRequest(mAdvertisingRequest)); + ReturnErrorOnFailure(System::MapErrorZephyr(bt_le_adv_stop())); + const bt_le_adv_param params = BT_LE_ADV_PARAM_INIT(mAdvertisingRequest.options, mAdvertisingRequest.minInterval, + mAdvertisingRequest.maxInterval, nullptr); + ReturnErrorOnFailure(System::MapErrorZephyr( + bt_le_adv_start(¶ms, mAdvertisingRequest.advertisingData.data(), mAdvertisingRequest.advertisingData.size(), + mAdvertisingRequest.scanResponseData.data(), mAdvertisingRequest.scanResponseData.size()))); + ChipLogProgress(DeviceLayer, "CHIPoBLE advertising started"); // Transition to the Advertising state... if (!mFlags.Has(Flags::kAdvertising)) @@ -375,7 +370,7 @@ CHIP_ERROR BLEManagerImpl::StopAdvertising(void) return CHIP_ERROR_INCORRECT_STATE; } - BLEAdvertisingArbiter::CancelRequest(mAdvertisingRequest); + ReturnErrorOnFailure(System::MapErrorZephyr(bt_le_adv_stop())); // Transition to the not Advertising state... if (mFlags.Has(Flags::kAdvertising)) From b187c3e61d4e76ca016b760c50695177dfa832a6 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 20 Apr 2023 03:55:20 -0400 Subject: [PATCH 03/54] Fix handling of path-specific errors in MTRBaseDevice subscribe code. (#26168) * Fix handling of path-specific errors in MTRBaseDevice subscribe code. 1) Improve documentation for subcribeTo* functions on MTRBaseDevice. 2) Fix the implementation to not call the subscriptionEstablished handler when the subscription actually errors out before the subscribe is complete. 3) Fix the error handling in the implementation to report path-specific errors using the same mechanism as MTRDevice. Fixes https://github.com/project-chip/connectedhomeip/issues/26076 * Address review comment. --- src/darwin/Framework/CHIP/MTRBaseDevice.h | 35 +++- src/darwin/Framework/CHIP/MTRBaseDevice.mm | 53 +++--- .../Framework/CHIPTests/MTRDeviceTests.m | 162 ++++++++++++++---- .../CHIPTests/MTRXPCListenerSampleTests.m | 6 +- 4 files changed, 192 insertions(+), 64 deletions(-) diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice.h b/src/darwin/Framework/CHIP/MTRBaseDevice.h index fecf8757befdc3..65050131d2fa12 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice.h +++ b/src/darwin/Framework/CHIP/MTRBaseDevice.h @@ -200,7 +200,7 @@ MTR_NEWLY_AVAILABLE * eventReportHandler will be called any time an event is reported (with a * non-nil "value") * - * The array passed to eventReportHandler will contain CHIPEventReport + * The array passed to eventReportHandler will contain MTREventReport * instances. Errors for specific paths, not the whole subscription, will be * reported via those objects. * @@ -347,6 +347,17 @@ MTR_NEWLY_AVAILABLE * * A non-nil attributeID along with a nil clusterID will only succeed if the * attribute ID is for a global attribute that applies to all clusters. + * + * The reportHandler will be called with an error if the subscription fails + * entirely. + * + * The reportHandler will be called with arrays of response-value dictionaries + * (which may be data or errors) as path-specific data is received. + * + * subscriptionEstablished will be called when the subscription is first + * successfully established (after the initial set of data reports has been + * delivered to reportHandler). If params allow automatic resubscription, it + * will be called any time resubscription succeeds. */ - (void)subscribeToAttributesWithEndpointID:(NSNumber * _Nullable)endpointID clusterID:(NSNumber * _Nullable)clusterID @@ -367,6 +378,17 @@ MTR_NEWLY_AVAILABLE * The reportHandler will be called with an error if the inputs are invalid (e.g., both attributePaths and eventPaths are * empty), or if the subscription fails entirely. * + * The reportHandler will be called with arrays of response-value dictionaries + * (which may be data or errors) as path-specific data is received. + * + * subscriptionEstablished will be called when the subscription is first + * successfully established (after the initial set of data reports has been + * delivered to reportHandler). If params allow automatic resubscription, it + * will be called any time resubscription succeeds. + * + * resubscriptionScheduled will be called if subscription drop is detected and + * params allow automatic resubscription. + * * If the sum of the lengths of attributePaths and eventPaths exceeds 3, the subscribe may fail due to the device not supporting * that many paths for a subscription. */ @@ -465,6 +487,17 @@ MTR_NEWLY_AVAILABLE * * If all of endpointID, clusterID, eventID are nil, all events on the * device will be subscribed to. + * + * The reportHandler will be called with an error if the subscription fails + * entirely. + * + * The reportHandler will be called with arrays of response-value dictionaries + * (which may be data or errors) as path-specific data is received. + * + * subscriptionEstablished will be called when the subscription is first + * successfully established (after the initial set of data reports has been + * delivered to reportHandler). If params allow automatic resubscription, it + * will be called any time resubscription succeeds. */ - (void)subscribeToEventsWithEndpointID:(NSNumber * _Nullable)endpointID clusterID:(NSNumber * _Nullable)clusterID diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice.mm b/src/darwin/Framework/CHIP/MTRBaseDevice.mm index a8e585d6bf33a9..a966a34dde8cf1 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice.mm +++ b/src/darwin/Framework/CHIP/MTRBaseDevice.mm @@ -1324,11 +1324,9 @@ - (void)subscribeToAttributePaths:(NSArray * _Nullabl completion:^(ExchangeManager * _Nullable exchangeManager, const Optional & session, NSError * _Nullable error) { if (error != nil) { - if (reportHandler) { - dispatch_async(queue, ^{ - reportHandler(nil, error); - }); - } + dispatch_async(queue, ^{ + reportHandler(nil, error); + }); return; } @@ -1356,29 +1354,34 @@ - (void)subscribeToAttributePaths:(NSArray * _Nullabl }); }; - auto establishedOrFailed = chip::Platform::MakeShared(NO); - auto onFailureCb = [establishedOrFailed, queue, subscriptionEstablished, reportHandler]( - const app::ConcreteAttributePath * attributePath, + auto onFailureCb = [queue, reportHandler](const app::ConcreteAttributePath * attributePath, const app::ConcreteEventPath * eventPath, CHIP_ERROR error) { - // TODO, Requires additional logic if attributePath or eventPath is not null - if (!(*establishedOrFailed)) { - *establishedOrFailed = YES; - if (subscriptionEstablished) { - dispatch_async(queue, subscriptionEstablished); - } - } - if (reportHandler) { + if (attributePath != nullptr) { + ConcreteAttributePath pathCopy(*attributePath); + dispatch_async(queue, ^{ + reportHandler(@[ @ { + MTRAttributePathKey : [[MTRAttributePath alloc] initWithPath:pathCopy], + MTRErrorKey : [MTRError errorForCHIPErrorCode:error] + } ], + nil); + }); + } else if (eventPath != nullptr) { + ConcreteEventPath pathCopy(*eventPath); + dispatch_async(queue, ^{ + reportHandler(@[ @ { + MTRAttributePathKey : [[MTREventPath alloc] initWithPath:pathCopy], + MTRErrorKey : [MTRError errorForCHIPErrorCode:error] + } ], + nil); + }); + } else { dispatch_async(queue, ^{ reportHandler(nil, [MTRError errorForCHIPErrorCode:error]); }); } }; - auto onEstablishedCb = [establishedOrFailed, queue, subscriptionEstablished]() { - if (*establishedOrFailed) { - return; - } - *establishedOrFailed = YES; + auto onEstablishedCb = [queue, subscriptionEstablished]() { if (subscriptionEstablished) { dispatch_async(queue, subscriptionEstablished); } @@ -1456,11 +1459,9 @@ - (void)subscribeToAttributePaths:(NSArray * _Nullabl } if (err != CHIP_NO_ERROR) { - if (reportHandler) { - dispatch_async(queue, ^{ - reportHandler(nil, [MTRError errorForCHIPErrorCode:err]); - }); - } + dispatch_async(queue, ^{ + reportHandler(nil, [MTRError errorForCHIPErrorCode:err]); + }); Platform::Delete(readClient); if (container.pathParams != nullptr) { Platform::MemoryFree(container.pathParams); diff --git a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m index cf2757097c1ca4..a71f3878d7515a 100644 --- a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m +++ b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m @@ -672,7 +672,6 @@ - (void)test008_InvokeCommandFailure - (void)test009_SubscribeFailure { - XCTestExpectation * expectation = [self expectationWithDescription:@"subscribe OnOff attribute"]; __block void (^reportHandler)(id _Nullable values, NSError * _Nullable error) = nil; // Set up expectation for report @@ -715,11 +714,11 @@ - (void)test009_SubscribeFailure } subscriptionEstablished:^{ NSLog(@"subscribe attribute: OnOff established"); - [expectation fulfill]; + XCTFail("Should not get subscriptionEstablished in the error case"); }]; // Wait till establishment and error report - [self waitForExpectations:[NSArray arrayWithObjects:expectation, errorReportExpectation, nil] timeout:kTimeoutInSeconds]; + [self waitForExpectations:@[ errorReportExpectation ] timeout:kTimeoutInSeconds]; } - (void)test010_ReadAllAttribute @@ -1840,12 +1839,72 @@ - (void)test023_SubscribeMultipleAttributes XCTestExpectation * expectation = [self expectationWithDescription:@"subscribe OnOff attribute"]; __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(1) maxInterval:@(10)]; - NSArray * attributePaths = - [NSArray arrayWithObjects:[MTRAttributeRequestPath requestPathWithEndpointID:@1 clusterID:@6 attributeID:@0], - [MTRAttributeRequestPath requestPathWithEndpointID:@0 clusterID:@40 attributeID:@5], nil]; + NSNumber * failClusterId = @5678; + NSNumber * failEndpointId = @1000; + + NSArray * attributePaths = @[ + [MTRAttributeRequestPath requestPathWithEndpointID:@1 clusterID:@6 attributeID:@0], + [MTRAttributeRequestPath requestPathWithEndpointID:@1 clusterID:failClusterId attributeID:@1], + ]; + + NSArray * eventPaths = @[ [MTREventRequestPath requestPathWithEndpointID:failEndpointId + clusterID:@40 + eventID:@0] ]; + + XCTestExpectation * onOffReportExpectation = [self expectationWithDescription:@"report OnOff attribute"]; + XCTestExpectation * attributeErrorReportExpectation = [self expectationWithDescription:@"report nonexistent attribute"]; + // TODO: Right now the server does not seem to actually produce an error + // when trying to subscribe to events on a non-existent endpoint. + // XCTestExpectation * eventErrorReportExpectation = [self expectationWithDescription:@"report nonexistent event"]; + globalReportHandler = ^(id _Nullable values, NSError * _Nullable error) { + XCTAssertNil(error); + XCTAssertEqual([MTRErrorTestUtils errorToZCLErrorCode:error], 0); + XCTAssertTrue([values isKindOfClass:[NSArray class]]); + + for (NSDictionary * result in values) { + if (result[@"attributePath"] != nil) { + MTRAttributePath * path = result[@"attributePath"]; + + if ([path.attribute isEqualToNumber:@0]) { + XCTAssertEqualObjects(path.endpoint, @1); + XCTAssertEqualObjects(path.cluster, @6); + XCTAssertTrue([result[@"data"] isKindOfClass:[NSDictionary class]]); + XCTAssertTrue([result[@"data"][@"type"] isEqualToString:@"Boolean"]); + XCTAssertEqualObjects(result[@"data"][@"value"], @NO); + [onOffReportExpectation fulfill]; + } else if ([path.attribute isEqualToNumber:@1]) { + XCTAssertEqualObjects(path.endpoint, @1); + XCTAssertEqualObjects(path.cluster, failClusterId); + XCTAssertNil(result[@"data"]); + XCTAssertNotNil(result[@"error"]); + XCTAssertEqual( + [MTRErrorTestUtils errorToZCLErrorCode:result[@"error"]], MTRInteractionErrorCodeUnsupportedCluster); + [attributeErrorReportExpectation fulfill]; + } else { + XCTFail("Unexpected attribute value"); + } + } else if (result[@"eventPath"] != nil) { + MTREventPath * path = result[@"eventPath"]; + XCTAssertEqualObjects(path.endpoint, @1); + XCTAssertEqualObjects(path.cluster, failClusterId); + XCTAssertEqualObjects(path.event, @0); + XCTAssertNil(result[@"data"]); + XCTAssertNotNil(result[@"error"]); + XCTAssertEqual( + [MTRErrorTestUtils errorToZCLErrorCode:result[@"error"]], MTRInteractionErrorCodeUnsupportedEndpoint); + // TODO: Right now the server does not seem to actually produce an error + // when trying to subscribe to events on a non-existent + // endpoint. Catch it if it starts doing that. + XCTFail("Need to re-enable the eventErrorReportExpectation bits"); + // [eventErrorReportExpectation fulfill]; + } else { + XCTFail("Unexpected result dictionary"); + } + } + }; [device subscribeToAttributePaths:attributePaths - eventPaths:nil + eventPaths:eventPaths params:params queue:queue reportHandler:^(id _Nullable values, NSError * _Nullable error) { @@ -1863,31 +1922,30 @@ - (void)test023_SubscribeMultipleAttributes resubscriptionScheduled:nil]; // Wait till establishment - [self waitForExpectations:[NSArray arrayWithObject:expectation] timeout:kTimeoutInSeconds]; + [self waitForExpectations:@[ + onOffReportExpectation, attributeErrorReportExpectation, /* eventErrorReportExpectation, */ expectation + ] + timeout:kTimeoutInSeconds]; // Set up expectation for report XCTestExpectation * reportExpectation = [self expectationWithDescription:@"report received"]; globalReportHandler = ^(id _Nullable values, NSError * _Nullable error) { + XCTAssertNil(error); XCTAssertEqual([MTRErrorTestUtils errorToZCLErrorCode:error], 0); XCTAssertTrue([values isKindOfClass:[NSArray class]]); NSDictionary * result = values[0]; MTRAttributePath * path = result[@"attributePath"]; - if (path.endpoint.unsignedShortValue == 1) { - XCTAssertEqual([path.cluster unsignedIntegerValue], 6); - XCTAssertEqual([path.attribute unsignedIntegerValue], 0); - XCTAssertTrue([result[@"data"] isKindOfClass:[NSDictionary class]]); - XCTAssertTrue([result[@"data"][@"type"] isEqualToString:@"Boolean"]); - if ([result[@"data"][@"value"] boolValue] == YES) { - [reportExpectation fulfill]; - globalReportHandler = nil; - } - } else if (path.endpoint.unsignedShortValue == 0) { - XCTAssertEqual([path.cluster unsignedIntegerValue], 40); - XCTAssertEqual([path.attribute unsignedIntegerValue], 5); - XCTAssertTrue([result[@"data"] isKindOfClass:[NSDictionary class]]); - XCTAssertTrue([result[@"data"][@"type"] isEqualToString:@"UTF8String"]); - } else { - XCTAssertTrue(NO); + + // We will only be getting incremental reports for the OnOff attribute. + XCTAssertEqualObjects(path.endpoint, @1); + XCTAssertEqualObjects(path.cluster, @6); + XCTAssertEqualObjects(path.attribute, @0); + + XCTAssertTrue([result[@"data"] isKindOfClass:[NSDictionary class]]); + XCTAssertTrue([result[@"data"][@"type"] isEqualToString:@"Boolean"]); + if ([result[@"data"][@"value"] boolValue] == YES) { + [reportExpectation fulfill]; + globalReportHandler = nil; } }; @@ -1911,9 +1969,9 @@ - (void)test023_SubscribeMultipleAttributes NSArray * resultArray = values; for (NSDictionary * result in resultArray) { MTRCommandPath * path = result[@"commandPath"]; - XCTAssertEqual([path.endpoint unsignedIntegerValue], 1); - XCTAssertEqual([path.cluster unsignedIntegerValue], 6); - XCTAssertEqual([path.command unsignedIntegerValue], 1); + XCTAssertEqualObjects(path.endpoint, @1); + XCTAssertEqualObjects(path.cluster, @6); + XCTAssertEqualObjects(path.command, @1); XCTAssertNil(result[@"error"]); } XCTAssertEqual([resultArray count], 1); @@ -1929,13 +1987,14 @@ - (void)test023_SubscribeMultipleAttributes // Set up expectation for 2nd report reportExpectation = [self expectationWithDescription:@"receive OnOff attribute report"]; globalReportHandler = ^(id _Nullable values, NSError * _Nullable error) { + XCTAssertNil(error); XCTAssertEqual([MTRErrorTestUtils errorToZCLErrorCode:error], 0); XCTAssertTrue([values isKindOfClass:[NSArray class]]); NSDictionary * result = values[0]; MTRAttributePath * path = result[@"attributePath"]; - XCTAssertEqual([path.endpoint unsignedIntegerValue], 1); - XCTAssertEqual([path.cluster unsignedIntegerValue], 6); - XCTAssertEqual([path.attribute unsignedIntegerValue], 0); + XCTAssertEqualObjects(path.endpoint, @1); + XCTAssertEqualObjects(path.cluster, @6); + XCTAssertEqualObjects(path.attribute, @0); XCTAssertTrue([result[@"data"] isKindOfClass:[NSDictionary class]]); XCTAssertTrue([result[@"data"][@"type"] isEqualToString:@"Boolean"]); if ([result[@"data"][@"value"] boolValue] == NO) { @@ -1963,9 +2022,9 @@ - (void)test023_SubscribeMultipleAttributes NSArray * resultArray = values; for (NSDictionary * result in resultArray) { MTRCommandPath * path = result[@"commandPath"]; - XCTAssertEqual([path.endpoint unsignedIntegerValue], 1); - XCTAssertEqual([path.cluster unsignedIntegerValue], 6); - XCTAssertEqual([path.command unsignedIntegerValue], 0); + XCTAssertEqualObjects(path.endpoint, @1); + XCTAssertEqualObjects(path.cluster, @6); + XCTAssertEqualObjects(path.command, @0); XCTAssertNil(result[@"error"]); } XCTAssertEqual([resultArray count], 1); @@ -1983,6 +2042,43 @@ - (void)test023_SubscribeMultipleAttributes [self waitForExpectations:@[ expectation ] timeout:kTimeoutInSeconds]; } +- (void)test024_SubscribeMultipleAttributesAllErrors +{ + MTRBaseDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + + // Subscribe + XCTestExpectation * errorExpectation = [self expectationWithDescription:@"subscribe failure"]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(1) maxInterval:@(10)]; + params.resubscribeAutomatically = NO; + + NSNumber * failClusterId = @5678; + NSNumber * failEndpointId = @1000; + + // All the paths are invalid, so we will just get an INVALID_ACTION error. + NSArray * attributePaths = @[ + [MTRAttributeRequestPath requestPathWithEndpointID:failEndpointId clusterID:@6 attributeID:@0], + [MTRAttributeRequestPath requestPathWithEndpointID:@1 clusterID:failClusterId attributeID:@1], + ]; + + [device subscribeToAttributePaths:attributePaths + eventPaths:nil + params:params + queue:queue + reportHandler:^(id _Nullable values, NSError * _Nullable error) { + XCTAssertNotNil(error); + XCTAssertEqual([MTRErrorTestUtils errorToZCLErrorCode:error], MTRInteractionErrorCodeInvalidAction); + XCTAssertNil(values); + [errorExpectation fulfill]; + } + subscriptionEstablished:^{ + XCTFail("This subscription should never be established"); + } + resubscriptionScheduled:nil]; + + [self waitForExpectations:@[ errorExpectation ] timeout:kTimeoutInSeconds]; +} + - (void)test900_SubscribeAllAttributes { MTRBaseDevice * device = GetConnectedDevice(); diff --git a/src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m b/src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m index c44b6baf0f32e4..c22bc7a72125ea 100644 --- a/src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m +++ b/src/darwin/Framework/CHIPTests/MTRXPCListenerSampleTests.m @@ -883,8 +883,6 @@ - (void)test007_InvokeCommandFailure - (void)test008_SubscribeFailure { - XCTestExpectation * expectation = [self expectationWithDescription:@"subscribe OnOff attribute"]; - // Set up expectation for report XCTestExpectation * errorReportExpectation = [self expectationWithDescription:@"receive OnOff attribute report"]; globalReportHandler = ^(id _Nullable values, NSError * _Nullable error) { @@ -916,11 +914,11 @@ - (void)test008_SubscribeFailure } subscriptionEstablished:^{ NSLog(@"subscribe attribute: OnOff established"); - [expectation fulfill]; + XCTFail("Should not have a subscriptionEstablished for an error case"); }]; // Wait till establishment and error report - [self waitForExpectations:[NSArray arrayWithObjects:expectation, errorReportExpectation, nil] timeout:kTimeoutInSeconds]; + [self waitForExpectations:@[ errorReportExpectation ] timeout:kTimeoutInSeconds]; } - (void)test009_ReadAttributeWithParams From 33636942a610caf58126aad1dde4174876382c7b Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 20 Apr 2023 08:40:08 -0400 Subject: [PATCH 04/54] Fix confusing error message. (#26157) We were logging a message about "stop pairing" when the real error was that we could not get the device being commissioned. --- src/darwin/Framework/CHIP/MTRDeviceController.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.mm b/src/darwin/Framework/CHIP/MTRDeviceController.mm index 9026251bae5fd3..f0ecc5441bddca 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController.mm @@ -548,7 +548,7 @@ - (MTRBaseDevice *)deviceBeingCommissionedWithNodeID:(NSNumber *)nodeID error:(N chip::CommissioneeDeviceProxy * deviceProxy; auto errorCode = self->_cppCommissioner->GetDeviceBeingCommissioned(nodeID.unsignedLongLongValue, &deviceProxy); - VerifyOrReturnValue(![MTRDeviceController checkForError:errorCode logMsg:kErrorStopPairing error:error], nil); + VerifyOrReturnValue(![MTRDeviceController checkForError:errorCode logMsg:kErrorGetCommissionee error:error], nil); return [[MTRBaseDevice alloc] initWithPASEDevice:deviceProxy controller:self]; }; From 11525a2c87f73f6d72acc40f155ccdf252991a50 Mon Sep 17 00:00:00 2001 From: Vincent Coubard Date: Thu, 20 Apr 2023 13:40:42 +0100 Subject: [PATCH 05/54] openiotsdk: Enable build with GCC 12 (#26162) TF-M fails to link with GCC 11.3 and onward as new warning are raised at link time and the linking step disallow warning. To workaround the issue we disable link warnings for TF-M by patching it. Signed-off-by: Vincent Coubard --- config/openiotsdk/cmake/sdk.cmake | 16 ++++++++++++++++ config/openiotsdk/cmake/tf-m.patch | 12 ++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 config/openiotsdk/cmake/tf-m.patch diff --git a/config/openiotsdk/cmake/sdk.cmake b/config/openiotsdk/cmake/sdk.cmake index 25851c2d7ded2f..dbe54d4d122c37 100644 --- a/config/openiotsdk/cmake/sdk.cmake +++ b/config/openiotsdk/cmake/sdk.cmake @@ -42,6 +42,22 @@ FetchContent_Declare( GIT_PROGRESS ON ) +# Apply a patch to TF-M to support GCC 12 +FetchContent_Declare( + trusted-firmware-m + GIT_REPOSITORY https://git.trustedfirmware.org/TF-M/trusted-firmware-m.git + GIT_TAG d0c0a67f1b412e89d09b0987091c12998c4e4660 + GIT_SHALLOW OFF + GIT_PROGRESS ON + # Note: This prevents FetchContent_MakeAvailable() from calling + # add_subdirectory() on the fetched repository. TF-M needs a + # standalone build because it relies on functions defined in its + # own toolchain files and contains paths that reference the + # top-level project instead of its own project. + SOURCE_SUBDIR NONE + PATCH_COMMAND git reset --hard --quiet && git clean --force -dx --quiet && git apply ${CMAKE_CURRENT_LIST_DIR}/tf-m.patch +) + # Open IoT SDK configuration set(IOTSDK_FETCH_LIST mcu-driver-reference-platforms-for-arm diff --git a/config/openiotsdk/cmake/tf-m.patch b/config/openiotsdk/cmake/tf-m.patch new file mode 100644 index 00000000000000..975696d5e63752 --- /dev/null +++ b/config/openiotsdk/cmake/tf-m.patch @@ -0,0 +1,12 @@ +diff --git a/toolchain_GNUARM.cmake b/toolchain_GNUARM.cmake +index d044ed4a5..3d8f64d17 100644 +--- a/toolchain_GNUARM.cmake ++++ b/toolchain_GNUARM.cmake +@@ -71,7 +71,6 @@ macro(tfm_toolchain_reset_linker_flags) + --entry=Reset_Handler + --specs=nano.specs + LINKER:-check-sections +- LINKER:-fatal-warnings + LINKER:--gc-sections + LINKER:--no-wchar-size-warning + ${MEMORY_USAGE_FLAG} From 28a95d24bb49a720563977de2984f71d5ba3d0fd Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 20 Apr 2023 08:40:57 -0400 Subject: [PATCH 06/54] Log the onboarding codes in the esp32 bridge-app example. (#26156) Fixes https://github.com/project-chip/connectedhomeip/issues/26152 --- examples/bridge-app/esp32/main/main.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/bridge-app/esp32/main/main.cpp b/examples/bridge-app/esp32/main/main.cpp index f0762ef631749b..4f92a657949466 100644 --- a/examples/bridge-app/esp32/main/main.cpp +++ b/examples/bridge-app/esp32/main/main.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -361,6 +362,8 @@ const EmberAfDeviceType gBridgedOnOffDeviceTypes[] = { { DEVICE_TYPE_LO_ON_OFF_L static void InitServer(intptr_t context) { + PrintOnboardingCodes(chip::RendezvousInformationFlags(CONFIG_RENDEZVOUS_MODE)); + Esp32AppServer::Init(); // Init ZCL Data Model and CHIP App Server AND Initialize device attestation config // Set starting endpoint id where dynamic endpoints will be assigned, which From 7b8b8d8d92865be829411b2426f96ca68fe5f7e2 Mon Sep 17 00:00:00 2001 From: Andrei Litvin Date: Thu, 20 Apr 2023 08:41:40 -0400 Subject: [PATCH 07/54] Fix template argument naming for value assign (#26144) * Fix typo in template argument order * Fix order of args * Apply the change for real * Fix typo --------- Co-authored-by: Andrei Litvin --- src/lib/assign/ValueAssign.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/assign/ValueAssign.h b/src/lib/assign/ValueAssign.h index 945777e4291548..c188c152866aef 100644 --- a/src/lib/assign/ValueAssign.h +++ b/src/lib/assign/ValueAssign.h @@ -21,8 +21,8 @@ namespace chip { namespace Value { -template -SRC & Assign(SRC & dest, const DEST & src) +template +DEST & Assign(DEST & dest, const SRC & src) { return dest = src; } From a14e6fb08ec040bd43290346dda7722a5e08a55b Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 20 Apr 2023 10:31:10 -0400 Subject: [PATCH 08/54] Switch from wasRemoved to isSupported for Darwin codegen. (#26146) * Update ZAP to v2023.04.18-nightly to pick up isSupported. * Switch from wasRemoved to isSupported for Darwin codegen. isSupported allows things to be marked as "provisional", which unlike "removed" can be overridden by a later "introduced" annotation. * Stop depending on controller-clusters.zap state entirely, now that we can. --- .../templates/commands.zapt | 48 ++++++------- .../docker/images/chip-cert-bins/Dockerfile | 2 +- scripts/setup/zap.json | 2 +- scripts/tools/zap/zap_execution.py | 2 +- .../MTRAttributeTLVValueDecoder-src.zapt | 12 ++-- .../CHIP/templates/MTRBaseClusters-src.zapt | 38 +++++------ .../CHIP/templates/MTRBaseClusters.zapt | 68 +++++++++---------- .../templates/MTRBaseClusters_Internal.zapt | 8 +-- .../CHIP/templates/MTRCallbackBridge-src.zapt | 20 +++--- .../CHIP/templates/MTRCallbackBridge.zapt | 40 +++++------ .../CHIP/templates/MTRClusterConstants.zapt | 54 +++++++-------- .../CHIP/templates/MTRClusters-src.zapt | 50 +++++++------- .../Framework/CHIP/templates/MTRClusters.zapt | 32 ++++----- .../CHIP/templates/MTRClusters_Internal.zapt | 8 +-- .../templates/MTRCommandPayloadsObjc-src.zapt | 6 +- .../templates/MTRCommandPayloadsObjc.zapt | 6 +- .../MTREventTLVValueDecoder-src.zapt | 16 ++--- .../CHIP/templates/MTRStructsObjc-src.zapt | 52 +++++++------- .../CHIP/templates/MTRStructsObjc.zapt | 32 ++++----- .../CHIP/templates/availability.yaml | 38 ++++++++--- 20 files changed, 277 insertions(+), 257 deletions(-) diff --git a/examples/darwin-framework-tool/templates/commands.zapt b/examples/darwin-framework-tool/templates/commands.zapt index 26a1457f8848cf..ae0c239dbf9e57 100644 --- a/examples/darwin-framework-tool/templates/commands.zapt +++ b/examples/darwin-framework-tool/templates/commands.zapt @@ -17,13 +17,13 @@ {{> clusters_header}} -{{#all_user_clusters side='client'}} -{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}} +{{#zcl_clusters}} +{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}} {{> cluster_header}} {{#zcl_commands}} {{#if (is_str_equal source 'client')}} -{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}} /* * Command {{asUpperCamelCase name}} */ @@ -90,12 +90,12 @@ private: {{/zcl_command_arguments}} }; -{{/unless}} +{{/if}} {{/if}} {{/zcl_commands}} {{#zcl_attributes_server removeKeys='isOptional'}} -{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} {{#*inline "cluster"}}Cluster{{asUpperCamelCase parent.name preserveAcronyms=true}}{{/inline}} {{#*inline "attribute"}}Attribute{{asUpperCamelCase name preserveAcronyms=true}}{{/inline}} @@ -247,16 +247,16 @@ public: }; {{/if}} -{{/unless}} +{{/if}} {{/zcl_attributes_server}} -{{/unless}} -{{/all_user_clusters}} +{{/if}} +{{/zcl_clusters}} /*----------------------------------------------------------------------------*\ | Register all Clusters commands | \*----------------------------------------------------------------------------*/ -{{#all_user_clusters side='client'}} -{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}} +{{#zcl_clusters}} +{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}} void registerCluster{{asUpperCamelCase name}}(Commands & commands) { using namespace chip::app::Clusters::{{asUpperCamelCase name}}; @@ -267,34 +267,34 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands) make_unique(Id), // {{#zcl_commands}} {{#if (is_str_equal source 'client')}} - {{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}} + {{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}} make_unique<{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}>(), // - {{/unless}} + {{/if}} {{/if}} {{/zcl_commands}} {{#zcl_attributes_server removeKeys='isOptional'}} {{#first}} make_unique(Id), // {{/first}} - {{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} + {{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} make_unique(), // - {{/unless}} + {{/if}} {{#first}} make_unique(Id), // {{/first}} - {{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} + {{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} {{#if isWritableAttribute}} make_unique(), // {{/if}} - {{/unless}} + {{/if}} {{#first}} make_unique(Id), // {{/first}} - {{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} + {{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} {{#if isReportableAttribute}} make_unique(), // {{/if}} - {{/unless}} + {{/if}} {{/zcl_attributes_server}} {{#zcl_events}} {{#first}} @@ -306,8 +306,8 @@ void registerCluster{{asUpperCamelCase name}}(Commands & commands) commands.Register(clusterName, clusterCommands); } -{{/unless}} -{{/all_user_clusters}} +{{/if}} +{{/zcl_clusters}} void registerClusterAny(Commands & commands) { @@ -329,9 +329,9 @@ void registerClusterAny(Commands & commands) void registerClusters(Commands & commands) { registerClusterAny(commands); -{{#all_user_clusters side='client'}} - {{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}} +{{#zcl_clusters}} + {{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}} registerCluster{{asUpperCamelCase name}}(commands); - {{/unless}} -{{/all_user_clusters}} + {{/if}} +{{/zcl_clusters}} } diff --git a/integrations/docker/images/chip-cert-bins/Dockerfile b/integrations/docker/images/chip-cert-bins/Dockerfile index d1d9c5d081f829..8e9db74f22455a 100644 --- a/integrations/docker/images/chip-cert-bins/Dockerfile +++ b/integrations/docker/images/chip-cert-bins/Dockerfile @@ -7,7 +7,7 @@ ARG COMMITHASH=7b99e6399c6069037c613782d78132c69b9dcabb # ZAP Development install, so that it runs on both x64 and arm64 # Generally this should match with the ZAP version that is used for codegen within the # specified SHA -ARG ZAP_VERSION=v2023.04.05-nightly +ARG ZAP_VERSION=v2023.04.18-nightly # Ensure TARGETPLATFORM is set RUN case ${TARGETPLATFORM} in \ diff --git a/scripts/setup/zap.json b/scripts/setup/zap.json index 88209409ae83d1..4ed3e0d4ab1ce2 100644 --- a/scripts/setup/zap.json +++ b/scripts/setup/zap.json @@ -8,7 +8,7 @@ "mac-arm64", "windows-amd64" ], - "tags": ["version:2@v2023.04.05-nightly.1"] + "tags": ["version:2@v2023.04.18-nightly.1"] } ] } diff --git a/scripts/tools/zap/zap_execution.py b/scripts/tools/zap/zap_execution.py index cfc4fcfc588281..29d8e83c957d37 100644 --- a/scripts/tools/zap/zap_execution.py +++ b/scripts/tools/zap/zap_execution.py @@ -23,7 +23,7 @@ # Use scripts/tools/zap/version_update.py to manage ZAP versioning as many # files may need updating for versions # -MIN_ZAP_VERSION = '2023.4.5' +MIN_ZAP_VERSION = '2023.4.18' class ZapTool: diff --git a/src/darwin/Framework/CHIP/templates/MTRAttributeTLVValueDecoder-src.zapt b/src/darwin/Framework/CHIP/templates/MTRAttributeTLVValueDecoder-src.zapt index b92d687ded3c11..8fd58f7cad306e 100644 --- a/src/darwin/Framework/CHIP/templates/MTRAttributeTLVValueDecoder-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRAttributeTLVValueDecoder-src.zapt @@ -18,14 +18,14 @@ id MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader & { switch (aPath.mClusterId) { - {{#all_user_clusters side='client'}} - {{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}} + {{#zcl_clusters}} + {{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}} case Clusters::{{asUpperCamelCase name}}::Id: { using namespace Clusters::{{asUpperCamelCase name}}; switch (aPath.mAttributeId) { {{#zcl_attributes_server removeKeys='isOptional'}} - {{#unless (wasRemoved (asUpperCamelCase ../name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} + {{#if (isSupported (asUpperCamelCase ../name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} case Attributes::{{asUpperCamelCase name}}::Id: { using TypeInfo = Attributes::{{asUpperCamelCase name}}::TypeInfo; TypeInfo::DecodableType cppValue; @@ -38,7 +38,7 @@ id MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader & {{>decode_value target="value" source="cppValue" cluster=parent.name errorCode="*aError = err; return nil;" depth=0}} return value; } - {{/unless}} + {{/if}} {{/zcl_attributes_server}} default: *aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB; @@ -46,8 +46,8 @@ id MTRDecodeAttributeValue(const ConcreteAttributePath & aPath, TLV::TLVReader & } break; } - {{/unless}} - {{/all_user_clusters}} + {{/if}} + {{/zcl_clusters}} default: { *aError = CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB; break; diff --git a/src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt b/src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt index 39ad0f4a67d429..db2bc872960c86 100644 --- a/src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRBaseClusters-src.zapt @@ -26,8 +26,8 @@ using chip::System::Clock::Timeout; using chip::System::Clock::Seconds16; // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks): Linter is unable to locate the delete on these objects. -{{#all_user_clusters side='client'}} -{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}} +{{#zcl_clusters}} +{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}} @implementation MTRBaseCluster{{asUpperCamelCase name preserveAcronyms=true}} - (instancetype)initWithDevice:(MTRBaseDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue @@ -50,15 +50,15 @@ using chip::System::Clock::Seconds16; {{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} {{#*inline "commandImpl"}} {{! This is used as the implementation for both the new-name and old-name bits, so check for both here. }} -{{#unless (and (wasRemoved cluster command=command) - (wasRemoved (compatClusterNameRemapping parent.name) command=(compatCommandNameRemapping parent.name name)))}} +{{#if (or (isSupported cluster command=command) + (isSupported (compatClusterNameRemapping parent.name) command=(compatCommandNameRemapping parent.name name)))}} {{#*inline "callbackName"}}{{#if hasSpecificResponse}}{{cluster}}Cluster{{asUpperCamelCase responseName preserveAcronyms=true}}{{else}}CommandSuccess{{/if}}{{/inline}} {{#*inline "paramsType"}} -{{#if (wasRemoved cluster command=command)}} +{{#unless (isSupported cluster command=command)}} MTR{{compatClusterNameRemapping parent.name}}Cluster{{compatCommandNameRemapping parent.name name}}Params {{else}} MTR{{cluster}}Cluster{{command}}Params -{{/if}} +{{/unless}} {{/inline}} {{#unless hasArguments}} - (void){{asLowerCamelCase name}}WithCompletion:({{>command_completion_type command=.}})completion @@ -124,7 +124,7 @@ MTR{{cluster}}Cluster{{command}}Params }); std::move(*bridge).DispatchAction(self.device); } -{{/unless}} +{{/if}} {{/inline}} {{> commandImpl cluster=(asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true)}} @@ -133,9 +133,9 @@ MTR{{cluster}}Cluster{{command}}Params {{#zcl_attributes_server removeKeys='isOptional'}} {{! This is used as the implementation for both the new-name and old-name bits, so check for both here. }} -{{#unless (and (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true)) - (or (wasRemoved (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name)) - (not wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))))}} +{{#if (or (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true)) + (and (isSupported (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name)) + (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))))}} {{#*inline "attribute"}}Attribute{{asUpperCamelCase name preserveAcronyms=true}}{{/inline}} - (void)read{{>attribute}}With {{~#if_is_fabric_scoped_struct type~}} @@ -233,28 +233,28 @@ reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value } {{/if}} -{{/unless}} +{{/if}} {{/zcl_attributes_server}} @end -{{/unless}} +{{/if}} {{#unless (isStrEqual (asUpperCamelCase name preserveAcronyms=true) (compatClusterNameRemapping name))}} -{{#unless (wasRemoved (compatClusterNameRemapping name))}} +{{#if (isSupported (compatClusterNameRemapping name))}} @implementation MTRBaseCluster{{compatClusterNameRemapping name}} @end -{{/unless}} +{{/if}} {{/unless}} {{#if (and (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping name)) - (not (wasRemoved (compatClusterNameRemapping name))))}} + (isSupported (compatClusterNameRemapping name)))}} @implementation MTRBaseCluster{{compatClusterNameRemapping name}} (Deprecated) {{#zcl_commands}} {{#if (is_str_equal source 'client')}} {{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} {{#*inline "commandImpl"}} -{{#unless (wasRemoved cluster command=command)}} +{{#if (isSupported cluster command=command)}} - (void){{asLowerCamelCase command}}WithParams:(MTR{{cluster}}Cluster{{command}}Params * {{#unless commandHasRequiredField}}_Nullable{{/unless}})params completionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler { [self {{asLowerCamelCase name}}WithParams:params completion: @@ -274,7 +274,7 @@ reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value [self {{asLowerCamelCase command}}WithParams:nil completionHandler:completionHandler]; } {{/unless}} -{{/unless}} +{{/if}} {{/inline}} {{> commandImpl cluster=(compatClusterNameRemapping parent.name) command=(compatCommandNameRemapping parent.name name)}} @@ -283,7 +283,7 @@ reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value {{#zcl_attributes_server removeKeys='isOptional'}} {{#if (and (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name)) - (not (wasRemoved (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))))}} + (isSupported (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name)))}} {{#*inline "attribute"}}Attribute{{compatAttributeNameRemapping parent.name name}}{{/inline}} - (void)read{{>attribute}}With {{~#if_is_fabric_scoped_struct type~}} @@ -349,6 +349,6 @@ subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptio @end {{/if}} -{{/all_user_clusters}} +{{/zcl_clusters}} // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks) diff --git a/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt b/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt index ace70655f1aeb0..576f811105c94f 100644 --- a/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRBaseClusters.zapt @@ -7,10 +7,10 @@ NS_ASSUME_NONNULL_BEGIN -{{#all_user_clusters side='client'}} +{{#zcl_clusters}} -{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}} /** * Cluster {{name}} * @@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN {{#if (is_str_equal source 'client')}} {{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} {{#*inline "commandDecl"}} -{{#unless (wasRemoved cluster command=command)}} +{{#if (isSupported cluster command=command)}} /** * Command {{name}} * @@ -37,7 +37,7 @@ NS_ASSUME_NONNULL_BEGIN {{#unless hasArguments}} - (void){{asLowerCamelCase name}}WithCompletion:({{>command_completion_type command=.}})completion {{availability cluster command=command minimalRelease="First major API revamp"}}; {{/unless}} -{{/unless}} +{{/if}} {{/inline}} {{> commandDecl cluster=(asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true)}} @@ -45,7 +45,7 @@ NS_ASSUME_NONNULL_BEGIN {{/zcl_commands}} {{#zcl_attributes_server removeKeys='isOptional'}} -{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} {{#*inline "attribute"}}Attribute{{asUpperCamelCase name preserveAcronyms=true}}{{/inline}} - (void)read{{>attribute}}With {{~#if_is_fabric_scoped_struct type~}} @@ -63,41 +63,41 @@ NS_ASSUME_NONNULL_BEGIN subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptionEstablished reportHandler:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value, NSError * _Nullable error))reportHandler {{availability (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true) minimalRelease="First major API revamp"}}; + (void) read{{>attribute}}WithClusterStateCache:(MTRClusterStateCacheContainer *)clusterStateCacheContainer endpoint:(NSNumber *)endpoint queue:(dispatch_queue_t)queue completion:(void (^)({{asObjectiveCClass type parent.name}} * _Nullable value, NSError * _Nullable error))completion {{availability (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true) minimalRelease="First major API revamp"}}; {{/if}} -{{/unless}} +{{/if}} {{/zcl_attributes_server}} - (instancetype)init NS_UNAVAILABLE; + (instancetype)new NS_UNAVAILABLE; @end -{{/unless}} +{{/if}} -{{/all_user_clusters}} +{{/zcl_clusters}} -{{#all_user_clusters side='client'}} +{{#zcl_clusters}} {{#unless (isStrEqual (asUpperCamelCase name preserveAcronyms=true) (compatClusterNameRemapping name))}} -{{#unless (wasRemoved (compatClusterNameRemapping name))}} +{{#if (isSupported (compatClusterNameRemapping name))}} {{availability (compatClusterNameRemapping name) deprecationMessage=(concat "Please use MTRBaseCluster" (asUpperCamelCase name preserveAcronyms=true))}} @interface MTRBaseCluster{{compatClusterNameRemapping name}} : MTRBaseCluster{{asUpperCamelCase name preserveAcronyms=true}} @end +{{/if}} {{/unless}} -{{/unless}} -{{/all_user_clusters}} +{{/zcl_clusters}} {{#zcl_clusters}} {{#zcl_enums}} {{#*inline "enumDef"}} typedef NS_ENUM({{asUnderlyingZclType name}}, {{objCEnumName clusterName enumName}}) { {{#zcl_enum_items}} - {{#unless (wasRemoved ../clusterName enum=../enumName enumValue=(asUpperCamelCase label preserveAcronyms=true))}} + {{#if (isSupported ../clusterName enum=../enumName enumValue=(asUpperCamelCase label preserveAcronyms=true))}} {{objCEnumName ../clusterName ../enumName}}{{asUpperCamelCase label preserveAcronyms=true}} {{availability ../clusterName enum=../enumName enumValue=(asUpperCamelCase label preserveAcronyms=true) deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (asUpperCamelCase label preserveAcronyms=true))}} = {{asHex value 2}}, - {{/unless}} + {{/if}} {{#*inline "oldNameItemDecl"}} {{#if oldItemName}} - {{#unless (wasRemoved ../clusterName enum=../enumName enumValue=oldItemName)}} + {{#if (isSupported ../clusterName enum=../enumName enumValue=oldItemName)}} {{objCEnumName ../clusterName ../enumName}}{{objCEnumItemLabel oldItemName}} {{availability ../clusterName enum=../enumName enumValue=oldItemName deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (asUpperCamelCase label preserveAcronyms=true))}} = {{asHex value 2}}, - {{/unless}} + {{/if}} {{/if}} {{/inline}} {{> oldNameItemDecl oldItemName=(oldName ../clusterName enum=../enumName enumValue=(asUpperCamelCase label preserveAcronyms=true))}} @@ -105,20 +105,20 @@ typedef NS_ENUM({{asUnderlyingZclType name}}, {{objCEnumName clusterName enumNam {{!We had extra "Not Supported" values for DoorLockUserStatus/DoorLockUserType that we have to wedge in here manually for now.}} {{#if (and (isStrEqual clusterName "DoorLock") (or (isStrEqual enumName "UserTypeEnum") (isStrEqual enumName "UserStatusEnum")) - (not (wasRemoved clusterName enum=enumName enumValue="NotSupported")))}} + (isSupported clusterName enum=enumName enumValue="NotSupported"))}} {{objCEnumName clusterName enumName}}{{objCEnumItemLabel "NotSupported"}} {{availability clusterName enum=enumName enumValue="NotSupported" deprecationMessage="This value is not part of the specification and will be removed"}} = 0xFF, {{/if}} } {{/inline}} -{{#unless (wasRemoved (asUpperCamelCase ../name preserveAcronyms=true) enum=(asUpperCamelCase label preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase ../name preserveAcronyms=true) enum=(asUpperCamelCase label preserveAcronyms=true))}} {{> enumDef name=name clusterName=(asUpperCamelCase ../name preserveAcronyms=true) enumName=(asUpperCamelCase label preserveAcronyms=true)}} {{availability (asUpperCamelCase ../name preserveAcronyms=true) enum=(asUpperCamelCase label preserveAcronyms=true) deprecationMessage="This enum is unused and will be removed"}}; -{{/unless}} +{{/if}} {{! Takes the name of the enum to use as enumName. }} {{#*inline "oldNameDecl"}} -{{#unless (wasRemoved (compatClusterNameRemapping ../name) enum=enumName)}} +{{#if (isSupported (compatClusterNameRemapping ../name) enum=enumName)}} {{> enumDef name=name clusterName=(compatClusterNameRemapping ../name) enumName=enumName}} {{availability (compatClusterNameRemapping ../name) enum=enumName deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../name preserveAcronyms=true) label))}}; -{{/unless}} +{{/if}} {{/inline}} {{! Takes the old name of the enum, if any, as oldEnumName. }} {{#*inline "oldNameCheck"}} @@ -138,29 +138,29 @@ typedef NS_ENUM({{asUnderlyingZclType name}}, {{objCEnumName clusterName enumNam {{#*inline "bitmapDef"}} typedef NS_OPTIONS({{asUnderlyingZclType name}}, {{objCEnumName clusterName bitmapName}}) { {{#zcl_bitmap_items}} - {{#unless (wasRemoved ../clusterName bitmap=../bitmapName bitmapValue=(asUpperCamelCase label preserveAcronyms=true))}} + {{#if (isSupported ../clusterName bitmap=../bitmapName bitmapValue=(asUpperCamelCase label preserveAcronyms=true))}} {{objCEnumName ../clusterName ../bitmapName}}{{asUpperCamelCase label preserveAcronyms=true}} {{availability ../clusterName bitmap=../bitmapName bitmapValue=(asUpperCamelCase label preserveAcronyms=true) deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (asUpperCamelCase label preserveAcronyms=true))}} = {{asHex mask}}, - {{/unless}} + {{/if}} {{#*inline "oldNameItemDecl"}} {{#if oldItemName}} - {{#unless (wasRemoved ../clusterName bitmap=../bitmapName bitmapValue=oldItemName)}} + {{#if (isSupported ../clusterName bitmap=../bitmapName bitmapValue=oldItemName)}} {{objCEnumName ../clusterName ../bitmapName}}{{objCEnumItemLabel oldItemName}} {{availability ../clusterName bitmap=../bitmapName bitmapValue=oldItemName deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../../name preserveAcronyms=true) ../label) (asUpperCamelCase label preserveAcronyms=true))}} = {{asHex mask}}, - {{/unless}} + {{/if}} {{/if}} {{/inline}} {{> oldNameItemDecl oldItemName=(oldName ../clusterName bitmap=../bitmapName bitmapValue=(asUpperCamelCase label preserveAcronyms=true))}} {{/zcl_bitmap_items}} } {{/inline}} -{{#unless (wasRemoved (asUpperCamelCase ../name preserveAcronyms=true) bitmap=(asUpperCamelCase label preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase ../name preserveAcronyms=true) bitmap=(asUpperCamelCase label preserveAcronyms=true))}} {{> bitmapDef name=name clusterName=(asUpperCamelCase ../name preserveAcronyms=true) bitmapName=(asUpperCamelCase label preserveAcronyms=true)}} {{availability (asUpperCamelCase ../name preserveAcronyms=true) bitmap=(asUpperCamelCase label preserveAcronyms=true)}}; -{{/unless}} +{{/if}} {{! Takes the name of the bitmap to use as bitmapName. }} {{#*inline "oldNameDecl"}} -{{#unless (wasRemoved (compatClusterNameRemapping ../name) bitmap=bitmapName)}} +{{#if (isSupported (compatClusterNameRemapping ../name) bitmap=bitmapName)}} {{> bitmapDef name=name clusterName=(compatClusterNameRemapping ../name) bitmapName=bitmapName}} {{availability (compatClusterNameRemapping ../name) bitmap=bitmapName deprecationMessage=(concat "Please use " (objCEnumName (asUpperCamelCase ../name preserveAcronyms=true) label))}}; -{{/unless}} +{{/if}} {{/inline}} {{! Takes the old name of the bitmap, if any, as oldBitmapName. }} {{#*inline "oldNameCheck"}} @@ -179,9 +179,9 @@ typedef NS_OPTIONS({{asUnderlyingZclType name}}, {{objCEnumName clusterName bitm {{/zcl_bitmaps}} {{/zcl_clusters}} -{{#all_user_clusters side='client'}} +{{#zcl_clusters}} {{#if (and (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping name)) - (not (wasRemoved (compatClusterNameRemapping name))))}} + (isSupported (compatClusterNameRemapping name)))}} @interface MTRBaseCluster{{compatClusterNameRemapping name}} (Deprecated) - (nullable instancetype)initWithDevice:(MTRBaseDevice *)device @@ -193,7 +193,7 @@ typedef NS_OPTIONS({{asUnderlyingZclType name}}, {{objCEnumName clusterName bitm {{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} {{#*inline "commandDecl"}} {{#if (and (wasIntroducedBeforeRelease "First major API revamp" cluster command=command) - (not (wasRemoved cluster command=command)))}} + (isSupported cluster command=command))}} - (void){{asLowerCamelCase command}}WithParams:(MTR{{cluster}}Cluster{{command}}Params * {{#unless commandHasRequiredField }}_Nullable{{/unless}})params completionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler {{availability cluster command=command deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use " (asLowerCamelCase name) "WithParams:completion:")}}; {{#unless hasArguments}} @@ -209,7 +209,7 @@ typedef NS_OPTIONS({{asUnderlyingZclType name}}, {{objCEnumName clusterName bitm {{#zcl_attributes_server removeKeys='isOptional'}} {{#if (and (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name)) - (not (wasRemoved (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))))}} + (isSupported (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name)))}} {{#*inline "attribute"}}Attribute{{compatAttributeNameRemapping parent.name name}}{{/inline}} - (void)read{{>attribute}}With {{~#if_is_fabric_scoped_struct type~}} @@ -234,6 +234,6 @@ subscriptionEstablished:(MTRSubscriptionEstablishedHandler _Nullable)subscriptio @end {{/if}} -{{/all_user_clusters}} +{{/zcl_clusters}} NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/templates/MTRBaseClusters_Internal.zapt b/src/darwin/Framework/CHIP/templates/MTRBaseClusters_Internal.zapt index 080441e292456b..0a8c82459ec042 100644 --- a/src/darwin/Framework/CHIP/templates/MTRBaseClusters_Internal.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRBaseClusters_Internal.zapt @@ -7,13 +7,13 @@ #include -{{#all_user_clusters side='client'}} +{{#zcl_clusters}} -{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}} @interface MTRBaseCluster{{asUpperCamelCase name preserveAcronyms=true}} () @property (nonatomic, strong, readonly) MTRBaseDevice * device; @property (nonatomic, assign, readonly) chip::EndpointId endpoint; @end -{{/unless}} +{{/if}} -{{/all_user_clusters}} +{{/zcl_clusters}} diff --git a/src/darwin/Framework/CHIP/templates/MTRCallbackBridge-src.zapt b/src/darwin/Framework/CHIP/templates/MTRCallbackBridge-src.zapt index b11da5a4c2d127..ec16a56876b224 100644 --- a/src/darwin/Framework/CHIP/templates/MTRCallbackBridge-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRCallbackBridge-src.zapt @@ -37,9 +37,9 @@ {{#>MTRCallbackBridge type="vendor_id" isNullable=false ns="chip"}}VendorIdAttributeCallback{{/MTRCallbackBridge}} {{#>MTRCallbackBridge type="vendor_id" isNullable=true ns="chip"}}NullableVendorIdAttributeCallback{{/MTRCallbackBridge}} -{{#all_user_clusters side='client'}} +{{#zcl_clusters}} {{#zcl_attributes_server removeKeys='isOptional'}} -{{#unless (wasRemoved (asUpperCamelCase ../name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase ../name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} {{#if isArray}} {{#>MTRCallbackBridge ns=parent.name }}{{asUpperCamelCase ../../name preserveAcronyms=true}}{{asUpperCamelCase ../name preserveAcronyms=true}}ListAttributeCallback{{/MTRCallbackBridge}} {{else}} @@ -50,23 +50,23 @@ {{#>MTRCallbackBridge ns=parent.name }}{{asUpperCamelCase ../../name preserveAcronyms=true}}{{asUpperCamelCase ../name preserveAcronyms=true}}AttributeCallback{{/MTRCallbackBridge}} {{/if_is_strongly_typed_bitmap}} {{/if}} -{{/unless}} +{{/if}} {{/zcl_attributes_server}} -{{/all_user_clusters}} +{{/zcl_clusters}} -{{#all_user_clusters side='client'}} +{{#zcl_clusters}} {{#zcl_command_responses}} -{{#unless (wasRemoved (asUpperCamelCase ../name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase ../name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}} {{#>MTRCallbackBridge partial-type="Command" }}{{asUpperCamelCase ../../name preserveAcronyms=true}}Cluster{{asUpperCamelCase ../name preserveAcronyms=true}}Callback{{/MTRCallbackBridge}} -{{/unless}} +{{/if}} {{/zcl_command_responses}} -{{/all_user_clusters}} +{{/zcl_clusters}} {{#zcl_clusters}} {{#zcl_enums}} -{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) enum=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) enum=(asUpperCamelCase name preserveAcronyms=true))}} {{#>MTRCallbackBridge type=(asType label) isNullable=false ns=parent.name}}{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}AttributeCallback{{/MTRCallbackBridge}} {{#>MTRCallbackBridge type=(asType label) isNullable=true ns=parent.name}}Nullable{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}AttributeCallback{{/MTRCallbackBridge}} -{{/unless}} +{{/if}} {{/zcl_enums}} {{/zcl_clusters}} diff --git a/src/darwin/Framework/CHIP/templates/MTRCallbackBridge.zapt b/src/darwin/Framework/CHIP/templates/MTRCallbackBridge.zapt index bc26085a07836b..84d60ddd4d1ab3 100644 --- a/src/darwin/Framework/CHIP/templates/MTRCallbackBridge.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRCallbackBridge.zapt @@ -14,26 +14,26 @@ typedef void (*DefaultSuccessCallbackType)(void *); typedef void (*VendorIdAttributeCallback)(void *, chip::VendorId); typedef void (*NullableVendorIdAttributeCallback)(void *, const chip::app::DataModel::Nullable &); -{{#all_user_clusters side='client'}} +{{#zcl_clusters}} {{#zcl_command_responses}} -{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}} typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}CallbackType)(void *, const chip::app::Clusters::{{asUpperCamelCase parent.name}}::Commands::{{asUpperCamelCase name}}::DecodableType &); -{{/unless}} +{{/if}} {{/zcl_command_responses}} -{{/all_user_clusters}} +{{/zcl_clusters}} {{#zcl_clusters}} {{#zcl_enums}} -{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) enum=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) enum=(asUpperCamelCase name preserveAcronyms=true))}} typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}AttributeCallback)(void *, chip::app::Clusters::{{asUpperCamelCase parent.name}}::{{asType label}}); typedef void (*Nullable{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}AttributeCallback)(void *, const chip::app::DataModel::Nullable &); -{{/unless}} +{{/if}} {{/zcl_enums}} {{/zcl_clusters}} -{{#all_user_clusters side='client'}} +{{#zcl_clusters}} {{#zcl_attributes_server removeKeys='isOptional'}} -{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} {{#if isArray}} typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}{{asUpperCamelCase name preserveAcronyms=true}}ListAttributeCallback)(void * context, {{zapTypeToDecodableClusterObjectType type ns=parent.name isArgument=true}} data); {{else}} @@ -44,9 +44,9 @@ typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}{{asUpperCa typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}{{asUpperCamelCase name preserveAcronyms=true}}AttributeCallback)(void *, {{zapTypeToDecodableClusterObjectType type ns=parent.name isArgument=true forceNotOptional=true}}); {{/if_is_strongly_typed_bitmap}} {{/if}} -{{/unless}} +{{/if}} {{/zcl_attributes_server}} -{{/all_user_clusters}} +{{/zcl_clusters}} {{#>MTRCallbackBridge header="1" partial-type="Status" }}DefaultSuccessCallback{{/MTRCallbackBridge}} {{#>MTRCallbackBridge header="1" partial-type="CommandStatus" }}CommandSuccessCallback{{/MTRCallbackBridge}} @@ -79,9 +79,9 @@ typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}{{asUpperCa {{#>MTRCallbackBridge header="1" type="vendor_id" isNullable=false ns="chip"}}VendorIdAttributeCallback{{/MTRCallbackBridge}} {{#>MTRCallbackBridge header="1" type="vendor_id" isNullable=true ns="chip"}}NullableVendorIdAttributeCallback{{/MTRCallbackBridge}} -{{#all_user_clusters side='client'}} +{{#zcl_clusters}} {{#zcl_attributes_server removeKeys='isOptional'}} -{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} {{#if isArray}} {{#>MTRCallbackBridge header="1" ns=parent.name }}{{asUpperCamelCase ../../name preserveAcronyms=true}}{{asUpperCamelCase ../name preserveAcronyms=true}}ListAttributeCallback{{/MTRCallbackBridge}} {{else}} @@ -92,23 +92,23 @@ typedef void (*{{asUpperCamelCase parent.name preserveAcronyms=true}}{{asUpperCa {{#>MTRCallbackBridge header="1" ns=parent.name }}{{asUpperCamelCase ../../name preserveAcronyms=true}}{{asUpperCamelCase ../name preserveAcronyms=true}}AttributeCallback{{/MTRCallbackBridge}} {{/if_is_strongly_typed_bitmap}} {{/if}} -{{/unless}} +{{/if}} {{/zcl_attributes_server}} -{{/all_user_clusters}} +{{/zcl_clusters}} -{{#all_user_clusters side='client'}} +{{#zcl_clusters}} {{#zcl_command_responses}} -{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}} {{#>MTRCallbackBridge header="1" partial-type="Command" }}{{asUpperCamelCase ../../name preserveAcronyms=true}}Cluster{{asUpperCamelCase ../name preserveAcronyms=true}}Callback{{/MTRCallbackBridge}} -{{/unless}} +{{/if}} {{/zcl_command_responses}} -{{/all_user_clusters}} +{{/zcl_clusters}} {{#zcl_clusters}} {{#zcl_enums}} -{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) enum=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) enum=(asUpperCamelCase name preserveAcronyms=true))}} {{#>MTRCallbackBridge header="1" type=(asType label) isNullable=false ns=parent.name}}{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}AttributeCallback{{/MTRCallbackBridge}} {{#>MTRCallbackBridge header="1" type=(asType label) isNullable=true ns=parent.name}}Nullable{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}AttributeCallback{{/MTRCallbackBridge}} -{{/unless}} +{{/if}} {{/zcl_enums}} {{/zcl_clusters}} diff --git a/src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt b/src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt index d363058c2ff8ff..bece573dd988e0 100644 --- a/src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRClusterConstants.zapt @@ -8,15 +8,15 @@ typedef NS_ENUM(uint32_t, MTRClusterIDType) { {{#zcl_clusters}} {{#if (and (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping name) isForIds=true) - (not (wasRemoved (compatClusterNameRemapping name) isForIds=true)))}} + (isSupported (compatClusterNameRemapping name) isForIds=true))}} MTRCluster{{compatClusterNameRemapping label}}ID {{availability (compatClusterNameRemapping name) deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use MTRClusterIDType" (asUpperCamelCase label preserveAcronyms=true) "ID") isForIds=true}} = {{asMEI manufacturerCode code}}, {{/if}} {{/zcl_clusters}} {{#zcl_clusters}} -{{#unless (wasRemoved (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}} +{{#if (isSupported (asUpperCamelCase label preserveAcronyms=true) isForIds=true)}} {{~#*inline "cluster"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}} MTRClusterIDType{{>cluster}}ID {{availability (asUpperCamelCase label preserveAcronyms=true) minimalRelease="First major API revamp" isForIds=true}} = {{asMEI manufacturerCode code}}, -{{/unless}} +{{/if}} {{/zcl_clusters}} }; @@ -38,9 +38,9 @@ MTRClusterGlobalAttribute{{asUpperCamelCase label}}ID {{#zcl_attributes_server}} {{~#*inline "attribute"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}} {{#unless clusterRef}} -{{#unless (wasRemoved "" globalAttribute=(asUpperCamelCase label) isForIds=true)}} +{{#if (isSupported "" globalAttribute=(asUpperCamelCase label) isForIds=true)}} MTRAttributeIDTypeGlobalAttribute{{>attribute}}ID {{availability "" globalAttribute=(asUpperCamelCase label) minimalRelease="First major API revamp" isForIds=true}} = {{asMEI manufacturerCode code}}, -{{/unless}} +{{/if}} {{/unless}} {{/zcl_attributes_server}} @@ -49,9 +49,9 @@ MTRAttributeIDTypeGlobalAttribute{{>attribute}}ID {{availability "" globalAttrib {{#zcl_attributes_server}} {{#first}} {{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping ../clusterName) isForIds=true)}} -{{#unless (wasRemoved (compatClusterNameRemapping ../clusterName))}} +{{#if (isSupported (compatClusterNameRemapping ../clusterName) isForIds=true)}} // Cluster {{compatClusterNameRemapping ../clusterName}} deprecated attribute names -{{/unless}} +{{/if}} {{/if}} {{/first}} {{! DeviceTypeList is special: we did not call it by that name @@ -65,7 +65,7 @@ MTRClusterDescriptorAttributeDeviceTypeListID {{/if}} {{/if}} {{#if (and (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping ../clusterName) attribute=(compatAttributeNameRemapping ../clusterName label) isForIds=true) - (not (wasRemoved (compatClusterNameRemapping ../clusterName) attribute=(compatAttributeNameRemapping ../clusterName label) isForIds=true)))}} + (isSupported (compatClusterNameRemapping ../clusterName) attribute=(compatAttributeNameRemapping ../clusterName label) isForIds=true))}} MTRCluster{{compatClusterNameRemapping ../clusterName}}Attribute{{compatAttributeNameRemapping ../clusterName label}}ID {{availability (compatClusterNameRemapping ../clusterName) attribute=(compatAttributeNameRemapping ../clusterName label) deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use MTRAttributeIDTypeCluster" (asUpperCamelCase ../clusterName preserveAcronyms=true) "Attribute" (asUpperCamelCase label preserveAcronyms=true) "ID") isForIds=true}} = {{#if clusterRef}} @@ -82,24 +82,24 @@ MTRClusterGlobalAttribute{{asUpperCamelCase label}}ID, {{~#*inline "cluster"}}{{asUpperCamelCase ../clusterName preserveAcronyms=true}}{{/inline~}} {{~#*inline "attribute"}}{{asUpperCamelCase label preserveAcronyms=true}}{{/inline~}} {{#first}} -{{#unless (wasRemoved (asUpperCamelCase ../clusterName preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) isForIds=true)}} // Cluster {{> cluster}} attributes -{{/unless}} +{{/if}} {{/first}} -{{#unless (wasRemoved (asUpperCamelCase ../clusterName preserveAcronyms=true) attribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true)}} +{{#if (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) attribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true)}} MTRAttributeIDTypeCluster{{>cluster}}Attribute{{>attribute}}ID {{availability (asUpperCamelCase ../clusterName preserveAcronyms=true) attribute=(asUpperCamelCase label preserveAcronyms=true) minimalRelease="First major API revamp" isForIds=true}} = {{#if clusterRef}} {{asMEI manufacturerCode code}}, {{else}} MTRAttributeIDTypeGlobalAttribute{{asUpperCamelCase label}}ID, {{/if}} -{{/unless}} +{{/if}} {{! Anything which has an old name, and the new name was introduced in the "First after major API revamp" release or later (or just after the "First major API revamp" release, but we don't have a good way to test for that), we need to generate the new-form id for the old name too, as long as it was not removed. }} {{#if (and (hasOldName (asUpperCamelCase ../clusterName preserveAcronyms=true) attribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true) (not (wasIntroducedBeforeRelease "First after major API revamp" (asUpperCamelCase ../clusterName preserveAcronyms=true) attribute=(asUpperCamelCase label preserveAcronyms=true) isForIds=true)) - (not (wasRemoved (compatClusterNameRemapping ../clusterName) attribute=(compatAttributeNameRemapping ../clusterName label) isForIds=true)))}} + (isSupported (compatClusterNameRemapping ../clusterName) attribute=(compatAttributeNameRemapping ../clusterName label) isForIds=true))}} MTRAttributeIDTypeCluster{{compatClusterNameRemapping ../clusterName}}Attribute{{compatAttributeNameRemapping ../clusterName label}}ID {{availability (compatClusterNameRemapping ../clusterName) attribute=(compatAttributeNameRemapping ../clusterName label) isForIds=true minimalRelease="First major API revamp" deprecationMessage=(concat "Please use MTRAttributeIDType" (asUpperCamelCase ../clusterName preserveAcronyms=true) "Attribute" (asUpperCamelCase label preserveAcronyms=true) "ID")}} = MTRAttributeIDTypeCluster{{>cluster}}Attribute{{>attribute}}ID, {{/if}} {{#last}} @@ -120,15 +120,15 @@ typedef NS_ENUM(uint32_t, MTRCommandIDType) { {{#zcl_commands}} {{#first}} {{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping ../clusterName) isForIds=true)}} -{{#unless (wasRemoved (compatClusterNameRemapping ../clusterName))}} +{{#if (isSupported (compatClusterNameRemapping ../clusterName) isForIds=true)}} // Cluster {{compatClusterNameRemapping ../clusterName}} deprecated command id names -{{/unless}} +{{/if}} {{/if}} {{/first}} {{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} {{#*inline "commandIdDecl"}} {{#if (and (wasIntroducedBeforeRelease "First major API revamp" cluster command=command isForIds=true) - (not (wasRemoved cluster command=command isForIds=true)))}} + (isSupported cluster command=command isForIds=true))}} MTRCluster{{cluster}}Command{{command}}ID {{availability cluster command=command deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use MTRCommandIDTypeCluster" (asUpperCamelCase ../clusterName preserveAcronyms=true) "Command" (asUpperCamelCase name preserveAcronyms=true) "ID") isForIds=true}} = {{asMEI manufacturerCode code}}, @@ -143,15 +143,15 @@ MTRCluster{{cluster}}Command{{command}}ID {{#zcl_commands}} {{~#*inline "cluster"}}{{asUpperCamelCase ../clusterName preserveAcronyms=true}}{{/inline~}} {{#first}} -{{#unless (wasRemoved (asUpperCamelCase ../clusterName preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) isForIds=true)}} // Cluster {{>cluster}} commands -{{/unless}} +{{/if}} {{/first}} {{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} {{#*inline "commandIdDecl"}} -{{#unless (wasRemoved cluster command=command isForIds=true)}} +{{#if (isSupported cluster command=command isForIds=true)}} MTRCommandIDTypeCluster{{cluster}}Command{{command}}ID {{availability cluster command=command minimalRelease="First major API revamp" isForIds=true}} = {{asMEI manufacturerCode code}}, -{{/unless}} +{{/if}} {{/inline}} {{> commandIdDecl cluster=(asUpperCamelCase ../clusterName preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true)}} @@ -173,13 +173,13 @@ typedef NS_ENUM(uint32_t, MTREventIDType) { {{#zcl_events}} {{#first}} {{#if (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping ../clusterName) isForIds=true)}} -{{#unless (wasRemoved (compatClusterNameRemapping ../clusterName))}} +{{#if (isSupported (compatClusterNameRemapping ../clusterName))}} // Cluster {{compatClusterNameRemapping ../clusterName}} deprecated event names -{{/unless}} +{{/if}} {{/if}} {{/first}} {{#if (and (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping ../clusterName) event=(asUpperCamelCase name) isForIds=true) - (not (wasRemoved (compatClusterNameRemapping ../clusterName) event=(asUpperCamelCase name) isForIds=true)))}} + (isSupported (compatClusterNameRemapping ../clusterName) event=(asUpperCamelCase name) isForIds=true))}} MTRCluster{{compatClusterNameRemapping ../clusterName}}Event{{asUpperCamelCase name}}ID {{availability (compatClusterNameRemapping ../clusterName) event=(asUpperCamelCase name) deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use MTREventIDTypeCluster" (asUpperCamelCase ../clusterName preserveAcronyms=true) "Event" (asUpperCamelCase name preserveAcronyms=true) "ID") isForIds=true}} = {{asMEI manufacturerCode code}}, @@ -192,13 +192,13 @@ MTRCluster{{compatClusterNameRemapping ../clusterName}}Event{{asUpperCamelCase n {{~#*inline "cluster"}}{{asUpperCamelCase ../clusterName preserveAcronyms=true}}{{/inline~}} {{~#*inline "event"}}{{asUpperCamelCase name preserveAcronyms=true}}{{/inline~}} {{#first}} -{{#unless (wasRemoved (asUpperCamelCase ../clusterName preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true))}} // Cluster {{>cluster}} events -{{/unless}} +{{/if}} {{/first}} -{{#unless (wasRemoved (asUpperCamelCase ../clusterName preserveAcronyms=true) event=(asUpperCamelCase name preserveAcronyms=true) isForIds=true)}} +{{#if (isSupported (asUpperCamelCase ../clusterName preserveAcronyms=true) event=(asUpperCamelCase name preserveAcronyms=true) isForIds=true)}} MTREventIDTypeCluster{{>cluster}}Event{{>event}}ID {{availability (asUpperCamelCase ../clusterName preserveAcronyms=true) event=(asUpperCamelCase name preserveAcronyms=true) minimalRelease="First major API revamp" isForIds=true}} = {{asMEI manufacturerCode code}}, -{{/unless}} +{{/if}} {{#last}} {{/last}} diff --git a/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt b/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt index 84537e0b9ec8e7..2d4f79e355b668 100644 --- a/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt @@ -40,8 +40,8 @@ static void MTRClustersLogCompletion(NSString *logPrefix, id value, NSError *err } // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks): Linter is unable to locate the delete on these objects. -{{#all_user_clusters side='client'}} -{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}} +{{#zcl_clusters}} +{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}} @implementation MTRCluster{{asUpperCamelCase name preserveAcronyms=true}} - (instancetype)initWithDevice:(MTRDevice *)device endpointID:(NSNumber *)endpointID queue:(dispatch_queue_t)queue @@ -63,29 +63,29 @@ static void MTRClustersLogCompletion(NSString *logPrefix, id value, NSError *err {{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} {{#*inline "commandImpl"}} {{! This is used as the implementation for both the new-name and old-name bits, so check for both here. }} -{{#unless (and (wasRemoved cluster command=command) - (wasRemoved (compatClusterNameRemapping parent.name) command=(compatCommandNameRemapping parent.name name)))}} +{{#if (or (isSupported cluster command=command) + (isSupported (compatClusterNameRemapping parent.name) command=(compatCommandNameRemapping parent.name name)))}} {{#*inline "callbackName"}}{{#if hasSpecificResponse}}{{cluster}}Cluster{{asUpperCamelCase responseName preserveAcronyms=true}}{{else}}CommandSuccess{{/if}}{{/inline}} {{#*inline "paramsType"}} -{{#if (wasRemoved cluster command=command)}} +{{#unless (isSupported cluster command=command)}} MTR{{compatClusterNameRemapping parent.name}}Cluster{{compatCommandNameRemapping parent.name name}}Params {{else}} MTR{{cluster}}Cluster{{command}}Params -{{/if}} +{{/unless}} {{/inline}} {{#*inline "clusterId"}} -{{#if (wasRemoved cluster command=command)}} +{{#unless (isSupported cluster command=command)}} {{asMEI ../manufacturerCode ../code}} {{else}} MTRClusterIDType{{cluster}}ID -{{/if}} +{{/unless}} {{/inline}} {{#*inline "commandId"}} -{{#if (wasRemoved cluster command=command)}} +{{#unless (isSupported cluster command=command)}} {{asMEI manufacturerCode code}} {{else}} MTRCommandIDTypeCluster{{cluster}}Command{{command}}ID -{{/if}} +{{/unless}} {{/inline}} {{#unless hasArguments}} - (void){{asLowerCamelCase name}}WithExpectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completion:({{>command_completion_type command=.}})completion @@ -176,7 +176,7 @@ MTRCommandIDTypeCluster{{cluster}}Command{{command}}ID [self.device setExpectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs]; } } -{{/unless}} +{{/if}} {{/inline}} {{#if (is_str_equal source 'client')}} {{> commandImpl cluster=(asUpperCamelCase parent.name preserveAcronyms=true) @@ -186,9 +186,9 @@ MTRCommandIDTypeCluster{{cluster}}Command{{command}}ID {{#zcl_attributes_server}} {{! This is used as the implementation for both the new-name and old-name bits, so check for both here. }} -{{#unless (and (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true)) - (or (wasRemoved (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name)) - (not wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))))}} +{{#if (or (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true)) + (and (isSupported (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name)) + (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping parent.name) attribute=(compatAttributeNameRemapping parent.name name))))}} {{#*inline "cluster"}}{{asUpperCamelCase parent.name preserveAcronyms=true}}{{/inline}} {{#*inline "attribute"}}Attribute{{asUpperCamelCase name preserveAcronyms=true}}{{/inline}} - (NSDictionary *)read{{>attribute}}WithParams:(MTRReadParams * _Nullable)params { @@ -215,20 +215,20 @@ MTRCommandIDTypeCluster{{cluster}}Command{{command}}ID {{/if}} -{{/unless}} +{{/if}} {{/zcl_attributes_server}} @end -{{/unless}} +{{/if}} {{#unless (isStrEqual (asUpperCamelCase name preserveAcronyms=true) (compatClusterNameRemapping name))}} -{{#unless (wasRemoved (compatClusterNameRemapping name))}} +{{#if (isSupported (compatClusterNameRemapping name))}} @implementation MTRCluster{{compatClusterNameRemapping name}} @end -{{/unless}} +{{/if}} {{/unless}} {{#if (and (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping name)) - (not (wasRemoved (compatClusterNameRemapping name))))}} + (isSupported (compatClusterNameRemapping name)))}} @implementation MTRCluster{{compatClusterNameRemapping name}} (Deprecated) - (instancetype)initWithDevice:(MTRDevice *)device endpoint:(uint16_t)endpoint queue:(dispatch_queue_t)queue @@ -240,7 +240,7 @@ MTRCommandIDTypeCluster{{cluster}}Command{{command}}ID {{#if (is_str_equal source 'client')}} {{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} {{#*inline "commandImpl"}} -{{#unless (wasRemoved cluster command=command)}} +{{#if (isSupported cluster command=command)}} - (void){{asLowerCamelCase command}}WithParams:(MTR{{cluster}}Cluster{{command}}Params * {{#unless commandHasRequiredField}}_Nullable{{/unless}})params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler { [self {{asLowerCamelCase name}}WithParams:params expectedValues:expectedDataValueDictionaries expectedValueInterval:expectedValueIntervalMs completion: @@ -260,7 +260,7 @@ MTRCommandIDTypeCluster{{cluster}}Command{{command}}ID [self {{asLowerCamelCase command}}WithParams:nil expectedValues:expectedValues expectedValueInterval:expectedValueIntervalMs completionHandler:completionHandler]; } {{/unless}} -{{/unless}} +{{/if}} {{/inline}} {{> commandImpl cluster=(compatClusterNameRemapping parent.name) command=(compatCommandNameRemapping parent.name name)}} @@ -268,8 +268,8 @@ MTRCommandIDTypeCluster{{cluster}}Command{{command}}ID {{/zcl_commands}} {{~#zcl_attributes_server}} {{~#*inline "attributeImpls"}} -{{#unless (or (isStrEqual attribute (asUpperCamelCase name preserveAcronyms=true)) - (wasRemoved (compatClusterNameRemapping parent.name) attribute=attribute))}} +{{#if (and (not (isStrEqual attribute (asUpperCamelCase name preserveAcronyms=true))) + (isSupported (compatClusterNameRemapping parent.name) attribute=attribute))}} - (NSDictionary *)readAttribute{{attribute}}WithParams:(MTRReadParams * _Nullable)params { return [self readAttribute{{asUpperCamelCase name preserveAcronyms=true}}WithParams:params]; @@ -284,13 +284,13 @@ MTRCommandIDTypeCluster{{cluster}}Command{{command}}ID [self writeAttribute{{asUpperCamelCase name preserveAcronyms=true}}WithValue:dataValueDictionary expectedValueInterval:expectedValueIntervalMs params:params]; } {{/if}} -{{/unless}} +{{/if}} {{/inline~}} {{> attributeImpls attribute=(compatAttributeNameRemapping parent.name name)}} {{/zcl_attributes_server}} @end {{/if}} -{{/all_user_clusters}} +{{/zcl_clusters}} // NOLINTEND(clang-analyzer-cplusplus.NewDeleteLeaks) diff --git a/src/darwin/Framework/CHIP/templates/MTRClusters.zapt b/src/darwin/Framework/CHIP/templates/MTRClusters.zapt index cb18aec5d5278c..d603d791ce190b 100644 --- a/src/darwin/Framework/CHIP/templates/MTRClusters.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRClusters.zapt @@ -8,10 +8,10 @@ NS_ASSUME_NONNULL_BEGIN -{{#all_user_clusters side='client'}} +{{#zcl_clusters}} -{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}} /** * Cluster {{name}} * {{description}} @@ -27,12 +27,12 @@ NS_ASSUME_NONNULL_BEGIN {{#if (is_str_equal source 'client')}} {{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} {{#*inline "commandDecl"}} -{{#unless (wasRemoved cluster command=command)}} +{{#if (isSupported cluster command=command)}} - (void){{asLowerCamelCase name}}WithParams:(MTR{{cluster}}Cluster{{command}}Params * {{#unless commandHasRequiredField}}_Nullable{{/unless}})params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completion:({{>command_completion_type command=.}})completion {{availability cluster command=command minimalRelease="First major API revamp"}}; {{#unless hasArguments}} - (void){{asLowerCamelCase name}}WithExpectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completion:({{>command_completion_type command=.}})completion {{availability cluster command=command minimalRelease="First major API revamp"}}; {{/unless}} -{{/unless}} +{{/if}} {{/inline}} {{> commandDecl cluster=(asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true)}} @@ -40,7 +40,7 @@ NS_ASSUME_NONNULL_BEGIN {{/zcl_commands}} {{#zcl_attributes_server}} -{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true))}} {{#*inline "attribute"}}Attribute{{asUpperCamelCase name preserveAcronyms=true}}{{/inline}} {{#*inline "availability"}} {{availability (asUpperCamelCase parent.name preserveAcronyms=true) attribute=(asUpperCamelCase name preserveAcronyms=true)}} @@ -50,7 +50,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)write{{>attribute}}WithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs {{> availability}}; - (void)write{{>attribute}}WithValue:(NSDictionary *)dataValueDictionary expectedValueInterval:(NSNumber *)expectedValueIntervalMs params:(MTRWriteParams * _Nullable)params {{> availability}}; {{/if}} -{{/unless}} +{{/if}} {{/zcl_attributes_server}} - (instancetype)init NS_UNAVAILABLE; @@ -58,23 +58,23 @@ NS_ASSUME_NONNULL_BEGIN @end -{{/unless}} -{{/all_user_clusters}} +{{/if}} +{{/zcl_clusters}} -{{#all_user_clusters side='client'}} +{{#zcl_clusters}} {{#unless (isStrEqual (asUpperCamelCase name preserveAcronyms=true) (compatClusterNameRemapping name))}} -{{#unless (wasRemoved (compatClusterNameRemapping name))}} +{{#if (isSupported (compatClusterNameRemapping name))}} {{availability (compatClusterNameRemapping name) deprecationMessage=(concat "Please use MTRCluster" (asUpperCamelCase name preserveAcronyms=true))}} @interface MTRCluster{{compatClusterNameRemapping name}} : MTRCluster{{asUpperCamelCase name preserveAcronyms=true}} @end +{{/if}} {{/unless}} -{{/unless}} -{{/all_user_clusters}} +{{/zcl_clusters}} -{{#all_user_clusters side='client'}} +{{#zcl_clusters}} {{#if (and (wasIntroducedBeforeRelease "First major API revamp" (compatClusterNameRemapping name)) - (not (wasRemoved (compatClusterNameRemapping name))))}} + (isSupported (compatClusterNameRemapping name)))}} @interface MTRCluster{{compatClusterNameRemapping name}} (Deprecated) - (nullable instancetype)initWithDevice:(MTRDevice *)device @@ -86,7 +86,7 @@ NS_ASSUME_NONNULL_BEGIN {{! Takes two arguments: cluster name and command name, plus the ambient state where the command is "this" }} {{#*inline "commandDecl"}} {{#if (and (wasIntroducedBeforeRelease "First major API revamp" cluster command=command) - (not (wasRemoved cluster command=command)))}} + (isSupported cluster command=command))}} - (void){{asLowerCamelCase command}}WithParams:(MTR{{cluster}}Cluster{{command}}Params * {{#unless commandHasRequiredField}}_Nullable{{/unless}})params expectedValues:(NSArray *> * _Nullable)expectedDataValueDictionaries expectedValueInterval:(NSNumber * _Nullable)expectedValueIntervalMs completionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler {{availability cluster command=command deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use " (asLowerCamelCase name) "WithParams:expectedValues:expectedValueInterval:completion:")}}; {{#unless hasArguments}} - (void){{asLowerCamelCase command}}WithExpectedValues:(NSArray *> *)expectedValues expectedValueInterval:(NSNumber *)expectedValueIntervalMs completionHandler:({{>command_completion_type command=. compatRemapNames=true}})completionHandler {{availability cluster command=command deprecatedRelease="First major API revamp" deprecationMessage=(concat "Please use " (asLowerCamelCase name) "WithExpectedValues:expectedValueInterval:completion:")}}; @@ -113,6 +113,6 @@ NS_ASSUME_NONNULL_BEGIN @end {{/if}} -{{/all_user_clusters}} +{{/zcl_clusters}} NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIP/templates/MTRClusters_Internal.zapt b/src/darwin/Framework/CHIP/templates/MTRClusters_Internal.zapt index 952911525082a2..12d6882cd182b4 100644 --- a/src/darwin/Framework/CHIP/templates/MTRClusters_Internal.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRClusters_Internal.zapt @@ -8,13 +8,13 @@ #include -{{#all_user_clusters side='client'}} +{{#zcl_clusters}} -{{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}} @interface MTRCluster{{asUpperCamelCase name preserveAcronyms=true}} () @property (nonatomic, readonly) uint16_t endpoint; @property (nonatomic, readonly) MTRDevice *device; @end -{{/unless}} +{{/if}} -{{/all_user_clusters}} +{{/zcl_clusters}} diff --git a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt index 9dfd496b795c7f..4dcdba48065f7c 100644 --- a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc-src.zapt @@ -7,7 +7,7 @@ NS_ASSUME_NONNULL_BEGIN {{#zcl_clusters}} {{#zcl_commands}} {{#*inline "completeImpl"}} -{{#unless (wasRemoved cluster command=command)}} +{{#if (isSupported cluster command=command isForCommandPayload=true)}} @implementation MTR{{cluster}}Cluster{{command}}Params - (instancetype)init { @@ -59,14 +59,14 @@ NS_ASSUME_NONNULL_BEGIN {{/zcl_command_arguments}} @end -{{/unless}} +{{/if}} {{/inline}} {{#*inline "oldNameImpl"}} @implementation MTR{{cluster}}Cluster{{command}}Params @end {{/inline}} -{{#if (not (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true)))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}} {{> completeImpl cluster=(asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true) includeRenamedProperties=false}} diff --git a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc.zapt b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc.zapt index 838795eca03de2..e6778ba0bfb062 100644 --- a/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRCommandPayloadsObjc.zapt @@ -8,7 +8,7 @@ NS_ASSUME_NONNULL_BEGIN {{#zcl_clusters}} {{#zcl_commands}} {{#*inline "completeDecl"}} -{{#unless (wasRemoved cluster command=command)}} +{{#if (isSupported cluster command=command isForCommandPayload=true)}} {{availability cluster command=command isForCommandPayload=true deprecationMessage="This command has been removed"}} @interface MTR{{cluster}}Cluster{{command}}Params : NSObject @@ -69,7 +69,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, copy, nullable) NSNumber * timedInvokeTimeoutMs {{availability "" api="Timed Invoke for server to client commands" deprecationMessage="Timed invoke does not make sense for server to client commands"}}; {{/if}} @end -{{/unless}} +{{/if}} {{/inline}} {{#*inline "oldNameDecl"}} @@ -78,7 +78,7 @@ NS_ASSUME_NONNULL_BEGIN @end {{/inline}} -{{#if (not (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true)))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true))}} {{> completeDecl cluster=(asUpperCamelCase parent.name preserveAcronyms=true) command=(asUpperCamelCase name preserveAcronyms=true) includeRenamedProperties=false}} diff --git a/src/darwin/Framework/CHIP/templates/MTREventTLVValueDecoder-src.zapt b/src/darwin/Framework/CHIP/templates/MTREventTLVValueDecoder-src.zapt index 93d0538c2d2678..7d476f8d5597dd 100644 --- a/src/darwin/Framework/CHIP/templates/MTREventTLVValueDecoder-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTREventTLVValueDecoder-src.zapt @@ -21,14 +21,14 @@ id MTRDecodeEventPayload(const ConcreteEventPath & aPath, TLV::TLVReader & aRead { switch (aPath.mClusterId) { - {{#all_user_clusters side='client'}} - {{#unless (wasRemoved (asUpperCamelCase name preserveAcronyms=true))}} + {{#zcl_clusters}} + {{#if (isSupported (asUpperCamelCase name preserveAcronyms=true))}} case Clusters::{{asUpperCamelCase name}}::Id: { using namespace Clusters::{{asUpperCamelCase name}}; switch (aPath.mEventId) { {{#zcl_events}} - {{#unless (wasRemoved (asUpperCamelCase ../name preserveAcronyms=true) event=(asUpperCamelCase name preserveAcronyms=true))}} + {{#if (isSupported (asUpperCamelCase ../name preserveAcronyms=true) event=(asUpperCamelCase name preserveAcronyms=true))}} case Events::{{asUpperCamelCase name}}::Id: { Events::{{asUpperCamelCase name}}::DecodableType cppValue; @@ -41,19 +41,19 @@ id MTRDecodeEventPayload(const ConcreteEventPath & aPath, TLV::TLVReader & aRead __auto_type *value = [MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}Event new]; {{#zcl_event_fields}} - {{#unless (wasRemoved (asUpperCamelCase ../../name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(asStructPropertyName name))}} + {{#if (isSupported (asUpperCamelCase ../../name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(asStructPropertyName name))}} do { {{asObjectiveCType type parent.parent.name}} memberValue; {{>decode_value target="memberValue" source=(concat "cppValue." (asLowerCamelCase name)) cluster=parent.parent.name errorCode="*aError = err; return nil;" depth=0}} value.{{asStructPropertyName name}} = memberValue; } while(0); - {{/unless}} + {{/if}} {{/zcl_event_fields}} return value; } - {{/unless}} + {{/if}} {{/zcl_events}} default: @@ -62,8 +62,8 @@ id MTRDecodeEventPayload(const ConcreteEventPath & aPath, TLV::TLVReader & aRead } break; } - {{/unless}} - {{/all_user_clusters}} + {{/if}} + {{/zcl_clusters}} default: { *aError = CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB; break; diff --git a/src/darwin/Framework/CHIP/templates/MTRStructsObjc-src.zapt b/src/darwin/Framework/CHIP/templates/MTRStructsObjc-src.zapt index 207d94403ec417..0bd5dad2895bf9 100644 --- a/src/darwin/Framework/CHIP/templates/MTRStructsObjc-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRStructsObjc-src.zapt @@ -12,9 +12,9 @@ NS_ASSUME_NONNULL_BEGIN { if (self = [super init]) { {{#zcl_struct_items}} - {{#unless (wasRemoved (asUpperCamelCase parent.parent.name preserveAcronyms=true) struct=(asUpperCamelCase parent.name preserveAcronyms=true) structField=(asStructPropertyName label))}} + {{#if (isSupported (asUpperCamelCase parent.parent.name preserveAcronyms=true) struct=(asUpperCamelCase parent.name preserveAcronyms=true) structField=(asStructPropertyName label))}} {{>init_struct_member label=label type=type cluster=parent.parent.name}} - {{/unless}} + {{/if}} {{/zcl_struct_items}} } return self; @@ -25,9 +25,9 @@ NS_ASSUME_NONNULL_BEGIN auto other = [[{{interfaceName}} alloc] init]; {{#zcl_struct_items}} - {{#unless (wasRemoved (asUpperCamelCase parent.parent.name preserveAcronyms=true) struct=(asUpperCamelCase parent.name preserveAcronyms=true) structField=(asStructPropertyName label))}} + {{#if (isSupported (asUpperCamelCase parent.parent.name preserveAcronyms=true) struct=(asUpperCamelCase parent.name preserveAcronyms=true) structField=(asStructPropertyName label))}} other.{{asStructPropertyName label}} = self.{{asStructPropertyName label}}; - {{/unless}} + {{/if}} {{/zcl_struct_items}} return other; @@ -36,19 +36,19 @@ NS_ASSUME_NONNULL_BEGIN - (NSString *)description { NSString *descriptionString = [NSString stringWithFormat:@"<%@: {{#zcl_struct_items~}} - {{~#unless (wasRemoved (asUpperCamelCase parent.parent.name preserveAcronyms=true) struct=(asUpperCamelCase parent.name preserveAcronyms=true) structField=(asStructPropertyName label))~}} + {{~#if (isSupported (asUpperCamelCase parent.parent.name preserveAcronyms=true) struct=(asUpperCamelCase parent.name preserveAcronyms=true) structField=(asStructPropertyName label))~}} {{~asStructPropertyName label}}:%@; {{!Just here to keep the preceding space}} - {{~/unless~}} + {{~/if~}} {{~/zcl_struct_items}}>", NSStringFromClass([self class]){{#zcl_struct_items~}} - {{~#unless (wasRemoved (asUpperCamelCase parent.parent.name preserveAcronyms=true) struct=(asUpperCamelCase parent.name preserveAcronyms=true) structField=(asStructPropertyName label))~}} + {{~#if (isSupported (asUpperCamelCase parent.parent.name preserveAcronyms=true) struct=(asUpperCamelCase parent.name preserveAcronyms=true) structField=(asStructPropertyName label))~}} ,{{#if isArray}}_{{asStructPropertyName label}}{{else if (isOctetString type)}}[_{{asStructPropertyName label}} base64EncodedStringWithOptions:0]{{else}}_{{asStructPropertyName label}}{{/if}} - {{~/unless~}} + {{~/if~}} {{~/zcl_struct_items}}]; return descriptionString; } {{#zcl_struct_items}} {{#if (and (hasOldName (asUpperCamelCase ../../name preserveAcronyms=true) struct=(asUpperCamelCase ../name preserveAcronyms=true) structField=(asStructPropertyName label)) - (not (wasRemoved (asUpperCamelCase ../../name preserveAcronyms=true) struct=(asUpperCamelCase ../name preserveAcronyms=true) structField=(oldName (asUpperCamelCase ../../name preserveAcronyms=true) struct=(asUpperCamelCase ../name preserveAcronyms=true) structField=(asStructPropertyName label)))))}} + (isSupported (asUpperCamelCase ../../name preserveAcronyms=true) struct=(asUpperCamelCase ../name preserveAcronyms=true) structField=(oldName (asUpperCamelCase ../../name preserveAcronyms=true) struct=(asUpperCamelCase ../name preserveAcronyms=true) structField=(asStructPropertyName label))))}} {{> renamed_struct_field_impl cluster=../../name type=type newName=label oldName=(oldName (asUpperCamelCase ../../name preserveAcronyms=true) struct=(asUpperCamelCase ../name preserveAcronyms=true) structField=(asStructPropertyName label))}} {{/if}} @@ -57,16 +57,16 @@ NS_ASSUME_NONNULL_BEGIN @end {{/inline}} -{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) struct=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) struct=(asUpperCamelCase name preserveAcronyms=true))}} {{> interfaceImpl interfaceName=(concat "MTR" (asUpperCamelCase parent.name preserveAcronyms=true) "Cluster" (asUpperCamelCase name preserveAcronyms=true))}} -{{/unless}} +{{/if}} {{! Takes the name of the struct to use as structName. }} {{#*inline "oldNameImpl"}} -{{#unless (wasRemoved (compatClusterNameRemapping parent.name) struct=structName)}} +{{#if (isSupported (compatClusterNameRemapping parent.name) struct=structName)}} @implementation MTR{{compatClusterNameRemapping parent.name}}Cluster{{structName}} : MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}} @end -{{/unless}} +{{/if}} {{/inline}} {{! Takes the old name of the struct, if any, as oldStructName. }} {{#*inline "oldNameCheck"}} @@ -84,15 +84,15 @@ NS_ASSUME_NONNULL_BEGIN {{/zcl_structs}} {{#zcl_events}} -{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) event=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) event=(asUpperCamelCase name preserveAcronyms=true))}} @implementation MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}Event - (instancetype)init { if (self = [super init]) { {{#zcl_event_fields}} - {{#unless (wasRemoved (asUpperCamelCase parent.parent.name preserveAcronyms=true) event=(asUpperCamelCase parent.name preserveAcronyms=true) eventField=(asStructPropertyName name))}} + {{#if (isSupported (asUpperCamelCase parent.parent.name preserveAcronyms=true) event=(asUpperCamelCase parent.name preserveAcronyms=true) eventField=(asStructPropertyName name))}} {{>init_struct_member label=name type=type cluster=parent.parent.name}} - {{/unless}} + {{/if}} {{/zcl_event_fields}} } return self; @@ -103,9 +103,9 @@ NS_ASSUME_NONNULL_BEGIN auto other = [[MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}Event alloc] init]; {{#zcl_event_fields}} - {{#unless (wasRemoved (asUpperCamelCase parent.parent.name preserveAcronyms=true) event=(asUpperCamelCase parent.name preserveAcronyms=true) eventField=(asStructPropertyName name))}} + {{#if (isSupported (asUpperCamelCase parent.parent.name preserveAcronyms=true) event=(asUpperCamelCase parent.name preserveAcronyms=true) eventField=(asStructPropertyName name))}} other.{{asStructPropertyName name}} = self.{{asStructPropertyName name}}; - {{/unless}} + {{/if}} {{/zcl_event_fields}} return other; @@ -114,33 +114,33 @@ NS_ASSUME_NONNULL_BEGIN - (NSString *)description { NSString *descriptionString = [NSString stringWithFormat:@"<%@: {{#zcl_event_fields~}} - {{~#unless (wasRemoved (asUpperCamelCase parent.parent.name preserveAcronyms=true) event=(asUpperCamelCase parent.name preserveAcronyms=true) eventField=(asStructPropertyName name))~}} + {{~#if (isSupported (asUpperCamelCase parent.parent.name preserveAcronyms=true) event=(asUpperCamelCase parent.name preserveAcronyms=true) eventField=(asStructPropertyName name))~}} {{asStructPropertyName name}}:%@; {{!Just here to keep the preceding space}} - {{~/unless~}} + {{~/if~}} {{~/zcl_event_fields}}>", NSStringFromClass([self class]){{#zcl_event_fields~}} - {{~#unless (wasRemoved (asUpperCamelCase parent.parent.name preserveAcronyms=true) event=(asUpperCamelCase parent.name preserveAcronyms=true) eventField=(asStructPropertyName name))~}} + {{~#if (isSupported (asUpperCamelCase parent.parent.name preserveAcronyms=true) event=(asUpperCamelCase parent.name preserveAcronyms=true) eventField=(asStructPropertyName name))~}} ,{{#if isArray}}_{{asStructPropertyName name}}{{else if (isOctetString type)}}[_{{asStructPropertyName name}} base64EncodedStringWithOptions:0]{{else}}_{{asStructPropertyName name}}{{/if}} - {{~/unless~}} + {{~/if~}} {{~/zcl_event_fields}}]; return descriptionString; } {{#zcl_event_fields}} {{#if (and (hasOldName (asUpperCamelCase ../parent.name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(asStructPropertyName name)) - (not (wasRemoved (asUpperCamelCase ../parent.name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(oldName (asUpperCamelCase ../parent.name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(asStructPropertyName name)))))}} + (isSupported (asUpperCamelCase ../parent.name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(oldName (asUpperCamelCase ../parent.name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(asStructPropertyName name))))}} {{> renamed_struct_field_impl cluster=../parent.name type=type newName=name oldName=(oldName (asUpperCamelCase ../parent.name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(asStructPropertyName name))}} {{/if}} {{/zcl_event_fields}} @end -{{/unless}} +{{/if}} {{! Takes the name of the event to use as eventName. }} {{#*inline "oldNameImpl"}} -{{#unless (wasRemoved (compatClusterNameRemapping parent.name) event=eventName)}} +{{#if (isSupported (compatClusterNameRemapping parent.name) event=eventName)}} @implementation MTR{{compatClusterNameRemapping parent.name}}Cluster{{eventName}}Event : MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}Event @end -{{/unless}} +{{/if}} {{/inline}} {{! Takes the old name of the event, if any, as oldEventName. }} {{#*inline "oldNameCheck"}} diff --git a/src/darwin/Framework/CHIP/templates/MTRStructsObjc.zapt b/src/darwin/Framework/CHIP/templates/MTRStructsObjc.zapt index 279b3fa3256f6a..868d8c130f067d 100644 --- a/src/darwin/Framework/CHIP/templates/MTRStructsObjc.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRStructsObjc.zapt @@ -8,30 +8,30 @@ NS_ASSUME_NONNULL_BEGIN {{#zcl_structs}} {{#*inline "interfaceDecl"}} {{#zcl_struct_items}} -{{#unless (wasRemoved (asUpperCamelCase ../../name preserveAcronyms=true) struct=../struct structField=(asStructPropertyName label))}} +{{#if (isSupported (asUpperCamelCase ../../name preserveAcronyms=true) struct=../struct structField=(asStructPropertyName label))}} {{> struct_field_decl cluster=parent.parent.name type=type label=label}} {{availability (asUpperCamelCase ../../name preserveAcronyms=true) struct=../struct structField=(asStructPropertyName label) deprecationMessage=(concat "Please use MTR" (asUpperCamelCase ../../name preserveAcronyms=true) "Cluster" (asUpperCamelCase ../name preserveAcronyms=true))}}; -{{/unless}} +{{/if}} {{#if (hasOldName (asUpperCamelCase ../../name preserveAcronyms=true) struct=(asUpperCamelCase ../name preserveAcronyms=true) structField=(asStructPropertyName label))}} -{{#unless (wasRemoved (asUpperCamelCase ../../name preserveAcronyms=true) struct=(asUpperCamelCase ../name preserveAcronyms=true) structField=(oldName (asUpperCamelCase ../../name preserveAcronyms=true) struct=(asUpperCamelCase ../name preserveAcronyms=true) structField=(asStructPropertyName label)))}} +{{#if (isSupported (asUpperCamelCase ../../name preserveAcronyms=true) struct=(asUpperCamelCase ../name preserveAcronyms=true) structField=(oldName (asUpperCamelCase ../../name preserveAcronyms=true) struct=(asUpperCamelCase ../name preserveAcronyms=true) structField=(asStructPropertyName label)))}} {{> struct_field_decl cluster=../../name type=type label=(oldName (asUpperCamelCase ../../name preserveAcronyms=true) struct=(asUpperCamelCase ../name preserveAcronyms=true) structField=(asStructPropertyName label))}} {{availability (asUpperCamelCase ../../name preserveAcronyms=true) struct=(asUpperCamelCase ../name preserveAcronyms=true) structField=(oldName (asUpperCamelCase ../../name preserveAcronyms=true) struct=(asUpperCamelCase ../name preserveAcronyms=true) structField=(asStructPropertyName label)) deprecationMessage=(concat "Please use " (asStructPropertyName label))}}; -{{/unless}} +{{/if}} {{/if}} {{/zcl_struct_items}} {{/inline}} -{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) struct=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) struct=(asUpperCamelCase name preserveAcronyms=true))}} {{availability (asUpperCamelCase parent.name preserveAcronyms=true) struct=(asUpperCamelCase name preserveAcronyms=true) deprecationMessage="This struct is unused and will be removed"}} @interface MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}} : NSObject {{> interfaceDecl struct=(asUpperCamelCase name preserveAcronyms=true)}} @end -{{/unless}} +{{/if}} {{! Takes the name of the struct to use as structName. }} {{#*inline "oldNameDecl"}} -{{#unless (wasRemoved (compatClusterNameRemapping parent.name) struct=structName)}} +{{#if (isSupported (compatClusterNameRemapping parent.name) struct=structName)}} {{availability (compatClusterNameRemapping parent.name) struct=structName deprecationMessage=(concat "Please use MTR" (asUpperCamelCase parent.name preserveAcronyms=true) "Cluster" (asUpperCamelCase name preserveAcronyms=true))}} @interface MTR{{compatClusterNameRemapping parent.name}}Cluster{{structName}} : MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}} @end -{{/unless}} +{{/if}} {{/inline}} {{! Takes the old name of the struct, if any, as oldStructName. }} {{#*inline "oldNameCheck"}} @@ -48,29 +48,29 @@ NS_ASSUME_NONNULL_BEGIN {{/zcl_structs}} {{#zcl_events}} -{{#unless (wasRemoved (asUpperCamelCase parent.name preserveAcronyms=true) event=(asUpperCamelCase name preserveAcronyms=true))}} +{{#if (isSupported (asUpperCamelCase parent.name preserveAcronyms=true) event=(asUpperCamelCase name preserveAcronyms=true))}} {{availability (asUpperCamelCase parent.name preserveAcronyms=true) event=(asUpperCamelCase name preserveAcronyms=true)}} @interface MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}Event : NSObject {{#zcl_event_fields}} -{{#unless (wasRemoved (asUpperCamelCase ../../name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(asStructPropertyName name))}} +{{#if (isSupported (asUpperCamelCase ../../name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(asStructPropertyName name))}} {{> struct_field_decl cluster=parent.parent.name type=type label=name}} {{availability (asUpperCamelCase ../../name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(asStructPropertyName name)}}; -{{/unless}} +{{/if}} {{#if (hasOldName (asUpperCamelCase ../parent.name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(asStructPropertyName name))}} -{{#unless (wasRemoved (asUpperCamelCase ../../name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(oldName (asUpperCamelCase ../parent.name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(asStructPropertyName name)))}} +{{#if (isSupported (asUpperCamelCase ../../name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(oldName (asUpperCamelCase ../parent.name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(asStructPropertyName name)))}} {{> struct_field_decl cluster=parent.parent.name type=type label=(oldName (asUpperCamelCase ../parent.name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(asStructPropertyName name))}} {{availability (asUpperCamelCase ../../name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(oldName (asUpperCamelCase ../parent.name preserveAcronyms=true) event=(asUpperCamelCase ../name preserveAcronyms=true) eventField=(asStructPropertyName name)) deprecationMessage=(concat "Please use " (asStructPropertyName name))}}; -{{/unless}} +{{/if}} {{/if}} {{/zcl_event_fields}} @end -{{/unless}} +{{/if}} {{! Takes the name of the event to use as eventName. }} {{#*inline "oldNameDecl"}} -{{#unless (wasRemoved (compatClusterNameRemapping parent.name) event=eventName)}} +{{#if (isSupported (compatClusterNameRemapping parent.name) event=eventName)}} {{availability (compatClusterNameRemapping parent.name) event=eventName deprecationMessage=(concat "Please use MTR" (asUpperCamelCase parent.name preserveAcronyms=true) "Cluster" (asUpperCamelCase name preserveAcronyms=true) "Event")}} @interface MTR{{compatClusterNameRemapping parent.name}}Cluster{{eventName}}Event : MTR{{asUpperCamelCase parent.name preserveAcronyms=true}}Cluster{{asUpperCamelCase name preserveAcronyms=true}}Event @end -{{/unless}} +{{/if}} {{/inline}} {{! Takes the old name of the event, if any, as oldEventName. }} {{#*inline "oldNameCheck"}} diff --git a/src/darwin/Framework/CHIP/templates/availability.yaml b/src/darwin/Framework/CHIP/templates/availability.yaml index fea814e6066845..6727e5bff1861b 100644 --- a/src/darwin/Framework/CHIP/templates/availability.yaml +++ b/src/darwin/Framework/CHIP/templates/availability.yaml @@ -53,6 +53,17 @@ # NOTE: support for "removed" may not be complete in the templates. # Please examine codegen carefully when using "removed" to make # sure all the things that should have been removed have been. +# +# * "provisional": Can contain clusters, commands, attributes, etc as described +# above for "introduced" and "deprecated". Items can be +# defined as provisional to prevent code generation for them. +# If they are then listed as introduced in a release that is +# later than the one where they were marked provisional, +# they will start being code-generated. +# NOTE: support for "provisional" may not be complete in the +# templates. Please examine codegen carefully when using +# "provisional" to make sure all the things that should have +# been omitted have been. - release: "Initial release" versions: @@ -4577,6 +4588,14 @@ apis: - Timed Invoke for server to client commands - Deprecated global attribute names + provisional: + clusters: + - PulseWidthModulation + - TimeSynchronization + - ProxyConfiguration + - ProxyDiscovery + - ProxyValid + - FaultInjection - release: "First dot-release" versions: @@ -6142,9 +6161,6 @@ - Timed Invoke for server to client commands - Deprecated global attribute names removed: - clusters: - # Not ready to be public API yet. - - ClientMonitoring commands: BasicInformation: - MfgSpecificPing @@ -6198,6 +6214,10 @@ - Dual CredentialRuleEnum: - Double + provisional: + clusters: + # Not ready to be public API yet. + - ClientMonitoring renames: clusters: UnitTesting: TestCluster @@ -6546,9 +6566,10 @@ watchos: "9.5" tvos: "16.5" introduced: - attributes: - TimeSynchronization: - - DSTOffset + ids: + attributes: + TimeSynchronization: + - DSTOffset command fields: DiagnosticLogs: RetrieveLogsRequest: @@ -6813,12 +6834,10 @@ PumpConfigurationAndControl: PumpFeature: - Local - removed: + provisional: global attributes: - # EventList is provisional for now. - EventList attributes: - # EventList is provisional for now. Scenes: - EventList OnOff: @@ -6961,6 +6980,7 @@ - EventList FaultInjection: - EventList + removed: enum values: DoorLock: DlLockDataType: From 1177ce8570ac19fb3c8db7ec15baf77f684857b8 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 20 Apr 2023 18:51:40 -0400 Subject: [PATCH 09/54] Include event header information in results from multi-path read/subscribe. (#26173) Fixes https://github.com/project-chip/connectedhomeip/issues/26075 --- src/darwin/Framework/CHIP/MTRBaseDevice.h | 19 +++ src/darwin/Framework/CHIP/MTRBaseDevice.mm | 120 ++++++++++++++---- .../Framework/CHIP/MTRBaseDevice_Internal.h | 8 ++ src/darwin/Framework/CHIP/MTRDevice.h | 6 - src/darwin/Framework/CHIP/MTRDevice.mm | 84 +----------- .../Framework/CHIP/MTRDevice_Internal.h | 7 - .../Framework/CHIPTests/MTRDeviceTests.m | 92 +++++++++++++- 7 files changed, 223 insertions(+), 113 deletions(-) diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice.h b/src/darwin/Framework/CHIP/MTRBaseDevice.h index 65050131d2fa12..e9caa66561f484 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice.h +++ b/src/darwin/Framework/CHIP/MTRBaseDevice.h @@ -41,6 +41,20 @@ NS_ASSUME_NONNULL_BEGIN * MTRDataKey: Data-value NSDictionary object. * Included when there is data and when there is no error. * The data-value is described below. + * MTREventNumberKey : NSNumber-wrapped uint64_t value. Monotonically increasing, and consecutive event reports + * should have consecutive numbers unless device reboots, or if events are lost. + * Only present when both MTREventPathKey and MTRDataKey are present. + * MTREventPriorityKey : NSNumber-wrapped MTREventPriority value. + * Only present when both MTREventPathKey and MTRDataKey are present. + * MTREventTimeTypeKey : NSNumber-wrapped MTREventTimeType value. + * Only present when both MTREventPathKey and MTRDataKey are present. + * MTREventSystemUpTimeKey : NSNumber-wrapped NSTimeInterval value. + * Only present when MTREventTimeTypeKey is MTREventTimeTypeSystemUpTime. + * MTREventTimestampDateKey : NSDate object. + * Only present when MTREventTimeTypeKey is MTREventTimeTypeTimestampDate. + * + * Only one of MTREventTimestampDateKey and MTREventSystemUpTimeKey will be present, depending on the value for + * MTREventTimeTypeKey. * * A data-value is an NSDictionary object with the following key values: * @@ -117,6 +131,11 @@ extern NSString * const MTRDoubleValueType; extern NSString * const MTRNullValueType; extern NSString * const MTRStructureValueType; extern NSString * const MTRArrayValueType; +extern NSString * const MTREventNumberKey API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); +extern NSString * const MTREventPriorityKey API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); +extern NSString * const MTREventTimeTypeKey API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); +extern NSString * const MTREventSystemUpTimeKey API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); +extern NSString * const MTREventTimestampDateKey API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); @class MTRClusterStateCacheContainer; @class MTRAttributeCacheContainer; diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice.mm b/src/darwin/Framework/CHIP/MTRBaseDevice.mm index a966a34dde8cf1..4522c63d7989c1 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice.mm +++ b/src/darwin/Framework/CHIP/MTRBaseDevice.mm @@ -74,6 +74,11 @@ NSString * const MTRNullValueType = @"Null"; NSString * const MTRStructureValueType = @"Structure"; NSString * const MTRArrayValueType = @"Array"; +NSString * const MTREventNumberKey = @"eventNumber"; +NSString * const MTREventPriorityKey = @"eventPriority"; +NSString * const MTREventTimeTypeKey = @"eventTimeType"; +NSString * const MTREventSystemUpTimeKey = @"eventSystemUpTime"; +NSString * const MTREventTimestampDateKey = @"eventTimestampDate"; class MTRDataValueDictionaryCallbackBridge; @@ -752,7 +757,7 @@ CHIP_ERROR Encode(chip::TLV::TLVWriter & writer, chip::TLV::Tag tag) const public: using OnSuccessAttributeCallbackType = std::function; - using OnSuccessEventCallbackType = std::function; + using OnSuccessEventCallbackType = std::function; using OnErrorCallbackType = std::function; using OnDoneCallbackType = std::function; @@ -844,7 +849,7 @@ void OnEventData(const EventHeader & aEventHeader, TLV::TLVReader * apData, cons SuccessOrExit(err = app::DataModel::Decode(*apData, value)); - mOnEventSuccess(aEventHeader.mPath, value); + mOnEventSuccess(aEventHeader, value); exit: if (err != CHIP_NO_ERROR) { @@ -944,31 +949,28 @@ - (void)readAttributePaths:(NSArray * _Nullable)attri auto resultArray = [[NSMutableArray alloc] init]; auto onAttributeSuccessCb - = [resultArray](const ConcreteAttributePath & attributePath, const MTRDataValueDictionaryDecodableType & aData) { + = [resultArray](const ConcreteAttributePath & aAttributePath, const MTRDataValueDictionaryDecodableType & aData) { [resultArray addObject:@ { - MTRAttributePathKey : [[MTRAttributePath alloc] initWithPath:attributePath], + MTRAttributePathKey : [[MTRAttributePath alloc] initWithPath:aAttributePath], MTRDataKey : aData.GetDecodedObject() }]; }; auto onEventSuccessCb - = [resultArray](const ConcreteEventPath & eventPath, const MTRDataValueDictionaryDecodableType & aData) { - [resultArray addObject:@ { - MTREventPathKey : [[MTREventPath alloc] initWithPath:eventPath], - MTRDataKey : aData.GetDecodedObject() - }]; + = [resultArray](const EventHeader & aEventHeader, const MTRDataValueDictionaryDecodableType & aData) { + [resultArray addObject:[MTRBaseDevice eventReportForHeader:aEventHeader andData:aData.GetDecodedObject()]]; }; - auto onFailureCb = [resultArray, interactionStatus](const app::ConcreteAttributePath * attributePath, - const app::ConcreteEventPath * eventPath, CHIP_ERROR aError) { - if (attributePath != nullptr) { + auto onFailureCb = [resultArray, interactionStatus](const app::ConcreteAttributePath * aAttributePath, + const app::ConcreteEventPath * aEventPath, CHIP_ERROR aError) { + if (aAttributePath != nullptr) { [resultArray addObject:@ { - MTRAttributePathKey : [[MTRAttributePath alloc] initWithPath:*attributePath], + MTRAttributePathKey : [[MTRAttributePath alloc] initWithPath:*aAttributePath], MTRErrorKey : [MTRError errorForCHIPErrorCode:aError] }]; - } else if (eventPath != nullptr) { + } else if (aEventPath != nullptr) { [resultArray addObject:@ { - MTREventPathKey : [[MTREventPath alloc] initWithPath:*eventPath], + MTREventPathKey : [[MTREventPath alloc] initWithPath:*aEventPath], MTRErrorKey : [MTRError errorForCHIPErrorCode:aError] }]; } else { @@ -1343,14 +1345,11 @@ - (void)subscribeToAttributePaths:(NSArray * _Nullabl }); }; - auto onEventReportCb = [queue, reportHandler](const ConcreteEventPath & eventPath, - const MTRDataValueDictionaryDecodableType & data) { - id valueObject = data.GetDecodedObject(); - ConcreteEventPath pathCopy(eventPath); + auto onEventReportCb = [queue, reportHandler]( + const EventHeader & eventHeader, const MTRDataValueDictionaryDecodableType & data) { + NSDictionary * report = [MTRBaseDevice eventReportForHeader:eventHeader andData:data.GetDecodedObject()]; dispatch_async(queue, ^{ - reportHandler( - @[ @ { MTREventPathKey : [[MTREventPath alloc] initWithPath:pathCopy], MTRDataKey : valueObject } ], - nil); + reportHandler(@[ report ], nil); }); }; @@ -1540,6 +1539,43 @@ static CHIP_ERROR OpenCommissioningWindow(Controller::DeviceController * control delete self; } +#pragma mark - Utility for time conversion +NSTimeInterval MTRTimeIntervalForEventTimestampValue(uint64_t timeValue) +{ + // Note: The event timestamp value as written in the spec is in microseconds, but the released 1.0 SDK implemented it in + // milliseconds. The following issue was filed to address the inconsistency: + // https://github.com/CHIP-Specifications/connectedhomeip-spec/issues/6236 + // For consistency with the released behavior, calculations here will be done in milliseconds. + + // First convert the event timestamp value (in milliseconds) to NSTimeInterval - to minimize potential loss of precision + // of uint64 => NSTimeInterval (double), convert whole seconds and remainder separately and then combine + uint64_t eventTimestampValueSeconds = timeValue / chip::kMillisecondsPerSecond; + uint64_t eventTimestampValueRemainderMilliseconds = timeValue % chip::kMillisecondsPerSecond; + NSTimeInterval eventTimestampValueRemainder + = NSTimeInterval(eventTimestampValueRemainderMilliseconds) / chip::kMillisecondsPerSecond; + NSTimeInterval eventTimestampValue = eventTimestampValueSeconds + eventTimestampValueRemainder; + + return eventTimestampValue; +} + +#pragma mark - Utility for event priority conversion +BOOL MTRPriorityLevelIsValid(chip::app::PriorityLevel priorityLevel) +{ + return (priorityLevel >= chip::app::PriorityLevel::Debug) && (priorityLevel <= chip::app::PriorityLevel::Critical); +} + +MTREventPriority MTREventPriorityForValidPriorityLevel(chip::app::PriorityLevel priorityLevel) +{ + switch (priorityLevel) { + case chip::app::PriorityLevel::Debug: + return MTREventPriorityDebug; + case chip::app::PriorityLevel::Info: + return MTREventPriorityInfo; + default: + return MTREventPriorityCritical; + } +} + } // anonymous namespace - (void)_openCommissioningWindowWithSetupPasscode:(nullable NSNumber *)setupPasscode @@ -1738,6 +1774,46 @@ - (void)subscribeToEventsWithEndpointID:(NSNumber * _Nullable)endpointID subscriptionEstablished:subscriptionEstablished resubscriptionScheduled:nil]; } + ++ (NSDictionary *)eventReportForHeader:(const chip::app::EventHeader &)header andData:(id _Nullable)data +{ + MTREventPath * eventPath = [[MTREventPath alloc] initWithPath:header.mPath]; + if (data == nil) { + MTR_LOG_ERROR("%@ could not decode event data", eventPath); + return @{ MTREventPathKey : eventPath, MTRErrorKey : [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_ARGUMENT] }; + } + + // Construct the right type, and key/value depending on the type + NSNumber * eventTimeType; + NSString * timestampKey; + id timestampValue; + if (header.mTimestamp.mType == Timestamp::Type::kSystem) { + eventTimeType = @(MTREventTimeTypeSystemUpTime); + timestampKey = MTREventSystemUpTimeKey; + timestampValue = @(MTRTimeIntervalForEventTimestampValue(header.mTimestamp.mValue)); + } else if (header.mTimestamp.mType == Timestamp::Type::kEpoch) { + eventTimeType = @(MTREventTimeTypeTimestampDate); + timestampKey = MTREventTimestampDateKey; + timestampValue = [NSDate dateWithTimeIntervalSince1970:MTRTimeIntervalForEventTimestampValue(header.mTimestamp.mValue)]; + } else { + MTR_LOG_ERROR("%@ Unsupported event timestamp type %u - ignoring", eventPath, (unsigned int) header.mTimestamp.mType); + return @{ MTREventPathKey : eventPath, MTRErrorKey : [MTRError errorForCHIPErrorCode:CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE] }; + } + + if (!MTRPriorityLevelIsValid(header.mPriorityLevel)) { + MTR_LOG_ERROR("%@ Unsupported event priority %u - ignoring", eventPath, (unsigned int) header.mPriorityLevel); + return @{ MTREventPathKey : eventPath, MTRErrorKey : [MTRError errorForCHIPErrorCode:CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE] }; + } + + return @{ + MTREventPathKey : eventPath, + MTRDataKey : data, + MTREventNumberKey : @(header.mEventNumber), + MTREventPriorityKey : @(MTREventPriorityForValidPriorityLevel(header.mPriorityLevel)), + MTREventTimeTypeKey : eventTimeType, + timestampKey : timestampValue + }; +} @end @implementation MTRBaseDevice (Deprecated) diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice_Internal.h b/src/darwin/Framework/CHIP/MTRBaseDevice_Internal.h index cf5944a0a66a5d..d6be73f96375c2 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice_Internal.h +++ b/src/darwin/Framework/CHIP/MTRBaseDevice_Internal.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -75,6 +76,13 @@ static inline MTRTransportType MTRMakeTransportType(chip::Transport::Type type) */ - (instancetype)initWithNodeID:(NSNumber *)nodeID controller:(MTRDeviceController *)controller; +/** + * Create a report, suitable in including in the sort of data structure that + * gets passed to MTRDeviceResponseHandler, from a given event header and + * already-decoded event data. The data is allowed to be nil in error cases + * (e.g. when TLV decoding failed). + */ ++ (NSDictionary *)eventReportForHeader:(const chip::app::EventHeader &)header andData:(id _Nullable)data; @end @interface MTRClusterPath () diff --git a/src/darwin/Framework/CHIP/MTRDevice.h b/src/darwin/Framework/CHIP/MTRDevice.h index 6f8bda9703e0bc..71f24c1e33528a 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.h +++ b/src/darwin/Framework/CHIP/MTRDevice.h @@ -202,12 +202,6 @@ typedef NS_ENUM(NSUInteger, MTRDeviceState) { @end -extern NSString * const MTREventNumberKey API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); -extern NSString * const MTREventPriorityKey API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); -extern NSString * const MTREventTimeTypeKey API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); -extern NSString * const MTREventSystemUpTimeKey API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); -extern NSString * const MTREventTimestampDateKey API_AVAILABLE(ios(16.5), macos(13.4), watchos(9.5), tvos(16.5)); - @protocol MTRDeviceDelegate @required /** diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index 5b8486fa4b2079..da828545025156 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -38,12 +38,6 @@ #include #include -NSString * const MTREventNumberKey = @"eventNumber"; -NSString * const MTREventPriorityKey = @"eventPriority"; -NSString * const MTREventTimeTypeKey = @"eventTimeType"; -NSString * const MTREventSystemUpTimeKey = @"eventSystemUpTime"; -NSString * const MTREventTimestampDateKey = @"eventTimestampDate"; - typedef void (^MTRDeviceAttributeReportHandler)(NSArray * _Nonnull); // Consider moving utility classes to their own file @@ -89,41 +83,6 @@ - (id)strongObject return aNumber; } -NSTimeInterval MTRTimeIntervalForEventTimestampValue(uint64_t timeValue) -{ - // Note: The event timestamp value as written in the spec is in microseconds, but the released 1.0 SDK implemented it in - // milliseconds. The following issue was filed to address the inconsistency: - // https://github.com/CHIP-Specifications/connectedhomeip-spec/issues/6236 - // For consistency with the released behavior, calculations here will be done in milliseconds. - - // First convert the event timestamp value (in milliseconds) to NSTimeInterval - to minimize potential loss of precision - // of uint64 => NSTimeInterval (double), convert whole seconds and remainder separately and then combine - uint64_t eventTimestampValueSeconds = timeValue / chip::kMillisecondsPerSecond; - uint64_t eventTimestampValueRemainderMilliseconds = timeValue % chip::kMillisecondsPerSecond; - NSTimeInterval eventTimestampValueRemainder - = NSTimeInterval(eventTimestampValueRemainderMilliseconds) / chip::kMillisecondsPerSecond; - NSTimeInterval eventTimestampValue = eventTimestampValueSeconds + eventTimestampValueRemainder; - - return eventTimestampValue; -} - -BOOL MTRPriorityLevelIsValid(chip::app::PriorityLevel priorityLevel) -{ - return (priorityLevel >= chip::app::PriorityLevel::Debug) && (priorityLevel <= chip::app::PriorityLevel::Critical); -} - -MTREventPriority MTREventPriorityForValidPriorityLevel(chip::app::PriorityLevel priorityLevel) -{ - switch (priorityLevel) { - case chip::app::PriorityLevel::Debug: - return MTREventPriorityDebug; - case chip::app::PriorityLevel::Info: - return MTREventPriorityInfo; - default: - return MTREventPriorityCritical; - } -} - #pragma mark - SubscriptionCallback class declaration using namespace chip; using namespace chip::app; @@ -1214,43 +1173,14 @@ - (void)invokeCommandWithEndpointID:(NSNumber *)endpointID MTRErrorKey : [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_ARGUMENT] }]; } else { - id value = MTRDecodeDataValueDictionaryFromCHIPTLV(apData); - if (value) { - // Construct the right type, and key/value depending on the type - NSNumber * eventTimeType; - NSString * timestampKey; - id timestampValue; - if (aEventHeader.mTimestamp.mType == Timestamp::Type::kSystem) { - eventTimeType = @(MTREventTimeTypeSystemUpTime); - timestampKey = MTREventSystemUpTimeKey; - timestampValue = @(MTRTimeIntervalForEventTimestampValue(aEventHeader.mTimestamp.mValue)); - } else if (aEventHeader.mTimestamp.mType == Timestamp::Type::kEpoch) { - eventTimeType = @(MTREventTimeTypeTimestampDate); - timestampKey = MTREventTimestampDateKey; - timestampValue = - [NSDate dateWithTimeIntervalSince1970:MTRTimeIntervalForEventTimestampValue(aEventHeader.mTimestamp.mValue)]; - } else { - MTR_LOG_INFO( - "%@ Unsupported event timestamp type %u - ignoring", eventPath, (unsigned int) aEventHeader.mTimestamp.mType); - ReportError(CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - return; - } - - if (!MTRPriorityLevelIsValid(aEventHeader.mPriorityLevel)) { - MTR_LOG_INFO("%@ Unsupported event priority %u - ignoring", eventPath, (unsigned int) aEventHeader.mPriorityLevel); - ReportError(CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE); - return; - } - - [mEventReports addObject:@{ - MTREventPathKey : eventPath, - MTRDataKey : value, - MTREventNumberKey : @(aEventHeader.mEventNumber), - MTREventPriorityKey : @(MTREventPriorityForValidPriorityLevel(aEventHeader.mPriorityLevel)), - MTREventTimeTypeKey : eventTimeType, - timestampKey : timestampValue - }]; + id value; + if (apData == nullptr) { + value = nil; + } else { + value = MTRDecodeDataValueDictionaryFromCHIPTLV(apData); } + + [mEventReports addObject:[MTRBaseDevice eventReportForHeader:aEventHeader andData:value]]; } } diff --git a/src/darwin/Framework/CHIP/MTRDevice_Internal.h b/src/darwin/Framework/CHIP/MTRDevice_Internal.h index cccff5027e2cb2..8da4cecb60f7bd 100644 --- a/src/darwin/Framework/CHIP/MTRDevice_Internal.h +++ b/src/darwin/Framework/CHIP/MTRDevice_Internal.h @@ -56,11 +56,4 @@ typedef void (^MTRDevicePerformAsyncBlock)(MTRBaseDevice * baseDevice); // Returns min or max, if it is below or above, respectively. NSNumber * MTRClampedNumber(NSNumber * aNumber, NSNumber * min, NSNumber * max); -#pragma mark - Utility for time conversion -NSTimeInterval MTRTimeIntervalForEventTimestampValue(uint64_t timeValue); - -#pragma mark - Utility for event priority conversion -BOOL MTRPriorityLevelIsValid(chip::app::PriorityLevel priorityLevel); -MTREventPriority MTREventPriorityForValidPriorityLevel(chip::app::PriorityLevel); - NS_ASSUME_NONNULL_END diff --git a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m index a71f3878d7515a..2a444a85ce0e81 100644 --- a/src/darwin/Framework/CHIPTests/MTRDeviceTests.m +++ b/src/darwin/Framework/CHIPTests/MTRDeviceTests.m @@ -1659,9 +1659,27 @@ - (void)test020_ReadMultipleAttributes XCTAssertEqualObjects(path.endpoint, @0); XCTAssertEqualObjects(path.cluster, @40); XCTAssertEqualObjects(path.event, @0); - XCTAssertNotNil(result[@"data"]); XCTAssertNil(result[@"error"]); + + XCTAssertNotNil(result[@"data"]); XCTAssertTrue([result[@"data"] isKindOfClass:[NSDictionary class]]); + + XCTAssertNotNil(result[@"eventNumber"]); + XCTAssertTrue([result[@"eventNumber"] isKindOfClass:[NSNumber class]]); + + XCTAssertNotNil(result[@"eventPriority"]); + XCTAssertTrue([result[@"eventPriority"] isKindOfClass:[NSNumber class]]); + XCTAssertEqualObjects(result[@"eventPriority"], @(MTREventPriorityCritical)); + + XCTAssertNotNil(result[@"eventTimeType"]); + XCTAssertTrue([result[@"eventTimeType"] isKindOfClass:[NSNumber class]]); + + XCTAssertTrue(result[@"eventSystemUpTime"] != nil || result[@"eventTimestampDate"] != nil); + if (result[@"eventSystemUpTime"] != nil) { + XCTAssertTrue([result[@"eventSystemUpTime"] isKindOfClass:[NSNumber class]]); + } else { + XCTAssertTrue([result[@"eventTimestampDate"] isKindOfClass:[NSDate class]]); + } } else if ([result objectForKey:@"attributePath"]) { ++attributeResultCount; MTRAttributePath * path = result[@"attributePath"]; @@ -2079,6 +2097,78 @@ - (void)test024_SubscribeMultipleAttributesAllErrors [self waitForExpectations:@[ errorExpectation ] timeout:kTimeoutInSeconds]; } +- (void)test025_SubscribeMultipleEvents +{ + MTRBaseDevice * device = GetConnectedDevice(); + dispatch_queue_t queue = dispatch_get_main_queue(); + + // Subscribe + XCTestExpectation * expectation = [self expectationWithDescription:@"subscribe multiple events"]; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(1) maxInterval:@(10)]; + + NSArray * eventPaths = @[ + // Startup event. + [MTREventRequestPath requestPathWithEndpointID:@0 clusterID:@40 eventID:@0], + // Shutdown event. + [MTREventRequestPath requestPathWithEndpointID:@0 clusterID:@40 eventID:@1], + ]; + + XCTestExpectation * startupEventExpectation = [self expectationWithDescription:@"report startup event"]; + __auto_type reportHandler = ^(id _Nullable values, NSError * _Nullable error) { + XCTAssertNil(error); + XCTAssertEqual([MTRErrorTestUtils errorToZCLErrorCode:error], 0); + XCTAssertTrue([values isKindOfClass:[NSArray class]]); + + for (NSDictionary * result in values) { + XCTAssertNotNil(result[@"eventPath"]); + + MTREventPath * path = result[@"eventPath"]; + // We only expect to see a Startup event here. + XCTAssertEqualObjects(path.endpoint, @0); + XCTAssertEqualObjects(path.cluster, @40); + XCTAssertEqualObjects(path.event, @0); + + XCTAssertNil(result[@"error"]); + + XCTAssertNotNil(result[@"data"]); + XCTAssertTrue([result[@"data"] isKindOfClass:[NSDictionary class]]); + + XCTAssertNotNil(result[@"eventNumber"]); + XCTAssertTrue([result[@"eventNumber"] isKindOfClass:[NSNumber class]]); + + XCTAssertNotNil(result[@"eventPriority"]); + XCTAssertTrue([result[@"eventPriority"] isKindOfClass:[NSNumber class]]); + XCTAssertEqualObjects(result[@"eventPriority"], @(MTREventPriorityCritical)); + + XCTAssertNotNil(result[@"eventTimeType"]); + XCTAssertTrue([result[@"eventTimeType"] isKindOfClass:[NSNumber class]]); + + XCTAssertTrue(result[@"eventSystemUpTime"] != nil || result[@"eventTimestampDate"] != nil); + if (result[@"eventSystemUpTime"] != nil) { + XCTAssertTrue([result[@"eventSystemUpTime"] isKindOfClass:[NSNumber class]]); + } else { + XCTAssertTrue([result[@"eventTimestampDate"] isKindOfClass:[NSDate class]]); + } + + [startupEventExpectation fulfill]; + } + }; + + [device subscribeToAttributePaths:nil + eventPaths:eventPaths + params:params + queue:queue + reportHandler:reportHandler + subscriptionEstablished:^{ + NSLog(@"subscribe complete"); + [expectation fulfill]; + } + resubscriptionScheduled:nil]; + + // Wait till establishment + [self waitForExpectations:@[ startupEventExpectation, expectation ] timeout:kTimeoutInSeconds]; +} + - (void)test900_SubscribeAllAttributes { MTRBaseDevice * device = GetConnectedDevice(); From 534403cd75190da4f632b2b7a79466d77c97f7f1 Mon Sep 17 00:00:00 2001 From: Hrishikesh Dhayagude Date: Fri, 21 Apr 2023 06:41:42 +0530 Subject: [PATCH 10/54] ESP32: Upgrade to ESP-IDF release v4.4.4 (#26182) --- docs/guides/esp32/setup_idf_chip.md | 16 ++++++++-------- .../docker/images/chip-build-esp32/Dockerfile | 2 +- integrations/docker/images/chip-build/version | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/guides/esp32/setup_idf_chip.md b/docs/guides/esp32/setup_idf_chip.md index bd30222934dcb4..13feaee221ca4e 100644 --- a/docs/guides/esp32/setup_idf_chip.md +++ b/docs/guides/esp32/setup_idf_chip.md @@ -13,27 +13,27 @@ step. ### Install Prerequisites -- [Linux](https://docs.espressif.com/projects/esp-idf/en/v4.4.3/esp32/get-started/linux-setup.html) -- [macOS](https://docs.espressif.com/projects/esp-idf/en/v4.4.3/esp32/get-started/macos-setup.html) +- [Linux](https://docs.espressif.com/projects/esp-idf/en/v4.4.4/esp32/get-started/linux-setup.html) +- [macOS](https://docs.espressif.com/projects/esp-idf/en/v4.4.4/esp32/get-started/macos-setup.html) -### Get IDF v4.4.3 +### Get IDF v4.4.4 - Clone ESP-IDF - [v4.4.3 release](https://github.com/espressif/esp-idf/releases/tag/v4.4.3) + [v4.4.4 release](https://github.com/espressif/esp-idf/releases/tag/v4.4.4) ``` - $ git clone -b v4.4.3 --recursive https://github.com/espressif/esp-idf.git + $ git clone -b v4.4.4 --recursive https://github.com/espressif/esp-idf.git $ cd esp-idf $ ./install.sh ``` -- To update an existing esp-idf toolchain to v4.4.3: +- To update an existing esp-idf toolchain to v4.4.4: ``` $ cd path/to/esp-idf $ git fetch origin - $ git checkout v4.4.3 - $ git reset --hard origin/v4.4.3 + $ git checkout v4.4.4 + $ git reset --hard origin/v4.4.4 $ git submodule update --recursive --init $ git clean -fdx $ ./install.sh diff --git a/integrations/docker/images/chip-build-esp32/Dockerfile b/integrations/docker/images/chip-build-esp32/Dockerfile index 26e507dc70cf8f..0a512b4a2895d9 100644 --- a/integrations/docker/images/chip-build-esp32/Dockerfile +++ b/integrations/docker/images/chip-build-esp32/Dockerfile @@ -10,7 +10,7 @@ RUN set -x \ && : # last line RUN set -x \ - && git clone --recursive -b v4.4.3 --depth 1 --shallow-submodule https://github.com/espressif/esp-idf.git /tmp/esp-idf \ + && git clone --recursive -b v4.4.4 --depth 1 --shallow-submodule https://github.com/espressif/esp-idf.git /tmp/esp-idf \ && : # last line FROM connectedhomeip/chip-build:${VERSION} diff --git a/integrations/docker/images/chip-build/version b/integrations/docker/images/chip-build/version index 51f244759f963d..239c2611130e59 100644 --- a/integrations/docker/images/chip-build/version +++ b/integrations/docker/images/chip-build/version @@ -1 +1 @@ -0.7.0 Version bump reason: [Android] Use NDK r23c and OpenSSL 1.1.1t +0.7.1 Version bump reason: [ESP32] Update ESP-IDF to v4.4.4 release From 2021b3ebcc70bfddc28845353a39b11958f90236 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Thu, 20 Apr 2023 21:26:38 -0400 Subject: [PATCH 11/54] Improve the logging for MTRDevice. (#26189) MTR_LOG_INFO does not get persisted by default. Move logging involving errors or the operation queue lifetime to MTR_LOG_ERROR/MTR_LOG_DEFAULT. --- src/darwin/Framework/CHIP/MTRDevice.mm | 295 +++++++++--------- .../CHIP/templates/MTRClusters-src.zapt | 9 +- .../CHIP/zap-generated/MTRClusters.mm | 9 +- 3 files changed, 161 insertions(+), 152 deletions(-) diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index da828545025156..a43cd41bcb1de4 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -310,14 +310,14 @@ - (void)_handleSubscriptionReset // if there is no delegate then also do not retry id delegate = _weakDelegate.strongObject; if (!delegate) { - MTR_LOG_INFO("%@ no delegate - do not reattempt subscription", self); + MTR_LOG_DEFAULT("%@ no delegate - do not reattempt subscription", self); os_unfair_lock_unlock(&self->_lock); return; } // don't schedule multiple retries if (self.reattemptingSubscription) { - MTR_LOG_INFO("%@ already reattempting subscription", self); + MTR_LOG_DEFAULT("%@ already reattempting subscription", self); os_unfair_lock_unlock(&self->_lock); return; } @@ -333,7 +333,7 @@ - (void)_handleSubscriptionReset } } - MTR_LOG_INFO("%@ scheduling to reattempt subscription in %u seconds", self, _lastSubscriptionAttemptWait); + MTR_LOG_DEFAULT("%@ scheduling to reattempt subscription in %u seconds", self, _lastSubscriptionAttemptWait); dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(_lastSubscriptionAttemptWait * NSEC_PER_SEC)), self.queue, ^{ os_unfair_lock_lock(&self->_lock); [self _reattemptSubscriptionNowIfNeeded]; @@ -350,7 +350,7 @@ - (void)_reattemptSubscriptionNowIfNeeded return; } - MTR_LOG_INFO("%@ reattempting subscription", self); + MTR_LOG_DEFAULT("%@ reattempting subscription", self); self.reattemptingSubscription = NO; [self _setupSubscription]; } @@ -437,7 +437,7 @@ - (void)_handleEventReport:(NSArray *> *)eventRepor } } if (oldEstimatedStartTime != _estimatedStartTime) { - MTR_LOG_INFO("%@ updated estimated start time to %@", self, _estimatedStartTime); + MTR_LOG_DEFAULT("%@ updated estimated start time to %@", self, _estimatedStartTime); } // Combine with previous unreported events, if they exist @@ -471,137 +471,137 @@ - (void)_setupSubscription _subscriptionActive = YES; - [_deviceController getSessionForNode:_nodeID.unsignedLongLongValue - completion:^(chip::Messaging::ExchangeManager * _Nullable exchangeManager, - const chip::Optional & session, NSError * _Nullable error) { - if (error != nil) { - MTR_LOG_INFO("%@ getSessionForNode error %@", self, error); - dispatch_async(self.queue, ^{ - [self _handleSubscriptionError:error]; - [self _handleSubscriptionReset]; - }); - return; - } - - // Wildcard endpoint, cluster, attribute, event. - auto attributePath = std::make_unique(); - auto eventPath = std::make_unique(); - // We want to get event reports at the minInterval, not the maxInterval. - eventPath->mIsUrgentEvent = true; - ReadPrepareParams readParams(session.Value()); - - readParams.mMinIntervalFloorSeconds = 0; - // Select a max interval based on the device's claimed idle sleep interval. - auto idleSleepInterval = std::chrono::duration_cast( - session.Value()->GetRemoteMRPConfig().mIdleRetransTimeout); - if (idleSleepInterval.count() < MTR_DEVICE_SUBSCRIPTION_MAX_INTERVAL_MIN) { - idleSleepInterval = System::Clock::Seconds32(MTR_DEVICE_SUBSCRIPTION_MAX_INTERVAL_MIN); - } - if (idleSleepInterval.count() > MTR_DEVICE_SUBSCRIPTION_MAX_INTERVAL_MAX) { - idleSleepInterval = System::Clock::Seconds32(MTR_DEVICE_SUBSCRIPTION_MAX_INTERVAL_MAX); - } - readParams.mMaxIntervalCeilingSeconds = static_cast(idleSleepInterval.count()); - - readParams.mpAttributePathParamsList = attributePath.get(); - readParams.mAttributePathParamsListSize = 1; - readParams.mpEventPathParamsList = eventPath.get(); - readParams.mEventPathParamsListSize = 1; - readParams.mKeepSubscriptions = true; - readParams.mIsFabricFiltered = false; - attributePath.release(); - eventPath.release(); - - auto callback = std::make_unique( - ^(NSArray * value) { - MTR_LOG_INFO("%@ got attribute report %@", self, value); - dispatch_async(self.queue, ^{ - // OnAttributeData (after OnReportEnd) - [self _handleAttributeReport:value]; - }); - }, - ^(NSArray * value) { - MTR_LOG_INFO("%@ got event report %@", self, value); - dispatch_async(self.queue, ^{ - // OnEventReport (after OnReportEnd) - [self _handleEventReport:value]; - }); - }, - ^(NSError * error) { - MTR_LOG_INFO("%@ got subscription error %@", self, error); - dispatch_async(self.queue, ^{ - // OnError - [self _handleSubscriptionError:error]; - }); - }, - ^(NSError * error, NSNumber * resubscriptionDelay) { - MTR_LOG_INFO("%@ got resubscription error %@ delay %@", self, error, resubscriptionDelay); - dispatch_async(self.queue, ^{ - // OnResubscriptionNeeded - [self _handleResubscriptionNeeded]; - }); - }, - ^(void) { - MTR_LOG_INFO("%@ got subscription established", self); - dispatch_async(self.queue, ^{ - // OnSubscriptionEstablished - [self _handleSubscriptionEstablished]; - }); - }, - ^(void) { - MTR_LOG_INFO("%@ got subscription done", self); - // Drop our pointer to the ReadClient immediately, since - // it's about to be destroyed and we don't want to be - // holding a dangling pointer. - os_unfair_lock_lock(&self->_lock); - self->_currentReadClient = nullptr; - os_unfair_lock_unlock(&self->_lock); - dispatch_async(self.queue, ^{ - // OnDone - [self _handleSubscriptionReset]; - }); - }, - ^(void) { - MTR_LOG_INFO("%@ got unsolicited message from publisher", self); - dispatch_async(self.queue, ^{ - // OnUnsolicitedMessageFromPublisher - [self _handleUnsolicitedMessageFromPublisher]; - }); - }); - - // Set up a cluster state cache. We really just want this for the - // logic it has for tracking data versions and event numbers so we - // minimize the amount of data we request on resubscribes; we - // don't care about the data it stores. Ideally we could use the - // dataversion-management logic without needing to store the data - // separately from the data store we already have, or we would - // stop storing our data separately. - auto clusterStateCache = std::make_unique(*callback.get()); - auto readClient - = std::make_unique(InteractionModelEngine::GetInstance(), exchangeManager, - clusterStateCache->GetBufferedCallback(), ReadClient::InteractionType::Subscribe); - - // SendAutoResubscribeRequest cleans up the params, even on failure. - CHIP_ERROR err = readClient->SendAutoResubscribeRequest(std::move(readParams)); - - if (err != CHIP_NO_ERROR) { - NSError * error = [MTRError errorForCHIPErrorCode:err]; - MTR_LOG_INFO("%@ SendAutoResubscribeRequest error %@", self, error); - dispatch_async(self.queue, ^{ - [self _handleSubscriptionError:error]; - }); - - return; - } - - // Callback and ClusterStateCache and ReadClient will be deleted - // when OnDone is called. - os_unfair_lock_lock(&self->_lock); - self->_currentReadClient = readClient.get(); - os_unfair_lock_unlock(&self->_lock); - callback->AdoptReadClient(std::move(readClient)); - callback->AdoptClusterStateCache(std::move(clusterStateCache)); - callback.release(); - }]; + [_deviceController + getSessionForNode:_nodeID.unsignedLongLongValue + completion:^(chip::Messaging::ExchangeManager * _Nullable exchangeManager, + const chip::Optional & session, NSError * _Nullable error) { + if (error != nil) { + MTR_LOG_ERROR("%@ getSessionForNode error %@", self, error); + dispatch_async(self.queue, ^{ + [self _handleSubscriptionError:error]; + [self _handleSubscriptionReset]; + }); + return; + } + + // Wildcard endpoint, cluster, attribute, event. + auto attributePath = std::make_unique(); + auto eventPath = std::make_unique(); + // We want to get event reports at the minInterval, not the maxInterval. + eventPath->mIsUrgentEvent = true; + ReadPrepareParams readParams(session.Value()); + + readParams.mMinIntervalFloorSeconds = 0; + // Select a max interval based on the device's claimed idle sleep interval. + auto idleSleepInterval = std::chrono::duration_cast( + session.Value()->GetRemoteMRPConfig().mIdleRetransTimeout); + if (idleSleepInterval.count() < MTR_DEVICE_SUBSCRIPTION_MAX_INTERVAL_MIN) { + idleSleepInterval = System::Clock::Seconds32(MTR_DEVICE_SUBSCRIPTION_MAX_INTERVAL_MIN); + } + if (idleSleepInterval.count() > MTR_DEVICE_SUBSCRIPTION_MAX_INTERVAL_MAX) { + idleSleepInterval = System::Clock::Seconds32(MTR_DEVICE_SUBSCRIPTION_MAX_INTERVAL_MAX); + } + readParams.mMaxIntervalCeilingSeconds = static_cast(idleSleepInterval.count()); + + readParams.mpAttributePathParamsList = attributePath.get(); + readParams.mAttributePathParamsListSize = 1; + readParams.mpEventPathParamsList = eventPath.get(); + readParams.mEventPathParamsListSize = 1; + readParams.mKeepSubscriptions = true; + readParams.mIsFabricFiltered = false; + attributePath.release(); + eventPath.release(); + + auto callback = std::make_unique( + ^(NSArray * value) { + MTR_LOG_INFO("%@ got attribute report %@", self, value); + dispatch_async(self.queue, ^{ + // OnAttributeData (after OnReportEnd) + [self _handleAttributeReport:value]; + }); + }, + ^(NSArray * value) { + MTR_LOG_INFO("%@ got event report %@", self, value); + dispatch_async(self.queue, ^{ + // OnEventReport (after OnReportEnd) + [self _handleEventReport:value]; + }); + }, + ^(NSError * error) { + MTR_LOG_ERROR("%@ got subscription error %@", self, error); + dispatch_async(self.queue, ^{ + // OnError + [self _handleSubscriptionError:error]; + }); + }, + ^(NSError * error, NSNumber * resubscriptionDelay) { + MTR_LOG_DEFAULT("%@ got resubscription error %@ delay %@", self, error, resubscriptionDelay); + dispatch_async(self.queue, ^{ + // OnResubscriptionNeeded + [self _handleResubscriptionNeeded]; + }); + }, + ^(void) { + MTR_LOG_DEFAULT("%@ got subscription established", self); + dispatch_async(self.queue, ^{ + // OnSubscriptionEstablished + [self _handleSubscriptionEstablished]; + }); + }, + ^(void) { + MTR_LOG_DEFAULT("%@ got subscription done", self); + // Drop our pointer to the ReadClient immediately, since + // it's about to be destroyed and we don't want to be + // holding a dangling pointer. + os_unfair_lock_lock(&self->_lock); + self->_currentReadClient = nullptr; + os_unfair_lock_unlock(&self->_lock); + dispatch_async(self.queue, ^{ + // OnDone + [self _handleSubscriptionReset]; + }); + }, + ^(void) { + MTR_LOG_DEFAULT("%@ got unsolicited message from publisher", self); + dispatch_async(self.queue, ^{ + // OnUnsolicitedMessageFromPublisher + [self _handleUnsolicitedMessageFromPublisher]; + }); + }); + + // Set up a cluster state cache. We really just want this for the + // logic it has for tracking data versions and event numbers so we + // minimize the amount of data we request on resubscribes; we + // don't care about the data it stores. Ideally we could use the + // dataversion-management logic without needing to store the data + // separately from the data store we already have, or we would + // stop storing our data separately. + auto clusterStateCache = std::make_unique(*callback.get()); + auto readClient = std::make_unique(InteractionModelEngine::GetInstance(), exchangeManager, + clusterStateCache->GetBufferedCallback(), ReadClient::InteractionType::Subscribe); + + // SendAutoResubscribeRequest cleans up the params, even on failure. + CHIP_ERROR err = readClient->SendAutoResubscribeRequest(std::move(readParams)); + + if (err != CHIP_NO_ERROR) { + NSError * error = [MTRError errorForCHIPErrorCode:err]; + MTR_LOG_ERROR("%@ SendAutoResubscribeRequest error %@", self, error); + dispatch_async(self.queue, ^{ + [self _handleSubscriptionError:error]; + }); + + return; + } + + // Callback and ClusterStateCache and ReadClient will be deleted + // when OnDone is called. + os_unfair_lock_lock(&self->_lock); + self->_currentReadClient = readClient.get(); + os_unfair_lock_unlock(&self->_lock); + callback->AdoptReadClient(std::move(readClient)); + callback->AdoptClusterStateCache(std::move(clusterStateCache)); + callback.release(); + }]; } #pragma mark Device Interactions @@ -614,7 +614,7 @@ - (void)_setupSubscription // Create work item, set ready handler to perform task, then enqueue the work MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.queue]; MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { - MTR_LOG_INFO("%@ dequeueWorkItem %@", logPrefix, self->_asyncCallbackWorkQueue); + MTR_LOG_DEFAULT("%@ dequeueWorkItem %@", logPrefix, self->_asyncCallbackWorkQueue); MTRBaseDevice * baseDevice = [self newBaseDevice]; [baseDevice readAttributesWithEndpointID:endpointID @@ -632,17 +632,17 @@ - (void)_setupSubscription // TODO: better retry logic if (error && (retryCount < 2)) { - MTR_LOG_INFO( + MTR_LOG_ERROR( "%@ completion error %@ retryWork %lu", logPrefix, error, (unsigned long) retryCount); [workItem retryWork]; } else { - MTR_LOG_INFO("%@ completion error %@ endWork", logPrefix, error); + MTR_LOG_DEFAULT("%@ completion error %@ endWork", logPrefix, error); [workItem endWork]; } }]; }; workItem.readyHandler = readyHandler; - MTR_LOG_INFO("%@ enqueueWorkItem %@", logPrefix, _asyncCallbackWorkQueue); + MTR_LOG_DEFAULT("%@ enqueueWorkItem %@", logPrefix, _asyncCallbackWorkQueue); [_asyncCallbackWorkQueue enqueueWorkItem:workItem]; // Return current known / expected value right away @@ -678,7 +678,7 @@ - (void)writeAttributeWithEndpointID:(NSNumber *)endpointID MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.queue]; MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { - MTR_LOG_INFO("%@ dequeueWorkItem %@", logPrefix, self->_asyncCallbackWorkQueue); + MTR_LOG_DEFAULT("%@ dequeueWorkItem %@", logPrefix, self->_asyncCallbackWorkQueue); MTRBaseDevice * baseDevice = [self newBaseDevice]; [baseDevice writeAttributeWithEndpointID:endpointID @@ -688,7 +688,7 @@ - (void)writeAttributeWithEndpointID:(NSNumber *)endpointID timedWriteTimeout:timeout queue:self.queue completion:^(NSArray *> * _Nullable values, NSError * _Nullable error) { - MTR_LOG_INFO("%@ completion error %@ endWork", logPrefix, error); + MTR_LOG_DEFAULT("%@ completion error %@ endWork", logPrefix, error); [workItem endWork]; if (error) { [self removeExpectedValueForAttributePath:attributePath expectedValueID:expectedValueID]; @@ -696,7 +696,7 @@ - (void)writeAttributeWithEndpointID:(NSNumber *)endpointID }]; }; workItem.readyHandler = readyHandler; - MTR_LOG_INFO("%@ enqueueWorkItem %@", logPrefix, _asyncCallbackWorkQueue); + MTR_LOG_DEFAULT("%@ enqueueWorkItem %@", logPrefix, _asyncCallbackWorkQueue); [_asyncCallbackWorkQueue enqueueWorkItem:workItem]; } @@ -731,7 +731,7 @@ - (void)invokeCommandWithEndpointID:(NSNumber *)endpointID } MTRAsyncCallbackQueueWorkItem * workItem = [[MTRAsyncCallbackQueueWorkItem alloc] initWithQueue:self.queue]; MTRAsyncCallbackReadyHandler readyHandler = ^(MTRDevice * device, NSUInteger retryCount) { - MTR_LOG_INFO("%@ dequeueWorkItem %@", logPrefix, self->_asyncCallbackWorkQueue); + MTR_LOG_DEFAULT("%@ dequeueWorkItem %@", logPrefix, self->_asyncCallbackWorkQueue); MTRBaseDevice * baseDevice = [self newBaseDevice]; [baseDevice invokeCommandWithEndpointID:endpointID @@ -741,7 +741,10 @@ - (void)invokeCommandWithEndpointID:(NSNumber *)endpointID timedInvokeTimeout:timeout queue:self.queue completion:^(NSArray *> * _Nullable values, NSError * _Nullable error) { - MTR_LOG_INFO("%@ completion values %@ error %@ endWork", logPrefix, values, error); + // Log the data at the INFO level (not usually persisted permanently), + // but make sure we log the work completion at the DEFAULT level. + MTR_LOG_INFO("%@ received response: %@ error: %@", logPrefix, values, error); + MTR_LOG_DEFAULT("%@ endWork", logPrefix); dispatch_async(queue, ^{ completion(values, error); }); @@ -752,7 +755,7 @@ - (void)invokeCommandWithEndpointID:(NSNumber *)endpointID }]; }; workItem.readyHandler = readyHandler; - MTR_LOG_INFO("%@ enqueueWorkItem %@", logPrefix, _asyncCallbackWorkQueue); + MTR_LOG_DEFAULT("%@ enqueueWorkItem %@", logPrefix, _asyncCallbackWorkQueue); [_asyncCallbackWorkQueue enqueueWorkItem:workItem]; } diff --git a/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt b/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt index 2d4f79e355b668..75bb323bd542df 100644 --- a/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt +++ b/src/darwin/Framework/CHIP/templates/MTRClusters-src.zapt @@ -28,15 +28,18 @@ using chip::System::Clock::Timeout; using chip::System::Clock::Seconds16; static void MTRClustersLogEnqueue(NSString *logPrefix, MTRAsyncCallbackWorkQueue *workQueue) { - MTR_LOG_INFO("%@ enqueueWorkItem %@", logPrefix, workQueue); + MTR_LOG_DEFAULT("%@ enqueueWorkItem %@", logPrefix, workQueue); } static void MTRClustersLogDequeue(NSString *logPrefix, MTRAsyncCallbackWorkQueue *workQueue) { - MTR_LOG_INFO("%@ dequeueWorkItem %@", logPrefix, workQueue); + MTR_LOG_DEFAULT("%@ dequeueWorkItem %@", logPrefix, workQueue); } static void MTRClustersLogCompletion(NSString *logPrefix, id value, NSError *error) { - MTR_LOG_INFO("%@ completion value %@ error %@ endWork", logPrefix, value, error); + // Log the data at the INFO level (not usually persisted permanently), + // but make sure we log the work completion at the DEFAULT level. + MTR_LOG_INFO("%@ received response: %@ error: %@", logPrefix, value, error); + MTR_LOG_DEFAULT("%@ endWork", logPrefix); } // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks): Linter is unable to locate the delete on these objects. diff --git a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm index f87fef144fa28e..e13f27f1464c38 100644 --- a/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm +++ b/src/darwin/Framework/CHIP/zap-generated/MTRClusters.mm @@ -44,17 +44,20 @@ static void MTRClustersLogEnqueue(NSString * logPrefix, MTRAsyncCallbackWorkQueue * workQueue) { - MTR_LOG_INFO("%@ enqueueWorkItem %@", logPrefix, workQueue); + MTR_LOG_DEFAULT("%@ enqueueWorkItem %@", logPrefix, workQueue); } static void MTRClustersLogDequeue(NSString * logPrefix, MTRAsyncCallbackWorkQueue * workQueue) { - MTR_LOG_INFO("%@ dequeueWorkItem %@", logPrefix, workQueue); + MTR_LOG_DEFAULT("%@ dequeueWorkItem %@", logPrefix, workQueue); } static void MTRClustersLogCompletion(NSString * logPrefix, id value, NSError * error) { - MTR_LOG_INFO("%@ completion value %@ error %@ endWork", logPrefix, value, error); + // Log the data at the INFO level (not usually persisted permanently), + // but make sure we log the work completion at the DEFAULT level. + MTR_LOG_INFO("%@ received response: %@ error: %@", logPrefix, value, error); + MTR_LOG_DEFAULT("%@ endWork", logPrefix); } // NOLINTBEGIN(clang-analyzer-cplusplus.NewDeleteLeaks): Linter is unable to locate the delete on these objects. From bf0178cfc7e4b44f116f2130baa0e020045966f4 Mon Sep 17 00:00:00 2001 From: Wang Qixiang <43193572+wqx6@users.noreply.github.com> Date: Fri, 21 Apr 2023 09:38:05 +0800 Subject: [PATCH 12/54] ESP32: Send AAAA query when the SRV response does not include IP addresses records (#26139) ESP32: Improve the performance of platform mDNS resolving --- src/platform/ESP32/DnssdImpl.cpp | 334 ++++++++++++++++++++----------- src/platform/ESP32/DnssdImpl.h | 131 ++++++------ 2 files changed, 276 insertions(+), 189 deletions(-) diff --git a/src/platform/ESP32/DnssdImpl.cpp b/src/platform/ESP32/DnssdImpl.cpp index 1615ea9e1b9119..a16659a642141d 100644 --- a/src/platform/ESP32/DnssdImpl.cpp +++ b/src/platform/ESP32/DnssdImpl.cpp @@ -44,9 +44,9 @@ struct MdnsQuery }; static MdnsQuery * sQueryList = nullptr; -void MdnsQueryNotifier(mdns_search_once_t * searchHandle); +static void MdnsQueryNotifier(mdns_search_once_t * queryHandle); -CHIP_ERROR AddQueryList(GenericContext * ctx) +static CHIP_ERROR AddQueryList(GenericContext * ctx) { MdnsQuery * ret = static_cast(chip::Platform::MemoryAlloc(sizeof(MdnsQuery))); if (ret == nullptr) @@ -60,21 +60,36 @@ CHIP_ERROR AddQueryList(GenericContext * ctx) return CHIP_NO_ERROR; } -GenericContext * FindMdnsQuery(mdns_search_once_t * searchHandle) +static GenericContext * FindMdnsQuery(mdns_search_once_t * queryHandle) { MdnsQuery * current = sQueryList; while (current) { - if (current->ctx && current->ctx->mSearchHandle == searchHandle) + if (current->ctx) { - return current->ctx; + if (current->ctx->mContextType == ContextType::Browse) + { + BrowseContext * browseCtx = reinterpret_cast(current->ctx); + if (browseCtx->mPtrQueryHandle == queryHandle) + { + return current->ctx; + } + } + else if (current->ctx->mContextType == ContextType::Resolve) + { + ResolveContext * resolveCtx = reinterpret_cast(current->ctx); + if (resolveCtx->mSrvQueryHandle == queryHandle || resolveCtx->mTxtQueryHandle == queryHandle) + { + return current->ctx; + } + } } current = current->next; } return nullptr; } -CHIP_ERROR RemoveMdnsQuery(GenericContext * ctx) +static CHIP_ERROR RemoveMdnsQuery(GenericContext * ctx) { MdnsQuery * current = sQueryList; MdnsQuery * front = nullptr; @@ -200,7 +215,7 @@ CHIP_ERROR ChipDnssdFinalizeServiceUpdate() return CHIP_NO_ERROR; } -Inet::IPAddressType MapAddressType(mdns_ip_protocol_t ip_protocol) +static Inet::IPAddressType MapAddressType(mdns_ip_protocol_t ip_protocol) { switch (ip_protocol) { @@ -215,7 +230,7 @@ Inet::IPAddressType MapAddressType(mdns_ip_protocol_t ip_protocol) } } -TextEntry * GetTextEntry(mdns_txt_item_t * txt_array, uint8_t * txt_value_len, size_t txt_count) +static TextEntry * GetTextEntry(mdns_txt_item_t * txt_array, uint8_t * txt_value_len, size_t txt_count) { if (txt_count == 0 || txt_array == NULL) { @@ -234,7 +249,7 @@ TextEntry * GetTextEntry(mdns_txt_item_t * txt_array, uint8_t * txt_value_len, s return ret; } -CHIP_ERROR GetIPAddress(Inet::IPAddress & outIPAddress, mdns_ip_addr_t * mdnsIPAddr) +static CHIP_ERROR GetIPAddress(Inet::IPAddress & outIPAddress, mdns_ip_addr_t * mdnsIPAddr) { if (!mdnsIPAddr) { @@ -269,48 +284,48 @@ size_t GetResultSize(mdns_result_t * result) return ret; } -CHIP_ERROR OnBrowseDone(BrowseContext * ctx) +static CHIP_ERROR OnBrowseDone(BrowseContext * ctx) { CHIP_ERROR error = CHIP_NO_ERROR; mdns_result_t * currentResult = nullptr; size_t servicesIndex = 0; VerifyOrExit(ctx && ctx->mBrowseCb, error = CHIP_ERROR_INVALID_ARGUMENT); - if (ctx->mResult) + if (ctx->mPtrQueryResult) { - ctx->mServiceSize = GetResultSize(ctx->mResult); + ctx->mServiceSize = GetResultSize(ctx->mPtrQueryResult); if (ctx->mServiceSize > 0) { - ctx->mServices = static_cast(chip::Platform::MemoryCalloc(ctx->mServiceSize, sizeof(DnssdService))); - if (!ctx->mServices) + ctx->mService = static_cast(chip::Platform::MemoryCalloc(ctx->mServiceSize, sizeof(DnssdService))); + if (!ctx->mService) { ChipLogError(DeviceLayer, "Failed to alloc memory for Dnssd services"); ctx->mServiceSize = 0; error = CHIP_ERROR_NO_MEMORY; ExitNow(); } - currentResult = ctx->mResult; + currentResult = ctx->mPtrQueryResult; servicesIndex = 0; while (currentResult) { - Platform::CopyString(ctx->mServices[servicesIndex].mName, currentResult->instance_name); - Platform::CopyString(ctx->mServices[servicesIndex].mHostName, currentResult->hostname); - Platform::CopyString(ctx->mServices[servicesIndex].mType, currentResult->service_type); - ctx->mServices[servicesIndex].mProtocol = ctx->mProtocol; - ctx->mServices[servicesIndex].mAddressType = MapAddressType(currentResult->ip_protocol); - ctx->mServices[servicesIndex].mTransportType = ctx->mAddressType; - ctx->mServices[servicesIndex].mPort = currentResult->port; - ctx->mServices[servicesIndex].mInterface = ctx->mInterfaceId; - ctx->mServices[servicesIndex].mTextEntries = + Platform::CopyString(ctx->mService[servicesIndex].mName, currentResult->instance_name); + Platform::CopyString(ctx->mService[servicesIndex].mHostName, currentResult->hostname); + Platform::CopyString(ctx->mService[servicesIndex].mType, currentResult->service_type); + ctx->mService[servicesIndex].mProtocol = ctx->mProtocol; + ctx->mService[servicesIndex].mAddressType = MapAddressType(currentResult->ip_protocol); + ctx->mService[servicesIndex].mTransportType = ctx->mAddressType; + ctx->mService[servicesIndex].mPort = currentResult->port; + ctx->mService[servicesIndex].mInterface = ctx->mInterfaceId; + ctx->mService[servicesIndex].mTextEntries = GetTextEntry(currentResult->txt, currentResult->txt_value_len, currentResult->txt_count); - ctx->mServices[servicesIndex].mTextEntrySize = currentResult->txt_count; - ctx->mServices[servicesIndex].mSubTypes = NULL; - ctx->mServices[servicesIndex].mSubTypeSize = 0; + ctx->mService[servicesIndex].mTextEntrySize = currentResult->txt_count; + ctx->mService[servicesIndex].mSubTypes = NULL; + ctx->mService[servicesIndex].mSubTypeSize = 0; if (currentResult->addr) { Inet::IPAddress IPAddr; error = GetIPAddress(IPAddr, currentResult->addr); SuccessOrExit(error); - ctx->mServices[servicesIndex].mAddress.SetValue(IPAddr); + ctx->mService[servicesIndex].mAddress.SetValue(IPAddr); } currentResult = currentResult->next; servicesIndex++; @@ -318,7 +333,7 @@ CHIP_ERROR OnBrowseDone(BrowseContext * ctx) } } exit: - ctx->mBrowseCb(ctx->mCbContext, ctx->mServices, ctx->mServiceSize, true, error); + ctx->mBrowseCb(ctx->mCbContext, ctx->mService, ctx->mServiceSize, true, error); return RemoveMdnsQuery(reinterpret_cast(ctx)); } @@ -333,91 +348,95 @@ size_t GetAddressCount(mdns_ip_addr_t * addr) return ret; } -CHIP_ERROR OnResolveQuerySrvDone(ResolveContext * ctx) +static CHIP_ERROR ParseIPAddresses(ResolveContext * ctx) { - CHIP_ERROR error = CHIP_NO_ERROR; size_t addressIndex = 0; - - VerifyOrExit(ctx && ctx->mResolveCb, error = CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrExit(ctx->mService == nullptr && ctx->mResolveState == ResolveContext::ResolveState::QuerySrv, - error = CHIP_ERROR_INCORRECT_STATE); - if (ctx->mResult) - { - ctx->mService = static_cast(chip::Platform::MemoryAlloc(sizeof(DnssdService))); - VerifyOrExit(ctx->mService != nullptr, error = CHIP_ERROR_NO_MEMORY); - Platform::CopyString(ctx->mService->mName, ctx->mResult->instance_name); - Platform::CopyString(ctx->mService->mHostName, ctx->mResult->hostname); - Platform::CopyString(ctx->mService->mType, ctx->mResult->service_type); - ctx->mService->mProtocol = ctx->mProtocol; - ctx->mService->mAddressType = MapAddressType(ctx->mResult->ip_protocol); - ctx->mService->mTransportType = ctx->mService->mAddressType; - ctx->mService->mPort = ctx->mResult->port; - ctx->mService->mInterface = ctx->mInterfaceId; - ctx->mService->mSubTypes = nullptr; - ctx->mService->mSubTypeSize = 0; - - if (ctx->mResult->addr) + if (ctx->mAddrQueryResult && ctx->mAddrQueryResult->addr) + { + ctx->mAddressCount = GetAddressCount(ctx->mAddrQueryResult->addr); + if (ctx->mAddressCount > 0) { - ctx->mAddressCount = GetAddressCount(ctx->mResult->addr); - if (ctx->mAddressCount > 0) + ctx->mAddresses = + static_cast(chip::Platform::MemoryCalloc(ctx->mAddressCount, sizeof(Inet::IPAddress))); + if (ctx->mAddresses == nullptr) { - ctx->mAddresses = - static_cast(chip::Platform::MemoryCalloc(ctx->mAddressCount, sizeof(Inet::IPAddress))); - if (ctx->mAddresses == nullptr) - { - ChipLogError(DeviceLayer, "Failed to alloc memory for addresses"); - error = CHIP_ERROR_NO_MEMORY; - ctx->mAddressCount = 0; - ExitNow(); - } - auto * addr = ctx->mResult->addr; - while (addr) - { - GetIPAddress(ctx->mAddresses[addressIndex], addr); - addressIndex++; - addr = addr->next; - } + ChipLogError(DeviceLayer, "Failed to alloc memory for addresses"); + ctx->mAddressCount = 0; + return CHIP_ERROR_NO_MEMORY; } - else + auto * addr = ctx->mAddrQueryResult->addr; + while (addr) { - ctx->mAddresses = nullptr; - ctx->mAddressCount = 0; + GetIPAddress(ctx->mAddresses[addressIndex], addr); + addressIndex++; + addr = addr->next; } + return CHIP_NO_ERROR; } } -exit: - if (error != CHIP_NO_ERROR) - { - ctx->mResolveCb(ctx->mCbContext, nullptr, Span(nullptr, 0), error); - RemoveMdnsQuery(reinterpret_cast(ctx)); - return error; - } - mdns_query_results_free(ctx->mResult); - mdns_query_async_delete(ctx->mSearchHandle); - ctx->mResult = nullptr; - ctx->mResolveState = ResolveContext::ResolveState::QueryTxt; - // then query the text entries - ctx->mSearchHandle = mdns_query_async_new(ctx->mInstanceName, ctx->mType, GetProtocolString(ctx->mProtocol), MDNS_TYPE_TXT, - kTimeoutMilli, kMaxResults, MdnsQueryNotifier); - return CHIP_NO_ERROR; + return CHIP_ERROR_INVALID_ARGUMENT; } -CHIP_ERROR OnResolveQueryTxtDone(ResolveContext * ctx) +static CHIP_ERROR ParseSrvResult(ResolveContext * ctx) { - CHIP_ERROR error = CHIP_NO_ERROR; + if (ctx->mSrvQueryResult) + { + if (!ctx->mService) + { + ctx->mService = static_cast(chip::Platform::MemoryAlloc(sizeof(DnssdService))); + } + VerifyOrReturnError(ctx->mService, CHIP_ERROR_NO_MEMORY); + ctx->mServiceSize = 1; + Platform::CopyString(ctx->mService->mName, ctx->mSrvQueryResult->instance_name); + Platform::CopyString(ctx->mService->mHostName, ctx->mSrvQueryResult->hostname); + Platform::CopyString(ctx->mService->mType, ctx->mSrvQueryResult->service_type); + ctx->mService->mProtocol = ctx->mProtocol; + ctx->mService->mAddressType = MapAddressType(ctx->mSrvQueryResult->ip_protocol); + ctx->mService->mTransportType = ctx->mService->mAddressType; + ctx->mService->mPort = ctx->mSrvQueryResult->port; + ctx->mService->mInterface = ctx->mInterfaceId; + ctx->mService->mSubTypes = nullptr; + ctx->mService->mSubTypeSize = 0; + return CHIP_NO_ERROR; + } + else + { + ctx->mService = nullptr; + ctx->mServiceSize = 0; + } + return CHIP_ERROR_INVALID_ARGUMENT; +} - VerifyOrExit(ctx && ctx->mResolveCb, error = CHIP_ERROR_INVALID_ARGUMENT); - VerifyOrExit(ctx->mService && ctx->mResolveState == ResolveContext::ResolveState::QueryTxt, error = CHIP_ERROR_INCORRECT_STATE); - if (ctx->mResult) +// ParseTxtResult should be called after ParseSrvResult +static CHIP_ERROR ParseTxtResult(ResolveContext * ctx) +{ + VerifyOrReturnError(ctx->mService, CHIP_ERROR_INCORRECT_STATE); + if (ctx->mTxtQueryResult) { - ctx->mService->mTextEntries = GetTextEntry(ctx->mResult->txt, ctx->mResult->txt_value_len, ctx->mResult->txt_count); - ctx->mService->mTextEntrySize = ctx->mResult->txt_count; + ctx->mService->mTextEntries = + GetTextEntry(ctx->mTxtQueryResult->txt, ctx->mTxtQueryResult->txt_value_len, ctx->mTxtQueryResult->txt_count); + ctx->mService->mTextEntrySize = ctx->mTxtQueryResult->txt_count; } else { ctx->mService->mTextEntries = nullptr; ctx->mService->mTextEntrySize = 0; } + return CHIP_NO_ERROR; +} + +static CHIP_ERROR OnResolveDone(ResolveContext * ctx) +{ + CHIP_ERROR error = CHIP_NO_ERROR; + + VerifyOrExit(ctx && ctx->mResolveCb, error = CHIP_ERROR_INVALID_ARGUMENT); + VerifyOrExit(!ctx->mService && ctx->mSrvAddrQueryFinished && ctx->mTxtQueryFinished, error = CHIP_ERROR_INCORRECT_STATE); + error = ParseSrvResult(ctx); + SuccessOrExit(error); + error = ParseIPAddresses(ctx); + SuccessOrExit(error); + error = ParseTxtResult(ctx); + SuccessOrExit(error); exit: if (error != CHIP_NO_ERROR) { @@ -431,40 +450,103 @@ CHIP_ERROR OnResolveQueryTxtDone(ResolveContext * ctx) return error; } -void MdnsQueryDone(intptr_t context) +static mdns_result_t * MdnsQueryGetResults(mdns_search_once_t * queryHandle) +{ + mdns_result_t * ret = nullptr; +#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) + if (mdns_query_async_get_results(queryHandle, kTimeoutMilli, &ret, NULL)) +#else + if (mdns_query_async_get_results(queryHandle, kTimeoutMilli, &ret)) +#endif + { + return ret; + } + return nullptr; +} + +static void MdnsQueryDone(intptr_t context) { if (!context) { return; } - mdns_search_once_t * searchHandle = reinterpret_cast(context); - GenericContext * ctx = FindMdnsQuery(searchHandle); -#if ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) - if (mdns_query_async_get_results(searchHandle, kTimeoutMilli, &(ctx->mResult), NULL)) -#else - if (mdns_query_async_get_results(searchHandle, kTimeoutMilli, &(ctx->mResult))) -#endif // ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(5, 0, 0) + mdns_search_once_t * queryHandle = reinterpret_cast(context); + mdns_result_t * result = MdnsQueryGetResults(queryHandle); + GenericContext * ctx = FindMdnsQuery(queryHandle); + if (!ctx) { - if (ctx->mContextType == ContextType::Browse) - { - OnBrowseDone(reinterpret_cast(ctx)); - } - else if (ctx->mContextType == ContextType::Resolve) + mdns_query_results_free(result); + mdns_query_async_delete(queryHandle); + return; + } + if (ctx->mContextType == ContextType::Browse) + { + BrowseContext * browseCtx = reinterpret_cast(ctx); + browseCtx->mPtrQueryResult = result; + OnBrowseDone(browseCtx); + } + else if (ctx->mContextType == ContextType::Resolve) + { + + ResolveContext * resolveCtx = reinterpret_cast(ctx); + if (resolveCtx->mSrvQueryHandle == queryHandle) { - ResolveContext * resolveCtx = reinterpret_cast(ctx); - if (resolveCtx->mResolveState == ResolveContext::ResolveState::QuerySrv) + // No result found. + if (!result) + { + resolveCtx->mResolveCb(ctx->mCbContext, nullptr, Span(nullptr, 0), CHIP_ERROR_INVALID_ARGUMENT); + RemoveMdnsQuery(ctx); + return; + } + // If SRV Query Result is empty, the result is for SRV Query. + if (!resolveCtx->mSrvQueryResult) + { + resolveCtx->mSrvQueryResult = result; + if (result->addr) + { + resolveCtx->mAddrQueryResult = result; + resolveCtx->mSrvAddrQueryFinished = true; + } + else + { + // If there is no A/AAAA records in SRV query response, we will send an AAAA query for the IP addresses. + mdns_query_async_delete(resolveCtx->mSrvQueryHandle); + resolveCtx->mAddrQueryResult = nullptr; + resolveCtx->mSrvQueryHandle = mdns_query_async_new(result->hostname, NULL, NULL, MDNS_TYPE_AAAA, kTimeoutMilli, + kMaxResults, MdnsQueryNotifier); + if (!resolveCtx->mSrvQueryHandle) + { + resolveCtx->mResolveCb(ctx->mCbContext, nullptr, Span(nullptr, 0), CHIP_ERROR_NO_MEMORY); + RemoveMdnsQuery(ctx); + return; + } + } + } + else if (!resolveCtx->mAddrQueryResult) { - OnResolveQuerySrvDone(resolveCtx); + resolveCtx->mAddrQueryResult = result; + resolveCtx->mSrvAddrQueryFinished = true; } - else if (resolveCtx->mResolveState == ResolveContext::ResolveState::QueryTxt) + else { - OnResolveQueryTxtDone(resolveCtx); + resolveCtx->mResolveCb(ctx->mCbContext, nullptr, Span(nullptr, 0), CHIP_ERROR_INCORRECT_STATE); + RemoveMdnsQuery(ctx); + return; } } + else if (resolveCtx->mTxtQueryHandle == queryHandle) + { + resolveCtx->mTxtQueryResult = result; + resolveCtx->mTxtQueryFinished = true; + } + if (resolveCtx->mTxtQueryFinished && resolveCtx->mSrvAddrQueryFinished) + { + OnResolveDone(resolveCtx); + } } } -void MdnsQueryNotifier(mdns_search_once_t * searchHandle) +static void MdnsQueryNotifier(mdns_search_once_t * searchHandle) { chip::DeviceLayer::PlatformMgr().ScheduleWork(MdnsQueryDone, reinterpret_cast(searchHandle)); } @@ -474,14 +556,15 @@ CHIP_ERROR ChipDnssdBrowse(const char * type, DnssdServiceProtocol protocol, chi intptr_t * browseIdentifier) { CHIP_ERROR error = CHIP_NO_ERROR; - mdns_search_once_t * searchHandle = + mdns_search_once_t * queryHandle = mdns_query_async_new(NULL, type, GetProtocolString(protocol), MDNS_TYPE_PTR, kTimeoutMilli, kMaxResults, MdnsQueryNotifier); + VerifyOrReturnError(queryHandle, CHIP_ERROR_NO_MEMORY); BrowseContext * ctx = - chip::Platform::New(type, protocol, interface, searchHandle, addressType, callback, context); + chip::Platform::New(type, protocol, interface, queryHandle, addressType, callback, context); if (!ctx) { ChipLogError(DeviceLayer, "Failed to alloc memory for browse context"); - mdns_query_async_delete(searchHandle); + mdns_query_async_delete(queryHandle); return CHIP_ERROR_NO_MEMORY; } error = AddQueryList(reinterpret_cast(ctx)); @@ -504,14 +587,23 @@ CHIP_ERROR ChipDnssdStopBrowse(intptr_t browseIdentifier) CHIP_ERROR ChipDnssdResolve(DnssdService * service, chip::Inet::InterfaceId interface, DnssdResolveCallback callback, void * context) { - CHIP_ERROR error = CHIP_NO_ERROR; - mdns_search_once_t * searchHandle = mdns_query_async_new(service->mName, service->mType, GetProtocolString(service->mProtocol), - MDNS_TYPE_SRV, kTimeoutMilli, kMaxResults, MdnsQueryNotifier); - ResolveContext * ctx = chip::Platform::New(service, interface, searchHandle, callback, context); + CHIP_ERROR error = CHIP_NO_ERROR; + mdns_search_once_t * querySrv = mdns_query_async_new(service->mName, service->mType, GetProtocolString(service->mProtocol), + MDNS_TYPE_SRV, kTimeoutMilli, kMaxResults, MdnsQueryNotifier); + VerifyOrReturnError(querySrv, CHIP_ERROR_NO_MEMORY); + mdns_search_once_t * queryTxt = mdns_query_async_new(service->mName, service->mType, GetProtocolString(service->mProtocol), + MDNS_TYPE_TXT, kTimeoutMilli, kMaxResults, MdnsQueryNotifier); + if (!queryTxt) + { + mdns_query_async_delete(querySrv); + return CHIP_ERROR_NO_MEMORY; + } + ResolveContext * ctx = chip::Platform::New(service, interface, querySrv, queryTxt, callback, context); if (!ctx) { ChipLogError(DeviceLayer, "Failed to alloc memory for resolve context"); - mdns_query_async_delete(searchHandle); + mdns_query_async_delete(querySrv); + mdns_query_async_delete(queryTxt); return CHIP_ERROR_NO_MEMORY; } error = AddQueryList(reinterpret_cast(ctx)); diff --git a/src/platform/ESP32/DnssdImpl.h b/src/platform/ESP32/DnssdImpl.h index 7f84eebb0fcbd9..658ec8fe67c7f6 100644 --- a/src/platform/ESP32/DnssdImpl.h +++ b/src/platform/ESP32/DnssdImpl.h @@ -32,57 +32,56 @@ enum class ContextType struct GenericContext { ContextType mContextType; - void * mCbContext; char mType[kDnssdTypeMaxSize + 1]; DnssdServiceProtocol mProtocol; Inet::InterfaceId mInterfaceId; - mdns_search_once_t * mSearchHandle; - mdns_result_t * mResult; -}; - -struct BrowseContext : public GenericContext -{ - DnssdBrowseCallback mBrowseCb; - Inet::IPAddressType mAddressType; - DnssdService * mServices; - size_t mServiceSize; - BrowseContext(const char * type, DnssdServiceProtocol protocol, Inet::InterfaceId ifId, mdns_search_once_t * searchHandle, - Inet::IPAddressType addrType, DnssdBrowseCallback cb, void * cbCtx) - + void * mCbContext; + DnssdService * mService = nullptr; + size_t mServiceSize = 0; + GenericContext(ContextType ctxType, const char * type, DnssdServiceProtocol protocol, Inet::InterfaceId ifId, void * cbCtx) : + mContextType(ctxType), mProtocol(protocol), mInterfaceId(ifId), mCbContext(cbCtx) { Platform::CopyString(mType, type); - mContextType = ContextType::Browse; - mAddressType = addrType; - mProtocol = protocol; - mBrowseCb = cb; - mCbContext = cbCtx; - mInterfaceId = ifId; - mSearchHandle = searchHandle; - mResult = nullptr; - mServices = nullptr; - mServiceSize = 0; } - - ~BrowseContext() + ~GenericContext() { - if (mServices && mServiceSize > 0) + if (mService && mServiceSize > 0) { for (size_t serviceIndex = 0; serviceIndex < mServiceSize; serviceIndex++) { - if (mServices[serviceIndex].mTextEntries) + if (mService[serviceIndex].mTextEntries) { - chip::Platform::MemoryFree(mServices[serviceIndex].mTextEntries); + chip::Platform::MemoryFree(mService[serviceIndex].mTextEntries); } } - chip::Platform::MemoryFree(mServices); + chip::Platform::MemoryFree(mService); } - if (mResult) + } +}; + +struct BrowseContext : public GenericContext +{ + DnssdBrowseCallback mBrowseCb; + Inet::IPAddressType mAddressType; + mdns_search_once_t * mPtrQueryHandle; + mdns_result_t * mPtrQueryResult = nullptr; + BrowseContext(const char * type, DnssdServiceProtocol protocol, Inet::InterfaceId ifId, mdns_search_once_t * queryHandle, + Inet::IPAddressType addrType, DnssdBrowseCallback cb, void * cbCtx) : + GenericContext(ContextType::Browse, type, protocol, ifId, cbCtx), + mBrowseCb(cb), mAddressType(addrType), mPtrQueryHandle(queryHandle) + + {} + + ~BrowseContext() + { + if (mPtrQueryResult) { - mdns_query_results_free(mResult); + mdns_query_results_free(mPtrQueryResult); } - if (mSearchHandle) + + if (mPtrQueryHandle) { - mdns_query_async_delete(mSearchHandle); + mdns_query_async_delete(mPtrQueryHandle); } } }; @@ -91,55 +90,51 @@ struct ResolveContext : public GenericContext { char mInstanceName[Common::kInstanceNameMaxLength + 1]; DnssdResolveCallback mResolveCb; - DnssdService * mService; - Inet::IPAddress * mAddresses; - size_t mAddressCount; + Inet::IPAddress * mAddresses = nullptr; + size_t mAddressCount = 0; - enum class ResolveState - { - QuerySrv, - QueryTxt, - } mResolveState; + mdns_search_once_t * mSrvQueryHandle; + mdns_result_t * mSrvQueryResult = nullptr; + mdns_result_t * mAddrQueryResult = nullptr; + bool mSrvAddrQueryFinished = false; + + mdns_search_once_t * mTxtQueryHandle; + mdns_result_t * mTxtQueryResult = nullptr; + bool mTxtQueryFinished = false; - ResolveContext(DnssdService * service, Inet::InterfaceId ifId, mdns_search_once_t * searchHandle, DnssdResolveCallback cb, - void * cbCtx) + ResolveContext(DnssdService * service, Inet::InterfaceId ifId, mdns_search_once_t * srvQuery, mdns_search_once_t * txtQuery, + DnssdResolveCallback cb, void * cbCtx) : + GenericContext(ContextType::Resolve, service->mType, service->mProtocol, ifId, cbCtx), + mResolveCb(cb), mSrvQueryHandle(srvQuery), mTxtQueryHandle(txtQuery) { - Platform::CopyString(mType, service->mType); Platform::CopyString(mInstanceName, service->mName); - mContextType = ContextType::Resolve; - mProtocol = service->mProtocol; - mResolveCb = cb; - mCbContext = cbCtx; - mInterfaceId = ifId; - mSearchHandle = searchHandle; - mResolveState = ResolveState::QuerySrv; - mResult = nullptr; - mService = nullptr; - mAddresses = nullptr; - mAddressCount = 0; } ~ResolveContext() { - if (mService) - { - if (mService->mTextEntries) - { - chip::Platform::MemoryFree(mService->mTextEntries); - } - chip::Platform::MemoryFree(mService); - } if (mAddresses) { chip::Platform::MemoryFree(mAddresses); } - if (mResult) + if (mSrvQueryResult) + { + mdns_query_results_free(mSrvQueryResult); + } + if (mAddrQueryResult && mAddrQueryResult != mSrvQueryResult) + { + mdns_query_results_free(mAddrQueryResult); + } + if (mTxtQueryResult) + { + mdns_query_results_free(mTxtQueryResult); + } + if (mSrvQueryHandle) { - mdns_query_results_free(mResult); + mdns_query_async_delete(mSrvQueryHandle); } - if (mSearchHandle) + if (mTxtQueryHandle) { - mdns_query_async_delete(mSearchHandle); + mdns_query_async_delete(mTxtQueryHandle); } } }; From 2eaf956b653901db4fa9df486364251fc45e199f Mon Sep 17 00:00:00 2001 From: Erwin Pan Date: Fri, 21 Apr 2023 09:42:25 +0800 Subject: [PATCH 13/54] [Chef] Fix compile -a doesn't work on ESP32 (#26095) * [Chef] Fix compile -a doesn't work on ESP32 with `chef.py --automated_test_stamp` we can assign timestamp as software version string when compiling chef sample device. However, this failed on ESP32. On ESP32, I found that it uses PROJECT_VER to overwrite CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING, so I set it in the esp32's CMakeLists.txt * chef.py set default sw_ver_string from "v1.0" to"" * Add comment in examples/chef/esp32/CMakeLists.txt --- examples/chef/chef.py | 5 +++-- examples/chef/esp32/CMakeLists.txt | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/examples/chef/chef.py b/examples/chef/chef.py index e69d3418fa021d..930309f8ddc07a 100755 --- a/examples/chef/chef.py +++ b/examples/chef/chef.py @@ -615,10 +615,11 @@ def main() -> int: f"\"{truncated_sw_ver_string}\" due to 64 bytes limitation") sw_ver_string = truncated_sw_ver_string - flush_print("Building...") - + flush_print(f"Software Version String: \"{sw_ver_string}\"") flush_print( f"Product ID 0x{options.pid:02X} / Vendor ID 0x{options.vid:02X}") + flush_print("Building...") + shell.run_cmd(f"cd {_CHEF_SCRIPT_PATH}") if (options.build_target == "esp32") or (options.build_target == "nrfconnect") or (options.build_target == "ameba"): diff --git a/examples/chef/esp32/CMakeLists.txt b/examples/chef/esp32/CMakeLists.txt index f4ea7c13eefede..950e07c59e9d90 100644 --- a/examples/chef/esp32/CMakeLists.txt +++ b/examples/chef/esp32/CMakeLists.txt @@ -46,8 +46,10 @@ idf_build_set_property(COMPILE_OPTIONS "-DCHIP_DEVICE_CONFIG_DEVICE_PRODUCT_ID=$ if(NOT ${CONFIG_DEVICE_PRODUCT_NAME} STREQUAL "") idf_build_set_property(COMPILE_OPTIONS "-DCHIP_DEVICE_CONFIG_DEVICE_PRODUCT_NAME=\"${CONFIG_DEVICE_PRODUCT_NAME}\"" APPEND) endif() +# Forwarding the customized software version string to the ESP32 firmware image if(NOT ${CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING} STREQUAL "") idf_build_set_property(COMPILE_OPTIONS "-DCHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING=\"${CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING}\"" APPEND) + set(PROJECT_VER ${CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING}) endif() idf_build_set_property(COMPILE_OPTIONS "-DCHIP_PLATFORM_ESP32=1" APPEND) From f3f7ecdc7ed681b0fc34a63764273cf5d6b06ae2 Mon Sep 17 00:00:00 2001 From: hyunuktak Date: Fri, 21 Apr 2023 11:44:48 +0900 Subject: [PATCH 14/54] [Tizen] Implement DiagnosticDataProvider interface (#26060) * [Tizen] Implement DiagnosticDataProvider interface * Restyled by clang-format * Apply some comments * Allocate memory for the bssid to WiFiMgr Signed-off-by: hyunuk.tak * Change to MutableByteSpan. But leave it as not implementation now. * Restyled by clang-format * Copy into the caller provided buffer --------- Signed-off-by: hyunuk.tak Co-authored-by: Restyled.io --- .../Linux/ConfigurationManagerImpl.cpp | 2 - .../Tizen/ConfigurationManagerImpl.cpp | 26 +- src/platform/Tizen/ConfigurationManagerImpl.h | 5 + .../Tizen/ConnectivityManagerImpl.cpp | 82 +++ src/platform/Tizen/ConnectivityManagerImpl.h | 9 + src/platform/Tizen/ConnectivityUtils.cpp | 657 +++++++++++++++++- src/platform/Tizen/ConnectivityUtils.h | 37 +- .../Tizen/DiagnosticDataProviderImpl.cpp | 624 ++++++++++++++++- .../Tizen/DiagnosticDataProviderImpl.h | 66 +- src/platform/Tizen/PlatformManagerImpl.cpp | 2 + src/platform/Tizen/PlatformManagerImpl.h | 3 + src/platform/Tizen/PosixConfig.cpp | 5 + src/platform/Tizen/PosixConfig.h | 3 + src/platform/Tizen/WiFiManager.cpp | 79 +++ src/platform/Tizen/WiFiManager.h | 4 + 15 files changed, 1582 insertions(+), 22 deletions(-) diff --git a/src/platform/Linux/ConfigurationManagerImpl.cpp b/src/platform/Linux/ConfigurationManagerImpl.cpp index e3710959e5a6f1..44e77e4e290ebe 100644 --- a/src/platform/Linux/ConfigurationManagerImpl.cpp +++ b/src/platform/Linux/ConfigurationManagerImpl.cpp @@ -23,8 +23,6 @@ * for Linux platforms. */ -#include - #include #include #include diff --git a/src/platform/Tizen/ConfigurationManagerImpl.cpp b/src/platform/Tizen/ConfigurationManagerImpl.cpp index 961df4130d4603..9d56863167076a 100644 --- a/src/platform/Tizen/ConfigurationManagerImpl.cpp +++ b/src/platform/Tizen/ConfigurationManagerImpl.cpp @@ -29,14 +29,16 @@ #include #include #include +#include +#include -#include "PosixConfig.h" #include "WiFiManager.h" -#include "platform/internal/GenericConfigurationManagerImpl.ipp" namespace chip { namespace DeviceLayer { +using namespace ::chip::DeviceLayer::Internal; + ConfigurationManagerImpl & ConfigurationManagerImpl::GetDefaultInstance() { static ConfigurationManagerImpl sInstance; @@ -175,6 +177,26 @@ void ConfigurationManagerImpl::RunConfigUnitTest() Internal::PosixConfig::RunConfigUnitTest(); } +CHIP_ERROR ConfigurationManagerImpl::GetTotalOperationalHours(uint32_t & totalOperationalHours) +{ + return ReadConfigValue(PosixConfig::kCounterKey_TotalOperationalHours, totalOperationalHours); +} + +CHIP_ERROR ConfigurationManagerImpl::StoreTotalOperationalHours(uint32_t totalOperationalHours) +{ + return WriteConfigValue(PosixConfig::kCounterKey_TotalOperationalHours, totalOperationalHours); +} + +CHIP_ERROR ConfigurationManagerImpl::GetBootReason(uint32_t & bootReason) +{ + return ReadConfigValue(PosixConfig::kCounterKey_BootReason, bootReason); +} + +CHIP_ERROR ConfigurationManagerImpl::StoreBootReason(uint32_t bootReason) +{ + return WriteConfigValue(PosixConfig::kCounterKey_BootReason, bootReason); +} + ConfigurationManager & ConfigurationMgrImpl() { return ConfigurationManagerImpl::GetDefaultInstance(); diff --git a/src/platform/Tizen/ConfigurationManagerImpl.h b/src/platform/Tizen/ConfigurationManagerImpl.h index ee9ddc5b427b07..e7f5d9d3b65c3b 100644 --- a/src/platform/Tizen/ConfigurationManagerImpl.h +++ b/src/platform/Tizen/ConfigurationManagerImpl.h @@ -46,6 +46,11 @@ class ConfigurationManagerImpl : public Internal::GenericConfigurationManagerImp CHIP_ERROR StoreVendorId(uint16_t vendorId); CHIP_ERROR StoreProductId(uint16_t productId); + CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours) override; + CHIP_ERROR StoreTotalOperationalHours(uint32_t totalOperationalHours) override; + CHIP_ERROR GetBootReason(uint32_t & bootReason) override; + CHIP_ERROR StoreBootReason(uint32_t bootReason) override; + // This returns an instance of this class. static ConfigurationManagerImpl & GetDefaultInstance(); diff --git a/src/platform/Tizen/ConnectivityManagerImpl.cpp b/src/platform/Tizen/ConnectivityManagerImpl.cpp index a954b6b7e0fbfc..9000ee710c0664 100644 --- a/src/platform/Tizen/ConnectivityManagerImpl.cpp +++ b/src/platform/Tizen/ConnectivityManagerImpl.cpp @@ -34,6 +34,8 @@ #include #include #include +#include + #include #include @@ -55,15 +57,32 @@ #include "WiFiManager.h" #endif +using namespace ::chip::DeviceLayer::Internal; +using namespace ::chip::app::Clusters::WiFiNetworkDiagnostics; + namespace chip { namespace DeviceLayer { ConnectivityManagerImpl ConnectivityManagerImpl::sInstance; +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +char ConnectivityManagerImpl::sWiFiIfName[]; +#endif + CHIP_ERROR ConnectivityManagerImpl::_Init() { CHIP_ERROR err = CHIP_NO_ERROR; + if (ConnectivityUtils::GetEthInterfaceName(mEthIfName, IFNAMSIZ) == CHIP_NO_ERROR) + { + ChipLogProgress(DeviceLayer, "Got Ethernet interface: %s", mEthIfName); + } + else + { + ChipLogError(DeviceLayer, "Failed to get Ethernet interface"); + mEthIfName[0] = '\0'; + } + #if CHIP_DEVICE_CONFIG_ENABLE_WIFI mWiFiStationMode = kWiFiStationMode_Disabled; mWiFiAPMode = kWiFiAPMode_Disabled; @@ -73,6 +92,16 @@ CHIP_ERROR ConnectivityManagerImpl::_Init() mWiFiAPIdleTimeout = System::Clock::Milliseconds32(CHIP_DEVICE_CONFIG_WIFI_AP_IDLE_TIMEOUT); Internal::WiFiMgr().Init(); + + if (ConnectivityUtils::GetWiFiInterfaceName(sWiFiIfName, IFNAMSIZ) == CHIP_NO_ERROR) + { + ChipLogProgress(DeviceLayer, "Got WiFi interface: %s", sWiFiIfName); + } + else + { + ChipLogError(DeviceLayer, "Failed to get WiFi interface"); + sWiFiIfName[0] = '\0'; + } #endif return err; @@ -224,6 +253,59 @@ bool ConnectivityManagerImpl::IsWiFiManagementStarted() return isActivated; } +CHIP_ERROR ConnectivityManagerImpl::GetWiFiBssId(MutableByteSpan & value) +{ + constexpr size_t bssIdSize = 6; + VerifyOrReturnError(value.size() >= bssIdSize, CHIP_ERROR_BUFFER_TOO_SMALL); + + uint8_t * bssId = nullptr; + CHIP_ERROR err = Internal::WiFiMgr().GetBssId(bssId); + ReturnErrorOnFailure(err); + + memcpy(value.data(), bssId, bssIdSize); + value.reduce_size(bssIdSize); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR ConnectivityManagerImpl::GetWiFiSecurityType(SecurityTypeEnum & securityType) +{ + wifi_manager_security_type_e secType; + CHIP_ERROR err = Internal::WiFiMgr().GetSecurityType(&secType); + ReturnErrorOnFailure(err); + + switch (secType) + { + case WIFI_MANAGER_SECURITY_TYPE_NONE: + securityType = SecurityTypeEnum::kNone; + break; + case WIFI_MANAGER_SECURITY_TYPE_WEP: + securityType = SecurityTypeEnum::kWep; + break; + case WIFI_MANAGER_SECURITY_TYPE_WPA_PSK: + securityType = SecurityTypeEnum::kWpa; + break; + case WIFI_MANAGER_SECURITY_TYPE_WPA2_PSK: + securityType = SecurityTypeEnum::kWpa2; + break; + case WIFI_MANAGER_SECURITY_TYPE_EAP: + case WIFI_MANAGER_SECURITY_TYPE_WPA_FT_PSK: + case WIFI_MANAGER_SECURITY_TYPE_SAE: + case WIFI_MANAGER_SECURITY_TYPE_OWE: + case WIFI_MANAGER_SECURITY_TYPE_DPP: + default: + securityType = SecurityTypeEnum::kUnspecified; + break; + } + + return CHIP_NO_ERROR; +} + +CHIP_ERROR ConnectivityManagerImpl::GetWiFiVersion(WiFiVersionEnum & wiFiVersion) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + #endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI } // namespace DeviceLayer diff --git a/src/platform/Tizen/ConnectivityManagerImpl.h b/src/platform/Tizen/ConnectivityManagerImpl.h index 32edbc146c9b0e..04d692a1f05f8f 100644 --- a/src/platform/Tizen/ConnectivityManagerImpl.h +++ b/src/platform/Tizen/ConnectivityManagerImpl.h @@ -87,8 +87,14 @@ class ConnectivityManagerImpl final : public ConnectivityManager, void StartWiFiManagement(); void StopWiFiManagement(); bool IsWiFiManagementStarted(); + CHIP_ERROR GetWiFiBssId(MutableByteSpan & value); + CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType); + CHIP_ERROR GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wiFiVersion); + const char * GetWiFiIfName() { return (sWiFiIfName[0] == '\0') ? nullptr : sWiFiIfName; } #endif + const char * GetEthernetIfName() { return (mEthIfName[0] == '\0') ? nullptr : mEthIfName; } + private: // ===== Members that implement the ConnectivityManager abstract interface. @@ -127,6 +133,8 @@ class ConnectivityManagerImpl final : public ConnectivityManager, // ===== Private members reserved for use by this class only. + char mEthIfName[IFNAMSIZ]; + #if CHIP_DEVICE_CONFIG_ENABLE_WIFI ConnectivityManager::WiFiStationMode mWiFiStationMode; ConnectivityManager::WiFiAPMode mWiFiAPMode; @@ -134,6 +142,7 @@ class ConnectivityManagerImpl final : public ConnectivityManager, System::Clock::Timestamp mLastAPDemandTime; System::Clock::Timeout mWiFiStationReconnectInterval; System::Clock::Timeout mWiFiAPIdleTimeout; + static char sWiFiIfName[IFNAMSIZ]; #endif }; diff --git a/src/platform/Tizen/ConnectivityUtils.cpp b/src/platform/Tizen/ConnectivityUtils.cpp index 4a1f94e5c7453e..c5aa2437adbb60 100644 --- a/src/platform/Tizen/ConnectivityUtils.cpp +++ b/src/platform/Tizen/ConnectivityUtils.cpp @@ -17,14 +17,11 @@ #include "ConnectivityUtils.h" -// XXX: This is a workaround for a bug in the Tizen SDK header files. It is not -// possible to include both and at the same time. -// This will cause warning that struct ifmap is redefined. On Linux, this -// is not a problem, because in the struct is guarded with -// ifdef. To prevent this, we will define _LINUX_IF_H, so the -// will not be included. -#define _LINUX_IF_H +#include +#include +#include +#include #include #include #include @@ -35,19 +32,50 @@ #include -#include #include #include +using namespace ::chip::app::Clusters::GeneralDiagnostics; +using namespace ::chip::app::Clusters::EthernetNetworkDiagnostics; + namespace chip { namespace DeviceLayer { namespace Internal { -app::Clusters::GeneralDiagnostics::InterfaceTypeEnum ConnectivityUtils::GetInterfaceConnectionType(const char * ifname) +uint16_t ConnectivityUtils::MapChannelToFrequency(const uint16_t inBand, const uint8_t inChannel) +{ + uint16_t frequency = 0; + + if (inBand == kWiFi_BAND_2_4_GHZ) + { + frequency = Map2400MHz(inChannel); + } + else if (inBand == kWiFi_BAND_5_0_GHZ) + { + frequency = Map5000MHz(inChannel); + } + + return frequency; +} + +uint8_t ConnectivityUtils::MapFrequencyToChannel(const uint16_t frequency) +{ + if (frequency < 2412) + return 0; + + if (frequency < 2484) + return static_cast((frequency - 2407) / 5); + + if (frequency == 2484) + return 14; + + return static_cast(frequency / 5 - 1000); +} + +InterfaceTypeEnum ConnectivityUtils::GetInterfaceConnectionType(const char * ifname) { - app::Clusters::GeneralDiagnostics::InterfaceTypeEnum ret = - app::Clusters::GeneralDiagnostics::InterfaceTypeEnum::EMBER_ZCL_INTERFACE_TYPE_ENUM_UNSPECIFIED; - int sock = -1; + InterfaceTypeEnum ret = InterfaceTypeEnum::EMBER_ZCL_INTERFACE_TYPE_ENUM_UNSPECIFIED; + int sock = -1; if ((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1) { @@ -61,7 +89,7 @@ app::Clusters::GeneralDiagnostics::InterfaceTypeEnum ConnectivityUtils::GetInter if (ioctl(sock, SIOCGIWNAME, &pwrq) != -1) { - ret = app::Clusters::GeneralDiagnostics::InterfaceTypeEnum::EMBER_ZCL_INTERFACE_TYPE_ENUM_WI_FI; + ret = InterfaceTypeEnum::EMBER_ZCL_INTERFACE_TYPE_ENUM_WI_FI; } else if ((strncmp(ifname, "en", 2) == 0) || (strncmp(ifname, "eth", 3) == 0)) { @@ -72,7 +100,7 @@ app::Clusters::GeneralDiagnostics::InterfaceTypeEnum ConnectivityUtils::GetInter Platform::CopyString(ifr.ifr_name, ifname); if (ioctl(sock, SIOCETHTOOL, &ifr) != -1) - ret = app::Clusters::GeneralDiagnostics::InterfaceTypeEnum::EMBER_ZCL_INTERFACE_TYPE_ENUM_ETHERNET; + ret = InterfaceTypeEnum::EMBER_ZCL_INTERFACE_TYPE_ENUM_ETHERNET; } close(sock); @@ -80,6 +108,607 @@ app::Clusters::GeneralDiagnostics::InterfaceTypeEnum ConnectivityUtils::GetInter return ret; } +CHIP_ERROR ConnectivityUtils::GetInterfaceHardwareAddrs(const char * ifname, uint8_t * buf, size_t bufSize) +{ + CHIP_ERROR err = CHIP_ERROR_READ_FAILED; + int skfd; + + if (ifname[0] == '\0') + { + ChipLogError(DeviceLayer, "Invalid argument for interface name"); + return CHIP_ERROR_INVALID_ARGUMENT; + } + + if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + { + ChipLogError(DeviceLayer, "Failed to create a channel to the NET kernel."); + return CHIP_ERROR_OPEN_FAILED; + } + + struct ifreq req; + Platform::CopyString(req.ifr_name, ifname); + if (ioctl(skfd, SIOCGIFHWADDR, &req) != -1) + { + // Copy 48-bit IEEE MAC Address + VerifyOrReturnError(bufSize >= 6, CHIP_ERROR_BUFFER_TOO_SMALL); + + memset(buf, 0, bufSize); + memcpy(buf, req.ifr_ifru.ifru_hwaddr.sa_data, 6); + err = CHIP_NO_ERROR; + } + + close(skfd); + return err; +} + +CHIP_ERROR ConnectivityUtils::GetInterfaceIPv4Addrs(const char * ifname, uint8_t & size, NetworkInterface * ifp) +{ + CHIP_ERROR err = CHIP_ERROR_READ_FAILED; + struct ifaddrs * ifaddr = nullptr; + + if (getifaddrs(&ifaddr) == -1) + { + ChipLogError(DeviceLayer, "Failed to get network interfaces"); + return err; + } + + uint8_t index = 0; + for (struct ifaddrs * ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) + { + if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET) + { + if (strcmp(ifname, ifa->ifa_name) == 0) + { + void * addPtr = &((struct sockaddr_in *) ifa->ifa_addr)->sin_addr; + + memcpy(ifp->Ipv4AddressesBuffer[index], addPtr, kMaxIPv4AddrSize); + ifp->Ipv4AddressSpans[index] = ByteSpan(ifp->Ipv4AddressesBuffer[index], kMaxIPv4AddrSize); + index++; + + if (index >= kMaxIPv4AddrCount) + { + break; + } + } + } + } + + if (index > 0) + { + err = CHIP_NO_ERROR; + size = index; + } + + freeifaddrs(ifaddr); + return err; +} + +CHIP_ERROR ConnectivityUtils::GetInterfaceIPv6Addrs(const char * ifname, uint8_t & size, NetworkInterface * ifp) +{ + CHIP_ERROR err = CHIP_ERROR_READ_FAILED; + struct ifaddrs * ifaddr = nullptr; + + if (getifaddrs(&ifaddr) == -1) + { + ChipLogError(DeviceLayer, "Failed to get network interfaces"); + return err; + } + + uint8_t index = 0; + for (struct ifaddrs * ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) + { + if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_INET6) + { + if (strcmp(ifname, ifa->ifa_name) == 0) + { + void * addPtr = &((struct sockaddr_in6 *) ifa->ifa_addr)->sin6_addr; + + memcpy(ifp->Ipv6AddressesBuffer[index], addPtr, kMaxIPv6AddrSize); + ifp->Ipv6AddressSpans[index] = ByteSpan(ifp->Ipv6AddressesBuffer[index], kMaxIPv6AddrSize); + index++; + + if (index >= kMaxIPv6AddrCount) + { + break; + } + } + } + } + + if (index > 0) + { + err = CHIP_NO_ERROR; + size = index; + } + + freeifaddrs(ifaddr); + return err; +} + +CHIP_ERROR ConnectivityUtils::GetWiFiInterfaceName(char * ifname, size_t bufSize) +{ + CHIP_ERROR err = CHIP_ERROR_READ_FAILED; + struct ifaddrs * ifaddr = nullptr; + + if (getifaddrs(&ifaddr) == -1) + { + ChipLogError(DeviceLayer, "Failed to get network interfaces"); + return err; + } + + struct ifaddrs * ifa = nullptr; + for (ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) + { + if (GetInterfaceConnectionType(ifa->ifa_name) == InterfaceTypeEnum::EMBER_ZCL_INTERFACE_TYPE_ENUM_WI_FI) + { + Platform::CopyString(ifname, bufSize, ifa->ifa_name); + err = CHIP_NO_ERROR; + break; + } + } + + freeifaddrs(ifaddr); + return err; +} + +CHIP_ERROR ConnectivityUtils::GetWiFiChannelNumber(const char * ifname, uint16_t & channelNumber) +{ + CHIP_ERROR err = CHIP_ERROR_READ_FAILED; + struct iwreq wrq; + int skfd; + + if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + { + ChipLogError(DeviceLayer, "Failed to create a channel to the NET kernel."); + return CHIP_ERROR_OPEN_FAILED; + } + + if ((err = GetWiFiParameter(skfd, ifname, SIOCGIWFREQ, &wrq)) == CHIP_NO_ERROR) + { + double freq = ConvertFrequenceToFloat(&(wrq.u.freq)); + VerifyOrReturnError((freq / 1000000) <= UINT16_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + channelNumber = MapFrequencyToChannel(static_cast(freq / 1000000)); + + err = CHIP_NO_ERROR; + } + else + { + ChipLogError(DeviceLayer, "Failed to get channel/frequency (Hz).") + } + + close(skfd); + return err; +} + +CHIP_ERROR ConnectivityUtils::GetWiFiRssi(const char * ifname, int8_t & rssi) +{ + CHIP_ERROR err = CHIP_ERROR_READ_FAILED; + struct iw_statistics stats; + int skfd; + + if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + { + ChipLogError(DeviceLayer, "Failed to create a channel to the NET kernel."); + return CHIP_ERROR_OPEN_FAILED; + } + + if ((err = GetWiFiStats(skfd, ifname, &stats)) == CHIP_NO_ERROR) + { + struct iw_quality * qual = &stats.qual; + + if (qual->updated & IW_QUAL_RCPI) + { + /* RCPI = int{(Power in dBm +110)*2} for 0dbm > Power > -110dBm */ + if (!(qual->updated & IW_QUAL_LEVEL_INVALID)) + { + double rcpilevel = (qual->level / 2.0) - 110.0; + VerifyOrReturnError(rcpilevel <= INT8_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + rssi = static_cast(rcpilevel); + err = CHIP_NO_ERROR; + } + } + else + { + if (qual->updated & IW_QUAL_DBM) + { + if (!(qual->updated & IW_QUAL_LEVEL_INVALID)) + { + int dblevel = qual->level; + /* dBm[-192; 63] */ + if (qual->level >= 64) + dblevel -= 0x100; + + VerifyOrReturnError(dblevel <= INT8_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + rssi = static_cast(dblevel); + err = CHIP_NO_ERROR; + } + } + else + { + if (!(qual->updated & IW_QUAL_LEVEL_INVALID)) + { + VerifyOrReturnError(qual->level <= INT8_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + rssi = static_cast(qual->level); + err = CHIP_NO_ERROR; + } + } + } + } + else + { + ChipLogError(DeviceLayer, "Failed to get /proc/net/wireless stats.") + } + + close(skfd); + return err; +} + +CHIP_ERROR ConnectivityUtils::GetWiFiBeaconLostCount(const char * ifname, uint32_t & beaconLostCount) +{ + CHIP_ERROR err = CHIP_ERROR_READ_FAILED; + struct iw_statistics stats; + int skfd; + + if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + { + ChipLogError(DeviceLayer, "Failed to create a channel to the NET kernel."); + return CHIP_ERROR_OPEN_FAILED; + } + + if (GetWiFiStats(skfd, ifname, &stats) == CHIP_NO_ERROR) + { + beaconLostCount = stats.miss.beacon; + err = CHIP_NO_ERROR; + } + + close(skfd); + return err; +} + +CHIP_ERROR ConnectivityUtils::GetWiFiCurrentMaxRate(const char * ifname, uint64_t & currentMaxRate) +{ + CHIP_ERROR err = CHIP_ERROR_READ_FAILED; + struct iwreq wrq; + int skfd; + + if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + { + ChipLogError(DeviceLayer, "Failed to create a channel to the NET kernel."); + return CHIP_ERROR_OPEN_FAILED; + } + + if ((err = GetWiFiParameter(skfd, ifname, SIOCGIWRATE, &wrq)) == CHIP_NO_ERROR) + { + currentMaxRate = wrq.u.bitrate.value; + err = CHIP_NO_ERROR; + } + else + { + ChipLogError(DeviceLayer, "Failed to get channel/frequency (Hz).") + } + + close(skfd); + return err; +} + +CHIP_ERROR ConnectivityUtils::GetEthInterfaceName(char * ifname, size_t bufSize) +{ + CHIP_ERROR err = CHIP_ERROR_READ_FAILED; + struct ifaddrs * ifaddr = nullptr; + + if (getifaddrs(&ifaddr) == -1) + { + ChipLogError(DeviceLayer, "Failed to get network interfaces"); + return err; + } + + struct ifaddrs * ifa = nullptr; + for (ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) + { + if (GetInterfaceConnectionType(ifa->ifa_name) == InterfaceTypeEnum::EMBER_ZCL_INTERFACE_TYPE_ENUM_ETHERNET) + { + Platform::CopyString(ifname, bufSize, ifa->ifa_name); + err = CHIP_NO_ERROR; + break; + } + } + + freeifaddrs(ifaddr); + return err; +} + +CHIP_ERROR ConnectivityUtils::GetEthPHYRate(const char * ifname, PHYRateEnum & pHYRate) +{ + CHIP_ERROR err = CHIP_NO_ERROR; + + int skfd; + uint32_t speed = 0; + struct ethtool_cmd ecmd = {}; + ecmd.cmd = ETHTOOL_GSET; + struct ifreq ifr = {}; + + ifr.ifr_data = reinterpret_cast(&ecmd); + Platform::CopyString(ifr.ifr_name, ifname); + + if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + { + ChipLogError(DeviceLayer, "Failed to create a channel to the NET kernel."); + return CHIP_ERROR_OPEN_FAILED; + } + + if (ioctl(skfd, SIOCETHTOOL, &ifr) == -1) + { + ChipLogError(DeviceLayer, "Cannot get device settings"); + close(skfd); + return CHIP_ERROR_READ_FAILED; + } + + speed = (ecmd.speed_hi << 16) | ecmd.speed; + switch (speed) + { + case 10: + pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE10_M; + break; + case 100: + pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE100_M; + break; + case 1000: + pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE1_G; + break; + case 25000: + pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE2_5_G; + break; + case 5000: + pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE5_G; + break; + case 10000: + pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE10_G; + break; + case 40000: + pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE40_G; + break; + case 100000: + pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE100_G; + break; + case 200000: + pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE200_G; + break; + case 400000: + pHYRate = EmberAfPHYRateEnum::EMBER_ZCL_PHY_RATE_ENUM_RATE400_G; + break; + default: + ChipLogError(DeviceLayer, "Undefined speed! (%d)\n", speed); + err = CHIP_ERROR_READ_FAILED; + break; + }; + + close(skfd); + + return err; +} + +CHIP_ERROR ConnectivityUtils::GetEthFullDuplex(const char * ifname, bool & fullDuplex) +{ + CHIP_ERROR err = CHIP_ERROR_READ_FAILED; + + int skfd; + struct ethtool_cmd ecmd = {}; + ecmd.cmd = ETHTOOL_GSET; + struct ifreq ifr = {}; + + ifr.ifr_data = reinterpret_cast(&ecmd); + Platform::CopyString(ifr.ifr_name, ifname); + + if ((skfd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) + { + ChipLogError(DeviceLayer, "Failed to create a channel to the NET kernel."); + return CHIP_ERROR_OPEN_FAILED; + } + + if (ioctl(skfd, SIOCETHTOOL, &ifr) == -1) + { + ChipLogError(DeviceLayer, "Cannot get device settings"); + err = CHIP_ERROR_READ_FAILED; + } + else + { + fullDuplex = ecmd.duplex == DUPLEX_FULL; + err = CHIP_NO_ERROR; + } + + close(skfd); + + return err; +} + +uint16_t ConnectivityUtils::Map2400MHz(const uint8_t inChannel) +{ + uint16_t frequency = 0; + + if (inChannel >= 1 && inChannel <= 13) + { + frequency = static_cast(2412 + ((inChannel - 1) * 5)); + } + else if (inChannel == 14) + { + frequency = 2484; + } + + return frequency; +} + +uint16_t ConnectivityUtils::Map5000MHz(const uint8_t inChannel) +{ + uint16_t frequency = 0; + + switch (inChannel) + { + case 183: + frequency = 4915; + break; + case 184: + frequency = 4920; + break; + case 185: + frequency = 4925; + break; + case 187: + frequency = 4935; + break; + case 188: + frequency = 4940; + break; + case 189: + frequency = 4945; + break; + case 192: + frequency = 4960; + break; + case 196: + frequency = 4980; + break; + case 7: + frequency = 5035; + break; + case 8: + frequency = 5040; + break; + case 9: + frequency = 5045; + break; + case 11: + frequency = 5055; + break; + case 12: + frequency = 5060; + break; + case 16: + frequency = 5080; + break; + case 34: + frequency = 5170; + break; + case 36: + frequency = 5180; + break; + case 38: + frequency = 5190; + break; + case 40: + frequency = 5200; + break; + case 42: + frequency = 5210; + break; + case 44: + frequency = 5220; + break; + case 46: + frequency = 5230; + break; + case 48: + frequency = 5240; + break; + case 52: + frequency = 5260; + break; + case 56: + frequency = 5280; + break; + case 60: + frequency = 5300; + break; + case 64: + frequency = 5320; + break; + case 100: + frequency = 5500; + break; + case 104: + frequency = 5520; + break; + case 108: + frequency = 5540; + break; + case 112: + frequency = 5560; + break; + case 116: + frequency = 5580; + break; + case 120: + frequency = 5600; + break; + case 124: + frequency = 5620; + break; + case 128: + frequency = 5640; + break; + case 132: + frequency = 5660; + break; + case 136: + frequency = 5680; + break; + case 140: + frequency = 5700; + break; + case 149: + frequency = 5745; + break; + case 153: + frequency = 5765; + break; + case 157: + frequency = 5785; + break; + case 161: + frequency = 5805; + break; + case 165: + frequency = 5825; + break; + } + + return frequency; +} + +double ConnectivityUtils::ConvertFrequenceToFloat(const iw_freq * in) +{ + double result = (double) in->m; + + for (int i = 0; i < in->e; i++) + result *= 10; + + return result; +} + +CHIP_ERROR ConnectivityUtils::GetWiFiParameter(int skfd, /* Socket to the kernel */ + const char * ifname, /* Device name */ + int request, /* WE ID */ + struct iwreq * pwrq) /* Fixed part of the request */ +{ + Platform::CopyString(pwrq->ifr_name, ifname); + + if (ioctl(skfd, request, pwrq) < 0) + return CHIP_ERROR_BAD_REQUEST; + + return CHIP_NO_ERROR; +} + +CHIP_ERROR ConnectivityUtils::GetWiFiStats(int skfd, const char * ifname, struct iw_statistics * stats) +{ + struct iwreq wrq; + + wrq.u.data.pointer = (caddr_t) stats; + wrq.u.data.length = sizeof(struct iw_statistics); + wrq.u.data.flags = 1; /*Clear updated flag */ + Platform::CopyString(wrq.ifr_name, ifname); + + return GetWiFiParameter(skfd, ifname, SIOCGIWSTATS, &wrq); +} + } // namespace Internal } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Tizen/ConnectivityUtils.h b/src/platform/Tizen/ConnectivityUtils.h index 16fb18268d8a79..a292b5f2ae682a 100644 --- a/src/platform/Tizen/ConnectivityUtils.h +++ b/src/platform/Tizen/ConnectivityUtils.h @@ -17,18 +17,51 @@ #pragma once -#include +#include +#include -#include "platform/internal/CHIPDeviceLayerInternal.h" +// XXX: This is a workaround for a bug in the Tizen SDK header files. It is not +// possible to include both and at the same time. +// This will cause warning that struct ifmap is redefined. On Linux, this +// is not a problem, because in the struct is guarded with +// ifdef. To prevent this, we will define _LINUX_IF_H, so the +// will not be included. +#define _LINUX_IF_H + +#include +#include namespace chip { namespace DeviceLayer { namespace Internal { +static constexpr uint16_t kWiFi_BAND_2_4_GHZ = 2400; +static constexpr uint16_t kWiFi_BAND_5_0_GHZ = 5000; + class ConnectivityUtils { public: + static uint16_t MapChannelToFrequency(const uint16_t inBand, const uint8_t inChannel); + static uint8_t MapFrequencyToChannel(const uint16_t frequency); static app::Clusters::GeneralDiagnostics::InterfaceTypeEnum GetInterfaceConnectionType(const char * ifname); + static CHIP_ERROR GetInterfaceHardwareAddrs(const char * ifname, uint8_t * buf, size_t bufSize); + static CHIP_ERROR GetInterfaceIPv4Addrs(const char * ifname, uint8_t & size, NetworkInterface * ifp); + static CHIP_ERROR GetInterfaceIPv6Addrs(const char * ifname, uint8_t & size, NetworkInterface * ifp); + static CHIP_ERROR GetWiFiInterfaceName(char * ifname, size_t bufSize); + static CHIP_ERROR GetWiFiChannelNumber(const char * ifname, uint16_t & channelNumber); + static CHIP_ERROR GetWiFiRssi(const char * ifname, int8_t & rssi); + static CHIP_ERROR GetWiFiBeaconLostCount(const char * ifname, uint32_t & beaconLostCount); + static CHIP_ERROR GetWiFiCurrentMaxRate(const char * ifname, uint64_t & currentMaxRate); + static CHIP_ERROR GetEthInterfaceName(char * ifname, size_t bufSize); + static CHIP_ERROR GetEthPHYRate(const char * ifname, app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum & pHYRate); + static CHIP_ERROR GetEthFullDuplex(const char * ifname, bool & fullDuplex); + +private: + static uint16_t Map2400MHz(const uint8_t inChannel); + static uint16_t Map5000MHz(const uint8_t inChannel); + static double ConvertFrequenceToFloat(const iw_freq * in); + static CHIP_ERROR GetWiFiParameter(int skfd, const char * ifname, int request, struct iwreq * pwrq); + static CHIP_ERROR GetWiFiStats(int skfd, const char * ifname, struct iw_statistics * stats); }; } // namespace Internal diff --git a/src/platform/Tizen/DiagnosticDataProviderImpl.cpp b/src/platform/Tizen/DiagnosticDataProviderImpl.cpp index ad143a4e642269..952cbb46db9ac9 100644 --- a/src/platform/Tizen/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Tizen/DiagnosticDataProviderImpl.cpp @@ -21,9 +21,164 @@ * for Tizen platform. */ -#include "DiagnosticDataProviderImpl.h" +#include +#include #include +#include +#include + +#include +#include +#include + +using namespace ::chip::app; +using namespace ::chip::DeviceLayer::Internal; +using namespace ::chip::app::Clusters::GeneralDiagnostics; + +namespace { + +enum class EthernetStatsCountType +{ + kEthPacketRxCount, + kEthPacketTxCount, + kEthTxErrCount, + kEthCollisionCount, + kEthOverrunCount +}; + +enum class WiFiStatsCountType +{ + kWiFiUnicastPacketRxCount, + kWiFiUnicastPacketTxCount, + kWiFiMulticastPacketRxCount, + kWiFiMulticastPacketTxCount, + kWiFiOverrunCount +}; + +CHIP_ERROR GetEthernetStatsCount(EthernetStatsCountType type, uint64_t & count) +{ + CHIP_ERROR err = CHIP_ERROR_READ_FAILED; + struct ifaddrs * ifaddr = nullptr; + + if (getifaddrs(&ifaddr) == -1) + { + ChipLogError(DeviceLayer, "Failed to get network interfaces"); + return err; + } + + struct ifaddrs * ifa = nullptr; + for (ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) + { + if (ConnectivityUtils::GetInterfaceConnectionType(ifa->ifa_name) == + InterfaceTypeEnum::EMBER_ZCL_INTERFACE_TYPE_ENUM_ETHERNET) + { + ChipLogProgress(DeviceLayer, "Found the primary Ethernet interface:%s", StringOrNullMarker(ifa->ifa_name)); + break; + } + } + + if (ifa != nullptr) + { + if (ifa->ifa_addr->sa_family == AF_PACKET && ifa->ifa_data != nullptr) + { + struct rtnl_link_stats * stats = (struct rtnl_link_stats *) ifa->ifa_data; + switch (type) + { + case EthernetStatsCountType::kEthPacketRxCount: + count = stats->rx_packets; + err = CHIP_NO_ERROR; + break; + case EthernetStatsCountType::kEthPacketTxCount: + count = stats->tx_packets; + err = CHIP_NO_ERROR; + break; + case EthernetStatsCountType::kEthTxErrCount: + count = stats->tx_errors; + err = CHIP_NO_ERROR; + break; + case EthernetStatsCountType::kEthCollisionCount: + count = stats->collisions; + err = CHIP_NO_ERROR; + break; + case EthernetStatsCountType::kEthOverrunCount: + count = stats->rx_over_errors; + err = CHIP_NO_ERROR; + break; + default: + ChipLogError(DeviceLayer, "Unknown Ethernet statistic metric type"); + break; + } + } + } + + freeifaddrs(ifaddr); + return err; +} + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +CHIP_ERROR GetWiFiStatsCount(WiFiStatsCountType type, uint64_t & count) +{ + CHIP_ERROR err = CHIP_ERROR_READ_FAILED; + struct ifaddrs * ifaddr = nullptr; + + if (getifaddrs(&ifaddr) == -1) + { + ChipLogError(DeviceLayer, "Failed to get network interfaces"); + return err; + } + + struct ifaddrs * ifa = nullptr; + for (ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) + { + if (ConnectivityUtils::GetInterfaceConnectionType(ifa->ifa_name) == InterfaceTypeEnum::EMBER_ZCL_INTERFACE_TYPE_ENUM_WI_FI) + { + ChipLogProgress(DeviceLayer, "Found the primary WiFi interface:%s", StringOrNullMarker(ifa->ifa_name)); + break; + } + } + + if (ifa != nullptr) + { + if (ifa->ifa_addr->sa_family == AF_PACKET && ifa->ifa_data != nullptr) + { + struct rtnl_link_stats * stats = (struct rtnl_link_stats *) ifa->ifa_data; + switch (type) + { + case WiFiStatsCountType::kWiFiUnicastPacketRxCount: + count = stats->rx_packets; + err = CHIP_NO_ERROR; + break; + case WiFiStatsCountType::kWiFiUnicastPacketTxCount: + count = stats->tx_packets; + err = CHIP_NO_ERROR; + break; + case WiFiStatsCountType::kWiFiMulticastPacketRxCount: + count = stats->multicast; + err = CHIP_NO_ERROR; + break; + case WiFiStatsCountType::kWiFiMulticastPacketTxCount: + count = 0; + err = CHIP_NO_ERROR; + break; + case WiFiStatsCountType::kWiFiOverrunCount: + count = stats->rx_over_errors; + err = CHIP_NO_ERROR; + break; + default: + ChipLogError(DeviceLayer, "Unknown WiFi statistic metric type"); + break; + } + } + } + + freeifaddrs(ifaddr); + + return err; +} +#endif // #if CHIP_DEVICE_CONFIG_ENABLE_WIFI + +} // namespace namespace chip { namespace DeviceLayer { @@ -34,6 +189,473 @@ DiagnosticDataProviderImpl & DiagnosticDataProviderImpl::GetDefaultInstance() return sInstance; } +CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapFree(uint64_t & currentHeapFree) +{ + struct mallinfo mallocInfo = mallinfo(); + currentHeapFree = mallocInfo.fordblks; + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapUsed(uint64_t & currentHeapUsed) +{ + struct mallinfo mallocInfo = mallinfo(); + currentHeapUsed = mallocInfo.uordblks; + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR DiagnosticDataProviderImpl::ResetWatermarks() +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetThreadMetrics(ThreadMetrics ** threadMetricsOut) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +void DiagnosticDataProviderImpl::ReleaseThreadMetrics(ThreadMetrics * threadMetrics) {} + +CHIP_ERROR DiagnosticDataProviderImpl::GetRebootCount(uint16_t & rebootCount) +{ + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetUpTime(uint64_t & upTime) +{ + System::Clock::Timestamp currentTime = System::SystemClock().GetMonotonicTimestamp(); + System::Clock::Timestamp startTime = PlatformMgrImpl().GetStartTime(); + + if (currentTime < startTime) + return CHIP_ERROR_INVALID_TIME; + + upTime = std::chrono::duration_cast(currentTime - startTime).count(); + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetTotalOperationalHours(uint32_t & totalOperationalHours) +{ + uint64_t upTime = 0; + + if (GetUpTime(upTime) == CHIP_NO_ERROR) + { + uint32_t totalHours = 0; + if (ConfigurationMgr().GetTotalOperationalHours(totalHours) == CHIP_NO_ERROR) + { + VerifyOrReturnError(upTime / 3600 <= UINT32_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + totalOperationalHours = totalHours + static_cast(upTime / 3600); + return CHIP_NO_ERROR; + } + } + + return CHIP_ERROR_INVALID_TIME; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetBootReason(BootReasonType & bootReason) +{ + uint32_t reason = 0; + + CHIP_ERROR err = ConfigurationMgr().GetBootReason(reason); + if (err == CHIP_NO_ERROR) + { + VerifyOrReturnError(reason <= UINT8_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + bootReason = static_cast(reason); + } + + return err; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetActiveHardwareFaults(GeneralFaults & hardwareFaults) +{ + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetActiveRadioFaults(GeneralFaults & radioFaults) +{ + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetActiveNetworkFaults(GeneralFaults & networkFaults) +{ + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** netifpp) +{ + CHIP_ERROR err = CHIP_ERROR_READ_FAILED; + struct ifaddrs * ifaddr = nullptr; + + if (getifaddrs(&ifaddr) == -1) + { + ChipLogError(DeviceLayer, "Failed to get network interfaces"); + return err; + } + + NetworkInterface * head = nullptr; + for (struct ifaddrs * ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) + { + if (ifa->ifa_addr && ifa->ifa_addr->sa_family == AF_PACKET) + { + uint8_t size = 0; + NetworkInterface * ifp = new NetworkInterface(); + + Platform::CopyString(ifp->Name, ifa->ifa_name); + + ifp->name = CharSpan::fromCharString(ifp->Name); + ifp->isOperational = ifa->ifa_flags & IFF_RUNNING; + ifp->type = ConnectivityUtils::GetInterfaceConnectionType(ifa->ifa_name); + ifp->offPremiseServicesReachableIPv4.SetNull(); + ifp->offPremiseServicesReachableIPv6.SetNull(); + + if (ConnectivityUtils::GetInterfaceIPv4Addrs(ifa->ifa_name, size, ifp) == CHIP_NO_ERROR) + { + if (size > 0) + { + ifp->IPv4Addresses = DataModel::List(ifp->Ipv4AddressSpans, size); + } + } + + if (ConnectivityUtils::GetInterfaceIPv6Addrs(ifa->ifa_name, size, ifp) == CHIP_NO_ERROR) + { + if (size > 0) + { + ifp->IPv6Addresses = DataModel::List(ifp->Ipv6AddressSpans, size); + } + } + + if (ConnectivityUtils::GetInterfaceHardwareAddrs(ifa->ifa_name, ifp->MacAddress, kMaxHardwareAddrSize) != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "Failed to get network hardware address"); + } + else + { + // Set 48-bit IEEE MAC Address + ifp->hardwareAddress = ByteSpan(ifp->MacAddress, 6); + } + + ifp->Next = head; + head = ifp; + } + } + + *netifpp = head; + err = CHIP_NO_ERROR; + + freeifaddrs(ifaddr); + + return err; +} + +void DiagnosticDataProviderImpl::ReleaseNetworkInterfaces(NetworkInterface * netifp) +{ + while (netifp) + { + NetworkInterface * del = netifp; + netifp = netifp->Next; + delete del; + } +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetEthPHYRate(app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum & pHYRate) +{ + if (ConnectivityMgrImpl().GetEthernetIfName() == nullptr) + { + return CHIP_ERROR_READ_FAILED; + } + + return ConnectivityUtils::GetEthPHYRate(ConnectivityMgrImpl().GetEthernetIfName(), pHYRate); +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetEthFullDuplex(bool & fullDuplex) +{ + if (ConnectivityMgrImpl().GetEthernetIfName() == nullptr) + { + return CHIP_ERROR_READ_FAILED; + } + + return ConnectivityUtils::GetEthFullDuplex(ConnectivityMgrImpl().GetEthernetIfName(), fullDuplex); +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetEthTimeSinceReset(uint64_t & timeSinceReset) +{ + return GetDiagnosticDataProvider().GetUpTime(timeSinceReset); +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetEthPacketRxCount(uint64_t & packetRxCount) +{ + uint64_t count; + + ReturnErrorOnFailure(GetEthernetStatsCount(EthernetStatsCountType::kEthPacketRxCount, count)); + VerifyOrReturnError(count >= mEthPacketRxCount, CHIP_ERROR_INVALID_INTEGER_VALUE); + + packetRxCount = count - mEthPacketRxCount; + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetEthPacketTxCount(uint64_t & packetTxCount) +{ + uint64_t count; + + ReturnErrorOnFailure(GetEthernetStatsCount(EthernetStatsCountType::kEthPacketTxCount, count)); + VerifyOrReturnError(count >= mEthPacketTxCount, CHIP_ERROR_INVALID_INTEGER_VALUE); + + packetTxCount = count - mEthPacketTxCount; + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetEthTxErrCount(uint64_t & txErrCount) +{ + uint64_t count; + + ReturnErrorOnFailure(GetEthernetStatsCount(EthernetStatsCountType::kEthTxErrCount, count)); + VerifyOrReturnError(count >= mEthTxErrCount, CHIP_ERROR_INVALID_INTEGER_VALUE); + + txErrCount = count - mEthTxErrCount; + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetEthCollisionCount(uint64_t & collisionCount) +{ + uint64_t count; + + ReturnErrorOnFailure(GetEthernetStatsCount(EthernetStatsCountType::kEthCollisionCount, count)); + VerifyOrReturnError(count >= mEthCollisionCount, CHIP_ERROR_INVALID_INTEGER_VALUE); + + collisionCount = count - mEthCollisionCount; + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetEthOverrunCount(uint64_t & overrunCount) +{ + uint64_t count; + + ReturnErrorOnFailure(GetEthernetStatsCount(EthernetStatsCountType::kEthOverrunCount, count)); + VerifyOrReturnError(count >= mEthOverrunCount, CHIP_ERROR_INVALID_INTEGER_VALUE); + + overrunCount = count - mEthOverrunCount; + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::ResetEthNetworkDiagnosticsCounts() +{ + CHIP_ERROR err = CHIP_ERROR_READ_FAILED; + struct ifaddrs * ifaddr = nullptr; + + if (getifaddrs(&ifaddr) == -1) + { + ChipLogError(DeviceLayer, "Failed to get network interfaces"); + return err; + } + + struct ifaddrs * ifa = nullptr; + for (ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) + { + if (ConnectivityUtils::GetInterfaceConnectionType(ifa->ifa_name) == + InterfaceTypeEnum::EMBER_ZCL_INTERFACE_TYPE_ENUM_ETHERNET) + { + ChipLogProgress(DeviceLayer, "Found the primary Ethernet interface:%s", StringOrNullMarker(ifa->ifa_name)); + break; + } + } + + if (ifa != nullptr) + { + if (ifa->ifa_addr->sa_family == AF_PACKET && ifa->ifa_data != nullptr) + { + struct rtnl_link_stats * stats = (struct rtnl_link_stats *) ifa->ifa_data; + + mEthPacketRxCount = stats->rx_packets; + mEthPacketTxCount = stats->tx_packets; + mEthTxErrCount = stats->tx_errors; + mEthCollisionCount = stats->collisions; + mEthOverrunCount = stats->rx_over_errors; + err = CHIP_NO_ERROR; + } + } + + freeifaddrs(ifaddr); + return err; +} + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBssId(MutableByteSpan & bssId) +{ + return ConnectivityMgrImpl().GetWiFiBssId(bssId); +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType) +{ + return ConnectivityMgrImpl().GetWiFiSecurityType(securityType); +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wiFiVersion) +{ + return ConnectivityMgrImpl().GetWiFiVersion(wiFiVersion); +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiChannelNumber(uint16_t & channelNumber) +{ + if (ConnectivityMgrImpl().GetWiFiIfName() == nullptr) + return CHIP_ERROR_READ_FAILED; + + return ConnectivityUtils::GetWiFiChannelNumber(ConnectivityMgrImpl().GetWiFiIfName(), channelNumber); +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiRssi(int8_t & rssi) +{ + if (ConnectivityMgrImpl().GetWiFiIfName() == nullptr) + return CHIP_ERROR_READ_FAILED; + + return ConnectivityUtils::GetWiFiRssi(ConnectivityMgrImpl().GetWiFiIfName(), rssi); +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiBeaconLostCount(uint32_t & beaconLostCount) +{ + uint32_t count; + + if (ConnectivityMgrImpl().GetWiFiIfName() == nullptr) + return CHIP_ERROR_READ_FAILED; + + ReturnErrorOnFailure(ConnectivityUtils::GetWiFiBeaconLostCount(ConnectivityMgrImpl().GetWiFiIfName(), count)); + VerifyOrReturnError(count >= mBeaconLostCount, CHIP_ERROR_INVALID_INTEGER_VALUE); + beaconLostCount = count - mBeaconLostCount; + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiCurrentMaxRate(uint64_t & currentMaxRate) +{ + if (ConnectivityMgrImpl().GetWiFiIfName() == nullptr) + return CHIP_ERROR_READ_FAILED; + + return ConnectivityUtils::GetWiFiCurrentMaxRate(ConnectivityMgrImpl().GetWiFiIfName(), currentMaxRate); +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketMulticastRxCount(uint32_t & packetMulticastRxCount) +{ + uint64_t count; + + ReturnErrorOnFailure(GetWiFiStatsCount(WiFiStatsCountType::kWiFiMulticastPacketRxCount, count)); + VerifyOrReturnError(count >= mPacketMulticastRxCount, CHIP_ERROR_INVALID_INTEGER_VALUE); + + count -= mPacketMulticastRxCount; + VerifyOrReturnError(count <= UINT32_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + + packetMulticastRxCount = static_cast(count); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketMulticastTxCount(uint32_t & packetMulticastTxCount) +{ + uint64_t count; + + ReturnErrorOnFailure(GetWiFiStatsCount(WiFiStatsCountType::kWiFiMulticastPacketTxCount, count)); + VerifyOrReturnError(count >= mPacketMulticastTxCount, CHIP_ERROR_INVALID_INTEGER_VALUE); + + count -= mPacketMulticastTxCount; + VerifyOrReturnError(count <= UINT32_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + + packetMulticastTxCount = static_cast(count); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketUnicastRxCount(uint32_t & packetUnicastRxCount) +{ + uint64_t count; + + ReturnErrorOnFailure(GetWiFiStatsCount(WiFiStatsCountType::kWiFiUnicastPacketRxCount, count)); + VerifyOrReturnError(count >= mPacketUnicastRxCount, CHIP_ERROR_INVALID_INTEGER_VALUE); + + count -= mPacketUnicastRxCount; + VerifyOrReturnError(count <= UINT32_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + + packetUnicastRxCount = static_cast(count); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiPacketUnicastTxCount(uint32_t & packetUnicastTxCount) +{ + uint64_t count; + + ReturnErrorOnFailure(GetWiFiStatsCount(WiFiStatsCountType::kWiFiUnicastPacketTxCount, count)); + VerifyOrReturnError(count >= mPacketUnicastTxCount, CHIP_ERROR_INVALID_INTEGER_VALUE); + + count -= mPacketUnicastTxCount; + VerifyOrReturnError(count <= UINT32_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + + packetUnicastTxCount = static_cast(count); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::GetWiFiOverrunCount(uint64_t & overrunCount) +{ + uint64_t count; + + ReturnErrorOnFailure(GetWiFiStatsCount(WiFiStatsCountType::kWiFiOverrunCount, count)); + VerifyOrReturnError(count >= mOverrunCount, CHIP_ERROR_INVALID_INTEGER_VALUE); + + overrunCount = count - mOverrunCount; + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DiagnosticDataProviderImpl::ResetWiFiNetworkDiagnosticsCounts() +{ + CHIP_ERROR err = CHIP_ERROR_READ_FAILED; + struct ifaddrs * ifaddr = nullptr; + + ReturnErrorOnFailure(GetWiFiBeaconLostCount(mBeaconLostCount)); + + if (getifaddrs(&ifaddr) == -1) + { + ChipLogError(DeviceLayer, "Failed to get network interfaces"); + return err; + } + + struct ifaddrs * ifa = nullptr; + for (ifa = ifaddr; ifa != nullptr; ifa = ifa->ifa_next) + { + if (ConnectivityUtils::GetInterfaceConnectionType(ifa->ifa_name) == InterfaceTypeEnum::EMBER_ZCL_INTERFACE_TYPE_ENUM_WI_FI) + { + ChipLogProgress(DeviceLayer, "Found the primary WiFi interface:%s", StringOrNullMarker(ifa->ifa_name)); + break; + } + } + + if (ifa != nullptr) + { + if (ifa->ifa_addr->sa_family == AF_PACKET && ifa->ifa_data != nullptr) + { + struct rtnl_link_stats * stats = (struct rtnl_link_stats *) ifa->ifa_data; + + mPacketMulticastRxCount = stats->multicast; + mPacketMulticastTxCount = 0; + mPacketUnicastRxCount = stats->rx_packets; + mPacketUnicastTxCount = stats->tx_packets; + mOverrunCount = stats->rx_over_errors; + + err = CHIP_NO_ERROR; + } + } + + freeifaddrs(ifaddr); + return err; +} +#endif // CHIP_DEVICE_CONFIG_ENABLE_WIFI + DiagnosticDataProvider & GetDiagnosticDataProviderImpl() { return DiagnosticDataProviderImpl::GetDefaultInstance(); diff --git a/src/platform/Tizen/DiagnosticDataProviderImpl.h b/src/platform/Tizen/DiagnosticDataProviderImpl.h index 1019bc9ec66ab0..80dd3ae7b09a2e 100644 --- a/src/platform/Tizen/DiagnosticDataProviderImpl.h +++ b/src/platform/Tizen/DiagnosticDataProviderImpl.h @@ -28,12 +28,76 @@ namespace chip { namespace DeviceLayer { /** - * Concrete implementation of the PlatformManager singleton object for Linux platforms. + * Concrete implementation of the DiagnosticDataProvider singleton object for Tizen platforms. */ class DiagnosticDataProviderImpl : public DiagnosticDataProvider { public: static DiagnosticDataProviderImpl & GetDefaultInstance(); + + // ===== Methods that implement the DiagnosticDataProvider abstract interface. + + bool SupportsWatermarks() override { return true; } + CHIP_ERROR GetCurrentHeapFree(uint64_t & currentHeapFree) override; + CHIP_ERROR GetCurrentHeapUsed(uint64_t & currentHeapUsed) override; + CHIP_ERROR GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark) override; + CHIP_ERROR GetThreadMetrics(ThreadMetrics ** threadMetricsOut) override; + CHIP_ERROR ResetWatermarks() override; + void ReleaseThreadMetrics(ThreadMetrics * threadMetrics) override; + + CHIP_ERROR GetRebootCount(uint16_t & rebootCount) override; + CHIP_ERROR GetUpTime(uint64_t & upTime) override; + CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours) override; + CHIP_ERROR GetBootReason(BootReasonType & bootReason) override; + + CHIP_ERROR GetActiveHardwareFaults(GeneralFaults & hardwareFaults) override; + CHIP_ERROR GetActiveRadioFaults(GeneralFaults & radioFaults) override; + CHIP_ERROR GetActiveNetworkFaults(GeneralFaults & networkFaults) override; + + CHIP_ERROR GetNetworkInterfaces(NetworkInterface ** netifpp) override; + void ReleaseNetworkInterfaces(NetworkInterface * netifp) override; + + CHIP_ERROR GetEthPHYRate(app::Clusters::EthernetNetworkDiagnostics::PHYRateEnum & pHYRate) override; + CHIP_ERROR GetEthFullDuplex(bool & fullDuplex) override; + CHIP_ERROR GetEthTimeSinceReset(uint64_t & timeSinceReset) override; + CHIP_ERROR GetEthPacketRxCount(uint64_t & packetRxCount) override; + CHIP_ERROR GetEthPacketTxCount(uint64_t & packetTxCount) override; + CHIP_ERROR GetEthTxErrCount(uint64_t & txErrCount) override; + CHIP_ERROR GetEthCollisionCount(uint64_t & collisionCount) override; + CHIP_ERROR GetEthOverrunCount(uint64_t & overrunCount) override; + CHIP_ERROR ResetEthNetworkDiagnosticsCounts() override; + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + CHIP_ERROR GetWiFiBssId(MutableByteSpan & bssId) override; + CHIP_ERROR GetWiFiSecurityType(app::Clusters::WiFiNetworkDiagnostics::SecurityTypeEnum & securityType) override; + CHIP_ERROR GetWiFiVersion(app::Clusters::WiFiNetworkDiagnostics::WiFiVersionEnum & wiFiVersion) override; + CHIP_ERROR GetWiFiChannelNumber(uint16_t & channelNumber) override; + CHIP_ERROR GetWiFiRssi(int8_t & rssi) override; + CHIP_ERROR GetWiFiBeaconLostCount(uint32_t & beaconLostCount) override; + CHIP_ERROR GetWiFiPacketMulticastRxCount(uint32_t & packetMulticastRxCount) override; + CHIP_ERROR GetWiFiPacketMulticastTxCount(uint32_t & packetMulticastTxCount) override; + CHIP_ERROR GetWiFiPacketUnicastRxCount(uint32_t & packetUnicastRxCount) override; + CHIP_ERROR GetWiFiPacketUnicastTxCount(uint32_t & packetUnicastTxCount) override; + CHIP_ERROR GetWiFiCurrentMaxRate(uint64_t & currentMaxRate) override; + CHIP_ERROR GetWiFiOverrunCount(uint64_t & overrunCount) override; + CHIP_ERROR ResetWiFiNetworkDiagnosticsCounts() override; +#endif + +private: + uint64_t mEthPacketRxCount = 0; + uint64_t mEthPacketTxCount = 0; + uint64_t mEthTxErrCount = 0; + uint64_t mEthCollisionCount = 0; + uint64_t mEthOverrunCount = 0; + +#if CHIP_DEVICE_CONFIG_ENABLE_WIFI + uint32_t mBeaconLostCount = 0; + uint32_t mPacketMulticastRxCount = 0; + uint32_t mPacketMulticastTxCount = 0; + uint32_t mPacketUnicastRxCount = 0; + uint32_t mPacketUnicastTxCount = 0; + uint64_t mOverrunCount = 0; +#endif }; /** diff --git a/src/platform/Tizen/PlatformManagerImpl.cpp b/src/platform/Tizen/PlatformManagerImpl.cpp index d0f62901a61bbe..41e011052742c0 100644 --- a/src/platform/Tizen/PlatformManagerImpl.cpp +++ b/src/platform/Tizen/PlatformManagerImpl.cpp @@ -117,6 +117,8 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack() // earlier, because the generic implementation sets a generic one. SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); + mStartTime = System::SystemClock().GetMonotonicTimestamp(); + return CHIP_NO_ERROR; } diff --git a/src/platform/Tizen/PlatformManagerImpl.h b/src/platform/Tizen/PlatformManagerImpl.h index 04ad1c02864705..8a3d0e450d9742 100644 --- a/src/platform/Tizen/PlatformManagerImpl.h +++ b/src/platform/Tizen/PlatformManagerImpl.h @@ -66,6 +66,7 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener { return _GLibMatterContextInvokeSync((CHIP_ERROR(*)(void *)) func, (void *) userData); } + System::Clock::Timestamp GetStartTime() { return mStartTime; } private: // ===== Methods that implement the PlatformManager abstract interface. @@ -79,6 +80,8 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener friend PlatformManagerImpl & PlatformMgrImpl(); friend class Internal::BLEManagerImpl; + System::Clock::Timestamp mStartTime = System::Clock::kZero; + static PlatformManagerImpl sInstance; /** diff --git a/src/platform/Tizen/PosixConfig.cpp b/src/platform/Tizen/PosixConfig.cpp index f5c641a2fbc83e..fc65c24bf189a9 100644 --- a/src/platform/Tizen/PosixConfig.cpp +++ b/src/platform/Tizen/PosixConfig.cpp @@ -67,6 +67,11 @@ const PosixConfig::Key PosixConfig::kConfigKey_RegulatoryLocation = { kConfigNam const PosixConfig::Key PosixConfig::kConfigKey_CountryCode = { kConfigNamespace_ChipConfig, "country-code" }; const PosixConfig::Key PosixConfig::kConfigKey_UniqueId = { kConfigNamespace_ChipConfig, "unique-id" }; +// Keys stored in the Chip-counters namespace +const PosixConfig::Key PosixConfig::kCounterKey_TotalOperationalHours = { kConfigNamespace_ChipCounters, + "total-operational-hours" }; +const PosixConfig::Key PosixConfig::kCounterKey_BootReason = { kConfigNamespace_ChipCounters, "boot-reason" }; + CHIP_ERROR PosixConfig::Init() { return CHIP_NO_ERROR; diff --git a/src/platform/Tizen/PosixConfig.h b/src/platform/Tizen/PosixConfig.h index 197adad14e3907..9c5402cadaaf34 100644 --- a/src/platform/Tizen/PosixConfig.h +++ b/src/platform/Tizen/PosixConfig.h @@ -76,6 +76,9 @@ class PosixConfig static const Key kConfigKey_VendorId; static const Key kConfigKey_ProductId; + static const Key kCounterKey_TotalOperationalHours; + static const Key kCounterKey_BootReason; + static CHIP_ERROR Init(void); // Config value accessors. diff --git a/src/platform/Tizen/WiFiManager.cpp b/src/platform/Tizen/WiFiManager.cpp index b45e34bda450c8..b6a8c09be7c22b 100644 --- a/src/platform/Tizen/WiFiManager.cpp +++ b/src/platform/Tizen/WiFiManager.cpp @@ -528,6 +528,33 @@ void WiFiManager::_WiFiSetConnectionState(wifi_manager_connection_state_e connec ChipLogProgress(DeviceLayer, "Set WiFi connection state [%s]", __WiFiConnectionStateToStr(mConnectionState)); } +wifi_manager_ap_h WiFiManager::_WiFiGetConnectedAP() +{ + int wifiErr = WIFI_MANAGER_ERROR_NONE; + wifi_manager_ap_h connectedAp = nullptr; + + wifiErr = wifi_manager_get_connected_ap(mWiFiManagerHandle, &connectedAp); + if (wifiErr == WIFI_MANAGER_ERROR_NONE) + { + char * ssidStr = nullptr; + if (connectedAp != nullptr) + { + wifiErr = wifi_manager_ap_get_essid(connectedAp, &ssidStr); + if (wifiErr != WIFI_MANAGER_ERROR_NONE) + { + ChipLogError(DeviceLayer, "FAIL: get ssid of connected AP [%s]", get_error_message(wifiErr)); + } + } + ChipLogProgress(DeviceLayer, "Get connected AP [%s]", ssidStr); + } + else + { + ChipLogError(DeviceLayer, "FAIL: get connected AP [%s]", get_error_message(wifiErr)); + } + + return connectedAp; +} + wifi_manager_ap_h WiFiManager::_WiFiGetFoundAP() { int wifiErr = WIFI_MANAGER_ERROR_NONE; @@ -798,6 +825,58 @@ CHIP_ERROR WiFiManager::GetConnectionState(wifi_manager_connection_state_e * con return err; } +CHIP_ERROR WiFiManager::GetBssId(uint8_t * bssId) +{ + VerifyOrReturnError(bssId != nullptr, CHIP_ERROR_INVALID_ARGUMENT); + + char * bssIdStr = nullptr; + std::unique_ptr _{ bssIdStr, &::free }; + + wifi_manager_ap_h connectedAp = _WiFiGetConnectedAP(); + if (connectedAp == nullptr) + { + return CHIP_ERROR_INCORRECT_STATE; + } + + int wifiErr = wifi_manager_ap_get_bssid(connectedAp, &bssIdStr); + if (wifiErr != WIFI_MANAGER_ERROR_NONE) + { + ChipLogError(DeviceLayer, "FAIL: get bssid [%s]", get_error_message(wifiErr)); + return CHIP_ERROR_READ_FAILED; + } + + if (sscanf(bssIdStr, "%hhx:%hhx:%hhx:%hhx:%hhx:%hhx", &mWiFiBSSID[0], &mWiFiBSSID[1], &mWiFiBSSID[2], &mWiFiBSSID[3], + &mWiFiBSSID[4], &mWiFiBSSID[5]) != 6) + { + ChipLogError(DeviceLayer, "FAIL: parse bssid"); + return CHIP_ERROR_READ_FAILED; + } + + bssId = mWiFiBSSID; + return CHIP_NO_ERROR; +} + +CHIP_ERROR WiFiManager::GetSecurityType(wifi_manager_security_type_e * securityType) +{ + wifi_manager_ap_h connectedAp = _WiFiGetConnectedAP(); + if (connectedAp == nullptr) + { + return CHIP_ERROR_INCORRECT_STATE; + } + + wifi_manager_security_type_e secType; + int wifiErr = wifi_manager_ap_get_security_type(connectedAp, &secType); + if (wifiErr != WIFI_MANAGER_ERROR_NONE) + { + ChipLogError(DeviceLayer, "FAIL: get security type [%s]", get_error_message(wifiErr)); + return CHIP_ERROR_READ_FAILED; + } + + *securityType = secType; + + return CHIP_NO_ERROR; +} + } // namespace Internal } // namespace DeviceLayer } // namespace chip diff --git a/src/platform/Tizen/WiFiManager.h b/src/platform/Tizen/WiFiManager.h index 6304642ed07f51..4ec6dec2e5d7aa 100644 --- a/src/platform/Tizen/WiFiManager.h +++ b/src/platform/Tizen/WiFiManager.h @@ -53,6 +53,8 @@ class WiFiManager CHIP_ERROR SetDeviceState(wifi_manager_device_state_e deviceState); CHIP_ERROR GetModuleState(wifi_manager_module_state_e * moduleState); CHIP_ERROR GetConnectionState(wifi_manager_connection_state_e * connectionState); + CHIP_ERROR GetBssId(uint8_t * bssId); + CHIP_ERROR GetSecurityType(wifi_manager_security_type_e * securityType); private: static void _DeviceStateChangedCb(wifi_manager_device_state_e deviceState, void * userData); @@ -82,6 +84,7 @@ class WiFiManager void _WiFiSetDeviceState(wifi_manager_device_state_e deviceState); void _WiFiSetModuleState(wifi_manager_module_state_e moduleState); void _WiFiSetConnectionState(wifi_manager_connection_state_e connectionState); + wifi_manager_ap_h _WiFiGetConnectedAP(); wifi_manager_ap_h _WiFiGetFoundAP(); friend WiFiManager & WiFiMgr(); @@ -93,6 +96,7 @@ class WiFiManager wifi_manager_module_state_e mModuleState; wifi_manager_connection_state_e mConnectionState; + uint8_t mWiFiBSSID[kWiFiBSSIDLength]; char mWiFiSSID[kMaxWiFiSSIDLength + 1]; char mWiFiKey[kMaxWiFiKeyLength + 1]; From c8c31e26259dab62f9f77b23549421dc3f0161ef Mon Sep 17 00:00:00 2001 From: srningap <107042150+srningap@users.noreply.github.com> Date: Fri, 21 Apr 2023 18:22:28 +0530 Subject: [PATCH 15/54] [Silabs] WiFi- Addressed build failures with wiseMCU package v1.0.1.4 (#26161) * Adds declarations for 917SoC which causing the build failure with 1.0.1.4 WisemcuSDK * removed a macro redefinition * adding warnings flags back, which removed for 1.0.18 package --- examples/platform/silabs/SiWx917/LEDWidget.h | 4 +++- third_party/silabs/SiWx917_sdk.gni | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/platform/silabs/SiWx917/LEDWidget.h b/examples/platform/silabs/SiWx917/LEDWidget.h index f033cb26c50f64..596f64af094d7a 100644 --- a/examples/platform/silabs/SiWx917/LEDWidget.h +++ b/examples/platform/silabs/SiWx917/LEDWidget.h @@ -19,9 +19,11 @@ #pragma once -#include "rsi_board.h" #include +extern "C" void RSI_Board_LED_Set(int, int); +extern "C" void RSI_Board_LED_Toggle(int); + class LEDWidget { public: diff --git a/third_party/silabs/SiWx917_sdk.gni b/third_party/silabs/SiWx917_sdk.gni index 22a24c9fa69215..75d776b720b8fe 100644 --- a/third_party/silabs/SiWx917_sdk.gni +++ b/third_party/silabs/SiWx917_sdk.gni @@ -128,7 +128,6 @@ template("siwx917_sdk") { "LWIP_ICMP=1", "LWIP_IGMP=1", "LWIP_DHCP=1", - "LWIP_DNS=0", ] } else { defines += [ "LWIP_IPV4=0" ] @@ -181,7 +180,14 @@ template("siwx917_sdk") { cflags += [ "-Wno-maybe-uninitialized", "-Wno-shadow", + "-Wno-empty-body", + "-Wno-cpp", + "-Wno-missing-braces", + "-Wno-sign-compare", "-Wno-error", + "-Wno-unknown-warning-option", + "-Wno-unused-variable", + "-Wno-unused-function", ] if (defined(invoker.defines)) { From 41abac7eb835915bebd7840ab6bed6629a1ef4c9 Mon Sep 17 00:00:00 2001 From: Alex Tsitsiura Date: Fri, 21 Apr 2023 17:32:59 +0300 Subject: [PATCH 16/54] [Telink] Update Telink Docker image (Zephyr update) (#26190) --- integrations/docker/images/chip-build-telink/Dockerfile | 2 +- integrations/docker/images/chip-build/version | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integrations/docker/images/chip-build-telink/Dockerfile b/integrations/docker/images/chip-build-telink/Dockerfile index 8492c85611a871..14c9d8dd3a8f17 100644 --- a/integrations/docker/images/chip-build-telink/Dockerfile +++ b/integrations/docker/images/chip-build-telink/Dockerfile @@ -23,7 +23,7 @@ RUN set -x \ && : # last line # Setup Zephyr -ARG ZEPHYR_REVISION=79e02527e04b369180ceef7c4cd682b24889801e +ARG ZEPHYR_REVISION=abb88b989a7ee31c04d99615cd91c946c81c0aa5 WORKDIR /opt/telink/zephyrproject RUN set -x \ && python3 -m pip install -U --no-cache-dir \ diff --git a/integrations/docker/images/chip-build/version b/integrations/docker/images/chip-build/version index 239c2611130e59..33084d044249a3 100644 --- a/integrations/docker/images/chip-build/version +++ b/integrations/docker/images/chip-build/version @@ -1 +1 @@ -0.7.1 Version bump reason: [ESP32] Update ESP-IDF to v4.4.4 release +0.7.2 Version bump reason: [Telink] Update Telink Docker image (Zephyr update) From e663f94c7f06332a64e6fc4c4eb31fd9819abaf5 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Fri, 21 Apr 2023 10:35:41 -0400 Subject: [PATCH 17/54] Assert the Matter lock is held in non-threadsafe SystemLayer methods. (#26180) ScheduleWork uses timers, and timers access a timer list member that is not protected against data races in any way. --- src/system/SystemLayer.h | 12 ++++++++---- src/system/SystemLayerImplFreeRTOS.cpp | 7 +++++++ src/system/SystemLayerImplSelect.cpp | 6 ++++++ 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/system/SystemLayer.h b/src/system/SystemLayer.h index 632037f45a328f..4321edeb02b883 100644 --- a/src/system/SystemLayer.h +++ b/src/system/SystemLayer.h @@ -96,7 +96,8 @@ class DLL_EXPORT Layer /** * @brief - * This method starts a one-shot timer. + * This method starts a one-shot timer. This method must be called while in the Matter context (from + * the Matter event loop, or while holding the Matter stack lock). * * @note * Only a single timer is allowed to be started with the same @a aComplete and @a aAppState @@ -114,8 +115,9 @@ class DLL_EXPORT Layer virtual CHIP_ERROR StartTimer(Clock::Timeout aDelay, TimerCompleteCallback aComplete, void * aAppState) = 0; /** - * @brief - * This method cancels a one-shot timer, started earlier through @p StartTimer(). + * @brief This method cancels a one-shot timer, started earlier through @p StartTimer(). This method must + * be called while in the Matter context (from the Matter event loop, or while holding the Matter + * stack lock). * * @note * The cancellation could fail silently if the timer specified by the combination of the callback @@ -129,7 +131,9 @@ class DLL_EXPORT Layer /** * @brief - * Schedules a function with a signature identical to `OnCompleteFunct` to be run as soon as possible in the CHIP context. + * Schedules a function with a signature identical to `OnCompleteFunct` to be run as soon as possible in the Matter context. + * This must only be called when already in the Matter context (from the Matter event loop, or while holding the Matter + * stack lock). * * @param[in] aComplete A pointer to a callback function to be called when this timer fires. * @param[in] aAppState A pointer to an application state object to be passed to the callback function as argument. diff --git a/src/system/SystemLayerImplFreeRTOS.cpp b/src/system/SystemLayerImplFreeRTOS.cpp index 1a9692302c9c48..ecc8d9504b0f14 100644 --- a/src/system/SystemLayerImplFreeRTOS.cpp +++ b/src/system/SystemLayerImplFreeRTOS.cpp @@ -22,6 +22,7 @@ */ #include +#include #include #include #include @@ -51,6 +52,8 @@ void LayerImplFreeRTOS::Shutdown() CHIP_ERROR LayerImplFreeRTOS::StartTimer(Clock::Timeout delay, TimerCompleteCallback onComplete, void * appState) { + assertChipStackLockedByCurrentThread(); + VerifyOrReturnError(mLayerState.IsInitialized(), CHIP_ERROR_INCORRECT_STATE); CHIP_SYSTEM_FAULT_INJECT(FaultInjection::kFault_TimeoutImmediate, delay = Clock::kZero); @@ -75,6 +78,8 @@ CHIP_ERROR LayerImplFreeRTOS::StartTimer(Clock::Timeout delay, TimerCompleteCall void LayerImplFreeRTOS::CancelTimer(TimerCompleteCallback onComplete, void * appState) { + assertChipStackLockedByCurrentThread(); + VerifyOrReturn(mLayerState.IsInitialized()); TimerList::Node * timer = mTimerList.Remove(onComplete, appState); @@ -86,6 +91,8 @@ void LayerImplFreeRTOS::CancelTimer(TimerCompleteCallback onComplete, void * app CHIP_ERROR LayerImplFreeRTOS::ScheduleWork(TimerCompleteCallback onComplete, void * appState) { + assertChipStackLockedByCurrentThread(); + VerifyOrReturnError(mLayerState.IsInitialized(), CHIP_ERROR_INCORRECT_STATE); // Ideally we would not use a timer here at all, but if we try to just diff --git a/src/system/SystemLayerImplSelect.cpp b/src/system/SystemLayerImplSelect.cpp index 88883a2a027520..171f14f8a6cfb7 100644 --- a/src/system/SystemLayerImplSelect.cpp +++ b/src/system/SystemLayerImplSelect.cpp @@ -122,6 +122,8 @@ void LayerImplSelect::Signal() CHIP_ERROR LayerImplSelect::StartTimer(Clock::Timeout delay, TimerCompleteCallback onComplete, void * appState) { + assertChipStackLockedByCurrentThread(); + VerifyOrReturnError(mLayerState.IsInitialized(), CHIP_ERROR_INCORRECT_STATE); CHIP_SYSTEM_FAULT_INJECT(FaultInjection::kFault_TimeoutImmediate, delay = System::Clock::kZero); @@ -167,6 +169,8 @@ CHIP_ERROR LayerImplSelect::StartTimer(Clock::Timeout delay, TimerCompleteCallba void LayerImplSelect::CancelTimer(TimerCompleteCallback onComplete, void * appState) { + assertChipStackLockedByCurrentThread(); + VerifyOrReturn(mLayerState.IsInitialized()); TimerList::Node * timer = mTimerList.Remove(onComplete, appState); @@ -194,6 +198,8 @@ void LayerImplSelect::CancelTimer(TimerCompleteCallback onComplete, void * appSt CHIP_ERROR LayerImplSelect::ScheduleWork(TimerCompleteCallback onComplete, void * appState) { + assertChipStackLockedByCurrentThread(); + VerifyOrReturnError(mLayerState.IsInitialized(), CHIP_ERROR_INCORRECT_STATE); #if CHIP_SYSTEM_CONFIG_USE_DISPATCH From 65f075c73127d8ec3b2d9a6f11a2ac4256e355e1 Mon Sep 17 00:00:00 2001 From: Timothy Maes Date: Fri, 21 Apr 2023 18:26:57 +0200 Subject: [PATCH 18/54] fix: Warning GCC 12.2 in mbed_alt (#26193) --- third_party/qpg_sdk/repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/qpg_sdk/repo b/third_party/qpg_sdk/repo index 1f0c845a7de8ad..e5c17b34e011a0 160000 --- a/third_party/qpg_sdk/repo +++ b/third_party/qpg_sdk/repo @@ -1 +1 @@ -Subproject commit 1f0c845a7de8ad2b81f07bfa4c83e6a8f22dbe99 +Subproject commit e5c17b34e011a0997a4b1614008aacff4f97e5b6 From de0dfcfbc42fe574774dc440a0e89a8884b28573 Mon Sep 17 00:00:00 2001 From: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> Date: Sun, 23 Apr 2023 19:50:31 -0400 Subject: [PATCH 19/54] Fix assert on SystemLayer().StartTimer call by aquiring the chipStack Lock before the call (#26200) --- src/platform/Linux/BLEManagerImpl.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/platform/Linux/BLEManagerImpl.cpp b/src/platform/Linux/BLEManagerImpl.cpp index c9ae6ae36bf771..2cc5c6a69d19c5 100644 --- a/src/platform/Linux/BLEManagerImpl.cpp +++ b/src/platform/Linux/BLEManagerImpl.cpp @@ -796,7 +796,11 @@ void BLEManagerImpl::OnDeviceScanned(BluezDevice1 * device, const chip::Ble::Chi } mBLEScanConfig.mBleScanState = BleScanState::kConnecting; + + chip::DeviceLayer::PlatformMgr().LockChipStack(); DeviceLayer::SystemLayer().StartTimer(kConnectTimeout, HandleConnectTimeout, mpEndpoint); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + mDeviceScanner->StopScan(); ConnectDevice(device, mpEndpoint); From 51f90c934b4b9a35c0deff28b8ca59d6718543f4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Apr 2023 09:48:22 -0400 Subject: [PATCH 20/54] Bump third_party/mbedtls/repo from `b76bcfb` to `e323fb3` (#26212) Bumps [third_party/mbedtls/repo](https://github.com/ARMmbed/mbedtls) from `b76bcfb` to `e323fb3`. - [Release notes](https://github.com/ARMmbed/mbedtls/releases) - [Commits](https://github.com/ARMmbed/mbedtls/compare/b76bcfb22869da08c2fa4f242295523f65881807...e323fb3ab5bf9dbdec8731c29108697e8d611755) --- updated-dependencies: - dependency-name: third_party/mbedtls/repo dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- third_party/mbedtls/repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/mbedtls/repo b/third_party/mbedtls/repo index b76bcfb22869da..e323fb3ab5bf9d 160000 --- a/third_party/mbedtls/repo +++ b/third_party/mbedtls/repo @@ -1 +1 @@ -Subproject commit b76bcfb22869da08c2fa4f242295523f65881807 +Subproject commit e323fb3ab5bf9dbdec8731c29108697e8d611755 From f331ffba29f316396a3ee7bb8c72b526a2aac68c Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 24 Apr 2023 10:15:24 -0400 Subject: [PATCH 21/54] Log payloads for read/subscribe even if we reject them. (#26188) Right now we only log read/subscribe payloads when we are actaully handling the read/subscribe. But that means when they are rejected it's hard to tell what might have caused them to get rejected. This just moves the logging to much earlier in the processing. --- src/app/InteractionModelEngine.cpp | 7 +++++++ src/app/ReadHandler.cpp | 14 ++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/app/InteractionModelEngine.cpp b/src/app/InteractionModelEngine.cpp index 08f3266f522b1d..2a5dd2f3216932 100644 --- a/src/app/InteractionModelEngine.cpp +++ b/src/app/InteractionModelEngine.cpp @@ -441,6 +441,10 @@ Protocols::InteractionModel::Status InteractionModelEngine::OnReadInitialRequest SubscribeRequestMessage::Parser subscribeRequestParser; VerifyOrReturnError(subscribeRequestParser.Init(reader) == CHIP_NO_ERROR, Status::InvalidAction); +#if CHIP_CONFIG_IM_PRETTY_PRINT + subscribeRequestParser.PrettyPrint(); +#endif + VerifyOrReturnError(subscribeRequestParser.GetKeepSubscriptions(&keepExistingSubscriptions) == CHIP_NO_ERROR, Status::InvalidAction); if (!keepExistingSubscriptions) @@ -538,6 +542,9 @@ Protocols::InteractionModel::Status InteractionModelEngine::OnReadInitialRequest ReadRequestMessage::Parser readRequestParser; VerifyOrReturnError(readRequestParser.Init(reader) == CHIP_NO_ERROR, Status::InvalidAction); +#if CHIP_CONFIG_IM_PRETTY_PRINT + readRequestParser.PrettyPrint(); +#endif { size_t requestedAttributePathCount = 0; size_t requestedEventPathCount = 0; diff --git a/src/app/ReadHandler.cpp b/src/app/ReadHandler.cpp index 5dc2ce668fec09..ef594e3badd163 100644 --- a/src/app/ReadHandler.cpp +++ b/src/app/ReadHandler.cpp @@ -394,9 +394,10 @@ CHIP_ERROR ReadHandler::ProcessReadRequest(System::PacketBufferHandle && aPayloa reader.Init(std::move(aPayload)); ReturnErrorOnFailure(readRequestParser.Init(reader)); -#if CHIP_CONFIG_IM_PRETTY_PRINT - readRequestParser.PrettyPrint(); -#endif + + // No need to pretty-print here. We pretty-print read requests in the read + // case of InteractionModelEngine::OnReadInitialRequest, so we do it even if + // we reject a read request. err = readRequestParser.GetAttributeRequests(&attributePathListParser); if (err == CHIP_END_OF_TLV) @@ -647,9 +648,10 @@ CHIP_ERROR ReadHandler::ProcessSubscribeRequest(System::PacketBufferHandle && aP SubscribeRequestMessage::Parser subscribeRequestParser; ReturnErrorOnFailure(subscribeRequestParser.Init(reader)); -#if CHIP_CONFIG_IM_PRETTY_PRINT - subscribeRequestParser.PrettyPrint(); -#endif + + // No need to pretty-print here. We pretty-print subscribe requests in the + // subscribe case of InteractionModelEngine::OnReadInitialRequest, so we do + // it even if we reject a subscribe request. AttributePathIBs::Parser attributePathListParser; CHIP_ERROR err = subscribeRequestParser.GetAttributeRequests(&attributePathListParser); From 228b35dedc92ee49d5ddd9c352e02873564c905a Mon Sep 17 00:00:00 2001 From: Markus Becker Date: Mon, 24 Apr 2023 16:15:39 +0200 Subject: [PATCH 22/54] ot cli command is called networkkey now (#26210) See https://github.com/openthread/openthread/blob/main/src/cli/README.md#networkkey --- docs/guides/nrfconnect_examples_cli.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/nrfconnect_examples_cli.md b/docs/guides/nrfconnect_examples_cli.md index 91b633287db737..5d785ef15d594c 100644 --- a/docs/guides/nrfconnect_examples_cli.md +++ b/docs/guides/nrfconnect_examples_cli.md @@ -83,7 +83,7 @@ available options for the given command. are accessible from the shell, but they must preceded by `ot`. For example: ```shell -uart:~$ ot masterkey +uart:~$ ot networkkey 00112233445566778899aabbccddeeff Done ``` From fa303cd9bc2329400374d6ecb3333f29b24f21a9 Mon Sep 17 00:00:00 2001 From: Marcel van der Veldt Date: Mon, 24 Apr 2023 16:24:48 +0200 Subject: [PATCH 23/54] Fix schema not found error on vendor specific data (#26120) --- src/controller/python/chip/clusters/Attribute.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/controller/python/chip/clusters/Attribute.py b/src/controller/python/chip/clusters/Attribute.py index 1bd60cbf23501d..3660d31234f0fe 100644 --- a/src/controller/python/chip/clusters/Attribute.py +++ b/src/controller/python/chip/clusters/Attribute.py @@ -146,7 +146,7 @@ def __init__(self, ClusterType: Cluster = None, AttributeType: ClusterAttributeD break if (self.ClusterType is None or self.AttributeType is None): - raise Exception("Schema not found") + raise KeyError(f"No Schema found for Attribute {Path}") # Next, let's figure out the label. for field in self.ClusterType.descriptor.Fields: @@ -156,7 +156,7 @@ def __init__(self, ClusterType: Cluster = None, AttributeType: ClusterAttributeD self.AttributeName = field.Label if (self.AttributeName is None): - raise Exception("Schema not found") + raise KeyError(f"Unable to resolve name for Attribute {Path}") self.Path = Path self.ClusterId = self.ClusterType.id @@ -745,8 +745,14 @@ def _handleReportEnd(self): if (self._subscription_handler is not None): for change in self._changedPathSet: + try: + attribute_path = TypedAttributePath(Path=change) + except (KeyError, ValueError) as err: + # path could not be resolved into a TypedAttributePath + logging.getLogger(__name__).exception(err) + continue self._subscription_handler.OnAttributeChangeCb( - TypedAttributePath(Path=change), self._subscription_handler) + attribute_path, self._subscription_handler) # Clear it out once we've notified of all changes in this transaction. self._changedPathSet = set() From 05d79a2fe28af1bd68103148d69cb28c3422135b Mon Sep 17 00:00:00 2001 From: Jean-Francois Penven <67962328+jepenven-silabs@users.noreply.github.com> Date: Mon, 24 Apr 2023 10:51:53 -0400 Subject: [PATCH 24/54] Add Silabs Platform abstraction (#26196) --- src/platform/silabs/SiWx917/BUILD.gn | 3 + src/platform/silabs/efr32/BUILD.gn | 3 + .../silabs/platformAbstraction/GSDK_SPAM.cpp | 76 +++++++++++++++++++ .../platformAbstraction/SilabsPlatform.h | 63 +++++++++++++++ .../platformAbstraction/SilabsPlatformBase.h | 56 ++++++++++++++ .../platformAbstraction/WiseMCU_SPAM.cpp | 66 ++++++++++++++++ 6 files changed, 267 insertions(+) create mode 100644 src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp create mode 100644 src/platform/silabs/platformAbstraction/SilabsPlatform.h create mode 100644 src/platform/silabs/platformAbstraction/SilabsPlatformBase.h create mode 100644 src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp diff --git a/src/platform/silabs/SiWx917/BUILD.gn b/src/platform/silabs/SiWx917/BUILD.gn index fadfbbd1177f39..346c4ad20652ff 100644 --- a/src/platform/silabs/SiWx917/BUILD.gn +++ b/src/platform/silabs/SiWx917/BUILD.gn @@ -53,6 +53,9 @@ static_library("SiWx917") { "${silabs_platform_dir}/SilabsConfig.cpp", "${silabs_platform_dir}/SilabsConfig.h", "${silabs_platform_dir}/SystemPlatformConfig.h", + "${silabs_platform_dir}/platformAbstraction/SilabsPlatform.h", + "${silabs_platform_dir}/platformAbstraction/SilabsPlatformBase.h", + "${silabs_platform_dir}/platformAbstraction/WiseMCU_SPAM.cpp", "../../FreeRTOS/SystemTimeSupport.cpp", "../../SingletonConfigurationManager.cpp", "BLEManagerImpl.cpp", diff --git a/src/platform/silabs/efr32/BUILD.gn b/src/platform/silabs/efr32/BUILD.gn index 61a1ddc26fc7e2..7b80bf07111915 100644 --- a/src/platform/silabs/efr32/BUILD.gn +++ b/src/platform/silabs/efr32/BUILD.gn @@ -57,6 +57,9 @@ static_library("efr32") { "${silabs_platform_dir}/SilabsConfig.cpp", "${silabs_platform_dir}/SilabsConfig.h", "${silabs_platform_dir}/SystemPlatformConfig.h", + "${silabs_platform_dir}/platformAbstraction/GSDK_SPAM.cpp", + "${silabs_platform_dir}/platformAbstraction/SilabsPlatform.h", + "${silabs_platform_dir}/platformAbstraction/SilabsPlatformBase.h", "../../FreeRTOS/SystemTimeSupport.cpp", "../../SingletonConfigurationManager.cpp", "ConfigurationManagerImpl.cpp", diff --git a/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp b/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp new file mode 100644 index 00000000000000..e0f954e101a90d --- /dev/null +++ b/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "init_efrPlatform.h" +#include + +namespace chip { +namespace DeviceLayer { +namespace Silabs { + +SilabsPlatform SilabsPlatform::sSilabsPlatformAbstractionManager; + +CHIP_ERROR SilabsPlatform::Init(void) +{ + init_efrPlatform(); + return CHIP_NO_ERROR; +} + +#ifdef ENABLE_WSTK_LEDS + +#include "sl_simple_led_instances.h" + +void SilabsPlatform::InitLed(void) +{ + sl_simple_led_init_instances(); +} + +CHIP_ERROR SilabsPlatform::SetLed(bool state, uint8_t led) +{ + if (led >= SL_SIMPLE_LED_COUNT) + { + return CHIP_ERROR_INVALID_ARGUMENT; + } + + (state) ? sl_led_turn_on(SL_SIMPLE_LED_INSTANCE(led)) : sl_led_turn_off(SL_SIMPLE_LED_INSTANCE(led)); + return CHIP_NO_ERROR; +} + +bool SilabsPlatform::GetLedState(uint8_t led) +{ + if (led >= SL_SIMPLE_LED_COUNT) + { + return 0; + } + + return sl_led_get_state(SL_SIMPLE_LED_INSTANCE(led)); +} + +CHIP_ERROR SilabsPlatform::ToggleLed(uint8_t led) +{ + if (led >= SL_SIMPLE_LED_COUNT) + { + return CHIP_ERROR_INVALID_ARGUMENT; + } + sl_led_toggle(SL_SIMPLE_LED_INSTANCE(led)); + return CHIP_NO_ERROR; +} +#endif // ENABLE_WSTK_LEDS + +} // namespace Silabs +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/silabs/platformAbstraction/SilabsPlatform.h b/src/platform/silabs/platformAbstraction/SilabsPlatform.h new file mode 100644 index 00000000000000..f5dabc9d4bd72a --- /dev/null +++ b/src/platform/silabs/platformAbstraction/SilabsPlatform.h @@ -0,0 +1,63 @@ +/* + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include +#include + +namespace chip { +namespace DeviceLayer { +namespace Silabs { + +class SilabsPlatform : virtual public SilabsPlatformAbstractionBase +{ + +public: + // Generic Peripherical methods + CHIP_ERROR Init(void) override; + + // LEDS +#ifdef ENABLE_WSTK_LEDS + void InitLed(void) override; + CHIP_ERROR SetLed(bool state, uint8_t led) override; + bool GetLedState(uint8_t led) override; + CHIP_ERROR ToggleLed(uint8_t led) override; +#endif + +private: + friend SilabsPlatform & GetPlatform(void); + + // To make underlying SDK thread safe + void SilabsPlatformLock(void); + void SilabsPlatformUnlock(void); + + SilabsPlatform(){}; + virtual ~SilabsPlatform() = default; + + static SilabsPlatform sSilabsPlatformAbstractionManager; +}; + +inline SilabsPlatform & GetPlatform(void) +{ + return SilabsPlatform::sSilabsPlatformAbstractionManager; +} + +} // namespace Silabs +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/silabs/platformAbstraction/SilabsPlatformBase.h b/src/platform/silabs/platformAbstraction/SilabsPlatformBase.h new file mode 100644 index 00000000000000..548fffac9e3599 --- /dev/null +++ b/src/platform/silabs/platformAbstraction/SilabsPlatformBase.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +#include + +namespace chip { +namespace DeviceLayer { +namespace Silabs { + +class SilabsPlatformAbstractionBase +{ + +public: + // Generic Peripherical methods + virtual CHIP_ERROR Init(void) = 0; + virtual CHIP_ERROR InitLCD() { return CHIP_ERROR_NOT_IMPLEMENTED; } + virtual CHIP_ERROR SetGPIO(uint32_t port, uint32_t pin, bool state) { return CHIP_ERROR_NOT_IMPLEMENTED; } + virtual bool GetGPIO(uint32_t port, uint32_t pin) { return false; } + + // Buttons + + // LEDS + virtual void InitLed(void) {} + virtual CHIP_ERROR SetLed(bool state, uint8_t led) { return CHIP_ERROR_NOT_IMPLEMENTED; } + virtual bool GetLedState(uint8_t led) { return 0; } + virtual CHIP_ERROR ToggleLed(uint8_t led) { return CHIP_ERROR_NOT_IMPLEMENTED; } + + // BLE Specific Method + +protected: + SilabsPlatformAbstractionBase(){}; + ~SilabsPlatformAbstractionBase(){}; +}; + +} // namespace Silabs +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp b/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp new file mode 100644 index 00000000000000..97004960f94d06 --- /dev/null +++ b/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include + +#include "init_ccpPlatform.h" + +// TODO add includes ? +extern "C" void RSI_Board_LED_Set(int, bool); +extern "C" void RSI_Board_LED_Toggle(int); + +namespace chip { +namespace DeviceLayer { +namespace Silabs { + +SilabsPlatform SilabsPlatform::sSilabsPlatformAbstractionManager; + +CHIP_ERROR SilabsPlatform::Init(void) +{ + init_ccpPlatform(); +} + +#ifdef ENABLE_WSTK_LEDS +void SilabsPlatform::InitLed(void) +{ + // TODO ? + SilabsPlatformAbstractionBase::InitLed(); +} + +CHIP_ERROR SilabsPlatform::SetLed(bool state, uint8_t led) override +{ + // TODO add range check ? + RSI_Board_LED_Set(led, state); + return CHIP_NO_ERROR; +} + +bool SilabsPlatform::GetLedState(uint8_t led) +{ + // TODO ? + return SilabsPlatformAbstractionBase::GetLedState(led); +} + +CHIP_ERROR SilabsPlatform::ToggleLed(uint8_t led) override +{ + // TODO add range check ? + RSI_Board_LED_Toggle(led) return CHIP_NO_ERROR; +} +#endif // ENABLE_WSTK_LEDS + +} // namespace Silabs +} // namespace DeviceLayer +} // namespace chip From 8306cb97069d18fd62329c669f3a9ca3a625a09d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 24 Apr 2023 10:24:55 -0700 Subject: [PATCH 25/54] Bump third_party/openthread/repo from `e63c5d3` to `6bfcc0d` (#26211) Bumps [third_party/openthread/repo](https://github.com/openthread/openthread) from `e63c5d3` to `6bfcc0d`. - [Release notes](https://github.com/openthread/openthread/releases) - [Commits](https://github.com/openthread/openthread/compare/e63c5d321ad138f40fbca52afeb5c8d875fb445c...6bfcc0d7d495fcc7bcf1cdd4070bee14c391ef95) --- updated-dependencies: - dependency-name: third_party/openthread/repo dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- third_party/openthread/repo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/third_party/openthread/repo b/third_party/openthread/repo index e63c5d321ad138..6bfcc0d7d495fc 160000 --- a/third_party/openthread/repo +++ b/third_party/openthread/repo @@ -1 +1 @@ -Subproject commit e63c5d321ad138f40fbca52afeb5c8d875fb445c +Subproject commit 6bfcc0d7d495fcc7bcf1cdd4070bee14c391ef95 From 343634a8fcc88826fd9ae09d44fd5a1666646509 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 24 Apr 2023 13:37:18 -0400 Subject: [PATCH 26/54] Fix the "not storing data" mode of ClusterStateCache to actually work. (#26187) Since we were storing no data, we were computing clusterSize to 0 for all clusters in GetSortedFilters, and then we were not adding any DataVersion filters into our requests at all. The fix is that in "don't store data" mode we still store how big the data would have been, so we can correctly prioritize our DataVersion filters. Without this fix, the change in https://github.com/project-chip/connectedhomeip/pull/26181 fails CI. That CI also acts as a test for this functionality, once https://github.com/project-chip/connectedhomeip/pull/26181 happens. --- src/app/ClusterStateCache.cpp | 75 +++++++++++++++++++++++++++-------- src/app/ClusterStateCache.h | 13 +++++- 2 files changed, 69 insertions(+), 19 deletions(-) diff --git a/src/app/ClusterStateCache.cpp b/src/app/ClusterStateCache.cpp index 302f70e44eea00..2644c1a89bbbe8 100644 --- a/src/app/ClusterStateCache.cpp +++ b/src/app/ClusterStateCache.cpp @@ -24,6 +24,31 @@ namespace chip { namespace app { +namespace { + +// Determine how much space a StatusIB takes up on the wire. +size_t SizeOfStatusIB(const StatusIB & aStatus) +{ + // 1 byte: anonymous tag control byte for struct. + // 1 byte: control byte for uint8 value. + // 1 byte: context-specific tag for uint8 value. + // 1 byte: the uint8 value. + // 1 byte: end of container. + size_t size = 5; + + if (aStatus.mClusterStatus.HasValue()) + { + // 1 byte: control byte for uint8 value. + // 1 byte: context-specific tag for uint8 value. + // 1 byte: the uint8 value. + size += 3; + } + + return size; +} + +} // anonymous namespace + CHIP_ERROR ClusterStateCache::GetElementTLVSize(TLV::TLVReader * apData, size_t & aSize) { Platform::ScopedMemoryBufferWithSize backingBuffer; @@ -57,10 +82,11 @@ CHIP_ERROR ClusterStateCache::UpdateCache(const ConcreteDataAttributePath & aPat if (apData) { + size_t elementSize = 0; + ReturnErrorOnFailure(GetElementTLVSize(apData, elementSize)); + if (mCacheData) { - size_t elementSize = 0; - ReturnErrorOnFailure(GetElementTLVSize(apData, elementSize)); Platform::ScopedMemoryBufferWithSize backingBuffer; backingBuffer.Calloc(elementSize); VerifyOrReturnError(backingBuffer.Get() != nullptr, CHIP_ERROR_NO_MEMORY); @@ -68,7 +94,11 @@ CHIP_ERROR ClusterStateCache::UpdateCache(const ConcreteDataAttributePath & aPat ReturnErrorOnFailure(writer.CopyElement(TLV::AnonymousTag(), *apData)); ReturnErrorOnFailure(writer.Finalize(backingBuffer)); - state.Set>(std::move(backingBuffer)); + state.Set(std::move(backingBuffer)); + } + else + { + state.Set(elementSize); } // // Clear out the committed data version and only set it again once we have received all data for this cluster. @@ -106,6 +136,10 @@ CHIP_ERROR ClusterStateCache::UpdateCache(const ConcreteDataAttributePath & aPat { state.Set(aStatus); } + else + { + state.Set(SizeOfStatusIB(aStatus)); + } } // @@ -117,9 +151,10 @@ CHIP_ERROR ClusterStateCache::UpdateCache(const ConcreteDataAttributePath & aPat mAddedEndpoints.push_back(aPath.mEndpointId); } + mCache[aPath.mEndpointId][aPath.mClusterId].mAttributes[aPath.mAttributeId] = std::move(state); + if (mCacheData) { - mCache[aPath.mEndpointId][aPath.mClusterId].mAttributes[aPath.mAttributeId] = std::move(state); mChangedAttributeSet.insert(aPath); } @@ -235,8 +270,12 @@ CHIP_ERROR ClusterStateCache::Get(const ConcreteAttributePath & path, TLV::TLVRe return CHIP_ERROR_IM_STATUS_CODE_RECEIVED; } - reader.Init(attributeState->Get>().Get(), - attributeState->Get>().AllocatedSize()); + if (!attributeState->Is()) + { + return CHIP_ERROR_KEY_NOT_FOUND; + } + + reader.Init(attributeState->Get().Get(), attributeState->Get().AllocatedSize()); return reader.Next(); } @@ -419,27 +458,25 @@ void ClusterStateCache::GetSortedFilters(std::vector()) { - clusterSize += - 5; // 1 byte: anonymous tag control byte for struct. 1 byte: control byte for uint8 value. 1 byte: - // context-specific tag for uint8 value.1 byte: the uint8 value. 1 byte: end of container. - if (attributeIter.second.Get().mClusterStatus.HasValue()) - { - clusterSize += 3; // 1 byte: control byte for uint8 value. 1 byte: context-specific tag for uint8 value. 1 - // byte: the uint8 value. - } + clusterSize += SizeOfStatusIB(attributeIter.second.Get()); + } + else if (attributeIter.second.Is()) + { + clusterSize += attributeIter.second.Get(); } else { + VerifyOrDie(attributeIter.second.Is()); TLV::TLVReader bufReader; - bufReader.Init(attributeIter.second.Get>().Get(), - attributeIter.second.Get>().AllocatedSize()); + bufReader.Init(attributeIter.second.Get().Get(), + attributeIter.second.Get().AllocatedSize()); ReturnOnFailure(bufReader.Next()); // Skip to the end of the element. ReturnOnFailure(bufReader.Skip()); @@ -448,8 +485,11 @@ void ClusterStateCache::GetSortedFilters(std::vector & x, const std::pair & y) { return x.second > y.second; diff --git a/src/app/ClusterStateCache.h b/src/app/ClusterStateCache.h index b0a2d2b540345f..b6fb2029c85b49 100644 --- a/src/app/ClusterStateCache.h +++ b/src/app/ClusterStateCache.h @@ -500,7 +500,16 @@ class ClusterStateCache : protected ReadClient::Callback CHIP_ERROR GetLastReportDataPath(ConcreteClusterPath & aPath); private: - using AttributeState = Variant, StatusIB>; + // An attribute state can be one of three things: + // * If we got a path-specific error for the attribute, the corresponding + // status. + // * If we got data for the attribute and we are storing data ourselves, the + // data. + // * If we got data for the attribute and we are not storing data + // oureselves, the size of the data, so we can still prioritize sending + // DataVersions correctly. + using AttributeData = Platform::ScopedMemoryBufferWithSize; + using AttributeState = Variant; // mPendingDataVersion represents a tentative data version for a cluster that we have gotten some reports for. // // mCurrentDataVersion represents a known data version for a cluster. In order for this to have a @@ -632,7 +641,7 @@ class ClusterStateCache : protected ReadClient::Callback std::map mEventStatusCache; BufferedReadCallback mBufferedReader; ConcreteClusterPath mLastReportDataPath = ConcreteClusterPath(kInvalidEndpointId, kInvalidClusterId); - bool mCacheData = true; + const bool mCacheData = true; }; }; // namespace app From b42d23a253a1f91d6c58121791a024288394a56b Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 24 Apr 2023 15:27:11 -0400 Subject: [PATCH 27/54] Minor cleanup around read/subscribe(To)AttributePaths. (#26171) 1) Use initWithArray:copyItems:YES when copying arrays, instead of hand-rolling the copy. 2) For read, empty paths should just lead to an empty result, not an error, just like they would if the read actually happened. Fixes https://github.com/project-chip/connectedhomeip/issues/26169 --- src/darwin/Framework/CHIP/MTRBaseDevice.h | 11 +++--- src/darwin/Framework/CHIP/MTRBaseDevice.mm | 39 +++++++++------------- 2 files changed, 21 insertions(+), 29 deletions(-) diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice.h b/src/darwin/Framework/CHIP/MTRBaseDevice.h index e9caa66561f484..0d4fbdd1f498f2 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice.h +++ b/src/darwin/Framework/CHIP/MTRBaseDevice.h @@ -287,9 +287,10 @@ MTR_NEWLY_AVAILABLE * * Lists of attribute and event paths to read can be provided via attributePaths and eventPaths. * - * The completion will be called with an error if the input parameters are invalid (e.g., both attributePaths and eventPaths are - * empty.) or the entire read interaction fails. Otherwise it will be called with values, which may be empty (e.g. if no paths - * matched the wildcard paths passed in) or may include per-path errors if particular paths failed. + * The completion will be called with an error if the entire read interaction fails. Otherwise it + * will be called with an array of values. This array may be empty (e.g. if no paths matched the + * wildcard paths passed in, or if empty lists of paths were passed in) or may include per-path + * errors if particular paths failed. * * If the sum of the lengths of attributePaths and eventPaths exceeds 9, the read may fail due to the device not supporting that * many read paths. @@ -394,8 +395,8 @@ MTR_NEWLY_AVAILABLE * * Lists of attribute and event paths to subscribe to can be provided via attributePaths and eventPaths. * - * The reportHandler will be called with an error if the inputs are invalid (e.g., both attributePaths and eventPaths are - * empty), or if the subscription fails entirely. + * The reportHandler will be called with an error if the subscription fails + * entirely (including when both attributePaths and eventPaths are empty). * * The reportHandler will be called with arrays of response-value dictionaries * (which may be data or errors) as path-specific data is received. diff --git a/src/darwin/Framework/CHIP/MTRBaseDevice.mm b/src/darwin/Framework/CHIP/MTRBaseDevice.mm index 4522c63d7989c1..f3251dbbc4db8f 100644 --- a/src/darwin/Framework/CHIP/MTRBaseDevice.mm +++ b/src/darwin/Framework/CHIP/MTRBaseDevice.mm @@ -917,26 +917,21 @@ - (void)readAttributePaths:(NSArray * _Nullable)attri completion:(MTRDeviceResponseHandler)completion { if ((attributePaths == nil || [attributePaths count] == 0) && (eventPaths == nil || [eventPaths count] == 0)) { + // No paths, just return an empty array. dispatch_async(queue, ^{ - completion(nil, [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_ARGUMENT]); + completion(@[], nil); }); return; } - NSMutableArray * attributes = nil; + NSArray * attributes = nil; if (attributePaths != nil) { - attributes = [[NSMutableArray alloc] init]; - for (MTRAttributeRequestPath * attributePath in attributePaths) { - [attributes addObject:[attributePath copy]]; - } + attributes = [[NSArray alloc] initWithArray:attributePaths copyItems:YES]; } - NSMutableArray * events = nil; + NSArray * events = nil; if (eventPaths != nil) { - events = [[NSMutableArray alloc] init]; - for (MTRAttributeRequestPath * eventPath in eventPaths) { - [events addObject:[eventPath copy]]; - } + events = [[NSArray alloc] initWithArray:eventPaths copyItems:YES]; } params = (params == nil) ? nil : [params copy]; auto * bridge = new MTRDataValueDictionaryCallbackBridge(queue, completion, @@ -1006,9 +1001,9 @@ - (void)readAttributePaths:(NSArray * _Nullable)attri chip::app::ReadPrepareParams readParams(session); [params toReadPrepareParams:readParams]; readParams.mpAttributePathParamsList = attributePathParamsList.Get(); - readParams.mAttributePathParamsListSize = [attributePaths count]; + readParams.mAttributePathParamsListSize = [attributes count]; readParams.mpEventPathParamsList = eventPathParamsList.Get(); - readParams.mEventPathParamsListSize = [eventPaths count]; + readParams.mEventPathParamsListSize = [events count]; AttributePathParams * attributePathParamsListToFree = attributePathParamsList.Get(); EventPathParams * eventPathParamsListToFree = eventPathParamsList.Get(); @@ -1288,8 +1283,10 @@ - (void)subscribeToAttributePaths:(NSArray * _Nullabl resubscriptionScheduled:(MTRDeviceResubscriptionScheduledHandler _Nullable)resubscriptionScheduled { if ((attributePaths == nil || [attributePaths count] == 0) && (eventPaths == nil || [eventPaths count] == 0)) { + // Per spec a server would respond InvalidAction to this, so just go + // ahead and do that. dispatch_async(queue, ^{ - reportHandler(nil, [MTRError errorForCHIPErrorCode:CHIP_ERROR_INVALID_ARGUMENT]); + reportHandler(nil, [MTRError errorForIMStatus:StatusIB(Status::InvalidAction)]); }); return; } @@ -1303,20 +1300,14 @@ - (void)subscribeToAttributePaths:(NSArray * _Nullabl } // Copy params before going async. - NSMutableArray * attributes = nil; + NSArray * attributes = nil; if (attributePaths != nil) { - attributes = [[NSMutableArray alloc] init]; - for (MTRAttributeRequestPath * attributePath in attributePaths) { - [attributes addObject:[attributePath copy]]; - } + attributes = [[NSArray alloc] initWithArray:attributePaths copyItems:YES]; } - NSMutableArray * events = nil; + NSArray * events = nil; if (eventPaths != nil) { - events = [[NSMutableArray alloc] init]; - for (MTRAttributeRequestPath * eventPath in eventPaths) { - [events addObject:[eventPath copy]]; - } + events = [[NSArray alloc] initWithArray:eventPaths copyItems:YES]; } params = (params == nil) ? nil : [params copy]; From 6025455464090462cd0f97e15d0bc383f115553c Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Mon, 24 Apr 2023 16:13:45 -0400 Subject: [PATCH 28/54] Bump third_party/pigweed/repo from `73cac22` to `b88cd71` (#26133) * Pin new pigweed branch * Fix issues caught in CI * Fix CI * Clean up * Fix QPG plaform CI issues * Fix CI issues for Ameba * Fix Ameba CI for real this time * Restyle * Fix k32w0 and mw320 CI * Restyle * CI fixes for TI platform stuff * Fixes CI for Infineon * Fix/efr32 ci with pw roll up (#113) * add syscall_stubs to efr32 test driver to support gcc 12 * fix release pw rpc build, and test driver * Fix CI for Infineon cyw30739 * Roll to latest pigweed commit * Clean up for review * Fix CI * Restyle * Fix CI --------- Co-authored-by: Junior Martinez <67972863+jmartinez-silabs@users.noreply.github.com> --- examples/all-clusters-app/nxp/mw320/BUILD.gn | 7 +- .../nxp/k32w/k32w0/BUILD.gn | 1 + examples/lighting-app/nxp/k32w/k32w0/BUILD.gn | 1 + examples/lock-app/nxp/k32w/k32w0/BUILD.gn | 1 + examples/platform/linux/system_rpc_server.cc | 11 +- examples/platform/nxp/mw320/BUILD.gn | 27 --- examples/platform/silabs/efr32/BUILD.gn | 4 +- examples/shell/nxp/k32w/k32w0/BUILD.gn | 1 + .../Ameba/DiagnosticDataProviderImpl.cpp | 87 ++++--- src/platform/BUILD.gn | 4 + src/platform/SyscallStubs.cpp | 221 ++++++++++++++++++ src/platform/cc32xx/CC32XXConfig.cpp | 2 +- src/test_driver/efr32/BUILD.gn | 6 +- third_party/infineon/cyw30739_sdk/BUILD.gn | 5 + third_party/infineon/psoc6/BUILD.gn | 10 + third_party/infineon/psoc6/syscalls_stubs.cpp | 221 ++++++++++++++++++ third_party/nlfaultinjection/BUILD.gn | 8 + third_party/nxp/k32w0_sdk/k32w0_sdk.gni | 10 +- third_party/pigweed/repo | 2 +- third_party/qpg_sdk/BUILD.gn | 1 + third_party/silabs/efr32_sdk.gni | 6 +- third_party/ti_simplelink_sdk/BUILD.gn | 8 + .../ti_simplelink_sdk/syscalls_stubs.cpp | 221 ++++++++++++++++++ 23 files changed, 779 insertions(+), 86 deletions(-) delete mode 100644 examples/platform/nxp/mw320/BUILD.gn create mode 100644 src/platform/SyscallStubs.cpp create mode 100644 third_party/infineon/psoc6/syscalls_stubs.cpp create mode 100644 third_party/ti_simplelink_sdk/syscalls_stubs.cpp diff --git a/examples/all-clusters-app/nxp/mw320/BUILD.gn b/examples/all-clusters-app/nxp/mw320/BUILD.gn index 84d41622d7d8f1..0884310a04d18a 100644 --- a/examples/all-clusters-app/nxp/mw320/BUILD.gn +++ b/examples/all-clusters-app/nxp/mw320/BUILD.gn @@ -63,6 +63,8 @@ mw320_executable("shell_mw320") { "${chip_root}/src/setup_payload", ] + deps = [ "${chip_root}/src/platform:syscalls_stub" ] + include_dirs = [ "${chip_root}/src/platform/nxp/mw320", "${examples_plat_dir}/app/project_include", @@ -84,7 +86,10 @@ mw320_executable("shell_mw320") { ldscript = "${examples_plat_dir}/app/ldscripts/88MW320_xx_xxxx_flash.ld" - ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ] + ldflags = [ + "-T" + rebase_path(ldscript, root_build_dir), + "-Wl,--no-warn-rwx-segment", + ] defines = [ "MW320_SHELL_STREAMER", "SHELL_STREAMER_APP_SPECIFIC", diff --git a/examples/contact-sensor-app/nxp/k32w/k32w0/BUILD.gn b/examples/contact-sensor-app/nxp/k32w/k32w0/BUILD.gn index bfc232e963525a..0087777552cdce 100644 --- a/examples/contact-sensor-app/nxp/k32w/k32w0/BUILD.gn +++ b/examples/contact-sensor-app/nxp/k32w/k32w0/BUILD.gn @@ -108,6 +108,7 @@ k32w0_executable("contact_sensor_app") { "${chip_root}/examples/contact-sensor-app/contact-sensor-common", "${chip_root}/examples/providers:device_info_provider", "${chip_root}/src/lib", + "${chip_root}/src/platform:syscalls_stub", "${chip_root}/third_party/mbedtls:mbedtls", "${k32w0_platform_dir}/app/support:freertos_mbedtls_utils", ] diff --git a/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn b/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn index 5daf13dfc7110c..3ccf6f3df1b282 100644 --- a/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn +++ b/examples/lighting-app/nxp/k32w/k32w0/BUILD.gn @@ -110,6 +110,7 @@ k32w0_executable("light_app") { "${chip_root}/examples/lighting-app/nxp/zap/", "${chip_root}/examples/providers:device_info_provider", "${chip_root}/src/lib", + "${chip_root}/src/platform:syscalls_stub", "${chip_root}/third_party/mbedtls:mbedtls", "${k32w0_platform_dir}/app/support:freertos_mbedtls_utils", ] diff --git a/examples/lock-app/nxp/k32w/k32w0/BUILD.gn b/examples/lock-app/nxp/k32w/k32w0/BUILD.gn index 2260f4cf1b58fd..70753788008300 100644 --- a/examples/lock-app/nxp/k32w/k32w0/BUILD.gn +++ b/examples/lock-app/nxp/k32w/k32w0/BUILD.gn @@ -109,6 +109,7 @@ k32w0_executable("lock_app") { "${chip_root}/examples/providers:device_info_provider", "${chip_root}/src/crypto", "${chip_root}/src/lib", + "${chip_root}/src/platform:syscalls_stub", "${chip_root}/third_party/mbedtls:mbedtls", "${chip_root}/third_party/simw-top-mini:se05x", "${k32w0_platform_dir}/app/support:freertos_mbedtls_utils", diff --git a/examples/platform/linux/system_rpc_server.cc b/examples/platform/linux/system_rpc_server.cc index dee4bb6d7d957e..ff8e52ec94d65e 100644 --- a/examples/platform/linux/system_rpc_server.cc +++ b/examples/platform/linux/system_rpc_server.cc @@ -37,6 +37,7 @@ namespace { constexpr size_t kMaxTransmissionUnit = 512; uint16_t socket_port = 33000; +stream::ServerSocket server_socket; stream::SocketStream socket_stream; hdlc::RpcChannelOutput hdlc_channel_output(socket_stream, hdlc::kDefaultRpcAddress, "HDLC channel"); @@ -63,7 +64,10 @@ void Init() }); PW_LOG_INFO("Starting pw_rpc server on port %d", socket_port); - PW_CHECK_OK(socket_stream.Serve(socket_port)); + PW_CHECK_OK(server_socket.Listen(socket_port)); + auto accept_result = server_socket.Accept(); + PW_CHECK_OK(accept_result.status()); + socket_stream = *std::move(accept_result); } rpc::Server & Server() @@ -88,7 +92,10 @@ Status Start() // An out of range status indicates the remote end has disconnected. // Start to serve the connection again, which will allow another // remote to connect. - PW_CHECK_OK(socket_stream.Serve(socket_port)); + PW_CHECK_OK(server_socket.Listen(socket_port)); + auto accept_result = server_socket.Accept(); + PW_CHECK_OK(accept_result.status()); + socket_stream = *std::move(accept_result); } continue; } diff --git a/examples/platform/nxp/mw320/BUILD.gn b/examples/platform/nxp/mw320/BUILD.gn deleted file mode 100644 index 2cfcbd4dcced8a..00000000000000 --- a/examples/platform/nxp/mw320/BUILD.gn +++ /dev/null @@ -1,27 +0,0 @@ -# Copyright (c) 2020 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build_overrides/chip.gni") -import("//build_overrides/mw320_sdk.gni") - -import("${mw320_sdk_build_root}/mw320_sdk.gni") - -config("chip_examples_project_config") { - include_dirs = [ "app/project_include" ] -} - -source_set("config_mw320_chip_examples") { - # sources = [ "app/project_include/CHIPProjectConfig.h" ] - public_configs = [ ":chip_examples_project_config" ] -} diff --git a/examples/platform/silabs/efr32/BUILD.gn b/examples/platform/silabs/efr32/BUILD.gn index fd33406f6911b1..48fb282c8fbb5f 100644 --- a/examples/platform/silabs/efr32/BUILD.gn +++ b/examples/platform/silabs/efr32/BUILD.gn @@ -228,9 +228,7 @@ config("efr32-common-config") { defines += [ "HEAP_MONITORING" ] } - # Do not warn for LOAD segment with RWX permissions - # Uncomment this cflag when pigweed update is done and GCC 12.2 is used. - #ldflags = [ "-Wl,--no-warn-rwx-segment" ] + ldflags = [ "-Wl,--no-warn-rwx-segment" ] } config("silabs-wifi-config") { diff --git a/examples/shell/nxp/k32w/k32w0/BUILD.gn b/examples/shell/nxp/k32w/k32w0/BUILD.gn index 19e52dcd502c7b..8b062831685aea 100644 --- a/examples/shell/nxp/k32w/k32w0/BUILD.gn +++ b/examples/shell/nxp/k32w/k32w0/BUILD.gn @@ -67,6 +67,7 @@ k32w0_executable("shell_app") { "${chip_root}/examples/common/QRCode", "${chip_root}/examples/lock-app/lock-common", "${chip_root}/examples/shell/shell_common:shell_common", + "${chip_root}/src/platform:syscalls_stub", "${chip_root}/third_party/mbedtls:mbedtls", "${chip_root}/third_party/simw-top-mini:se05x", "${k32w0_platform_dir}/app/support:freertos_mbedtls_utils", diff --git a/src/platform/Ameba/DiagnosticDataProviderImpl.cpp b/src/platform/Ameba/DiagnosticDataProviderImpl.cpp index ad6ae4e31ec4f8..b9f2f018e6987d 100644 --- a/src/platform/Ameba/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Ameba/DiagnosticDataProviderImpl.cpp @@ -186,56 +186,49 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetNetworkInterfaces(NetworkInterface ** NetworkInterface * head = NULL; struct ifaddrs * ifaddr = nullptr; - if (xnetif == NULL) + // xnetif is never null, no need to check. If we do check with -Werror=address, we get compiler error. + for (struct netif * ifa = xnetif; ifa != NULL; ifa = ifa->next) { - ChipLogError(DeviceLayer, "Failed to get network interfaces"); - } - else - { - for (struct netif * ifa = xnetif; ifa != NULL; ifa = ifa->next) + NetworkInterface * ifp = new NetworkInterface(); + + Platform::CopyString(ifp->Name, ifa->name); + + ifp->name = CharSpan::fromCharString(ifp->Name); + ifp->isOperational = true; + if ((ifa->flags) & NETIF_FLAG_ETHERNET) + ifp->type = EMBER_ZCL_INTERFACE_TYPE_ENUM_ETHERNET; + else + ifp->type = EMBER_ZCL_INTERFACE_TYPE_ENUM_WI_FI; + ifp->offPremiseServicesReachableIPv4.SetNull(); + ifp->offPremiseServicesReachableIPv6.SetNull(); + + memcpy(ifp->MacAddress, ifa->hwaddr, sizeof(ifa->hwaddr)); + + if (0) { - NetworkInterface * ifp = new NetworkInterface(); - - Platform::CopyString(ifp->Name, ifa->name); - - ifp->name = CharSpan::fromCharString(ifp->Name); - ifp->isOperational = true; - if ((ifa->flags) & NETIF_FLAG_ETHERNET) - ifp->type = EMBER_ZCL_INTERFACE_TYPE_ENUM_ETHERNET; - else - ifp->type = EMBER_ZCL_INTERFACE_TYPE_ENUM_WI_FI; - ifp->offPremiseServicesReachableIPv4.SetNull(); - ifp->offPremiseServicesReachableIPv6.SetNull(); - - memcpy(ifp->MacAddress, ifa->hwaddr, sizeof(ifa->hwaddr)); - - if (0) - { - ChipLogError(DeviceLayer, "Failed to get network hardware address"); - } - else - { - // Set 48-bit IEEE MAC Address - ifp->hardwareAddress = ByteSpan(ifp->MacAddress, 6); - } - - if (ifa->ip_addr.u_addr.ip4.addr != 0) - { - memcpy(ifp->Ipv4AddressesBuffer[0], &(ifa->ip_addr.u_addr.ip4.addr), kMaxIPv4AddrSize); - ifp->Ipv4AddressSpans[0] = ByteSpan(ifp->Ipv4AddressesBuffer[0], kMaxIPv4AddrSize); - ifp->IPv4Addresses = chip::app::DataModel::List(ifp->Ipv4AddressSpans, 1); - } - - if (ifa->ip6_addr->u_addr.ip6.addr != 0) - { - memcpy(ifp->Ipv6AddressesBuffer[0], &(ifa->ip6_addr->u_addr.ip6.addr), kMaxIPv6AddrSize); - ifp->Ipv6AddressSpans[0] = ByteSpan(ifp->Ipv6AddressesBuffer[0], kMaxIPv6AddrSize); - ifp->IPv6Addresses = chip::app::DataModel::List(ifp->Ipv6AddressSpans, 1); - } - - ifp->Next = head; - head = ifp; + ChipLogError(DeviceLayer, "Failed to get network hardware address"); } + else + { + // Set 48-bit IEEE MAC Address + ifp->hardwareAddress = ByteSpan(ifp->MacAddress, 6); + } + + if (ifa->ip_addr.u_addr.ip4.addr != 0) + { + memcpy(ifp->Ipv4AddressesBuffer[0], &(ifa->ip_addr.u_addr.ip4.addr), kMaxIPv4AddrSize); + ifp->Ipv4AddressSpans[0] = ByteSpan(ifp->Ipv4AddressesBuffer[0], kMaxIPv4AddrSize); + ifp->IPv4Addresses = chip::app::DataModel::List(ifp->Ipv4AddressSpans, 1); + } + + // ifa->ip6_addr->u_addr.ip6.addr is never null, no need to check. If we do check with -Werror=address, we get compiler + // error. + memcpy(ifp->Ipv6AddressesBuffer[0], &(ifa->ip6_addr->u_addr.ip6.addr), kMaxIPv6AddrSize); + ifp->Ipv6AddressSpans[0] = ByteSpan(ifp->Ipv6AddressesBuffer[0], kMaxIPv6AddrSize); + ifp->IPv6Addresses = chip::app::DataModel::List(ifp->Ipv6AddressSpans, 1); + + ifp->Next = head; + head = ifp; } *netifpp = head; diff --git a/src/platform/BUILD.gn b/src/platform/BUILD.gn index 678cbb8778fc79..b4876e13103364 100644 --- a/src/platform/BUILD.gn +++ b/src/platform/BUILD.gn @@ -487,3 +487,7 @@ if (chip_device_platform != "none") { public_deps = [ ":platform_buildconfig" ] } } + +source_set("syscalls_stub") { + sources = [ "SyscallStubs.cpp" ] +} diff --git a/src/platform/SyscallStubs.cpp b/src/platform/SyscallStubs.cpp new file mode 100644 index 00000000000000..8ce83ddc3ecbeb --- /dev/null +++ b/src/platform/SyscallStubs.cpp @@ -0,0 +1,221 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + This file is only used to implement weak syscall stubs + that gcc-arm-none-eabi 12.2.1 expect to link when using Libc + (newlib/libc_nano) +*/ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int _open(const char * pathname, int flags, int mode); +int _close(int file); +int _fstat(int file, struct stat * st); +int _isatty(int file); +int _lseek(int file, int ptr, int dir); +int _read(int file, char * ptr, int len); +int _write(int file, const char * ptr, int len); + +/************************************************************************** + * @brief + * Open a file. + * + * @param[in] file + * File you want to open. + * + * @return + * Returns -1 since there is not logic here to open file. + **************************************************************************/ +int __attribute__((weak)) _open(const char * pathname, int flags, int mode) +{ + (void) pathname; + (void) flags; + (void) mode; + return -1; +} + +/************************************************************************** + * @brief + * Close a file. + * + * @param[in] file + * File you want to close. + * + * @return + * Returns 0 when the file is closed. + **************************************************************************/ +int __attribute__((weak)) _close(int file) +{ + (void) file; + return 0; +} + +/************************************************************************** + * @brief Exit the program. + * @param[in] status The value to return to the parent process as the + * exit status (not used). + **************************************************************************/ +void __attribute__((weak)) _exit(int status) +{ + (void) status; + while (true) + { + } /* Hang here forever... */ +} + +/************************************************************************* + * @brief + * Status of an open file. + * + * @param[in] file + * Check status for this file. + * + * @param[in] st + * Status information. + * + * @return + * Returns 0 when st_mode is set to character special. + ************************************************************************/ +int __attribute__((weak)) _fstat(int file, struct stat * st) +{ + (void) file; + (void) st; + return 0; +} + +/************************************************************************** + * @brief Get process ID. + *************************************************************************/ +int __attribute__((weak)) _getpid(void) +{ + return 1; +} + +/************************************************************************** + * @brief + * Query whether output stream is a terminal. + * + * @param[in] file + * Descriptor for the file. + * + * @return + * Returns 1 when query is done. + **************************************************************************/ +int __attribute__((weak)) _isatty(int file) +{ + (void) file; + return 1; +} + +/************************************************************************** + * @brief Send signal to process. + * @param[in] pid Process id (not used). + * @param[in] sig Signal to send (not used). + *************************************************************************/ +int __attribute__((weak)) _kill(int pid, int sig) +{ + (void) pid; + (void) sig; + return -1; +} + +/************************************************************************** + * @brief + * Set position in a file. + * + * @param[in] file + * Descriptor for the file. + * + * @param[in] ptr + * Poiter to the argument offset. + * + * @param[in] dir + * Directory whence. + * + * @return + * Returns 0 when position is set. + *************************************************************************/ +int __attribute__((weak)) _lseek(int file, int ptr, int dir) +{ + (void) file; + (void) ptr; + (void) dir; + return 0; +} + +/************************************************************************** + * @brief + * Read from a file. + * + * @param[in] file + * Descriptor for the file you want to read from. + * + * @param[in] ptr + * Pointer to the chacaters that are beeing read. + * + * @param[in] len + * Number of characters to be read. + * + * @return + * Number of characters that have been read. + *************************************************************************/ +int __attribute__((weak)) _read(int file, char * ptr, int len) +{ + (void) file; + (void) ptr; + (void) len; + return 0; +} + +/************************************************************************** + * @brief + * Write to a file. + * + * @param[in] file + * Descriptor for the file you want to write to. + * + * @param[in] ptr + * Pointer to the text you want to write + * + * @param[in] len + * Number of characters to be written. + * + * @return + * Number of characters that have been written. + **************************************************************************/ +int __attribute__((weak)) _write(int file, const char * ptr, int len) +{ + (void) file; + (void) ptr; + + return len; +} + +#ifdef __cplusplus +} +#endif diff --git a/src/platform/cc32xx/CC32XXConfig.cpp b/src/platform/cc32xx/CC32XXConfig.cpp index ad0e52ce5571c0..b6ed391b25fea0 100644 --- a/src/platform/cc32xx/CC32XXConfig.cpp +++ b/src/platform/cc32xx/CC32XXConfig.cpp @@ -282,7 +282,7 @@ class CC32XXKVSList // value is stored in the LL, we do not need the value variable above - delete value; + delete[] value; } } }; diff --git a/src/test_driver/efr32/BUILD.gn b/src/test_driver/efr32/BUILD.gn index 8ffd6d346033c7..08a5e4186903c5 100644 --- a/src/test_driver/efr32/BUILD.gn +++ b/src/test_driver/efr32/BUILD.gn @@ -72,6 +72,7 @@ silabs_executable("efr32_device_tests") { "${chip_root}/examples/common/pigweed/efr32/PigweedLoggerMutex.cpp", "${examples_common_plat_dir}/PigweedLogger.cpp", "${examples_common_plat_dir}/heap_4_silabs.c", + "${examples_common_plat_dir}/syscalls_stubs.cpp", "${examples_plat_dir}/init_efrPlatform.cpp", "${examples_plat_dir}/uart.cpp", "src/main.cpp", @@ -111,7 +112,10 @@ silabs_executable("efr32_device_tests") { inputs = [ ldscript ] - ldflags = [ "-T" + rebase_path(ldscript, root_build_dir) ] + ldflags = [ + "-T" + rebase_path(ldscript, root_build_dir), + "-Wl,--no-warn-rwx-segment", + ] output_dir = root_out_dir } diff --git a/third_party/infineon/cyw30739_sdk/BUILD.gn b/third_party/infineon/cyw30739_sdk/BUILD.gn index 75b9e272840b63..46ca83b4eae8e4 100644 --- a/third_party/infineon/cyw30739_sdk/BUILD.gn +++ b/third_party/infineon/cyw30739_sdk/BUILD.gn @@ -25,8 +25,13 @@ declare_args() { assert(cyw30739_sdk_target != "", "cyw30739_sdk_target must be specified") +config("cyw30739_sdk_no_warn_rwx") { + ldflags = [ "-Wl,--no-warn-rwx-segment" ] +} + group("cyw30739_sdk") { public_deps = [ cyw30739_sdk_target ] + all_dependent_configs = [ ":cyw30739_sdk_no_warn_rwx" ] } config("mbedtls_cyw30739_config") { diff --git a/third_party/infineon/psoc6/BUILD.gn b/third_party/infineon/psoc6/BUILD.gn index ebb79e618655c3..59464a8e2a7cf5 100644 --- a/third_party/infineon/psoc6/BUILD.gn +++ b/third_party/infineon/psoc6/BUILD.gn @@ -67,6 +67,9 @@ config("psoc6_sdk_config") { asmflags = mtb_json.asflags ldflags = filter_exclude(mtb_json.ldflags, [ "-T*" ]) + # TODO, once the issue is properly fixed we should no longer need this warning. + cflags_c += [ "-Wno-error=array-parameter" ] + # Pull out linker flags with paths (-T flags) and make paths absolute # OTA app provides it's own linker script if (!chip_enable_ota_requestor) { @@ -82,6 +85,8 @@ config("psoc6_sdk_config") { } } + ldflags += [ "-Wl,--no-warn-rwx-segment" ] + # --specs=nano.specs is getting added twice and causing compile issues so remove from cxx flags here. cflags_c -= [ "--specs=nano.specs" ] cflags_cc -= [ "--specs=nano.specs" ] @@ -89,7 +94,12 @@ config("psoc6_sdk_config") { ldflags -= [ "--specs=nano.specs" ] } +source_set("syscalls_stub") { + sources = [ "syscalls_stubs.cpp" ] +} + group("psoc6_build") { public_configs = [ ":psoc6_sdk_config" ] public_deps = [ psoc6_target_project ] + deps = [ ":syscalls_stub" ] } diff --git a/third_party/infineon/psoc6/syscalls_stubs.cpp b/third_party/infineon/psoc6/syscalls_stubs.cpp new file mode 100644 index 00000000000000..8ce83ddc3ecbeb --- /dev/null +++ b/third_party/infineon/psoc6/syscalls_stubs.cpp @@ -0,0 +1,221 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + This file is only used to implement weak syscall stubs + that gcc-arm-none-eabi 12.2.1 expect to link when using Libc + (newlib/libc_nano) +*/ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int _open(const char * pathname, int flags, int mode); +int _close(int file); +int _fstat(int file, struct stat * st); +int _isatty(int file); +int _lseek(int file, int ptr, int dir); +int _read(int file, char * ptr, int len); +int _write(int file, const char * ptr, int len); + +/************************************************************************** + * @brief + * Open a file. + * + * @param[in] file + * File you want to open. + * + * @return + * Returns -1 since there is not logic here to open file. + **************************************************************************/ +int __attribute__((weak)) _open(const char * pathname, int flags, int mode) +{ + (void) pathname; + (void) flags; + (void) mode; + return -1; +} + +/************************************************************************** + * @brief + * Close a file. + * + * @param[in] file + * File you want to close. + * + * @return + * Returns 0 when the file is closed. + **************************************************************************/ +int __attribute__((weak)) _close(int file) +{ + (void) file; + return 0; +} + +/************************************************************************** + * @brief Exit the program. + * @param[in] status The value to return to the parent process as the + * exit status (not used). + **************************************************************************/ +void __attribute__((weak)) _exit(int status) +{ + (void) status; + while (true) + { + } /* Hang here forever... */ +} + +/************************************************************************* + * @brief + * Status of an open file. + * + * @param[in] file + * Check status for this file. + * + * @param[in] st + * Status information. + * + * @return + * Returns 0 when st_mode is set to character special. + ************************************************************************/ +int __attribute__((weak)) _fstat(int file, struct stat * st) +{ + (void) file; + (void) st; + return 0; +} + +/************************************************************************** + * @brief Get process ID. + *************************************************************************/ +int __attribute__((weak)) _getpid(void) +{ + return 1; +} + +/************************************************************************** + * @brief + * Query whether output stream is a terminal. + * + * @param[in] file + * Descriptor for the file. + * + * @return + * Returns 1 when query is done. + **************************************************************************/ +int __attribute__((weak)) _isatty(int file) +{ + (void) file; + return 1; +} + +/************************************************************************** + * @brief Send signal to process. + * @param[in] pid Process id (not used). + * @param[in] sig Signal to send (not used). + *************************************************************************/ +int __attribute__((weak)) _kill(int pid, int sig) +{ + (void) pid; + (void) sig; + return -1; +} + +/************************************************************************** + * @brief + * Set position in a file. + * + * @param[in] file + * Descriptor for the file. + * + * @param[in] ptr + * Poiter to the argument offset. + * + * @param[in] dir + * Directory whence. + * + * @return + * Returns 0 when position is set. + *************************************************************************/ +int __attribute__((weak)) _lseek(int file, int ptr, int dir) +{ + (void) file; + (void) ptr; + (void) dir; + return 0; +} + +/************************************************************************** + * @brief + * Read from a file. + * + * @param[in] file + * Descriptor for the file you want to read from. + * + * @param[in] ptr + * Pointer to the chacaters that are beeing read. + * + * @param[in] len + * Number of characters to be read. + * + * @return + * Number of characters that have been read. + *************************************************************************/ +int __attribute__((weak)) _read(int file, char * ptr, int len) +{ + (void) file; + (void) ptr; + (void) len; + return 0; +} + +/************************************************************************** + * @brief + * Write to a file. + * + * @param[in] file + * Descriptor for the file you want to write to. + * + * @param[in] ptr + * Pointer to the text you want to write + * + * @param[in] len + * Number of characters to be written. + * + * @return + * Number of characters that have been written. + **************************************************************************/ +int __attribute__((weak)) _write(int file, const char * ptr, int len) +{ + (void) file; + (void) ptr; + + return len; +} + +#ifdef __cplusplus +} +#endif diff --git a/third_party/nlfaultinjection/BUILD.gn b/third_party/nlfaultinjection/BUILD.gn index 02f3a7fba06e16..740ee69c4d6d28 100644 --- a/third_party/nlfaultinjection/BUILD.gn +++ b/third_party/nlfaultinjection/BUILD.gn @@ -18,6 +18,13 @@ config("nlfaultinjection_config") { include_dirs = [ "repo/include" ] } +config("nlfaultinjection_disable_warnings_config") { + cflags = [ + # We are intentionally inducing faults with this library so it makes sense to ignore errors. + "-Wno-error=array-bounds", + ] +} + static_library("nlfaultinjection") { sources = [ "repo/include/nlfaultinjection.hpp", @@ -27,6 +34,7 @@ static_library("nlfaultinjection") { deps = [ "${nlassert_root}:nlassert" ] public_configs = [ ":nlfaultinjection_config" ] + configs += [ ":nlfaultinjection_disable_warnings_config" ] output_name = "libnlfaultinjection" output_dir = "${root_out_dir}/lib" diff --git a/third_party/nxp/k32w0_sdk/k32w0_sdk.gni b/third_party/nxp/k32w0_sdk/k32w0_sdk.gni index c42bfd85baa780..b9900540a79169 100644 --- a/third_party/nxp/k32w0_sdk/k32w0_sdk.gni +++ b/third_party/nxp/k32w0_sdk/k32w0_sdk.gni @@ -455,7 +455,15 @@ template("k32w0_sdk") { "-Wno-parentheses-equality", ] } else { - cflags += [ "-fno-optimize-strlen" ] + cflags += [ + "-fno-optimize-strlen", + + # TODO After upgrading the compiler we started to see new error from address + # warning. To allow PR that rolls up compiler we have suppress this warning + # as an error temporarily. + # see https://github.com/project-chip/connectedhomeip/issues/26221 + "-Wno-error=address", + ] } # Now add our "system-header" include dirs diff --git a/third_party/pigweed/repo b/third_party/pigweed/repo index 73cac22f49069a..b88cd71d271c41 160000 --- a/third_party/pigweed/repo +++ b/third_party/pigweed/repo @@ -1 +1 @@ -Subproject commit 73cac22f49069a18fbec3bb60cb5f762b32ce20b +Subproject commit b88cd71d271c41e34a36dfc1c435e1e6ee3bc72a diff --git a/third_party/qpg_sdk/BUILD.gn b/third_party/qpg_sdk/BUILD.gn index 55e3bb4b5217f6..26cf78cf4e52be 100755 --- a/third_party/qpg_sdk/BUILD.gn +++ b/third_party/qpg_sdk/BUILD.gn @@ -163,6 +163,7 @@ config("qpg_retain_bootloader") { ldflags = [ "-Wl,-u_binary_bl_userlicense_bin_start", "-Wl,-u_binary_bootloader_bin_start", + "-Wl,--no-warn-rwx-segment", ] } diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index baf89660ce836b..97de1caf125afe 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -504,8 +504,10 @@ template("efr32_sdk") { "-Wno-shadow", # see https://github.com/project-chip/connectedhomeip/issues/26058 - # Uncomment this cflag when pigweed update is done and GCC 12.2 is used. - # "-Wno-error=array-parameter", + "-Wno-error=array-parameter", + + # see https://github.com/project-chip/connectedhomeip/issues/26170 + "-Wno-error=array-bounds", ] if (silabs_family == "efr32mg24" || silabs_family == "mgm24") { diff --git a/third_party/ti_simplelink_sdk/BUILD.gn b/third_party/ti_simplelink_sdk/BUILD.gn index 2451ab80e67195..d0b8d79372ea31 100644 --- a/third_party/ti_simplelink_sdk/BUILD.gn +++ b/third_party/ti_simplelink_sdk/BUILD.gn @@ -34,6 +34,10 @@ group("ti_simplelink_sysconfig") { public_deps = [ ti_simplelink_sysconfig_target ] } +source_set("syscalls_stub") { + sources = [ "syscalls_stubs.cpp" ] +} + config("ti_simplelink_mbedtls_config") { if (ti_simplelink_device_family == "cc13x2_26x2" || ti_simplelink_device_family == "cc13x2x7_26x2x7") { @@ -67,6 +71,8 @@ mbedtls_target("mbedtls") { public_configs = [ ":ti_simplelink_mbedtls_config" ] public_deps = [ ti_simplelink_sysconfig_target ] + + deps = [ ":syscalls_stub" ] } config("ti_simplelink_freertos_config") { @@ -108,4 +114,6 @@ freertos_target("freertos") { public_deps = [ "${chip_root}/third_party/ti_simplelink_sdk:ti_simplelink_sysconfig" ] } + + deps = [ ":syscalls_stub" ] } diff --git a/third_party/ti_simplelink_sdk/syscalls_stubs.cpp b/third_party/ti_simplelink_sdk/syscalls_stubs.cpp new file mode 100644 index 00000000000000..8ce83ddc3ecbeb --- /dev/null +++ b/third_party/ti_simplelink_sdk/syscalls_stubs.cpp @@ -0,0 +1,221 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + This file is only used to implement weak syscall stubs + that gcc-arm-none-eabi 12.2.1 expect to link when using Libc + (newlib/libc_nano) +*/ + +#include +#include +#include +#include +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +int _open(const char * pathname, int flags, int mode); +int _close(int file); +int _fstat(int file, struct stat * st); +int _isatty(int file); +int _lseek(int file, int ptr, int dir); +int _read(int file, char * ptr, int len); +int _write(int file, const char * ptr, int len); + +/************************************************************************** + * @brief + * Open a file. + * + * @param[in] file + * File you want to open. + * + * @return + * Returns -1 since there is not logic here to open file. + **************************************************************************/ +int __attribute__((weak)) _open(const char * pathname, int flags, int mode) +{ + (void) pathname; + (void) flags; + (void) mode; + return -1; +} + +/************************************************************************** + * @brief + * Close a file. + * + * @param[in] file + * File you want to close. + * + * @return + * Returns 0 when the file is closed. + **************************************************************************/ +int __attribute__((weak)) _close(int file) +{ + (void) file; + return 0; +} + +/************************************************************************** + * @brief Exit the program. + * @param[in] status The value to return to the parent process as the + * exit status (not used). + **************************************************************************/ +void __attribute__((weak)) _exit(int status) +{ + (void) status; + while (true) + { + } /* Hang here forever... */ +} + +/************************************************************************* + * @brief + * Status of an open file. + * + * @param[in] file + * Check status for this file. + * + * @param[in] st + * Status information. + * + * @return + * Returns 0 when st_mode is set to character special. + ************************************************************************/ +int __attribute__((weak)) _fstat(int file, struct stat * st) +{ + (void) file; + (void) st; + return 0; +} + +/************************************************************************** + * @brief Get process ID. + *************************************************************************/ +int __attribute__((weak)) _getpid(void) +{ + return 1; +} + +/************************************************************************** + * @brief + * Query whether output stream is a terminal. + * + * @param[in] file + * Descriptor for the file. + * + * @return + * Returns 1 when query is done. + **************************************************************************/ +int __attribute__((weak)) _isatty(int file) +{ + (void) file; + return 1; +} + +/************************************************************************** + * @brief Send signal to process. + * @param[in] pid Process id (not used). + * @param[in] sig Signal to send (not used). + *************************************************************************/ +int __attribute__((weak)) _kill(int pid, int sig) +{ + (void) pid; + (void) sig; + return -1; +} + +/************************************************************************** + * @brief + * Set position in a file. + * + * @param[in] file + * Descriptor for the file. + * + * @param[in] ptr + * Poiter to the argument offset. + * + * @param[in] dir + * Directory whence. + * + * @return + * Returns 0 when position is set. + *************************************************************************/ +int __attribute__((weak)) _lseek(int file, int ptr, int dir) +{ + (void) file; + (void) ptr; + (void) dir; + return 0; +} + +/************************************************************************** + * @brief + * Read from a file. + * + * @param[in] file + * Descriptor for the file you want to read from. + * + * @param[in] ptr + * Pointer to the chacaters that are beeing read. + * + * @param[in] len + * Number of characters to be read. + * + * @return + * Number of characters that have been read. + *************************************************************************/ +int __attribute__((weak)) _read(int file, char * ptr, int len) +{ + (void) file; + (void) ptr; + (void) len; + return 0; +} + +/************************************************************************** + * @brief + * Write to a file. + * + * @param[in] file + * Descriptor for the file you want to write to. + * + * @param[in] ptr + * Pointer to the text you want to write + * + * @param[in] len + * Number of characters to be written. + * + * @return + * Number of characters that have been written. + **************************************************************************/ +int __attribute__((weak)) _write(int file, const char * ptr, int len) +{ + (void) file; + (void) ptr; + + return len; +} + +#ifdef __cplusplus +} +#endif From 20cb8dd32902baa80be60855cb2cbc5dc6b732ba Mon Sep 17 00:00:00 2001 From: achaulk-goog <107196446+achaulk-goog@users.noreply.github.com> Date: Mon, 24 Apr 2023 16:50:11 -0400 Subject: [PATCH 29/54] Update bridge app codegen to handle Optional<> (#26229) --- scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py b/scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py index f48c5eac5cc080..5325ce8043f10e 100644 --- a/scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py +++ b/scripts/py_matter_idl/matter_idl/generators/bridge/__init__.py @@ -88,7 +88,7 @@ def get_field_type(definition: Field, cluster: Cluster, idl: Idl): cType = 'std::vector<{}>'.format(cType) if definition.is_nullable: cType = '::chip::app::DataModel::Nullable<{}>'.format(cType) - if definition.is_nullable: + if definition.is_optional: cType = '::chip::Optional<{}>'.format(cType) return cType From ecf6b98d6c82a0b4de7c1b5a29753fc9108c654a Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 24 Apr 2023 17:55:12 -0400 Subject: [PATCH 30/54] Stop storing two copies of attribute/event data in MTRDevice. (#26181) We have our own attribute value cache; we're just using ClusterStateCache to track DataVersions and event numbers. --- src/darwin/Framework/CHIP/MTRDevice.mm | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/darwin/Framework/CHIP/MTRDevice.mm b/src/darwin/Framework/CHIP/MTRDevice.mm index a43cd41bcb1de4..b9df4f0fdf40ab 100644 --- a/src/darwin/Framework/CHIP/MTRDevice.mm +++ b/src/darwin/Framework/CHIP/MTRDevice.mm @@ -569,14 +569,12 @@ - (void)_setupSubscription }); }); - // Set up a cluster state cache. We really just want this for the - // logic it has for tracking data versions and event numbers so we - // minimize the amount of data we request on resubscribes; we - // don't care about the data it stores. Ideally we could use the - // dataversion-management logic without needing to store the data - // separately from the data store we already have, or we would - // stop storing our data separately. - auto clusterStateCache = std::make_unique(*callback.get()); + // Set up a cluster state cache. We just want this for the logic it has for + // tracking data versions and event numbers so we minimize the amount of data we + // request on resubscribes, so tell it not to store data. + auto clusterStateCache = std::make_unique(*callback.get(), + /* highestReceivedEventNumber = */ NullOptional, + /* cacheData = */ false); auto readClient = std::make_unique(InteractionModelEngine::GetInstance(), exchangeManager, clusterStateCache->GetBufferedCallback(), ReadClient::InteractionType::Subscribe); From fe07225d5080b690bd7555fc8492c48a5d91e8ce Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 25 Apr 2023 01:52:48 +0000 Subject: [PATCH 31/54] Bump igsekor/pyspelling-any from 0.0.2 to 1.0.4 (#25121) Bumps [igsekor/pyspelling-any](https://github.com/igsekor/pyspelling-any) from 0.0.2 to 1.0.4. - [Release notes](https://github.com/igsekor/pyspelling-any/releases) - [Commits](https://github.com/igsekor/pyspelling-any/compare/v0.0.2...v1.0.4) --- updated-dependencies: - dependency-name: igsekor/pyspelling-any dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/spell.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/spell.yml b/.github/workflows/spell.yml index 2ccd0133f89225..f073c203385e53 100644 --- a/.github/workflows/spell.yml +++ b/.github/workflows/spell.yml @@ -52,4 +52,4 @@ jobs: token: ${{ github.token }} attempt_limit: 3 attempt_delay: 2000 - - uses: igsekor/pyspelling-any@v0.0.2 + - uses: igsekor/pyspelling-any@v1.0.4 From bcf1b80f82f68e1b7de218a13b485e3a387b9d31 Mon Sep 17 00:00:00 2001 From: Jean-Francois Penven <67962328+jepenven-silabs@users.noreply.github.com> Date: Tue, 25 Apr 2023 01:05:09 -0400 Subject: [PATCH 32/54] [Silabs] merge LEDWidget (#26222) * Silabs merge LEDWidget * Fix CI --- examples/chef/efr32/src/AppTask.cpp | 8 +- .../silabs/SiWx917/src/AppTask.cpp | 2 - .../silabs/efr32/src/AppTask.cpp | 3 - .../silabs/SiWx917/src/AppTask.cpp | 6 -- .../lighting-app/silabs/efr32/src/AppTask.cpp | 15 +--- .../lighting-app/silabs/efr32/src/main.cpp | 7 +- .../lock-app/silabs/SiWx917/src/AppTask.cpp | 11 --- .../lock-app/silabs/efr32/src/AppTask.cpp | 17 +--- .../silabs/{SiWx917 => }/LEDWidget.cpp | 14 ++- .../platform/silabs/{efr32 => }/LEDWidget.h | 6 +- examples/platform/silabs/SiWx917/BUILD.gn | 5 +- .../silabs/SiWx917/BaseApplication.cpp | 17 ---- examples/platform/silabs/SiWx917/LEDWidget.h | 44 --------- examples/platform/silabs/efr32/BUILD.gn | 5 +- .../platform/silabs/efr32/BaseApplication.cpp | 2 +- examples/platform/silabs/efr32/LEDWidget.cpp | 89 ------------------- .../thermostat/silabs/efr32/src/AppTask.cpp | 3 - .../silabs/SiWx917/include/WindowAppImpl.h | 4 - .../silabs/SiWx917/src/WindowAppImpl.cpp | 41 +++------ .../silabs/efr32/include/WindowAppImpl.h | 5 -- .../silabs/efr32/src/WindowAppImpl.cpp | 46 +++------- .../silabs/platformAbstraction/GSDK_SPAM.cpp | 11 ++- .../platformAbstraction/WiseMCU_SPAM.cpp | 11 +-- 23 files changed, 61 insertions(+), 311 deletions(-) rename examples/platform/silabs/{SiWx917 => }/LEDWidget.cpp (84%) rename examples/platform/silabs/{efr32 => }/LEDWidget.h (92%) delete mode 100644 examples/platform/silabs/SiWx917/LEDWidget.h delete mode 100644 examples/platform/silabs/efr32/LEDWidget.cpp diff --git a/examples/chef/efr32/src/AppTask.cpp b/examples/chef/efr32/src/AppTask.cpp index 111340eeb66e5a..397fab5d482f7d 100644 --- a/examples/chef/efr32/src/AppTask.cpp +++ b/examples/chef/efr32/src/AppTask.cpp @@ -21,10 +21,7 @@ #include "AppConfig.h" #include "AppEvent.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "lcd.h" @@ -51,10 +48,7 @@ #include -#ifdef ENABLE_WSTK_LEDS -#define SYSTEM_STATE_LED &sl_led_led0 -#endif // ENABLE_WSTK_LEDS - +#define SYSTEM_STATE_LED 0 #define APP_FUNCTION_BUTTON &sl_button_btn0 using namespace chip; diff --git a/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp b/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp index 2fbad4ed4d3286..d53505b3374775 100644 --- a/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/light-switch-app/silabs/SiWx917/src/AppTask.cpp @@ -26,9 +26,7 @@ #include "AppEvent.h" #include "BindingHandler.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#endif // ENABLE_WSTK_LEDS #include "LightSwitchMgr.h" diff --git a/examples/light-switch-app/silabs/efr32/src/AppTask.cpp b/examples/light-switch-app/silabs/efr32/src/AppTask.cpp index 4f2aca11f0712b..fab53ca052baf6 100644 --- a/examples/light-switch-app/silabs/efr32/src/AppTask.cpp +++ b/examples/light-switch-app/silabs/efr32/src/AppTask.cpp @@ -26,10 +26,7 @@ #include "AppEvent.h" #include "BindingHandler.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #include "LightSwitchMgr.h" diff --git a/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp b/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp index 8da8003549c216..409890949085dd 100644 --- a/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/lighting-app/silabs/SiWx917/src/AppTask.cpp @@ -36,19 +36,15 @@ #include -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" #define APP_ACTION_LED 1 -#endif // ENABLE_WSTK_LEDS using namespace chip; using namespace ::chip::DeviceLayer; namespace { -#ifdef ENABLE_WSTK_LEDS LEDWidget sLightLED; -#endif // ENABLE_WSTK_LEDS EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; @@ -143,10 +139,8 @@ CHIP_ERROR AppTask::Init() LightMgr().SetCallbacks(ActionInitiated, ActionCompleted); -#ifdef ENABLE_WSTK_LEDS sLightLED.Init(APP_ACTION_LED); sLightLED.Set(LightMgr().IsLightOn()); -#endif // ENABLE_WSTK_LEDS return err; } diff --git a/examples/lighting-app/silabs/efr32/src/AppTask.cpp b/examples/lighting-app/silabs/efr32/src/AppTask.cpp index 1169e09619eb32..58197087f4b2cb 100755 --- a/examples/lighting-app/silabs/efr32/src/AppTask.cpp +++ b/examples/lighting-app/silabs/efr32/src/AppTask.cpp @@ -21,10 +21,7 @@ #include "AppConfig.h" #include "AppEvent.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #include #include @@ -41,13 +38,11 @@ #include -#ifdef ENABLE_WSTK_LEDS #if defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) -#define LIGHT_LED &sl_led_led1 +#define LIGHT_LED 1 #else -#define LIGHT_LED &sl_led_led0 +#define LIGHT_LED 0 #endif -#endif // ENABLE_WSTK_LEDS #ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT @@ -60,9 +55,7 @@ using namespace ::chip::DeviceLayer; namespace { -#ifdef ENABLE_WSTK_LEDS LEDWidget sLightLED; -#endif // ENABLE_WSTK_LEDS EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; @@ -157,10 +150,8 @@ CHIP_ERROR AppTask::Init() LightMgr().SetCallbacks(ActionInitiated, ActionCompleted); -#ifdef ENABLE_WSTK_LEDS sLightLED.Init(LIGHT_LED); sLightLED.Set(LightMgr().IsLightOn()); -#endif // ENABLE_WSTK_LEDS // Update the LCD with the Stored value. Show QR Code if not provisioned #ifdef DISPLAY_ENABLED @@ -298,9 +289,7 @@ void AppTask::ActionInitiated(LightingManager::Action_t aAction, int32_t aActor) bool lightOn = aAction == LightingManager::ON_ACTION; SILABS_LOG("Turning light %s", (lightOn) ? "On" : "Off") -#ifdef ENABLE_WSTK_LEDS sLightLED.Set(lightOn); -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED sAppTask.GetLCD().WriteDemoUI(lightOn); diff --git a/examples/lighting-app/silabs/efr32/src/main.cpp b/examples/lighting-app/silabs/efr32/src/main.cpp index 73d81d7c2979c5..7bfae98d5b397f 100644 --- a/examples/lighting-app/silabs/efr32/src/main.cpp +++ b/examples/lighting-app/silabs/efr32/src/main.cpp @@ -20,7 +20,6 @@ #include #include "AppConfig.h" -#include "init_efrPlatform.h" #ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT #include "sl_simple_button_instances.h" #endif @@ -35,11 +34,14 @@ #include #endif +#include + #define BLE_DEV_NAME "SiLabs-Light" using namespace ::chip; using namespace ::chip::Inet; using namespace ::chip::DeviceLayer; using namespace ::chip::Credentials; +using namespace chip::DeviceLayer::Silabs; #define UNUSED_PARAMETER(a) (a = a) @@ -51,7 +53,8 @@ static chip::DeviceLayer::DeviceInfoProviderImpl gExampleDeviceInfoProvider; // ================================================================================ int main(void) { - init_efrPlatform(); + GetPlatform().Init(); + if (SilabsMatterConfig::InitMatter(BLE_DEV_NAME) != CHIP_NO_ERROR) appError(CHIP_ERROR_INTERNAL); diff --git a/examples/lock-app/silabs/SiWx917/src/AppTask.cpp b/examples/lock-app/silabs/SiWx917/src/AppTask.cpp index abc276588bdab6..a85ac491927d3f 100644 --- a/examples/lock-app/silabs/SiWx917/src/AppTask.cpp +++ b/examples/lock-app/silabs/SiWx917/src/AppTask.cpp @@ -24,9 +24,7 @@ #include "EventHandlerLibShell.h" #endif // ENABLE_CHIP_SHELL -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "lcd.h" @@ -53,9 +51,7 @@ #include -#ifdef ENABLE_WSTK_LEDS #define LOCK_STATE_LED 1 -#endif // ENABLE_WSTK_LEDS using chip::app::Clusters::DoorLock::DlLockState; using chip::app::Clusters::DoorLock::OperationErrorEnum; @@ -67,9 +63,7 @@ using namespace ::chip::DeviceLayer::Internal; using namespace SI917DoorLock::LockInitParams; namespace { -#ifdef ENABLE_WSTK_LEDS LEDWidget sLockLED; -#endif // ENABLE_WSTK_LEDS EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; } // namespace @@ -238,11 +232,8 @@ CHIP_ERROR AppTask::Init() LockMgr().SetCallbacks(ActionInitiated, ActionCompleted); -#ifdef ENABLE_WSTK_LEDS - // Initialize LEDs sLockLED.Init(LOCK_STATE_LED); sLockLED.Set(state.Value() == DlLockState::kUnlocked); -#endif // ENABLE_WSTK_LEDS chip::DeviceLayer::PlatformMgr().ScheduleWork(UpdateClusterState, reinterpret_cast(nullptr)); @@ -371,9 +362,7 @@ void AppTask::ActionInitiated(LockManager::Action_t aAction, int32_t aActor) { bool locked = (aAction == LockManager::LOCK_ACTION); SILABS_LOG("%s Action has been initiated", (locked) ? "Lock" : "Unlock"); -#ifdef ENABLE_WSTK_LEDS sLockLED.Set(!locked); -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED sAppTask.GetLCD().WriteDemoUI(locked); diff --git a/examples/lock-app/silabs/efr32/src/AppTask.cpp b/examples/lock-app/silabs/efr32/src/AppTask.cpp index ef01ebedff6885..ed1b51df6831d4 100644 --- a/examples/lock-app/silabs/efr32/src/AppTask.cpp +++ b/examples/lock-app/silabs/efr32/src/AppTask.cpp @@ -24,10 +24,7 @@ #include "EventHandlerLibShell.h" #endif // ENABLE_CHIP_SHELL -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "lcd.h" @@ -53,11 +50,8 @@ #include #include - -#ifdef ENABLE_WSTK_LEDS -#define SYSTEM_STATE_LED &sl_led_led0 -#define LOCK_STATE_LED &sl_led_led1 -#endif // ENABLE_WSTK_LEDS +#define SYSTEM_STATE_LED 0 +#define LOCK_STATE_LED 1 #define APP_FUNCTION_BUTTON &sl_button_btn0 #define APP_LOCK_SWITCH &sl_button_btn1 @@ -72,9 +66,7 @@ using namespace ::chip::DeviceLayer::Internal; using namespace EFR32DoorLock::LockInitParams; namespace { -#ifdef ENABLE_WSTK_LEDS LEDWidget sLockLED; -#endif // ENABLE_WSTK_LEDS EmberAfIdentifyEffectIdentifier sIdentifyEffect = EMBER_ZCL_IDENTIFY_EFFECT_IDENTIFIER_STOP_EFFECT; } // namespace @@ -243,11 +235,8 @@ CHIP_ERROR AppTask::Init() LockMgr().SetCallbacks(ActionInitiated, ActionCompleted); -#ifdef ENABLE_WSTK_LEDS - // Initialize LEDs sLockLED.Init(LOCK_STATE_LED); sLockLED.Set(state.Value() == DlLockState::kUnlocked); -#endif // ENABLE_WSTK_LEDS // Update the LCD with the Stored value. Show QR Code if not provisioned #ifdef DISPLAY_ENABLED @@ -395,9 +384,7 @@ void AppTask::ActionInitiated(LockManager::Action_t aAction, int32_t aActor) { bool locked = (aAction == LockManager::LOCK_ACTION); SILABS_LOG("%s Action has been initiated", (locked) ? "Lock" : "Unlock"); -#ifdef ENABLE_WSTK_LEDS sLockLED.Set(!locked); -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED sAppTask.GetLCD().WriteDemoUI(locked); diff --git a/examples/platform/silabs/SiWx917/LEDWidget.cpp b/examples/platform/silabs/LEDWidget.cpp similarity index 84% rename from examples/platform/silabs/SiWx917/LEDWidget.cpp rename to examples/platform/silabs/LEDWidget.cpp index bb80fa3f9dfcd1..3156a3bdbc8afc 100644 --- a/examples/platform/silabs/SiWx917/LEDWidget.cpp +++ b/examples/platform/silabs/LEDWidget.cpp @@ -20,10 +20,18 @@ #include "LEDWidget.h" #include +#include using namespace ::chip::System; +using namespace chip::DeviceLayer::Silabs; -void LEDWidget::Init(int led) +void LEDWidget::InitGpio(void) +{ + // Sets gpio pin mode for ALL board Leds. + GetPlatform().InitLed(); +} + +void LEDWidget::Init(const uint8_t led) { mLastChangeTimeMS = 0; mBlinkOnTimeMS = 0; @@ -36,14 +44,14 @@ void LEDWidget::Init(int led) void LEDWidget::Invert(void) { - RSI_Board_LED_Toggle(mLed); + GetPlatform().ToggleLed(mLed); mLedStatus = !mLedStatus; } void LEDWidget::Set(bool state) { mLastChangeTimeMS = mBlinkOnTimeMS = mBlinkOffTimeMS = 0; - state ? RSI_Board_LED_Set(mLed, true) : RSI_Board_LED_Set(mLed, false); + GetPlatform().SetLed(state, mLed); mLedStatus = state; } diff --git a/examples/platform/silabs/efr32/LEDWidget.h b/examples/platform/silabs/LEDWidget.h similarity index 92% rename from examples/platform/silabs/efr32/LEDWidget.h rename to examples/platform/silabs/LEDWidget.h index d779cb9d3ef4b6..856c52c47d8209 100644 --- a/examples/platform/silabs/efr32/LEDWidget.h +++ b/examples/platform/silabs/LEDWidget.h @@ -19,14 +19,13 @@ #pragma once -#include "sl_led.h" #include class LEDWidget { public: static void InitGpio(void); - void Init(const sl_led_t * led); + void Init(uint8_t led); void Set(bool state); void Invert(void); void Blink(uint32_t changeRateMS); @@ -37,5 +36,6 @@ class LEDWidget uint64_t mLastChangeTimeMS; uint32_t mBlinkOnTimeMS; uint32_t mBlinkOffTimeMS; - const sl_led_t * mLed; + uint8_t mLed; + bool mLedStatus; }; diff --git a/examples/platform/silabs/SiWx917/BUILD.gn b/examples/platform/silabs/SiWx917/BUILD.gn index 098829c4cde527..7404436fbc90d8 100644 --- a/examples/platform/silabs/SiWx917/BUILD.gn +++ b/examples/platform/silabs/SiWx917/BUILD.gn @@ -236,6 +236,7 @@ source_set("siwx917-common") { ] sources = [ + "${silabs_common_plat_dir}/LEDWidget.cpp", "${silabs_common_plat_dir}/heap_4_silabs.c", "${wifi_sdk_dir}/dhcp_client.cpp", "${wifi_sdk_dir}/ethernetif.cpp", @@ -252,10 +253,6 @@ source_set("siwx917-common") { sources += [ "BaseApplication.cpp" ] } - if (use_wstk_leds) { - sources += [ "LEDWidget.cpp" ] - } - if (chip_enable_pw_rpc || chip_build_libshell) { sources += [ "uart.cpp" ] } diff --git a/examples/platform/silabs/SiWx917/BaseApplication.cpp b/examples/platform/silabs/SiWx917/BaseApplication.cpp index 4ed8ea273e0a5f..f0dde1ffc39e80 100644 --- a/examples/platform/silabs/SiWx917/BaseApplication.cpp +++ b/examples/platform/silabs/SiWx917/BaseApplication.cpp @@ -25,9 +25,7 @@ #include "AppEvent.h" #include "AppTask.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "lcd.h" @@ -68,9 +66,7 @@ #define APP_TASK_PRIORITY 2 #define APP_EVENT_QUEUE_SIZE 10 #define EXAMPLE_VENDOR_ID 0xcafe -#ifdef ENABLE_WSTK_LEDS #define APP_STATE_LED 0 -#endif // ENABLE_WSTK_LEDS using namespace chip; using namespace ::chip::DeviceLayer; @@ -87,9 +83,7 @@ TimerHandle_t sLightTimer; TaskHandle_t sAppTaskHandle; QueueHandle_t sAppEventQueue; -#ifdef ENABLE_WSTK_LEDS LEDWidget sStatusLED; -#endif // ENABLE_WSTK_LEDS #ifdef SL_WIFI app::Clusters::NetworkCommissioning::Instance @@ -204,9 +198,7 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj) SILABS_LOG("Current Software Version String: %s", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION_STRING); SILABS_LOG("Current Software Version: %d", CHIP_DEVICE_CONFIG_DEVICE_SOFTWARE_VERSION); -#ifdef ENABLE_WSTK_LEDS sStatusLED.Init(APP_STATE_LED); -#endif // ENABLE_WSTK_LEDS ConfigurationMgr().LogDeviceConfig(); @@ -302,7 +294,6 @@ void BaseApplication::LightEventHandler() // the LEDs at an even rate of 100ms. // // Otherwise, blink the LED ON for a very short time. -#ifdef ENABLE_WSTK_LEDS if (mFunction != kFunction_FactoryReset) { if ((gIdentifyptr != nullptr) && (gIdentifyptr->mActive)) @@ -348,7 +339,6 @@ void BaseApplication::LightEventHandler() } sStatusLED.Animate(); -#endif // ENABLE_WSTK_LEDS } void BaseApplication::ButtonHandler(AppEvent * aEvent) @@ -382,13 +372,10 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent) break; } -#ifdef ENABLE_WSTK_LEDS // Turn off status LED before starting blink to make sure blink is // co-ordinated. sStatusLED.Set(false); sStatusLED.Blink(500); -#endif // ENABLE_WSTK_LEDS - SILABS_LOG("Factory reset triggering in %d sec release button to cancel", count--); // Delay of 1sec before checking the button status again @@ -397,9 +384,7 @@ void BaseApplication::ButtonHandler(AppEvent * aEvent) if (count > 0) { -#ifdef ENABLE_WSTK_LEDS sStatusLED.Set(false); -#endif SILABS_LOG("Factory Reset has been Canceled"); // button held past Timeout wait till button is released } @@ -467,9 +452,7 @@ void BaseApplication::StartStatusLEDTimer() void BaseApplication::StopStatusLEDTimer() { -#ifdef ENABLE_WSTK_LEDS sStatusLED.Set(false); -#endif // ENABLE_WSTK_LEDS if (xTimerStop(sLightTimer, pdMS_TO_TICKS(100)) != pdPASS) { diff --git a/examples/platform/silabs/SiWx917/LEDWidget.h b/examples/platform/silabs/SiWx917/LEDWidget.h deleted file mode 100644 index 596f64af094d7a..00000000000000 --- a/examples/platform/silabs/SiWx917/LEDWidget.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#pragma once - -#include - -extern "C" void RSI_Board_LED_Set(int, int); -extern "C" void RSI_Board_LED_Toggle(int); - -class LEDWidget -{ -public: - void Init(int led); - void Set(bool state); - void Invert(void); - void Blink(uint32_t changeRateMS); - void Blink(uint32_t onTimeMS, uint32_t offTimeMS); - void Animate(); - -private: - uint64_t mLastChangeTimeMS; - uint32_t mBlinkOnTimeMS; - uint32_t mBlinkOffTimeMS; - int mLed; - // created a temporary mLedStatus since Led status is not updating from the platform API(RSI_EGPIO_GetPin) - bool mLedStatus; -}; diff --git a/examples/platform/silabs/efr32/BUILD.gn b/examples/platform/silabs/efr32/BUILD.gn index 48fb282c8fbb5f..d74792a1cba233 100644 --- a/examples/platform/silabs/efr32/BUILD.gn +++ b/examples/platform/silabs/efr32/BUILD.gn @@ -280,6 +280,7 @@ source_set("efr32-common") { include_dirs = [ "." ] sources = [ + "${silabs_common_plat_dir}/LEDWidget.cpp", "${silabs_common_plat_dir}/heap_4_silabs.c", "${silabs_common_plat_dir}/syscalls_stubs.cpp", "efr32_utils.cpp", @@ -291,10 +292,6 @@ source_set("efr32-common") { sources += [ "BaseApplication.cpp" ] } - if (use_wstk_leds) { - sources += [ "LEDWidget.cpp" ] - } - if (chip_enable_pw_rpc || chip_build_libshell || enable_openthread_cli) { sources += [ "uart.cpp" ] } diff --git a/examples/platform/silabs/efr32/BaseApplication.cpp b/examples/platform/silabs/efr32/BaseApplication.cpp index bbb18fc005883a..e29797607f7e35 100644 --- a/examples/platform/silabs/efr32/BaseApplication.cpp +++ b/examples/platform/silabs/efr32/BaseApplication.cpp @@ -73,7 +73,7 @@ #define EXAMPLE_VENDOR_ID 0xcafe #if defined(ENABLE_WSTK_LEDS) && defined(SL_CATALOG_SIMPLE_LED_LED1_PRESENT) -#define SYSTEM_STATE_LED &sl_led_led0 +#define SYSTEM_STATE_LED 0 #endif // ENABLE_WSTK_LEDS #ifdef SL_CATALOG_SIMPLE_BUTTON_PRESENT #define APP_FUNCTION_BUTTON &sl_button_btn0 diff --git a/examples/platform/silabs/efr32/LEDWidget.cpp b/examples/platform/silabs/efr32/LEDWidget.cpp deleted file mode 100644 index 10ffcac363520d..00000000000000 --- a/examples/platform/silabs/efr32/LEDWidget.cpp +++ /dev/null @@ -1,89 +0,0 @@ -/* - * - * Copyright (c) 2020 Project CHIP Authors - * Copyright (c) 2019 Google LLC. - * All rights reserved. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "LEDWidget.h" - -extern "C" { -#include "sl_simple_led_instances.h" -} - -#include - -using namespace ::chip::System; - -void LEDWidget::InitGpio(void) -{ - // Sets gpio pin mode for ALL board Leds. - sl_simple_led_init_instances(); -} - -void LEDWidget::Init(const sl_led_t * led) -{ - mLastChangeTimeMS = 0; - mBlinkOnTimeMS = 0; - mBlinkOffTimeMS = 0; - mLed = led; - - Set(false); -} - -void LEDWidget::Invert(void) -{ - if (mLed) - { - sl_led_toggle(mLed); - } -} - -void LEDWidget::Set(bool state) -{ - mLastChangeTimeMS = mBlinkOnTimeMS = mBlinkOffTimeMS = 0; - if (mLed) - { - state ? sl_led_turn_on(mLed) : sl_led_turn_off(mLed); - } -} - -void LEDWidget::Blink(uint32_t changeRateMS) -{ - Blink(changeRateMS, changeRateMS); -} - -void LEDWidget::Blink(uint32_t onTimeMS, uint32_t offTimeMS) -{ - mBlinkOnTimeMS = onTimeMS; - mBlinkOffTimeMS = offTimeMS; - Animate(); -} - -void LEDWidget::Animate() -{ - if (mBlinkOnTimeMS != 0 && mBlinkOffTimeMS != 0) - { - uint64_t nowMS = chip::System::SystemClock().GetMonotonicMilliseconds64().count(); - uint64_t stateDurMS = sl_led_get_state(mLed) ? mBlinkOnTimeMS : mBlinkOffTimeMS; - uint64_t nextChangeTimeMS = mLastChangeTimeMS + stateDurMS; - - if (nextChangeTimeMS < nowMS) - { - Invert(); - mLastChangeTimeMS = nowMS; - } - } -} diff --git a/examples/thermostat/silabs/efr32/src/AppTask.cpp b/examples/thermostat/silabs/efr32/src/AppTask.cpp index 2ccaec5fed2e1c..21cee0c90cc122 100644 --- a/examples/thermostat/silabs/efr32/src/AppTask.cpp +++ b/examples/thermostat/silabs/efr32/src/AppTask.cpp @@ -25,10 +25,7 @@ #include "AppConfig.h" #include "AppEvent.h" -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED #include "ThermostatUI.h" diff --git a/examples/window-app/silabs/SiWx917/include/WindowAppImpl.h b/examples/window-app/silabs/SiWx917/include/WindowAppImpl.h index 0acb38a4b1de22..827e3b120e7992 100644 --- a/examples/window-app/silabs/SiWx917/include/WindowAppImpl.h +++ b/examples/window-app/silabs/SiWx917/include/WindowAppImpl.h @@ -19,9 +19,7 @@ #include -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#endif // ENABLE_WSTK_LEDS #include #include @@ -90,10 +88,8 @@ class WindowAppImpl : public WindowApp TaskHandle_t mHandle = nullptr; QueueHandle_t mQueue = nullptr; -#ifdef ENABLE_WSTK_LEDS LEDWidget mStatusLED; LEDWidget mActionLED; -#endif // ENABLE_WSTK_LEDS // Get QR Code and emulate its content using NFC tag char mQRCodeBuffer[chip::QRCodeBasicSetupPayloadGenerator::kMaxQRCodeBase38RepresentationLength + 1]; diff --git a/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp b/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp index 108fd77f9f8e37..2d65b5a2117451 100644 --- a/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp +++ b/examples/window-app/silabs/SiWx917/src/WindowAppImpl.cpp @@ -203,10 +203,9 @@ CHIP_ERROR WindowAppImpl::Init() } // Initialize LEDs -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Init(APP_STATE_LED); mActionLED.Init(APP_ACTION_LED); -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED slLCD.Init(); @@ -393,21 +392,19 @@ void WindowAppImpl::UpdateLEDs() Cover & cover = GetCover(); if (mResetWarning) { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Set(false); mStatusLED.Blink(500); mActionLED.Set(false); mActionLED.Blink(500); -#endif // ENABLE_WSTK_LEDS } else { if (mState.isWinking) { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Blink(200, 200); -#endif // ENABLE_WSTK_LEDS } else #if CHIP_ENABLE_OPENTHREAD @@ -417,22 +414,11 @@ void WindowAppImpl::UpdateLEDs() #endif { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Blink(950, 50); -#endif // ENABLE_WSTK_LEDS - } - else if (mState.haveBLEConnections) - { -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Blink(100, 100); -#endif // ENABLE_WSTK_LEDS - } - else - { -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Blink(50, 950); -#endif // ENABLE_WSTK_LEDS } + else if (mState.haveBLEConnections) { mStatusLED.Blink(100, 100); } + else { mStatusLED.Blink(50, 950); } // Action LED NPercent100ths current; @@ -450,27 +436,23 @@ void WindowAppImpl::UpdateLEDs() if (OperationalState::Stall != cover.mLiftOpState) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Blink(100); -#endif // ENABLE_WSTK_LEDS } else if (LimitStatus::IsUpOrOpen == liftLimit) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Set(true); -#endif // ENABLE_WSTK_LEDS } else if (LimitStatus::IsDownOrClose == liftLimit) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Set(false); -#endif // ENABLE_WSTK_LEDS } else { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Blink(1000); -#endif // ENABLE_WSTK_LEDS } } } @@ -519,10 +501,9 @@ void WindowAppImpl::UpdateLCD() void WindowAppImpl::OnMainLoop() { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Animate(); mActionLED.Animate(); -#endif // ENABLE_WSTK_LEDS } //------------------------------------------------------------------------------ diff --git a/examples/window-app/silabs/efr32/include/WindowAppImpl.h b/examples/window-app/silabs/efr32/include/WindowAppImpl.h index a43f68ed85f6ef..27a26dba9a4399 100644 --- a/examples/window-app/silabs/efr32/include/WindowAppImpl.h +++ b/examples/window-app/silabs/efr32/include/WindowAppImpl.h @@ -19,10 +19,7 @@ #include -#ifdef ENABLE_WSTK_LEDS #include "LEDWidget.h" -#include "sl_simple_led_instances.h" -#endif // ENABLE_WSTK_LEDS #include #include @@ -85,10 +82,8 @@ class WindowAppImpl : public WindowApp TaskHandle_t mHandle = nullptr; QueueHandle_t mQueue = nullptr; -#ifdef ENABLE_WSTK_LEDS LEDWidget mStatusLED; LEDWidget mActionLED; -#endif // ENABLE_WSTK_LEDS // Get QR Code and emulate its content using NFC tag char mQRCodeBuffer[chip::QRCodeBasicSetupPayloadGenerator::kMaxQRCodeBase38RepresentationLength + 1]; diff --git a/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp b/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp index 77d3d6800c5d0a..734a4b4bc5d1a3 100644 --- a/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp +++ b/examples/window-app/silabs/efr32/src/WindowAppImpl.cpp @@ -33,10 +33,6 @@ #endif // QR_CODE_ENABLED #include -#ifdef ENABLE_WSTK_LEDS -#include -#endif // ENABLE_WSTK_LEDS - #include #ifdef SL_WIFI @@ -60,8 +56,8 @@ SilabsLCD slLCD; using namespace chip::app::Clusters::WindowCovering; using namespace chip; using namespace ::chip::DeviceLayer; -#define APP_STATE_LED &sl_led_led0 -#define APP_ACTION_LED &sl_led_led1 +#define APP_STATE_LED 0 +#define APP_ACTION_LED 1 #ifdef SL_WIFI chip::app::Clusters::NetworkCommissioning::Instance @@ -208,11 +204,9 @@ CHIP_ERROR WindowAppImpl::Init() } // Initialize LEDs -#ifdef ENABLE_WSTK_LEDS LEDWidget::InitGpio(); mStatusLED.Init(APP_STATE_LED); mActionLED.Init(APP_ACTION_LED); -#endif // ENABLE_WSTK_LEDS #ifdef DISPLAY_ENABLED slLCD.Init(); @@ -397,21 +391,17 @@ void WindowAppImpl::UpdateLEDs() Cover & cover = GetCover(); if (mResetWarning) { -#ifdef ENABLE_WSTK_LEDS mStatusLED.Set(false); mStatusLED.Blink(500); mActionLED.Set(false); mActionLED.Blink(500); -#endif // ENABLE_WSTK_LEDS } else { if (mState.isWinking) { -#ifdef ENABLE_WSTK_LEDS mStatusLED.Blink(200, 200); -#endif // ENABLE_WSTK_LEDS } else #if CHIP_ENABLE_OPENTHREAD @@ -421,22 +411,11 @@ void WindowAppImpl::UpdateLEDs() #endif { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Blink(950, 50); -#endif // ENABLE_WSTK_LEDS - } - else if (mState.haveBLEConnections) - { -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Blink(100, 100); -#endif // ENABLE_WSTK_LEDS - } - else - { -#ifdef ENABLE_WSTK_LEDS - mStatusLED.Blink(50, 950); -#endif // ENABLE_WSTK_LEDS } + else if (mState.haveBLEConnections) { mStatusLED.Blink(100, 100); } + else { mStatusLED.Blink(50, 950); } // Action LED NPercent100ths current; @@ -454,27 +433,23 @@ void WindowAppImpl::UpdateLEDs() if (OperationalState::Stall != cover.mLiftOpState) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Blink(100); -#endif // ENABLE_WSTK_LEDS } else if (LimitStatus::IsUpOrOpen == liftLimit) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Set(true); -#endif // ENABLE_WSTK_LEDS } else if (LimitStatus::IsDownOrClose == liftLimit) { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Set(false); -#endif // ENABLE_WSTK_LEDS } else { -#ifdef ENABLE_WSTK_LEDS + mActionLED.Blink(1000); -#endif // ENABLE_WSTK_LEDS } } } @@ -523,10 +498,9 @@ void WindowAppImpl::UpdateLCD() void WindowAppImpl::OnMainLoop() { -#ifdef ENABLE_WSTK_LEDS + mStatusLED.Animate(); mActionLED.Animate(); -#endif // ENABLE_WSTK_LEDS } //------------------------------------------------------------------------------ diff --git a/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp b/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp index e0f954e101a90d..007977a6d66639 100644 --- a/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp +++ b/src/platform/silabs/platformAbstraction/GSDK_SPAM.cpp @@ -18,6 +18,12 @@ #include "init_efrPlatform.h" #include +#ifdef ENABLE_WSTK_LEDS +extern "C" { +#include "sl_simple_led_instances.h" +} +#endif + namespace chip { namespace DeviceLayer { namespace Silabs { @@ -31,9 +37,6 @@ CHIP_ERROR SilabsPlatform::Init(void) } #ifdef ENABLE_WSTK_LEDS - -#include "sl_simple_led_instances.h" - void SilabsPlatform::InitLed(void) { sl_simple_led_init_instances(); @@ -54,7 +57,7 @@ bool SilabsPlatform::GetLedState(uint8_t led) { if (led >= SL_SIMPLE_LED_COUNT) { - return 0; + return false; } return sl_led_get_state(SL_SIMPLE_LED_INSTANCE(led)); diff --git a/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp b/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp index 97004960f94d06..816c9a6df4459d 100644 --- a/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp +++ b/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp @@ -37,27 +37,28 @@ CHIP_ERROR SilabsPlatform::Init(void) #ifdef ENABLE_WSTK_LEDS void SilabsPlatform::InitLed(void) { - // TODO ? + // TODO SilabsPlatformAbstractionBase::InitLed(); } CHIP_ERROR SilabsPlatform::SetLed(bool state, uint8_t led) override { - // TODO add range check ? + // TODO add range check RSI_Board_LED_Set(led, state); return CHIP_NO_ERROR; } bool SilabsPlatform::GetLedState(uint8_t led) { - // TODO ? + // TODO return SilabsPlatformAbstractionBase::GetLedState(led); } CHIP_ERROR SilabsPlatform::ToggleLed(uint8_t led) override { - // TODO add range check ? - RSI_Board_LED_Toggle(led) return CHIP_NO_ERROR; + // TODO add range check + RSI_Board_LED_Toggle(led); + return CHIP_NO_ERROR; } #endif // ENABLE_WSTK_LEDS From 710c951da5218c54a07cf7862c63644821ea88de Mon Sep 17 00:00:00 2001 From: Sergei Lissianoi <54454955+selissia@users.noreply.github.com> Date: Tue, 25 Apr 2023 08:27:27 -0400 Subject: [PATCH 33/54] Reset the OTARequestor state if the downloaded image is invalid (#26230) --- src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp | 4 ++++ src/platform/silabs/efr32/OTAImageProcessorImpl.cpp | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp b/src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp index a838564d919520..2cfcc9694267e9 100644 --- a/src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp +++ b/src/platform/silabs/SiWx917/OTAImageProcessorImpl.cpp @@ -190,6 +190,8 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) if (err != SL_BOOTLOADER_OK) { ChipLogError(SoftwareUpdate, "ERROR: bootloader_verifyImage() error %ld", err); + // Call the OTARequestor API to reset the state + GetRequestorInstance()->CancelImageUpdate(); return; } @@ -198,6 +200,8 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) if (err != SL_BOOTLOADER_OK) { ChipLogError(SoftwareUpdate, "ERROR: bootloader_setImageToBootload() error %ld", err); + // Call the OTARequestor API to reset the state + GetRequestorInstance()->CancelImageUpdate(); return; } diff --git a/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp b/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp index 83b815568b24fa..6d2bce9fdfb41b 100644 --- a/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp +++ b/src/platform/silabs/efr32/OTAImageProcessorImpl.cpp @@ -201,6 +201,8 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) if (err != SL_BOOTLOADER_OK) { ChipLogError(SoftwareUpdate, "ERROR: bootloader_verifyImage() error %ld", err); + // Call the OTARequestor API to reset the state + GetRequestorInstance()->CancelImageUpdate(); return; } @@ -209,6 +211,8 @@ void OTAImageProcessorImpl::HandleApply(intptr_t context) if (err != SL_BOOTLOADER_OK) { ChipLogError(SoftwareUpdate, "ERROR: bootloader_setImageToBootload() error %ld", err); + // Call the OTARequestor API to reset the state + GetRequestorInstance()->CancelImageUpdate(); return; } From d8b703f79702a9ff9c1d89eec77c8db9485d8982 Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Tue, 25 Apr 2023 09:29:37 -0400 Subject: [PATCH 34/54] Fix Disconnect RPC for ESP 32 (#26231) * Fix Disconnect RPC for ESP 32 * Restyle --- examples/platform/esp32/Rpc.cpp | 10 +++++++--- src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp | 6 ++++++ 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/examples/platform/esp32/Rpc.cpp b/examples/platform/esp32/Rpc.cpp index 3d865ed13bdc7a..1ad91dddef4253 100644 --- a/examples/platform/esp32/Rpc.cpp +++ b/examples/platform/esp32/Rpc.cpp @@ -204,8 +204,11 @@ class Esp32WiFi final : public WiFi size_t password_size = std::min(sizeof(password) - 1, static_cast(request.secret.size)); memcpy(password, request.secret.bytes, password_size); password[password_size] = '\0'; - if (chip::DeviceLayer::NetworkCommissioning::ESPWiFiDriver::GetInstance().ConnectWiFiNetwork( - ssid, strlen(ssid), password, strlen(password)) != CHIP_NO_ERROR) + chip::DeviceLayer::PlatformMgr().LockChipStack(); + CHIP_ERROR error = chip::DeviceLayer::NetworkCommissioning::ESPWiFiDriver::GetInstance().ConnectWiFiNetwork( + ssid, strlen(ssid), password, strlen(password)); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + if (error != CHIP_NO_ERROR) { return pw::Status::Internal(); } @@ -214,8 +217,9 @@ class Esp32WiFi final : public WiFi pw::Status Disconnect(const pw_protobuf_Empty & request, pw_protobuf_Empty & response) override { + chip::DeviceLayer::PlatformMgr().LockChipStack(); chip::DeviceLayer::ConnectivityMgr().ClearWiFiStationProvision(); - chip::DeviceLayer::ConnectivityMgr().SetWiFiStationMode(chip::DeviceLayer::ConnectivityManager::kWiFiStationMode_Disabled); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); return pw::OkStatus(); } diff --git a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp index 4c962d24a5e5b0..48251a27129962 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp @@ -105,6 +105,12 @@ void ConnectivityManagerImpl::_ClearWiFiStationProvision(void) { if (mWiFiStationMode != kWiFiStationMode_ApplicationControlled) { + CHIP_ERROR error = chip::DeviceLayer::Internal::ESP32Utils::ClearWiFiStationProvision(); + if (error != CHIP_NO_ERROR) + { + ChipLogError(DeviceLayer, "ClearWiFiStationProvision failed: %s", chip::ErrorStr(error)); + return; + } DeviceLayer::SystemLayer().ScheduleWork(DriveStationState, NULL); #if CHIP_DEVICE_CONFIG_ENABLE_WIFI_AP DeviceLayer::SystemLayer().ScheduleWork(DriveAPState, NULL); From 3212d3556f68f18969bf45b3951743457c232ef0 Mon Sep 17 00:00:00 2001 From: chirag-silabs <100861685+chirag-silabs@users.noreply.github.com> Date: Tue, 25 Apr 2023 19:47:15 +0530 Subject: [PATCH 35/54] adding the lock and unlock chip stack and some build fixes for 917 SoC (#26245) --- examples/platform/silabs/SiWx917/BaseApplication.cpp | 3 +++ examples/platform/silabs/efr32/BaseApplication.cpp | 3 +++ src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp | 4 ++-- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/platform/silabs/SiWx917/BaseApplication.cpp b/examples/platform/silabs/SiWx917/BaseApplication.cpp index f0dde1ffc39e80..62b5f4cc1bc361 100644 --- a/examples/platform/silabs/SiWx917/BaseApplication.cpp +++ b/examples/platform/silabs/SiWx917/BaseApplication.cpp @@ -166,7 +166,10 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj) SILABS_LOG("APP: Done WiFi Init"); /* We will init server when we get IP */ + chip::DeviceLayer::PlatformMgr().LockChipStack(); sWiFiNetworkCommissioningInstance.Init(); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + #endif // Create FreeRTOS sw timer for Function Selection. diff --git a/examples/platform/silabs/efr32/BaseApplication.cpp b/examples/platform/silabs/efr32/BaseApplication.cpp index e29797607f7e35..6ce48e736d121e 100644 --- a/examples/platform/silabs/efr32/BaseApplication.cpp +++ b/examples/platform/silabs/efr32/BaseApplication.cpp @@ -178,7 +178,10 @@ CHIP_ERROR BaseApplication::Init(Identify * identifyObj) SILABS_LOG("APP: Done WiFi Init"); /* We will init server when we get IP */ + chip::DeviceLayer::PlatformMgr().LockChipStack(); sWiFiNetworkCommissioningInstance.Init(); + chip::DeviceLayer::PlatformMgr().UnlockChipStack(); + #endif // Create FreeRTOS sw timer for Function Selection. diff --git a/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp b/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp index 816c9a6df4459d..7b5af3e6e87c2b 100644 --- a/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp +++ b/src/platform/silabs/platformAbstraction/WiseMCU_SPAM.cpp @@ -41,7 +41,7 @@ void SilabsPlatform::InitLed(void) SilabsPlatformAbstractionBase::InitLed(); } -CHIP_ERROR SilabsPlatform::SetLed(bool state, uint8_t led) override +CHIP_ERROR SilabsPlatform::SetLed(bool state, uint8_t led) { // TODO add range check RSI_Board_LED_Set(led, state); @@ -54,7 +54,7 @@ bool SilabsPlatform::GetLedState(uint8_t led) return SilabsPlatformAbstractionBase::GetLedState(led); } -CHIP_ERROR SilabsPlatform::ToggleLed(uint8_t led) override +CHIP_ERROR SilabsPlatform::ToggleLed(uint8_t led) { // TODO add range check RSI_Board_LED_Toggle(led); From b2069493e8b296fe2f844479557d0c1aff8b8037 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 25 Apr 2023 10:50:24 -0400 Subject: [PATCH 36/54] Switch to using zcl_struct_items_by_struct_and_cluster_name in templates. (#26226) Our existing uses of zcl_struct_items_by_struct_name were broken if two different clusters used structs with the same name: we would end up enumerating all the struct fields from both structs in a bunch of places. The fix is to use zcl_struct_items_by_struct_and_cluster_name, which takes as input the struct name _and_ the cluster name. No visible codegen changes for now, because we have no such name collisions so far, due to it leading to incorrect codegen. Instead we have been working around it by having our naming not match the spec. This required a few changes other than just the change of helper: 1. The valueEquals in chip-tool did not use to take a cluster name. That needed to be added, and threaded through the call-chain from the place where a cluster name is available, as well as through the recursive invocations of valueEquals. 2. In the java codegen, the cluster name being passed in to encode_value and decode_value was the already-upper-camel-cased version, which does not work as input to zcl_struct_items_by_struct_and_cluster_name. Callsites were changed to pass in the raw cluster name, and actual uses of the name were changed to asUpperCamelCase as needed. 3. While testing, using actual name collisions, a bug was found in the Python codegen: the id of the command being processed was being used when the id of the cluster was intended. --- .../checks/maybeCheckExpectedValue.zapt | 2 +- .../tests/partials/command_value.zapt | 4 ++-- .../tests/partials/test_step_response.zapt | 2 +- .../tests/partials/value_equals.zapt | 18 +++++++------- .../templates/partials/decodable_value.zapt | 4 ++-- .../tests/partials/check_test_value.zapt | 4 ++-- .../templates/tests/partials/test_value.zapt | 4 ++-- .../docker/images/chip-cert-bins/Dockerfile | 2 +- scripts/setup/zap.json | 2 +- scripts/tools/zap/zap_execution.py | 2 +- .../CHIPAttributeTLVValueDecoder-src.zapt | 2 +- .../java/templates/CHIPClustersWrite-JNI.zapt | 2 +- .../CHIPEventTLVValueDecoder-src.zapt | 2 +- .../templates/CHIPInvokeCallbacks-src.zapt | 2 +- .../java/templates/CHIPReadCallbacks-src.zapt | 4 ++-- .../java/templates/partials/decode_value.zapt | 24 +++++++++---------- .../java/templates/partials/encode_value.zapt | 6 ++--- .../templates/python-CHIPClusters-py.zapt | 8 +++---- .../CHIP/templates/partials/decode_value.zapt | 4 ++-- .../CHIP/templates/partials/encode_value.zapt | 4 ++-- 20 files changed, 51 insertions(+), 51 deletions(-) diff --git a/examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedValue.zapt b/examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedValue.zapt index e303eda9cd7a99..a75e7d7be6bcd3 100644 --- a/examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedValue.zapt +++ b/examples/chip-tool/templates/tests/partials/checks/maybeCheckExpectedValue.zapt @@ -1,3 +1,3 @@ {{~#if hasExpectedValue}} - {{~>valueEquals actual=(asPropertyValue dontUnwrapValue=true) label=(asLowerCamelCase name) expected=expectedValue depth=0~}} + {{~>valueEquals actual=(asPropertyValue dontUnwrapValue=true) label=(asLowerCamelCase name) expected=expectedValue cluster=cluster depth=0~}} {{~/if~}} diff --git a/examples/chip-tool/templates/tests/partials/command_value.zapt b/examples/chip-tool/templates/tests/partials/command_value.zapt index d5a1159cceb7fb..150b34294e5e2c 100644 --- a/examples/chip-tool/templates/tests/partials/command_value.zapt +++ b/examples/chip-tool/templates/tests/partials/command_value.zapt @@ -29,11 +29,11 @@ {{else}} {{#if_is_struct type}} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type ns}} {{#if_include_struct_item_value ../definedValue name}} {{>commandValue ns=parent.ns container=(concat parent.container "." (asLowerCamelCase label)) definedValue=(lookup ../definedValue name) depth=(incrementDepth ../depth)}} {{/if_include_struct_item_value}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{container}} = diff --git a/examples/chip-tool/templates/tests/partials/test_step_response.zapt b/examples/chip-tool/templates/tests/partials/test_step_response.zapt index eae82bf13bc463..0f520b856794e7 100644 --- a/examples/chip-tool/templates/tests/partials/test_step_response.zapt +++ b/examples/chip-tool/templates/tests/partials/test_step_response.zapt @@ -29,7 +29,7 @@ switch(mTestSubStepIndex) {{asDecodableType}} value; VerifyOrReturn(CheckDecodeValue(chip::app::DataModel::Decode(*data, value))); {{#chip_tests_item_response_parameters}} - {{>maybeCheckExpectedValue}} + {{>maybeCheckExpectedValue cluster=../cluster}} {{>maybeCheckExpectedConstraints}} {{>maybeSaveAs}} {{/chip_tests_item_response_parameters}} diff --git a/examples/chip-tool/templates/tests/partials/value_equals.zapt b/examples/chip-tool/templates/tests/partials/value_equals.zapt index 5cda33b2b92df9..614ed51ffc9ba4 100644 --- a/examples/chip-tool/templates/tests/partials/value_equals.zapt +++ b/examples/chip-tool/templates/tests/partials/value_equals.zapt @@ -1,6 +1,6 @@ {{#if isOptional}} VerifyOrReturn(CheckValuePresent("{{label}}", {{actual}})); - {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isOptional=false depth=(incrementDepth depth)}} + {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isOptional=false cluster=cluster depth=(incrementDepth depth)}} {{else if isNullable}} {{#if (isLiteralNull expected)}} VerifyOrReturn(CheckValueNull("{{label}}", {{actual}})); @@ -14,15 +14,15 @@ else { VerifyOrReturn(CheckValueNonNull("{{label}}", {{actual}})); - {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=(concat expected ".Value()") isNullable=false keepAsExpected=true depth=(incrementDepth depth)}} + {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=(concat expected ".Value()") isNullable=false keepAsExpected=true cluster=cluster depth=(incrementDepth depth)}} } {{else}} VerifyOrReturn(CheckValueNonNull("{{label}}", {{actual}})); - {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isNullable=false keepAsExpected=true depth=(incrementDepth depth)}} + {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isNullable=false keepAsExpected=true cluster=cluster depth=(incrementDepth depth)}} {{/if}} {{else}} VerifyOrReturn(CheckValueNonNull("{{label}}", {{actual}})); - {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isNullable=false depth=(incrementDepth depth)}} + {{>valueEquals label=(concat label ".Value()") actual=(concat actual ".Value()") expected=expected isNullable=false cluster=cluster depth=(incrementDepth depth)}} {{/if}} {{/if}} {{else if isArray}} @@ -31,14 +31,14 @@ auto iter_{{depth}} = {{actual}}.begin(); {{#each expected}} VerifyOrReturn(CheckNextListItemDecodes("{{../label}}", iter_{{../depth}}, {{@index}})); - {{>valueEquals label=(concat ../label "[" @index "]") actual=(concat "iter_" ../depth ".GetValue()") expected=this isArray=false type=../type chipType=../chipType depth=(incrementDepth ../depth) parent=../parent}} + {{>valueEquals label=(concat ../label "[" @index "]") actual=(concat "iter_" ../depth ".GetValue()") expected=this isArray=false type=../type chipType=../chipType cluster=../cluster depth=(incrementDepth ../depth) parent=../parent}} {{/each}} VerifyOrReturn(CheckNoMoreListItems("{{label}}", iter_{{depth}}, {{expected.length}})); } {{else if isEvent}} {{#zcl_events_fields_by_event_name type}} {{#if (hasProperty ../expected label)}} - {{>valueEquals label=(concat ../label "." (asLowerCamelCase label)) actual=(concat ../actual "." (asLowerCamelCase label)) expected=(lookup ../expected label) depth=(incrementDepth ../depth)}} + {{>valueEquals label=(concat ../label "." (asLowerCamelCase label)) actual=(concat ../actual "." (asLowerCamelCase label)) expected=(lookup ../expected label) cluster=../cluster depth=(incrementDepth ../depth)}} {{/if}} {{/zcl_events_fields_by_event_name}} {{else}} @@ -46,11 +46,11 @@ {{! Iterate over the actual types in the struct, so we pick up the right type/optionality/nullability information for them for our recursive call. }} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{#if (hasProperty ../expected label)}} - {{>valueEquals label=(concat ../label "." (asLowerCamelCase label)) actual=(concat ../actual "." (asLowerCamelCase label)) expected=(lookup ../expected label) depth=(incrementDepth ../depth)}} + {{>valueEquals label=(concat ../label "." (asLowerCamelCase label)) actual=(concat ../actual "." (asLowerCamelCase label)) expected=(lookup ../expected label) cluster=../cluster depth=(incrementDepth ../depth)}} {{/if}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{! Maybe we should add a check for properties in the expected object (other than "global") that are not present in the struct ? }} {{else}} diff --git a/examples/darwin-framework-tool/templates/partials/decodable_value.zapt b/examples/darwin-framework-tool/templates/partials/decodable_value.zapt index 76a8e54369f509..8d0442000a070c 100644 --- a/examples/darwin-framework-tool/templates/partials/decodable_value.zapt +++ b/examples/darwin-framework-tool/templates/partials/decodable_value.zapt @@ -23,9 +23,9 @@ {{else}} {{#if_is_struct type}} {{target}} = [{{asObjectiveCClass type cluster forceNotList=true}} new]; - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{>decodable_value target=(concat ../target "." (asStructPropertyName label)) source=(concat ../source "." (asLowerCamelCase label)) cluster=../cluster depth=(incrementDepth ../depth) }} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{#if_is_strongly_typed_chip_enum type}} {{target}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:chip::to_underlying({{source}})]; diff --git a/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt b/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt index e84e485fcdb792..26aa91ac9ce056 100644 --- a/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt +++ b/examples/darwin-framework-tool/templates/tests/partials/check_test_value.zapt @@ -28,11 +28,11 @@ {{! Iterate over the actual types in the struct, so we pick up the right type/optionality/nullability information for them for our recursive call. }} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{#if (hasProperty ../expected label)}} {{>check_test_value actual=(concat "((MTR" (asUpperCamelCase ../cluster) "Cluster" (asUpperCamelCase ../type) " *)" ../actual ")." (asStructPropertyName label)) expected=(lookup ../expected label) cluster=../cluster}} {{/if}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{! Maybe we should add a check for properties in the expected object (other than "global") that are not present in the struct ? }} {{else}} diff --git a/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt b/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt index 623f5e0e6c38d2..30c342cecb809d 100644 --- a/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt +++ b/examples/darwin-framework-tool/templates/tests/partials/test_value.zapt @@ -19,14 +19,14 @@ {{else}} {{#if_is_struct type}} {{target}} = [[MTR{{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}} alloc] init]; - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{#if_include_struct_item_value ../definedValue name}} {{! target may be some place where we lost type information (e.g. an id), so add explicit cast when trying to assign to our properties. }} {{>test_value target=(concat "((MTR" (asUpperCamelCase ../cluster) "Cluster" (asUpperCamelCase ../type) " *)" ../target ")." (asStructPropertyName label)) definedValue=(lookup ../definedValue name) cluster=../cluster depth=(incrementDepth ../depth)}} {{/if_include_struct_item_value}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{target}} = diff --git a/integrations/docker/images/chip-cert-bins/Dockerfile b/integrations/docker/images/chip-cert-bins/Dockerfile index 8e9db74f22455a..218438bb81ec79 100644 --- a/integrations/docker/images/chip-cert-bins/Dockerfile +++ b/integrations/docker/images/chip-cert-bins/Dockerfile @@ -7,7 +7,7 @@ ARG COMMITHASH=7b99e6399c6069037c613782d78132c69b9dcabb # ZAP Development install, so that it runs on both x64 and arm64 # Generally this should match with the ZAP version that is used for codegen within the # specified SHA -ARG ZAP_VERSION=v2023.04.18-nightly +ARG ZAP_VERSION=v2023.04.21-nightly # Ensure TARGETPLATFORM is set RUN case ${TARGETPLATFORM} in \ diff --git a/scripts/setup/zap.json b/scripts/setup/zap.json index 4ed3e0d4ab1ce2..df3f76ff5b5d0f 100644 --- a/scripts/setup/zap.json +++ b/scripts/setup/zap.json @@ -8,7 +8,7 @@ "mac-arm64", "windows-amd64" ], - "tags": ["version:2@v2023.04.18-nightly.1"] + "tags": ["version:2@v2023.04.21-nightly.1"] } ] } diff --git a/scripts/tools/zap/zap_execution.py b/scripts/tools/zap/zap_execution.py index 29d8e83c957d37..3fdeeab5a1da93 100644 --- a/scripts/tools/zap/zap_execution.py +++ b/scripts/tools/zap/zap_execution.py @@ -23,7 +23,7 @@ # Use scripts/tools/zap/version_update.py to manage ZAP versioning as many # files may need updating for versions # -MIN_ZAP_VERSION = '2023.4.18' +MIN_ZAP_VERSION = '2023.4.21' class ZapTool: diff --git a/src/controller/java/templates/CHIPAttributeTLVValueDecoder-src.zapt b/src/controller/java/templates/CHIPAttributeTLVValueDecoder-src.zapt index ce42d5d1140680..c4ecf0256ace49 100644 --- a/src/controller/java/templates/CHIPAttributeTLVValueDecoder-src.zapt +++ b/src/controller/java/templates/CHIPAttributeTLVValueDecoder-src.zapt @@ -51,7 +51,7 @@ jobject DecodeAttributeValue(const app::ConcreteAttributePath & aPath, TLV::TLVR { return nullptr; } - {{>decode_value target="value" source="cppValue" cluster=(asUpperCamelCase parent.name) depth=0 earlyReturn="nullptr"}} + {{>decode_value target="value" source="cppValue" cluster=parent.name depth=0 earlyReturn="nullptr"}} return value; } {{/zcl_attributes_server}} diff --git a/src/controller/java/templates/CHIPClustersWrite-JNI.zapt b/src/controller/java/templates/CHIPClustersWrite-JNI.zapt index 9be7cfb69dcd39..2a77e14c42d1bb 100644 --- a/src/controller/java/templates/CHIPClustersWrite-JNI.zapt +++ b/src/controller/java/templates/CHIPClustersWrite-JNI.zapt @@ -45,7 +45,7 @@ JNI_METHOD(void, {{asUpperCamelCase ../name}}Cluster, write{{asUpperCamelCase na std::vector> cleanupByteArrays; std::vector> cleanupStrings; - {{>encode_value target="cppValue" source="value" cluster=(asUpperCamelCase parent.name) depth=0}} + {{>encode_value target="cppValue" source="value" cluster=parent.name depth=0}} std::unique_ptr onSuccess(Platform::New(callback), Platform::Delete); VerifyOrReturn(onSuccess.get() != nullptr, chip::AndroidClusterExceptions::GetInstance().ReturnIllegalStateException(env, callback, "Error creating native success callback", CHIP_ERROR_NO_MEMORY)); diff --git a/src/controller/java/templates/CHIPEventTLVValueDecoder-src.zapt b/src/controller/java/templates/CHIPEventTLVValueDecoder-src.zapt index 58554412612858..a9e78ba6590ff8 100644 --- a/src/controller/java/templates/CHIPEventTLVValueDecoder-src.zapt +++ b/src/controller/java/templates/CHIPEventTLVValueDecoder-src.zapt @@ -51,7 +51,7 @@ jobject DecodeEventValue(const app::ConcreteEventPath & aPath, TLV::TLVReader & return nullptr; } {{#zcl_event_fields}} - {{>decode_value target=(concat "value_" (asLowerCamelCase name)) source=(concat "cppValue." (asLowerCamelCase name)) cluster=(asUpperCamelCase parent.parent.name) depth=0 earlyReturn="nullptr"}} + {{>decode_value target=(concat "value_" (asLowerCamelCase name)) source=(concat "cppValue." (asLowerCamelCase name)) cluster=parent.parent.name depth=0 earlyReturn="nullptr"}} {{/zcl_event_fields}} jclass {{asLowerCamelCase name}}StructClass; diff --git a/src/controller/java/templates/CHIPInvokeCallbacks-src.zapt b/src/controller/java/templates/CHIPInvokeCallbacks-src.zapt index 9f4d999174ce21..29a6769214ee7e 100644 --- a/src/controller/java/templates/CHIPInvokeCallbacks-src.zapt +++ b/src/controller/java/templates/CHIPInvokeCallbacks-src.zapt @@ -64,7 +64,7 @@ void CHIP{{asUpperCamelCase parent.name}}Cluster{{asUpperCamelCase name}}Callbac VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Error invoking Java callback: %s", ErrorStr(err))); {{#zcl_command_arguments}} - {{>decode_value source=(concat "dataResponse." (asLowerCamelCase name)) target=(asSymbol label) cluster=(asUpperCamelCase parent.parent.name) depth=0}} + {{>decode_value source=(concat "dataResponse." (asLowerCamelCase name)) target=(asSymbol label) cluster=parent.parent.name depth=0}} {{/zcl_command_arguments}} env->CallVoidMethod(javaCallbackRef, javaMethod{{#zcl_command_arguments}}, {{asSymbol label}}{{/zcl_command_arguments}}); diff --git a/src/controller/java/templates/CHIPReadCallbacks-src.zapt b/src/controller/java/templates/CHIPReadCallbacks-src.zapt index 60bc0b09447780..5a643e5369079d 100644 --- a/src/controller/java/templates/CHIPReadCallbacks-src.zapt +++ b/src/controller/java/templates/CHIPReadCallbacks-src.zapt @@ -139,7 +139,7 @@ void CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCallb err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "(Ljava/util/List;)V", &javaMethod); VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); - {{>decode_value source="list" target="arrayListObj" cluster=(asUpperCamelCase parent.name) depth=0}} + {{>decode_value source="list" target="arrayListObj" cluster=parent.name depth=0}} env->ExceptionClear(); env->CallVoidMethod(javaCallbackRef, javaMethod, arrayListObj); @@ -165,7 +165,7 @@ void CHIP{{asUpperCamelCase parent.name}}{{asUpperCamelCase name}}AttributeCallb err = chip::JniReferences::GetInstance().FindMethod(env, javaCallbackRef, "onSuccess", "({{#if isArray}}{{else if isStruct}}{{else if isOptional}}Ljava/util/Optional;{{else if (isOctetString type)}}[B{{else if (isCharString type)}}Ljava/lang/String;{{else}}{{asJniSignatureBasic type true}}{{/if}})V", &javaMethod); VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Zcl, "Could not find onSuccess() method")); - {{>decode_value source="value" target="javaValue" cluster=(asUpperCamelCase parent.name) depth=0}} + {{>decode_value source="value" target="javaValue" cluster=parent.name depth=0}} env->CallVoidMethod(javaCallbackRef, javaMethod, javaValue); } diff --git a/src/controller/java/templates/partials/decode_value.zapt b/src/controller/java/templates/partials/decode_value.zapt index d1c51b5edeee33..8837a43711e578 100644 --- a/src/controller/java/templates/partials/decode_value.zapt +++ b/src/controller/java/templates/partials/decode_value.zapt @@ -27,32 +27,32 @@ if ({{source}}.IsNull()) { } {{else}} {{#if_is_struct type}} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{>decode_value target=(concat ../target "_" (asLowerCamelCase label)) source=(concat ../source "." (asLowerCamelCase label)) cluster=../cluster depth=(incrementDepth ../depth) omitDeclaration=false earlyReturn=../earlyReturn}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} jclass {{asLowerCamelCase type}}StructClass_{{depth}}; - err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipStructs${{cluster}}Cluster{{asUpperCamelCase type}}", {{asLowerCamelCase type}}StructClass_{{depth}}); + err = chip::JniReferences::GetInstance().GetClassRef(env, "chip/devicecontroller/ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}}", {{asLowerCamelCase type}}StructClass_{{depth}}); if (err != CHIP_NO_ERROR) { - ChipLogError(Zcl, "Could not find class ChipStructs${{cluster}}Cluster{{asUpperCamelCase type}}"); + ChipLogError(Zcl, "Could not find class ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}}"); return {{earlyReturn}}; } jmethodID {{asLowerCamelCase type}}StructCtor_{{depth}} = env->GetMethodID({{asLowerCamelCase type}}StructClass_{{depth}}, "" - , "({{#zcl_struct_items_by_struct_name type}}{{asJniSignature type null ../cluster true}}{{/zcl_struct_items_by_struct_name}})V"); + , "({{#zcl_struct_items_by_struct_and_cluster_name type cluster}}{{asJniSignature type null (asUpperCamelCase ../cluster) true}}{{/zcl_struct_items_by_struct_and_cluster_name}})V"); if ({{asLowerCamelCase type}}StructCtor_{{depth}} == nullptr) { - ChipLogError(Zcl, "Could not find ChipStructs${{cluster}}Cluster{{asUpperCamelCase type}} constructor"); + ChipLogError(Zcl, "Could not find ChipStructs${{asUpperCamelCase cluster}}Cluster{{asUpperCamelCase type}} constructor"); return {{earlyReturn}}; } {{target}} = env->NewObject({{asLowerCamelCase type}}StructClass_{{depth}}, {{asLowerCamelCase type}}StructCtor_{{depth}} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} , {{../target}}_{{asLowerCamelCase label}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} ); {{else}} {{#if_is_strongly_typed_chip_enum type}} - std::string {{target}}ClassName = "{{asJniClassName type null cluster}}"; - std::string {{target}}CtorSignature = "({{asJniSignature type null cluster false}})V"; + std::string {{target}}ClassName = "{{asJniClassName type null (asUpperCamelCase cluster)}}"; + std::string {{target}}CtorSignature = "({{asJniSignature type null (asUpperCamelCase cluster) false}})V"; chip::JniReferences::GetInstance().CreateBoxedObject<{{asUnderlyingBasicType type}}>({{target}}ClassName.c_str(), {{target}}CtorSignature.c_str(), static_cast<{{asUnderlyingBasicType type}}>({{source}}), {{target}}); {{else}} {{#if (isOctetString type)}} @@ -62,8 +62,8 @@ if ({{source}}.IsNull()) { {{else if (isCharString type)}} LogErrorOnFailure(chip::JniReferences::GetInstance().CharToStringUTF({{source}}, {{target}})); {{else}} - std::string {{target}}ClassName = "{{asJniClassName type null cluster}}"; - std::string {{target}}CtorSignature = "({{asJniSignature type null cluster false}})V"; + std::string {{target}}ClassName = "{{asJniClassName type null (asUpperCamelCase cluster)}}"; + std::string {{target}}CtorSignature = "({{asJniSignature type null (asUpperCamelCase cluster) false}})V"; {{#if_is_strongly_typed_bitmap type}} chip::JniReferences::GetInstance().CreateBoxedObject<{{asUnderlyingBasicType type}}>({{target}}ClassName.c_str(), {{target}}CtorSignature.c_str(), {{source}}.Raw(), {{target}}); {{else}} diff --git a/src/controller/java/templates/partials/encode_value.zapt b/src/controller/java/templates/partials/encode_value.zapt index 181688acb2c6f0..8540e487d9ca58 100644 --- a/src/controller/java/templates/partials/encode_value.zapt +++ b/src/controller/java/templates/partials/encode_value.zapt @@ -42,11 +42,11 @@ {{target}} = cleanupStrings.back()->charSpan(); {{else}} {{#if_is_struct type}} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} jobject {{../source}}_{{asLowerCamelCase label}}Item_{{../depth}}; - chip::JniReferences::GetInstance().GetObjectField({{../source}}, "{{asLowerCamelCase label}}", "{{asJniSignature type null ../cluster true}}", {{../source}}_{{asLowerCamelCase label}}Item_{{../depth}}); + chip::JniReferences::GetInstance().GetObjectField({{../source}}, "{{asLowerCamelCase label}}", "{{asJniSignature type null (asUpperCamelCase ../cluster) true}}", {{../source}}_{{asLowerCamelCase label}}Item_{{../depth}}); {{>encode_value target=(concat ../target "." (asLowerCamelCase label)) source=(concat ../source "_" (asLowerCamelCase label) "Item_" ../depth) cluster=../cluster depth=(incrementDepth ../depth)}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{#if_chip_enum type}} {{target}} = static_cast>(chip::JniReferences::GetInstance().{{asJavaType type null parent.parent.name forceNotList=true}}ToPrimitive({{source}})); diff --git a/src/controller/python/templates/python-CHIPClusters-py.zapt b/src/controller/python/templates/python-CHIPClusters-py.zapt index 4b1443e7211de4..9917fecb1ba5b2 100644 --- a/src/controller/python/templates/python-CHIPClusters-py.zapt +++ b/src/controller/python/templates/python-CHIPClusters-py.zapt @@ -27,11 +27,11 @@ class ChipClusters: "args": { {{#zcl_command_arguments}} {{#if_is_struct type}} - {{#zcl_struct_items_by_struct_name type}} - "{{asLowerCamelCase label}}": "{{#if (isCharString type)}}str{{else}}{{as_underlying_python_zcl_type type ../../id}}{{/if}}", - {{/zcl_struct_items_by_struct_name}} + {{#zcl_struct_items_by_struct_and_cluster_name type ../../name}} + "{{asLowerCamelCase label}}": "{{#if (isCharString type)}}str{{else}}{{as_underlying_python_zcl_type type ../../../id}}{{/if}}", + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} - "{{asLowerCamelCase label}}": "{{#if (isCharString type)}}str{{else}}{{as_underlying_python_zcl_type type ../id}}{{/if}}", + "{{asLowerCamelCase label}}": "{{#if (isCharString type)}}str{{else}}{{as_underlying_python_zcl_type type ../../id}}{{/if}}", {{/if_is_struct}} {{/zcl_command_arguments}} }, diff --git a/src/darwin/Framework/CHIP/templates/partials/decode_value.zapt b/src/darwin/Framework/CHIP/templates/partials/decode_value.zapt index 50477cd01d70a4..29e64683ba5062 100644 --- a/src/darwin/Framework/CHIP/templates/partials/decode_value.zapt +++ b/src/darwin/Framework/CHIP/templates/partials/decode_value.zapt @@ -29,9 +29,9 @@ {{else}} {{#if_is_struct type}} {{target}} = [{{asObjectiveCClass type cluster forceNotList=true}} new]; - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{>decode_value target=(concat ../target "." (asStructPropertyName label)) source=(concat ../source "." (asLowerCamelCase label)) cluster=../cluster errorCode=../errorCode depth=(incrementDepth ../depth) }} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{#if_is_strongly_typed_chip_enum type}} {{target}} = [NSNumber numberWith{{asObjectiveCNumberType "" type false}}:chip::to_underlying({{source}})]; diff --git a/src/darwin/Framework/CHIP/templates/partials/encode_value.zapt b/src/darwin/Framework/CHIP/templates/partials/encode_value.zapt index 0c54e8124e19a1..79d38dc87f3c91 100644 --- a/src/darwin/Framework/CHIP/templates/partials/encode_value.zapt +++ b/src/darwin/Framework/CHIP/templates/partials/encode_value.zapt @@ -45,9 +45,9 @@ {{target}} = [self asCharSpan:{{source}}]; {{else}} {{#if_is_struct type}} - {{#zcl_struct_items_by_struct_name type}} + {{#zcl_struct_items_by_struct_and_cluster_name type cluster}} {{>encode_value target=(concat ../target "." (asLowerCamelCase label)) source=(concat ../source "." (asStructPropertyName label)) cluster=../cluster errorCode=../errorCode depth=(incrementDepth ../depth)}} - {{/zcl_struct_items_by_struct_name}} + {{/zcl_struct_items_by_struct_and_cluster_name}} {{else}} {{#if_is_strongly_typed_chip_enum type}} {{target}} = static_cast>({{source}}.{{asObjectiveCNumberType source type true}}Value); From 4850ad8ffa185543129e2d1d70d65fa56b64b65f Mon Sep 17 00:00:00 2001 From: shripad621git <79364691+shripad621git@users.noreply.github.com> Date: Tue, 25 Apr 2023 20:45:08 +0530 Subject: [PATCH 37/54] Suppressing the logs related to events' Long dispatch time and Log related changes in Logging.cpp. (#26227) -Provided the config option specific to ESP32 to set the threshold for events dispatching time. -Set the config option by default to 0 to suppress the Long dispatch time logs. -The log related changes mainly changes the way the logs are converted into the idf specific format. -The arguments are directly used from chip_log instead of converting them to a string and then calling the IDF API. -This also removes the need for the extra buffer, and also removes the limit for the 256 length for the log + arguments size. --- config/esp32/components/chip/Kconfig | 8 ++++++++ src/platform/ESP32/CHIPPlatformConfig.h | 1 + src/platform/ESP32/Logging.cpp | 27 +++++++++++++++++++------ 3 files changed, 30 insertions(+), 6 deletions(-) diff --git a/config/esp32/components/chip/Kconfig b/config/esp32/components/chip/Kconfig index 3b6d84a5c776fc..e92764e5dfa078 100644 --- a/config/esp32/components/chip/Kconfig +++ b/config/esp32/components/chip/Kconfig @@ -108,6 +108,14 @@ menu "CHIP Core" help Build CHIP test binaries. + config DISPATCH_EVENT_LONG_DISPATCH_TIME_WARNING_THRESHOLD_MS + int "Set threshold in ms" + default 700 + help + Time threshold for events dispatching. By default set to 0 to + to disable event dispatching time measurement and suppress the + logs for Long dispatch time. + # TODO: add log level selection endmenu # "General Options" diff --git a/src/platform/ESP32/CHIPPlatformConfig.h b/src/platform/ESP32/CHIPPlatformConfig.h index be023dfde901ae..9f7faedb8a0ff7 100644 --- a/src/platform/ESP32/CHIPPlatformConfig.h +++ b/src/platform/ESP32/CHIPPlatformConfig.h @@ -51,6 +51,7 @@ // The following values are configured via the ESP-IDF Kconfig mechanism. +#define CHIP_DISPATCH_EVENT_LONG_DISPATCH_TIME_WARNING_THRESHOLD_MS CONFIG_DISPATCH_EVENT_LONG_DISPATCH_TIME_WARNING_THRESHOLD_MS #define CHIP_CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS CONFIG_MAX_UNSOLICITED_MESSAGE_HANDLERS #define CHIP_CONFIG_MAX_EXCHANGE_CONTEXTS CONFIG_MAX_EXCHANGE_CONTEXTS #define CHIP_CONFIG_SECURITY_TEST_MODE CONFIG_SECURITY_TEST_MODE diff --git a/src/platform/ESP32/Logging.cpp b/src/platform/ESP32/Logging.cpp index b2fbaac3cfbd1a..7f96a70dabecb2 100644 --- a/src/platform/ESP32/Logging.cpp +++ b/src/platform/ESP32/Logging.cpp @@ -26,20 +26,35 @@ void ENFORCE_FORMAT(3, 0) LogV(const char * module, uint8_t category, const char snprintf(tag, sizeof(tag), "chip[%s]", module); tag[sizeof(tag) - 1] = 0; - char formattedMsg[CHIP_CONFIG_LOG_MESSAGE_MAX_SIZE]; - vsnprintf(formattedMsg, sizeof(formattedMsg), msg, v); - switch (category) { case kLogCategory_Error: - ESP_LOGE(tag, "%s", formattedMsg); + if (esp_log_default_level >= ESP_LOG_ERROR) + { + printf(LOG_COLOR_E "E"); // set color + printf(" (%u) %s: ", esp_log_timestamp(), tag); // add timestamp + esp_log_writev(ESP_LOG_ERROR, tag, msg, v); + printf(LOG_RESET_COLOR "\n"); + } break; case kLogCategory_Progress: default: - ESP_LOGI(tag, "%s", formattedMsg); + if (esp_log_default_level >= ESP_LOG_INFO) + { + printf(LOG_COLOR_I "I"); // set color + printf(" (%u) %s: ", esp_log_timestamp(), tag); // add timestamp + esp_log_writev(ESP_LOG_INFO, tag, msg, v); + printf(LOG_RESET_COLOR "\n"); + } break; case kLogCategory_Detail: - ESP_LOGD(tag, "%s", formattedMsg); + if (esp_log_default_level >= ESP_LOG_DEBUG) + { + printf(LOG_COLOR_D "D"); // set color + printf(" (%u) %s: ", esp_log_timestamp(), tag); // add timestamp + esp_log_writev(ESP_LOG_DEBUG, tag, msg, v); + printf(LOG_RESET_COLOR "\n"); + } break; } } From 3124f51bc2c9fee6930ec3cb5cc31a0cf85a9c14 Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Tue, 25 Apr 2023 17:16:32 +0200 Subject: [PATCH 38/54] [Linux] Fix event loop task consecutive start/stop (#26195) * [Linux] Fix event loop task consecutive start/stop * Wait for lambdas before stopping loop task * Add comment for sleep() usage in test --- .../GenericPlatformManagerImpl_POSIX.ipp | 4 ++ src/platform/tests/TestPlatformMgr.cpp | 48 +++++++++++++++++-- 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.ipp b/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.ipp index 6050950bf4c261..1b09d298eb2867 100644 --- a/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.ipp +++ b/src/include/platform/internal/GenericPlatformManagerImpl_POSIX.ipp @@ -59,6 +59,8 @@ CHIP_ERROR GenericPlatformManagerImpl_POSIX::_InitChipStack() // Call up to the base class _InitChipStack() to perform the bulk of the initialization. ReturnErrorOnFailure(GenericPlatformManagerImpl::_InitChipStack()); + mShouldRunEventLoop.store(true, std::memory_order_relaxed); + int ret = pthread_cond_init(&mEventQueueStoppedCond, nullptr); VerifyOrReturnError(ret == 0, CHIP_ERROR_POSIX(ret)); @@ -225,6 +227,8 @@ CHIP_ERROR GenericPlatformManagerImpl_POSIX::_StartEventLoopTask() VerifyOrReturnError(err == 0, CHIP_ERROR_POSIX(err)); #endif + mShouldRunEventLoop.store(true, std::memory_order_relaxed); + // // We need to grab the lock here since we have to protect setting // mHasValidChipTask, which will be read right away upon creating the diff --git a/src/platform/tests/TestPlatformMgr.cpp b/src/platform/tests/TestPlatformMgr.cpp index cd2caab4b96eb9..449e96d30eddbd 100644 --- a/src/platform/tests/TestPlatformMgr.cpp +++ b/src/platform/tests/TestPlatformMgr.cpp @@ -28,6 +28,8 @@ #include #include +#include + #include #include #include @@ -55,14 +57,52 @@ static void TestPlatformMgr_InitShutdown(nlTestSuite * inSuite, void * inContext static void TestPlatformMgr_BasicEventLoopTask(nlTestSuite * inSuite, void * inContext) { + std::atomic counterRun{ 0 }; + CHIP_ERROR err = PlatformMgr().InitChipStack(); NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); - err = PlatformMgr().StartEventLoopTask(); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + // Start/stop the event loop task a few times. + for (size_t i = 0; i < 3; i++) + { + err = PlatformMgr().StartEventLoopTask(); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + + std::atomic counterSync{ 2 }; + + // Verify that the event loop will not exit until we tell it to by + // scheduling few lambdas (for the test to pass, the event loop will + // have to process more than one event). + DeviceLayer::SystemLayer().ScheduleLambda([&]() { + counterRun++; + counterSync--; + }); + + // Sleep for a short time to allow the event loop to process the + // scheduled event and go to idle state. Without this sleep, the + // event loop may process both scheduled lambdas during single + // iteration of the event loop which would defeat the purpose of + // this test on POSIX platforms where the event loop is implemented + // using a "do { ... } while (shouldRun)" construct. + chip::test_utils::SleepMillis(10); + + DeviceLayer::SystemLayer().ScheduleLambda([&]() { + counterRun++; + counterSync--; + }); + + // Wait for the event loop to process the scheduled events. + // Note, that we can not use any synchronization primitives like + // condition variables or barriers, because the test has to compile + // on all platforms. Instead we use a busy loop with a timeout. + for (size_t t = 0; counterSync != 0 && t < 1000; t++) + chip::test_utils::SleepMillis(1); + + err = PlatformMgr().StopEventLoopTask(); + NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + } - err = PlatformMgr().StopEventLoopTask(); - NL_TEST_ASSERT(inSuite, err == CHIP_NO_ERROR); + NL_TEST_ASSERT(inSuite, counterRun == (3 * 2)); PlatformMgr().Shutdown(); } From bab40deb8fa7ecdd1b0f27bce5b58de01e186b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arkadiusz=20Ba=C5=82ys?= Date: Tue, 25 Apr 2023 17:25:52 +0200 Subject: [PATCH 39/54] [nrfconnect] Repair Rotating Device ID UID parsing (#26179) Rotating Device Id Unique Id was parsing wrongly in nrfconnect's factory data provider implementation. There was also a problem, that testing Rotating Device Id UID was not being provided by Zephyr's Kconfig. Repaired the factory_data build for nRFconnect devices. --- .../nrfconnect/main/AppTask.cpp | 1 + .../nrfconnect/main/include/AppTask.h | 2 + .../nrfconnect/main/AppTask.cpp | 1 + .../nrfconnect/main/include/AppTask.h | 2 + .../nrfconnect/main/AppTask.cpp | 1 + .../nrfconnect/main/include/AppTask.h | 2 + .../lighting-app/nrfconnect/main/AppTask.cpp | 1 + .../nrfconnect/main/include/AppTask.h | 2 + examples/lock-app/nrfconnect/main/AppTask.cpp | 1 + .../nrfconnect/main/include/AppTask.h | 2 + examples/pump-app/nrfconnect/main/AppTask.cpp | 1 + .../nrfconnect/main/include/AppTask.h | 2 + .../nrfconnect/main/AppTask.cpp | 1 + .../nrfconnect/main/include/AppTask.h | 2 + .../window-app/nrfconnect/main/AppTask.cpp | 1 + .../nrfconnect/main/include/AppTask.h | 2 + src/platform/nrfconnect/BUILD.gn | 5 ++ .../DeviceInstanceInfoProviderImpl.cpp | 47 +++++++++++++++++++ .../DeviceInstanceInfoProviderImpl.h | 43 +++++++++++++++++ src/platform/nrfconnect/FactoryDataParser.c | 15 +++--- .../nrfconnect/FactoryDataProvider.cpp | 2 +- 21 files changed, 126 insertions(+), 10 deletions(-) create mode 100644 src/platform/nrfconnect/DeviceInstanceInfoProviderImpl.cpp create mode 100644 src/platform/nrfconnect/DeviceInstanceInfoProviderImpl.h diff --git a/examples/all-clusters-app/nrfconnect/main/AppTask.cpp b/examples/all-clusters-app/nrfconnect/main/AppTask.cpp index 0cee0e74ba78c8..05103f4c87f25d 100644 --- a/examples/all-clusters-app/nrfconnect/main/AppTask.cpp +++ b/examples/all-clusters-app/nrfconnect/main/AppTask.cpp @@ -190,6 +190,7 @@ CHIP_ERROR AppTask::Init() memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); } #else + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif diff --git a/examples/all-clusters-app/nrfconnect/main/include/AppTask.h b/examples/all-clusters-app/nrfconnect/main/include/AppTask.h index a369eeefe55c6b..4b57d1dc3f249c 100644 --- a/examples/all-clusters-app/nrfconnect/main/include/AppTask.h +++ b/examples/all-clusters-app/nrfconnect/main/include/AppTask.h @@ -24,6 +24,8 @@ #if CONFIG_CHIP_FACTORY_DATA #include +#else +#include #endif #ifdef CONFIG_MCUMGR_SMP_BT diff --git a/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp b/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp index fc565a94d1c12f..19ce36436419b3 100644 --- a/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp +++ b/examples/all-clusters-minimal-app/nrfconnect/main/AppTask.cpp @@ -144,6 +144,7 @@ CHIP_ERROR AppTask::Init() SetDeviceAttestationCredentialsProvider(&mFactoryDataProvider); SetCommissionableDataProvider(&mFactoryDataProvider); #else + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif diff --git a/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h b/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h index 1a6922e9286f0d..9921de58383521 100644 --- a/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h +++ b/examples/all-clusters-minimal-app/nrfconnect/main/include/AppTask.h @@ -24,6 +24,8 @@ #if CONFIG_CHIP_FACTORY_DATA #include +#else +#include #endif #ifdef CONFIG_MCUMGR_SMP_BT diff --git a/examples/light-switch-app/nrfconnect/main/AppTask.cpp b/examples/light-switch-app/nrfconnect/main/AppTask.cpp index 4419f8615be960..e77184a6a6c355 100644 --- a/examples/light-switch-app/nrfconnect/main/AppTask.cpp +++ b/examples/light-switch-app/nrfconnect/main/AppTask.cpp @@ -208,6 +208,7 @@ CHIP_ERROR AppTask::Init() memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); } #else + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif diff --git a/examples/light-switch-app/nrfconnect/main/include/AppTask.h b/examples/light-switch-app/nrfconnect/main/include/AppTask.h index 4e0a264af03667..a40c5e82bfd51f 100644 --- a/examples/light-switch-app/nrfconnect/main/include/AppTask.h +++ b/examples/light-switch-app/nrfconnect/main/include/AppTask.h @@ -25,6 +25,8 @@ #if CONFIG_CHIP_FACTORY_DATA #include +#else +#include #endif #ifdef CONFIG_MCUMGR_SMP_BT diff --git a/examples/lighting-app/nrfconnect/main/AppTask.cpp b/examples/lighting-app/nrfconnect/main/AppTask.cpp index 485d000d5cfb75..3b4d1a020de535 100644 --- a/examples/lighting-app/nrfconnect/main/AppTask.cpp +++ b/examples/lighting-app/nrfconnect/main/AppTask.cpp @@ -232,6 +232,7 @@ CHIP_ERROR AppTask::Init() memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); } #else + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif diff --git a/examples/lighting-app/nrfconnect/main/include/AppTask.h b/examples/lighting-app/nrfconnect/main/include/AppTask.h index 874be7d759b5a8..51df03f650c530 100644 --- a/examples/lighting-app/nrfconnect/main/include/AppTask.h +++ b/examples/lighting-app/nrfconnect/main/include/AppTask.h @@ -26,6 +26,8 @@ #if CONFIG_CHIP_FACTORY_DATA #include +#else +#include #endif #ifdef CONFIG_CHIP_PW_RPC diff --git a/examples/lock-app/nrfconnect/main/AppTask.cpp b/examples/lock-app/nrfconnect/main/AppTask.cpp index 61b96e266e6038..9e59b86fcdcc4e 100644 --- a/examples/lock-app/nrfconnect/main/AppTask.cpp +++ b/examples/lock-app/nrfconnect/main/AppTask.cpp @@ -202,6 +202,7 @@ CHIP_ERROR AppTask::Init() memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); } #else + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif diff --git a/examples/lock-app/nrfconnect/main/include/AppTask.h b/examples/lock-app/nrfconnect/main/include/AppTask.h index 402752d6412738..76738ac9afd331 100644 --- a/examples/lock-app/nrfconnect/main/include/AppTask.h +++ b/examples/lock-app/nrfconnect/main/include/AppTask.h @@ -27,6 +27,8 @@ #if CONFIG_CHIP_FACTORY_DATA #include +#else +#include #endif #ifdef CONFIG_MCUMGR_SMP_BT diff --git a/examples/pump-app/nrfconnect/main/AppTask.cpp b/examples/pump-app/nrfconnect/main/AppTask.cpp index 94a7088dbc7644..1a45d22444af03 100644 --- a/examples/pump-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-app/nrfconnect/main/AppTask.cpp @@ -175,6 +175,7 @@ CHIP_ERROR AppTask::Init() memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); } #else + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif diff --git a/examples/pump-app/nrfconnect/main/include/AppTask.h b/examples/pump-app/nrfconnect/main/include/AppTask.h index a534482c2b7c87..bcf2d1eaf20dad 100644 --- a/examples/pump-app/nrfconnect/main/include/AppTask.h +++ b/examples/pump-app/nrfconnect/main/include/AppTask.h @@ -27,6 +27,8 @@ #if CONFIG_CHIP_FACTORY_DATA #include +#else +#include #endif #ifdef CONFIG_MCUMGR_SMP_BT diff --git a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp index b97b11eabc1baf..6a8954c121f0e1 100644 --- a/examples/pump-controller-app/nrfconnect/main/AppTask.cpp +++ b/examples/pump-controller-app/nrfconnect/main/AppTask.cpp @@ -173,6 +173,7 @@ CHIP_ERROR AppTask::Init() memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); } #else + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif diff --git a/examples/pump-controller-app/nrfconnect/main/include/AppTask.h b/examples/pump-controller-app/nrfconnect/main/include/AppTask.h index 742923f106a195..02e7f0a5320d12 100644 --- a/examples/pump-controller-app/nrfconnect/main/include/AppTask.h +++ b/examples/pump-controller-app/nrfconnect/main/include/AppTask.h @@ -27,6 +27,8 @@ #if CONFIG_CHIP_FACTORY_DATA #include +#else +#include #endif #ifdef CONFIG_MCUMGR_SMP_BT diff --git a/examples/window-app/nrfconnect/main/AppTask.cpp b/examples/window-app/nrfconnect/main/AppTask.cpp index b0b3886a0a802f..280f63316a669c 100644 --- a/examples/window-app/nrfconnect/main/AppTask.cpp +++ b/examples/window-app/nrfconnect/main/AppTask.cpp @@ -179,6 +179,7 @@ CHIP_ERROR AppTask::Init() memset(sTestEventTriggerEnableKey, 0, sizeof(sTestEventTriggerEnableKey)); } #else + SetDeviceInstanceInfoProvider(&DeviceInstanceInfoProviderMgrImpl()); SetDeviceAttestationCredentialsProvider(Examples::GetExampleDACProvider()); #endif diff --git a/examples/window-app/nrfconnect/main/include/AppTask.h b/examples/window-app/nrfconnect/main/include/AppTask.h index 4d134a791fa8fd..28a7331d9737ba 100644 --- a/examples/window-app/nrfconnect/main/include/AppTask.h +++ b/examples/window-app/nrfconnect/main/include/AppTask.h @@ -24,6 +24,8 @@ #if CONFIG_CHIP_FACTORY_DATA #include +#else +#include #endif #ifdef CONFIG_MCUMGR_SMP_BT diff --git a/src/platform/nrfconnect/BUILD.gn b/src/platform/nrfconnect/BUILD.gn index 40c6f8cac3d292..1efcadfa9fe82e 100644 --- a/src/platform/nrfconnect/BUILD.gn +++ b/src/platform/nrfconnect/BUILD.gn @@ -69,6 +69,11 @@ static_library("nrfconnect") { "FactoryDataProvider.cpp", "FactoryDataProvider.h", ] + } else { + sources += [ + "DeviceInstanceInfoProviderImpl.cpp", + "DeviceInstanceInfoProviderImpl.h", + ] } if (chip_enable_openthread) { diff --git a/src/platform/nrfconnect/DeviceInstanceInfoProviderImpl.cpp b/src/platform/nrfconnect/DeviceInstanceInfoProviderImpl.cpp new file mode 100644 index 00000000000000..ed4f2124edf754 --- /dev/null +++ b/src/platform/nrfconnect/DeviceInstanceInfoProviderImpl.cpp @@ -0,0 +1,47 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "DeviceInstanceInfoProviderImpl.h" +#include + +namespace chip { +namespace DeviceLayer { + +CHIP_ERROR DeviceInstanceInfoProviderImpl::GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) +{ +#if CHIP_ENABLE_ROTATING_DEVICE_ID && defined(CONFIG_CHIP_DEVICE_ROTATING_DEVICE_UID) + static_assert(ConfigurationManager::kRotatingDeviceIDUniqueIDLength >= ConfigurationManager::kMinRotatingDeviceIDUniqueIDLength, + "Length of unique ID for rotating device ID is smaller than minimum."); + + ReturnErrorCodeIf(ConfigurationManager::kRotatingDeviceIDUniqueIDLength > uniqueIdSpan.size(), CHIP_ERROR_BUFFER_TOO_SMALL); + + size_t bytesLen = chip::Encoding::HexToBytes(CONFIG_CHIP_DEVICE_ROTATING_DEVICE_UID, + ConfigurationManager::kRotatingDeviceIDUniqueIDLength * 2, uniqueIdSpan.data(), + uniqueIdSpan.size()); + + ReturnErrorCodeIf(bytesLen != ConfigurationManager::kRotatingDeviceIDUniqueIDLength, CHIP_ERROR_INVALID_STRING_LENGTH); + uniqueIdSpan.reduce_size(bytesLen); + + return CHIP_NO_ERROR; +#endif // CHIP_ENABLE_ROTATING_DEVICE_ID + + return CHIP_ERROR_NOT_IMPLEMENTED; +} + +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nrfconnect/DeviceInstanceInfoProviderImpl.h b/src/platform/nrfconnect/DeviceInstanceInfoProviderImpl.h new file mode 100644 index 00000000000000..1489f2810b4170 --- /dev/null +++ b/src/platform/nrfconnect/DeviceInstanceInfoProviderImpl.h @@ -0,0 +1,43 @@ +/* + * + * Copyright (c) 2023 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#pragma once + +#include +#include + +namespace chip { +namespace DeviceLayer { + +class DeviceInstanceInfoProviderImpl : public Internal::GenericDeviceInstanceInfoProvider +{ +public: + CHIP_ERROR GetRotatingDeviceIdUniqueId(MutableByteSpan & uniqueIdSpan) override; + + DeviceInstanceInfoProviderImpl(ConfigurationManagerImpl & configManager) : + Internal::GenericDeviceInstanceInfoProvider(configManager) + {} +}; + +inline DeviceInstanceInfoProviderImpl & DeviceInstanceInfoProviderMgrImpl() +{ + static DeviceInstanceInfoProviderImpl sInstance(ConfigurationManagerImpl::GetDefaultInstance()); + return sInstance; +} +} // namespace DeviceLayer +} // namespace chip diff --git a/src/platform/nrfconnect/FactoryDataParser.c b/src/platform/nrfconnect/FactoryDataParser.c index 85caee5f9ac6b2..56da5343d973dc 100644 --- a/src/platform/nrfconnect/FactoryDataParser.c +++ b/src/platform/nrfconnect/FactoryDataParser.c @@ -18,15 +18,12 @@ #include "FactoryDataParser.h" #include -#include #include #include #define MAX_FACTORY_DATA_NESTING_LEVEL 3 -LOG_MODULE_DECLARE(app, CONFIG_MATTER_LOG_LEVEL); - static inline bool uint16_decode(zcbor_state_t * states, uint16_t * value) { uint32_t u32; @@ -174,14 +171,14 @@ bool ParseFactoryData(uint8_t * buffer, uint16_t bufferSize, struct FactoryData isdigit(date.value[3]) && date.value[4] == '-' && isdigit(date.value[5]) && isdigit(date.value[6]) && date.value[7] == '-' && isdigit(date.value[8]) && isdigit(date.value[9])) { - factoryData->date_year = - 1000 * (date.value[0] - '0') + 100 * (date.value[1] - '0') + 10 * (date.value[2] - '0') + date.value[3] - '0'; - factoryData->date_month = 10 * (date.value[5] - '0') + date.value[6] - '0'; - factoryData->date_day = 10 * (date.value[8] - '0') + date.value[9] - '0'; + factoryData->date_year = (uint16_t)(1000 * (uint16_t)(date.value[0] - '0') + 100 * (uint16_t)(date.value[1] - '0') + + 10 * (uint16_t)(date.value[2] - '0') + (uint16_t)(date.value[3] - '0')); + factoryData->date_month = (uint8_t)(10 * (uint16_t)(date.value[5] - '0') + (uint16_t)(date.value[6] - '0')); + factoryData->date_day = (uint8_t)(10 * (uint16_t)(date.value[8] - '0') + (uint16_t)(date.value[9] - '0')); } else { - LOG_ERR("Parsing error - wrong date format"); + res = false; } } else if (strncmp("hw_ver_str", (const char *) currentString.value, currentString.len) == 0) @@ -240,7 +237,7 @@ bool ParseFactoryData(uint8_t * buffer, uint16_t bufferSize, struct FactoryData { factoryData->user.data = (void *) states->payload; res = res && zcbor_any_skip(states, NULL); - factoryData->user.len = (void *) states->payload - factoryData->user.data; + factoryData->user.len = (size_t)((void *) states->payload - factoryData->user.data); } else { diff --git a/src/platform/nrfconnect/FactoryDataProvider.cpp b/src/platform/nrfconnect/FactoryDataProvider.cpp index 200b8fac0f33e8..229eb2745d6c91 100644 --- a/src/platform/nrfconnect/FactoryDataProvider.cpp +++ b/src/platform/nrfconnect/FactoryDataProvider.cpp @@ -81,7 +81,7 @@ CHIP_ERROR FactoryDataProvider::Init() return error; } - if (!ParseFactoryData(factoryData, factoryDataSize, &mFactoryData)) + if (!ParseFactoryData(factoryData, static_cast(factoryDataSize), &mFactoryData)) { ChipLogError(DeviceLayer, "Failed to parse factory data"); return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND; From 798c2663911021e624ef74c89e45ca624b206ff3 Mon Sep 17 00:00:00 2001 From: Jeonghwan Kim Date: Wed, 26 Apr 2023 00:29:12 +0900 Subject: [PATCH 40/54] [Android] Support Android MDNS subtype (#26136) * [Android] Support Android MDNS subtype (#25235) * Restyled by whitespace * Restyled by clang-format --------- Co-authored-by: Restyled.io --- src/platform/android/DnssdImpl.cpp | 56 ++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/src/platform/android/DnssdImpl.cpp b/src/platform/android/DnssdImpl.cpp index d0caa2ba3d741d..66e43dab29e84b 100644 --- a/src/platform/android/DnssdImpl.cpp +++ b/src/platform/android/DnssdImpl.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include namespace chip { @@ -52,6 +53,9 @@ jmethodID sRemoveServicesMethod = nullptr; // Implementation of functions declared in lib/dnssd/platform/Dnssd.h +constexpr const char * kProtocolTcp = "._tcp"; +constexpr const char * kProtocolUdp = "._udp"; + CHIP_ERROR ChipDnssdInit(DnssdAsyncReturnCallback initCallback, DnssdAsyncReturnCallback errorCallback, void * context) { VerifyOrReturnError(initCallback != nullptr, CHIP_ERROR_INVALID_ARGUMENT); @@ -149,6 +153,33 @@ CHIP_ERROR ChipDnssdFinalizeServiceUpdate() return CHIP_NO_ERROR; } +std::string GetFullType(const char * type, DnssdServiceProtocol protocol) +{ + std::ostringstream typeBuilder; + typeBuilder << type; + typeBuilder << (protocol == DnssdServiceProtocol::kDnssdProtocolUdp ? kProtocolUdp : kProtocolTcp); + return typeBuilder.str(); +} + +std::string GetFullTypeWithSubTypes(const char * type, DnssdServiceProtocol protocol) +{ + auto fullType = GetFullType(type, protocol); + + std::string subtypeDelimiter = "._sub."; + size_t position = fullType.find(subtypeDelimiter); + if (position != std::string::npos) + { + fullType = fullType.substr(position + subtypeDelimiter.size()) + "," + fullType.substr(0, position); + } + + return fullType; +} + +std::string GetFullType(const DnssdService * service) +{ + return GetFullType(service->mType, service->mProtocol); +} + CHIP_ERROR ChipDnssdBrowse(const char * type, DnssdServiceProtocol protocol, Inet::IPAddressType addressType, Inet::InterfaceId interface, DnssdBrowseCallback callback, void * context, intptr_t * browseIdentifier) { @@ -156,11 +187,8 @@ CHIP_ERROR ChipDnssdBrowse(const char * type, DnssdServiceProtocol protocol, Ine VerifyOrReturnError(sBrowserObject != nullptr && sBrowseMethod != nullptr, CHIP_ERROR_INVALID_ARGUMENT); VerifyOrReturnError(sMdnsCallbackObject != nullptr, CHIP_ERROR_INCORRECT_STATE); - std::string serviceType = type; - serviceType += '.'; - serviceType += (protocol == DnssdServiceProtocol::kDnssdProtocolUdp ? "_udp" : "_tcp"); - - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + std::string serviceType = GetFullTypeWithSubTypes(type, protocol); + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); UtfString jniServiceType(env, serviceType.c_str()); env->CallVoidMethod(sBrowserObject, sBrowseMethod, jniServiceType.jniValue(), reinterpret_cast(callback), @@ -196,14 +224,19 @@ CHIP_ERROR extractProtocol(const char * serviceType, char (&outServiceName)[N], outServiceName[lengthWithoutProtocol] = '\0'; // Set a null terminator outProtocol = DnssdServiceProtocol::kDnssdProtocolUnknown; - if (strcmp("._tcp", dotPos) == 0) + if (strstr(dotPos, "._tcp") != 0) { outProtocol = DnssdServiceProtocol::kDnssdProtocolTcp; } - else if (strcmp("._udp", dotPos) == 0) + else if (strstr(dotPos, "._udp") != 0) { outProtocol = DnssdServiceProtocol::kDnssdProtocolUdp; } + else + { + ChipLogError(Discovery, "protocol type don't include neithor TCP nor UDP!"); + return CHIP_ERROR_INVALID_ARGUMENT; + } ReturnErrorCodeIf(outProtocol == DnssdServiceProtocol::kDnssdProtocolUnknown, CHIP_ERROR_INVALID_ARGUMENT); @@ -216,11 +249,8 @@ CHIP_ERROR ChipDnssdResolve(DnssdService * service, Inet::InterfaceId interface, VerifyOrReturnError(sResolverObject != nullptr && sResolveMethod != nullptr, CHIP_ERROR_INCORRECT_STATE); VerifyOrReturnError(sMdnsCallbackObject != nullptr, CHIP_ERROR_INCORRECT_STATE); - std::string serviceType = service->mType; - serviceType += '.'; - serviceType += (service->mProtocol == DnssdServiceProtocol::kDnssdProtocolUdp ? "_udp" : "_tcp"); - - JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); + std::string serviceType = GetFullType(service); + JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); UtfString jniInstanceName(env, service->mName); UtfString jniServiceType(env, serviceType.c_str()); @@ -433,8 +463,6 @@ void HandleBrowse(jobjectArray instanceName, jstring serviceType, jlong callback JNIEnv * env = JniReferences::GetInstance().GetEnvForCurrentThread(); JniUtfString jniServiceType(env, serviceType); - VerifyOrReturn(strlen(jniServiceType.c_str()) <= kDnssdTypeAndProtocolMaxSize, dispatch(CHIP_ERROR_INVALID_ARGUMENT)); - auto size = env->GetArrayLength(instanceName); DnssdService * service = new DnssdService[size]; for (decltype(size) i = 0; i < size; i++) From 85fd5cecff99c28016b28e22e4ecde28d1a1b7be Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Tue, 25 Apr 2023 13:00:26 -0400 Subject: [PATCH 41/54] Improve documentation for MTRDeviceControllerStartupParams init methods. (#26251) --- .../CHIP/MTRDeviceControllerStartupParams.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.h b/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.h index 49970304ad517e..9df0257445374e 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.h +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerStartupParams.h @@ -32,6 +32,10 @@ NS_ASSUME_NONNULL_BEGIN * Prepare to initialize a controller given a keypair to use for signing * operational certificates. * + * A controller created from MTRDeviceControllerStartupParams initialized with + * this method will be able to issue operational certificates to devices it + * commissions, using nocSigner to sign them. + * @param ipk The Identity Protection Key, must be 16 bytes in length * @param fabricID The fabric identifier, must be non-zero. */ @@ -40,17 +44,20 @@ NS_ASSUME_NONNULL_BEGIN nocSigner:(id)nocSigner API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); /** - * Prepare to initialize a controller with a complete operational certificate - * chain. This initialization method should be used when none of the - * certificate-signing private keys are available locally. + * Prepare to initialize a controller that is not able to sign operational + * certificates itself, and therefore needs to be provided with a complete + * operational certificate chain. This initialization method should be used + * when none of the certificate-signing private keys are available locally. + * + * A controller created from MTRDeviceControllerStartupParams initialized with + * this method will not be able to commission devices unless + * operationalCertificateIssuer and operationalCertificateIssuerQueue are set. * - * The fabric id and node id to use will be derived from the provided + * The fabric id and node id to use for the controller will be derived from the provided * operationalCertificate. * * @param ipk The Identity Protection Key, must be 16 bytes in length * @param intermediateCertificate may be nil if operationalCertificate is directly signed by rootCertificate. - * - * ipk must be 16 bytes in length. */ - (instancetype)initWithIPK:(NSData *)ipk operationalKeypair:(id)operationalKeypair From c2a28c8183c62cb8508266a451250e3447d218eb Mon Sep 17 00:00:00 2001 From: Hrishikesh Dhayagude Date: Wed, 26 Apr 2023 00:43:23 +0530 Subject: [PATCH 42/54] ESP32: Move the BLE deinit after BLE connection is closed, post commissioning (#26183) --- .../esp32/common/CommonDeviceCallbacks.cpp | 66 +++++++++++-------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/examples/platform/esp32/common/CommonDeviceCallbacks.cpp b/examples/platform/esp32/common/CommonDeviceCallbacks.cpp index 4a112aef9ed7f0..c4409a59cc20f2 100644 --- a/examples/platform/esp32/common/CommonDeviceCallbacks.cpp +++ b/examples/platform/esp32/common/CommonDeviceCallbacks.cpp @@ -33,6 +33,7 @@ #include "esp_heap_caps.h" #include "esp_log.h" #include +#include #include #include #if CONFIG_ENABLE_OTA_REQUESTOR @@ -61,6 +62,43 @@ void CommonDeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, i case DeviceEventType::kCHIPoBLEConnectionClosed: ESP_LOGI(TAG, "CHIPoBLE disconnected"); +#if CONFIG_BT_ENABLED +#if CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING + + if (chip::Server::GetInstance().GetFabricTable().FabricCount() > 0) + { + esp_err_t err = ESP_OK; +#if CONFIG_BT_NIMBLE_ENABLED + if (ble_hs_is_enabled()) + { + int ret = nimble_port_stop(); + if (ret == 0) + { + nimble_port_deinit(); +#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) + err = esp_nimble_hci_and_controller_deinit(); +#endif // ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) +#endif // CONFIG_BT_NIMBLE_ENABLED + +#if CONFIG_IDF_TARGET_ESP32 + err += esp_bt_mem_release(ESP_BT_MODE_BTDM); +#elif CONFIG_IDF_TARGET_ESP32C2 || CONFIG_IDF_TARGET_ESP32C3 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32H2 + err += esp_bt_mem_release(ESP_BT_MODE_BLE); +#endif + if (err == ESP_OK) + { + ESP_LOGI(TAG, "BLE deinit successful and memory reclaimed"); + } + } + else + { + ESP_LOGW(TAG, "nimble_port_stop() failed"); + } + } + else { ESP_LOGI(TAG, "BLE already deinited"); } + } +#endif // CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING +#endif // CONFIG_BT_ENABLED break; case DeviceEventType::kDnssdInitialized: @@ -76,34 +114,6 @@ void CommonDeviceCallbacks::DeviceEventCallback(const ChipDeviceEvent * event, i case DeviceEventType::kCommissioningComplete: { ESP_LOGI(TAG, "Commissioning complete"); -#if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE && CONFIG_BT_NIMBLE_ENABLED && CONFIG_USE_BLE_ONLY_FOR_COMMISSIONING - - if (ble_hs_is_enabled()) - { - int ret = nimble_port_stop(); - esp_err_t err = ESP_OK; - if (ret == 0) - { - nimble_port_deinit(); -#if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) - err = esp_nimble_hci_and_controller_deinit(); -#endif // ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) - err += esp_bt_mem_release(ESP_BT_MODE_BTDM); - if (err == ESP_OK) - { - ESP_LOGI(TAG, "BLE deinit successful and memory reclaimed"); - } - } - else - { - ESP_LOGW(TAG, "nimble_port_stop() failed"); - } - } - else - { - ESP_LOGI(TAG, "BLE already deinited"); - } -#endif } break; From 23a8e5ae65520741698ac6aa5af52912d3ad996c Mon Sep 17 00:00:00 2001 From: AlvinHsiao Date: Wed, 26 Apr 2023 21:06:20 +0800 Subject: [PATCH 43/54] [Infineon] Implement button wake up handler (#26178) * Add API to re-send the pending event if wake up from button. --- .../include/wiced_button_manager.h | 7 ++++++ .../cyw30739_sdk/src/wiced_button_manager.c | 23 +++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/third_party/infineon/cyw30739_sdk/include/wiced_button_manager.h b/third_party/infineon/cyw30739_sdk/include/wiced_button_manager.h index 6162dc95b830c8..65091250a0d809 100644 --- a/third_party/infineon/cyw30739_sdk/include/wiced_button_manager.h +++ b/third_party/infineon/cyw30739_sdk/include/wiced_button_manager.h @@ -229,6 +229,13 @@ extern wiced_result_t wiced_button_manager_init(button_manager_t * manager, */ extern wiced_result_t wiced_button_manager_deinit(button_manager_t * manager); +/** + * Checks if there is pending event and then re-send the event. + * + * @return void : no return value is expected. + */ +extern void wiced_button_manager_pending_event_handle(void); + #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/third_party/infineon/cyw30739_sdk/src/wiced_button_manager.c b/third_party/infineon/cyw30739_sdk/src/wiced_button_manager.c index 9309b5a78aaa9c..c8761c6e354023 100644 --- a/third_party/infineon/cyw30739_sdk/src/wiced_button_manager.c +++ b/third_party/infineon/cyw30739_sdk/src/wiced_button_manager.c @@ -44,6 +44,7 @@ #include "wiced_memory.h" #include "wiced_misc_rtos_utils.h" #endif +#include /****************************************************** * Macros @@ -675,6 +676,28 @@ static button_manager_button_t * get_button(platform_button_t id) return NULL; } +/** + * Checks if there is pending event and then re-send the event. + * + * @return void : no return value is expected. + */ +void wiced_button_manager_pending_event_handle(void) +{ + uint32_t a; + if (wiced_sleep_get_boot_mode() == WICED_SLEEP_FAST_BOOT) + { + for (a = 0; a < button_manager->number_of_buttons; a++) + { + if (platform_button_pending_event_get_and_clear(button_manager->buttons[a].configuration->button)) + { + button_manager->configuration->event_handler(&button_manager->buttons[a], BUTTON_CLICK_EVENT, + BUTTON_STATE_RELEASED); + break; + } + } + } +} + #ifdef CYW55572 static void button_event_defer_to_mpaf(void * arg) { From 980a1a1e677bf3194e55eda0910b5d4ee2798415 Mon Sep 17 00:00:00 2001 From: "Robin.Gao" Date: Thu, 27 Apr 2023 00:08:35 +0800 Subject: [PATCH 44/54] [Darwin]Fix: enable controller to skip complete step (#26248) * [Darwin]Fix: enable controller to skip complete step; * [Darwin]set skipCommissioningComplete to boolean value and append MTR_NEWLY_AVAILABLE annotation * Update src/darwin/Framework/CHIP/MTRCommissioningParameters.h Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceController.mm Co-authored-by: Boris Zbarsky --------- Co-authored-by: Boris Zbarsky --- src/darwin/Framework/CHIP/MTRCommissioningParameters.h | 8 ++++++++ src/darwin/Framework/CHIP/MTRDeviceController.mm | 1 + 2 files changed, 9 insertions(+) diff --git a/src/darwin/Framework/CHIP/MTRCommissioningParameters.h b/src/darwin/Framework/CHIP/MTRCommissioningParameters.h index 722bc1ee8ca4ec..c16aaf692de1bb 100644 --- a/src/darwin/Framework/CHIP/MTRCommissioningParameters.h +++ b/src/darwin/Framework/CHIP/MTRCommissioningParameters.h @@ -80,6 +80,14 @@ NS_ASSUME_NONNULL_BEGIN */ @property (nonatomic, copy, nullable) NSNumber * failSafeTimeout API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +/** + * Only perform the PASE steps of commissioning. + * If set to YES, commissioning will be completed by another admin on the network. + * + * Defaults to NO. + */ +@property (nonatomic, assign) BOOL skipCommissioningComplete MTR_NEWLY_AVAILABLE; + @end @interface MTRCommissioningParameters (Deprecated) diff --git a/src/darwin/Framework/CHIP/MTRDeviceController.mm b/src/darwin/Framework/CHIP/MTRDeviceController.mm index f0ecc5441bddca..e6388e083cd3fa 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceController.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceController.mm @@ -463,6 +463,7 @@ - (BOOL)commissionNodeWithID:(NSNumber *)nodeID if (commissioningParams.threadOperationalDataset) { params.SetThreadOperationalDataset(AsByteSpan(commissioningParams.threadOperationalDataset)); } + params.SetSkipCommissioningComplete(commissioningParams.skipCommissioningComplete); if (commissioningParams.wifiSSID) { chip::ByteSpan ssid = AsByteSpan(commissioningParams.wifiSSID); chip::ByteSpan credentials; From 7bbb240b9b445d56cede49c24230319eed6e9efd Mon Sep 17 00:00:00 2001 From: joonhaengHeo <85541460+joonhaengHeo@users.noreply.github.com> Date: Thu, 27 Apr 2023 01:50:36 +0900 Subject: [PATCH 45/54] [Darwin] add commissioning callback (read Commissioning Info, commissioningComplete add deviceId) (#25832) * Implement commissioning event callback api * restyle * Add comment, fix typo * Modify from comment * Update after review * restyle * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * Change Variable name(nodeID) remove ununsed code * Modify readCommissioningInfo to interface * restyle * restyle-2 * Modify nodeID error check * restyle * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * Update src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h Co-authored-by: Boris Zbarsky * modify for changing variable name * restyle * restyle-2 * Apply suggestions from code review * Fix deprecation message. * Remove redundant availability annotations. --------- Co-authored-by: Boris Zbarsky --- .../QRCode/QRCodeViewController.h | 2 +- .../QRCode/QRCodeViewController.m | 22 +++++++--- .../CHIP/MTRDeviceControllerDelegate.h | 35 ++++++++++++++- .../CHIP/MTRDeviceControllerDelegateBridge.h | 3 ++ .../CHIP/MTRDeviceControllerDelegateBridge.mm | 44 +++++++++++++++++++ 5 files changed, 97 insertions(+), 9 deletions(-) diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.h b/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.h index 77d143c2c5a2bb..85a2f1f133f2f5 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.h +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.h @@ -21,6 +21,6 @@ #import @interface QRCodeViewController - : UIViewController + : UIViewController @end diff --git a/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m b/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m index 2105bec3b20545..66c2883964932d 100644 --- a/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m +++ b/src/darwin/CHIPTool/CHIPTool/View Controllers/QRCode/QRCodeViewController.m @@ -408,7 +408,7 @@ - (void)viewDidLoad dispatch_queue_t callbackQueue = dispatch_queue_create("com.csa.matter.qrcodevc.callback", DISPATCH_QUEUE_SERIAL); self.chipController = InitializeMTR(); - [self.chipController setPairingDelegate:self queue:callbackQueue]; + [self.chipController setDeviceControllerDelegate:self queue:callbackQueue]; UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(dismissKeyboard)]; [self.view addGestureRecognizer:tap]; @@ -478,8 +478,8 @@ - (void)setVendorIDOnAccessory } } -// MARK: MTRDevicePairingDelegate -- (void)onPairingComplete:(NSError * _Nullable)error +// MARK: MTRDeviceControllerDelegate +- (void)controller:(MTRDeviceController *)controller commissioningSessionEstablishmentDone:(NSError * _Nullable)error { if (error != nil) { NSLog(@"Got pairing error back %@", error); @@ -672,18 +672,26 @@ - (void)commissionWithSSID:(NSString *)ssid password:(NSString *)password } } -- (void)onCommissioningComplete:(NSError * _Nullable)error +// MARK: MTRDeviceControllerDelegate +- (void)controller:(MTRDeviceController *)controller + commissioningComplete:(NSError * _Nullable)error + nodeID:(NSNumber * _Nullable)nodeID { if (error != nil) { NSLog(@"Error retrieving device informations over Mdns: %@", error); return; } // track this device - uint64_t deviceId = MTRGetNextAvailableDeviceID() - 1; - MTRSetDevicePaired(deviceId, YES); + MTRSetDevicePaired([nodeID unsignedLongLongValue], YES); [self setVendorIDOnAccessory]; } +// MARK: MTRDeviceControllerDelegate +- (void)controller:(MTRDeviceController *)controller readCommissioningInfo:(MTRProductIdentity *)info +{ + NSLog(@"readCommissioningInfo, vendorID:%@, productID:%@", info.vendorID, info.productID); +} + - (void)updateUIFields:(MTRSetupPayload *)payload rawPayload:(nullable NSString *)rawPayload isManualCode:(BOOL)isManualCode { if (isManualCode) { @@ -789,7 +797,7 @@ - (void)_restartMatterStack { self.chipController = MTRRestartController(self.chipController); dispatch_queue_t callbackQueue = dispatch_queue_create("com.csa.matter.qrcodevc.callback", DISPATCH_QUEUE_SERIAL); - [self.chipController setPairingDelegate:self queue:callbackQueue]; + [self.chipController setDeviceControllerDelegate:self queue:callbackQueue]; } - (void)handleRendezVousDefault:(NSString *)payload diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h index 5245b980de5fbf..37c2f691307d02 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegate.h @@ -28,6 +28,19 @@ typedef NS_ENUM(NSInteger, MTRCommissioningStatus) { = 3, } API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)); +/** + * A representation of a (vendor, product) pair that identifies a specific product. + */ +MTR_NEWLY_AVAILABLE +@interface MTRProductIdentity : NSObject + +@property (nonatomic, copy, readonly) NSNumber * vendorID; + +@property (nonatomic, copy, readonly) NSNumber * productID; + +- (instancetype)initWithVendorID:(NSNumber *)vendorID productID:(NSNumber *)productID; +@end + @class MTRDeviceController; /** @@ -52,8 +65,28 @@ API_AVAILABLE(ios(16.4), macos(13.3), watchos(9.4), tvos(16.4)) /** * Notify the delegate when commissioning is completed. */ -- (void)controller:(MTRDeviceController *)controller commissioningComplete:(NSError * _Nullable)error; +- (void)controller:(MTRDeviceController *)controller + commissioningComplete:(NSError * _Nullable)error MTR_NEWLY_DEPRECATED("Please use controller:commissioningComplete:nodeID:"); + +/** + * Notify the delegate when commissioning is completed. + * + * Exactly one of error and nodeID will be nil. + * + * If nodeID is not nil, then it represents the node id the node was assigned, as encoded in its operational certificate. + */ +- (void)controller:(MTRDeviceController *)controller + commissioningComplete:(NSError * _Nullable)error + nodeID:(NSNumber * _Nullable)nodeID MTR_NEWLY_AVAILABLE; +/** + * Notify the delegate when commissioning infomation has been read from the Basic + * Information cluster of the commissionee. + * + * At the point when this notification happens, device attestation has not been performed yet, + * so the information delivered by this notification should not be trusted. + */ +- (void)controller:(MTRDeviceController *)controller readCommissioningInfo:(MTRProductIdentity *)info MTR_NEWLY_AVAILABLE; @end typedef NS_ENUM(NSUInteger, MTRPairingStatus) { diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.h b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.h index 464f0c91093d8d..d13331f46bd2ac 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.h +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.h @@ -18,6 +18,7 @@ #import "MTRDeviceControllerDelegate.h" #include +#include #include NS_ASSUME_NONNULL_BEGIN @@ -37,6 +38,8 @@ class MTRDeviceControllerDelegateBridge : public chip::Controller::DevicePairing void OnPairingDeleted(CHIP_ERROR error) override; + void OnReadCommissioningInfo(const chip::Controller::ReadCommissioningInfo & info) override; + void OnCommissioningComplete(chip::NodeId deviceId, CHIP_ERROR error) override; private: diff --git a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm index 59d18882e536c4..71ca534e67ddff 100644 --- a/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm +++ b/src/darwin/Framework/CHIP/MTRDeviceControllerDelegateBridge.mm @@ -94,6 +94,25 @@ // This is never actually called; just do nothing. } +void MTRDeviceControllerDelegateBridge::OnReadCommissioningInfo(const chip::Controller::ReadCommissioningInfo & info) +{ + chip::VendorId vendorId = info.basic.vendorId; + uint16_t productId = info.basic.productId; + + MTR_LOG_DEFAULT("DeviceControllerDelegate Read Commissioning Info. VendorId %u ProductId %u", vendorId, productId); + + id strongDelegate = mDelegate; + MTRDeviceController * strongController = mController; + if (strongDelegate && mQueue && strongController) { + if ([strongDelegate respondsToSelector:@selector(controller:readCommissioningInfo:)]) { + dispatch_async(mQueue, ^{ + auto * info = [[MTRProductIdentity alloc] initWithVendorID:@(vendorId) productID:@(productId)]; + [strongDelegate controller:strongController readCommissioningInfo:info]; + }); + } + } +} + void MTRDeviceControllerDelegateBridge::OnCommissioningComplete(chip::NodeId nodeId, CHIP_ERROR error) { MTR_LOG_DEFAULT("DeviceControllerDelegate Commissioning complete. NodeId %llu Status %s", nodeId, chip::ErrorStr(error)); @@ -101,6 +120,18 @@ id strongDelegate = mDelegate; MTRDeviceController * strongController = mController; if (strongDelegate && mQueue && strongController) { + if ([strongDelegate respondsToSelector:@selector(controller:commissioningComplete:nodeID:)]) { + dispatch_async(mQueue, ^{ + NSError * nsError = [MTRError errorForCHIPErrorCode:error]; + NSNumber * nodeID = nil; + if (error == CHIP_NO_ERROR) { + nodeID = @(nodeId); + } + [strongDelegate controller:strongController commissioningComplete:nsError nodeID:nodeID]; + }); + return; + } + // If only the DEPRECATED function is defined if ([strongDelegate respondsToSelector:@selector(controller:commissioningComplete:)]) { dispatch_async(mQueue, ^{ NSError * nsError = [MTRError errorForCHIPErrorCode:error]; @@ -109,3 +140,16 @@ } } } + +@implementation MTRProductIdentity + +- (instancetype)initWithVendorID:(NSNumber *)vendorID productID:(NSNumber *)productID +{ + if (self = [super init]) { + _vendorID = vendorID; + _productID = productID; + } + return self; +} + +@end From cc6c41447349554a971ab7f6dcd1157cdccebe3a Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 26 Apr 2023 14:22:01 -0400 Subject: [PATCH 46/54] Fix chip-tool handling of same-named structs in different clusters. (#26253) The chip-tool code was assuming that the only way a struct with the same name could occur in multiple clusters was if it was the same struct, shared by the two clusters. But that's just not true in the spec. For example, there are totally different TargetStruct structs in different clusters. This fixes chip-tool to do the same thing as cluster-objects in terms of deciding what the set of structs we have to deal with is. --- .../templates/ComplexArgumentParser-src.zapt | 62 +- .../templates/ComplexArgumentParser.zapt | 16 +- .../logging/DataModelLogger-src.zapt | 30 +- .../templates/logging/DataModelLogger.zapt | 16 +- .../templates/partials/StructLoggerDecl.zapt | 2 + .../templates/partials/StructLoggerImpl.zapt | 18 + .../templates/partials/StructParserDecl.zapt | 4 + .../templates/partials/StructParserImpl.zapt | 47 + examples/chip-tool/templates/templates.json | 16 + .../cluster/ComplexArgumentParser.cpp | 3105 +++++++++-------- .../cluster/ComplexArgumentParser.h | 269 +- .../cluster/logging/DataModelLogger.cpp | 1591 +++++---- .../cluster/logging/DataModelLogger.h | 177 +- 13 files changed, 2822 insertions(+), 2531 deletions(-) create mode 100644 examples/chip-tool/templates/partials/StructLoggerDecl.zapt create mode 100644 examples/chip-tool/templates/partials/StructLoggerImpl.zapt create mode 100644 examples/chip-tool/templates/partials/StructParserDecl.zapt create mode 100644 examples/chip-tool/templates/partials/StructParserImpl.zapt diff --git a/examples/chip-tool/templates/ComplexArgumentParser-src.zapt b/examples/chip-tool/templates/ComplexArgumentParser-src.zapt index b2c9d172fec555..f9b0f4bef764c5 100644 --- a/examples/chip-tool/templates/ComplexArgumentParser-src.zapt +++ b/examples/chip-tool/templates/ComplexArgumentParser-src.zapt @@ -2,52 +2,16 @@ #include -{{#structs_with_clusters groupByStructName=1}} -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::Type & request, Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); - - // Copy to track which members we already processed. - Json::Value valueCopy(value); - - {{#zcl_struct_items}} - {{#unless isOptional}} - {{~! Fabric index fields are not sent on writes, so don't force people to - provide them. ~}} - {{#unless (is_num_equal fieldIdentifier 254)}} - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("{{parent.name}}.{{asLowerCamelCase label}}", "{{asLowerCamelCase label}}", value.isMember("{{asLowerCamelCase label}}"))); - {{/unless}} - {{/unless}} - {{/zcl_struct_items}} - - char labelWithMember[kMaxLabelLength]; - {{#zcl_struct_items}} - {{#if isOptional}} - if (value.isMember("{{asLowerCamelCase label}}")) - { - {{else if (is_num_equal fieldIdentifier 254)}} - if (value.isMember("{{asLowerCamelCase label}}")) - { - {{/if}} - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "{{asLowerCamelCase label}}"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.{{asLowerCamelCase label}}, value["{{asLowerCamelCase label}}"])); - {{#if isOptional}} - } - {{else if (is_num_equal fieldIdentifier 254)}} - } - {{/if}} - valueCopy.removeMember("{{asLowerCamelCase label}}"); - - {{/zcl_struct_items}} - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} - -void ComplexArgumentParser::Finalize(chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::Type & request) -{ - {{#zcl_struct_items}} - ComplexArgumentParser::Finalize(request.{{asLowerCamelCase label}}); - {{/zcl_struct_items}} -} -{{/structs_with_clusters}} - +{{#zcl_structs}} +{{#if has_more_than_one_cluster}} +{{> struct_parser_impl namespace="detail"}} +{{/if}} +{{/zcl_structs}} + +{{#zcl_clusters}} +{{#zcl_structs}} +{{#unless has_more_than_one_cluster}} +{{> struct_parser_impl namespace=(as_camel_cased ../name false)}} +{{/unless}} +{{/zcl_structs}} +{{/zcl_clusters}} diff --git a/examples/chip-tool/templates/ComplexArgumentParser.zapt b/examples/chip-tool/templates/ComplexArgumentParser.zapt index e057f0462df0a4..7364b243188333 100644 --- a/examples/chip-tool/templates/ComplexArgumentParser.zapt +++ b/examples/chip-tool/templates/ComplexArgumentParser.zapt @@ -5,8 +5,16 @@ #include #include -{{#structs_with_clusters groupByStructName=1}} -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::Type & request, Json::Value & value); +{{#zcl_structs}} +{{#if has_more_than_one_cluster}} +{{> struct_parser_decl namespace="detail"}} +{{/if}} +{{/zcl_structs}} -static void Finalize(chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::Type & request); -{{/structs_with_clusters}} +{{#zcl_clusters}} +{{#zcl_structs}} +{{#unless has_more_than_one_cluster}} +{{> struct_parser_decl namespace=(as_camel_cased ../name false)}} +{{/unless}} +{{/zcl_structs}} +{{/zcl_clusters}} diff --git a/examples/chip-tool/templates/logging/DataModelLogger-src.zapt b/examples/chip-tool/templates/logging/DataModelLogger-src.zapt index d710ff53735f6c..d400874cf67ffb 100644 --- a/examples/chip-tool/templates/logging/DataModelLogger-src.zapt +++ b/examples/chip-tool/templates/logging/DataModelLogger-src.zapt @@ -4,25 +4,19 @@ using namespace chip::app::Clusters; -{{#structs_with_clusters groupByStructName=1}} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); -{{#zcl_struct_items}} - { - CHIP_ERROR err = LogValue("{{asUpperCamelCase label}}", indent + 1, value.{{asLowerCamelCase label}}); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for '{{asUpperCamelCase label}}'"); - return err; - } - } -{{/zcl_struct_items}} - DataModelLogger::LogString(indent, "}"); +{{#zcl_structs}} +{{#if has_more_than_one_cluster}} +{{> struct_logger_impl namespace="detail"}} +{{/if}} +{{/zcl_structs}} - return CHIP_NO_ERROR; -} -{{/structs_with_clusters}} +{{#zcl_clusters}} +{{#zcl_structs}} +{{#unless has_more_than_one_cluster}} +{{> struct_logger_impl namespace=(as_camel_cased ../name false)}} +{{/unless}} +{{/zcl_structs}} +{{/zcl_clusters}} {{#zcl_clusters}} {{#zcl_events}} diff --git a/examples/chip-tool/templates/logging/DataModelLogger.zapt b/examples/chip-tool/templates/logging/DataModelLogger.zapt index c0ea82e116e1ba..222ab67dee0364 100644 --- a/examples/chip-tool/templates/logging/DataModelLogger.zapt +++ b/examples/chip-tool/templates/logging/DataModelLogger.zapt @@ -3,9 +3,19 @@ #include #include -{{#structs_with_clusters groupByStructName=1}} -static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::{{#unless (is_number_greater_than structClusterCount 1)}}{{as_camel_cased clusterName false}}{{else}}detail{{/unless}}::Structs::{{name}}::DecodableType & value); -{{/structs_with_clusters}} +{{#zcl_structs}} +{{#if has_more_than_one_cluster}} +{{> struct_logger_decl namespace="detail"}} +{{/if}} +{{/zcl_structs}} + +{{#zcl_clusters}} +{{#zcl_structs}} +{{#unless has_more_than_one_cluster}} +{{> struct_logger_decl namespace=(as_camel_cased ../name false)}} +{{/unless}} +{{/zcl_structs}} +{{/zcl_clusters}} {{#zcl_clusters}} {{#zcl_events}} diff --git a/examples/chip-tool/templates/partials/StructLoggerDecl.zapt b/examples/chip-tool/templates/partials/StructLoggerDecl.zapt new file mode 100644 index 00000000000000..0f7e47ddc8ecca --- /dev/null +++ b/examples/chip-tool/templates/partials/StructLoggerDecl.zapt @@ -0,0 +1,2 @@ +static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::{{namespace}}::Structs::{{name}}::DecodableType & value); + diff --git a/examples/chip-tool/templates/partials/StructLoggerImpl.zapt b/examples/chip-tool/templates/partials/StructLoggerImpl.zapt new file mode 100644 index 00000000000000..3dbd99e7400ef4 --- /dev/null +++ b/examples/chip-tool/templates/partials/StructLoggerImpl.zapt @@ -0,0 +1,18 @@ +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const chip::app::Clusters::{{namespace}}::Structs::{{name}}::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); +{{#zcl_struct_items}} + { + CHIP_ERROR err = LogValue("{{asUpperCamelCase label}}", indent + 1, value.{{asLowerCamelCase label}}); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for '{{asUpperCamelCase label}}'"); + return err; + } + } +{{/zcl_struct_items}} + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + diff --git a/examples/chip-tool/templates/partials/StructParserDecl.zapt b/examples/chip-tool/templates/partials/StructParserDecl.zapt new file mode 100644 index 00000000000000..7fd3364d034c89 --- /dev/null +++ b/examples/chip-tool/templates/partials/StructParserDecl.zapt @@ -0,0 +1,4 @@ +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::{{namespace}}::Structs::{{name}}::Type & request, Json::Value & value); + +static void Finalize(chip::app::Clusters::{{namespace}}::Structs::{{name}}::Type & request); + diff --git a/examples/chip-tool/templates/partials/StructParserImpl.zapt b/examples/chip-tool/templates/partials/StructParserImpl.zapt new file mode 100644 index 00000000000000..268b09451c6036 --- /dev/null +++ b/examples/chip-tool/templates/partials/StructParserImpl.zapt @@ -0,0 +1,47 @@ +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::{{namespace}}::Structs::{{name}}::Type & request, Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + {{#zcl_struct_items}} + {{#unless isOptional}} + {{~! Fabric index fields are not sent on writes, so don't force people to + provide them. ~}} + {{#unless (is_num_equal fieldIdentifier 254)}} + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("{{parent.name}}.{{asLowerCamelCase label}}", "{{asLowerCamelCase label}}", value.isMember("{{asLowerCamelCase label}}"))); + {{/unless}} + {{/unless}} + {{/zcl_struct_items}} + + char labelWithMember[kMaxLabelLength]; + {{#zcl_struct_items}} + {{#if isOptional}} + if (value.isMember("{{asLowerCamelCase label}}")) + { + {{else if (is_num_equal fieldIdentifier 254)}} + if (value.isMember("{{asLowerCamelCase label}}")) + { + {{/if}} + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "{{asLowerCamelCase label}}"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.{{asLowerCamelCase label}}, value["{{asLowerCamelCase label}}"])); + {{#if isOptional}} + } + {{else if (is_num_equal fieldIdentifier 254)}} + } + {{/if}} + valueCopy.removeMember("{{asLowerCamelCase label}}"); + + {{/zcl_struct_items}} + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::{{namespace}}::Structs::{{name}}::Type & request) +{ + {{#zcl_struct_items}} + ComplexArgumentParser::Finalize(request.{{asLowerCamelCase label}}); + {{/zcl_struct_items}} +} + diff --git a/examples/chip-tool/templates/templates.json b/examples/chip-tool/templates/templates.json index 1552ab8566bfa6..528c7d266dcb97 100644 --- a/examples/chip-tool/templates/templates.json +++ b/examples/chip-tool/templates/templates.json @@ -21,6 +21,22 @@ { "name": "cluster_header", "path": "../../../src/app/zap-templates/partials/cluster_header.zapt" + }, + { + "name": "struct_parser_decl", + "path": "partials/StructParserDecl.zapt" + }, + { + "name": "struct_parser_impl", + "path": "partials/StructParserImpl.zapt" + }, + { + "name": "struct_logger_decl", + "path": "partials/StructLoggerDecl.zapt" + }, + { + "name": "struct_logger_impl", + "path": "partials/StructLoggerImpl.zapt" } ], "templates": [ diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp index 859fd542e6cc77..3d128bfb24f2e8 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.cpp @@ -19,6 +19,253 @@ #include +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ApplicationStruct.catalogVendorID", "catalogVendorID", + value.isMember("catalogVendorID"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ApplicationStruct.applicationID", "applicationID", + value.isMember("applicationID"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "catalogVendorID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.catalogVendorID, value["catalogVendorID"])); + valueCopy.removeMember("catalogVendorID"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "applicationID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.applicationID, value["applicationID"])); + valueCopy.removeMember("applicationID"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.catalogVendorID); + ComplexArgumentParser::Finalize(request.applicationID); +} + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::detail::Structs::LabelStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("LabelStruct.label", "label", value.isMember("label"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("LabelStruct.value", "value", value.isMember("value"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "label"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.label, value["label"])); + valueCopy.removeMember("label"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "value"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.value, value["value"])); + valueCopy.removeMember("value"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::detail::Structs::LabelStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.label); + ComplexArgumentParser::Finalize(request.value); +} + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::Scenes::Structs::AttributeValuePair::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("AttributeValuePair.attributeValue", "attributeValue", + value.isMember("attributeValue"))); + + char labelWithMember[kMaxLabelLength]; + if (value.isMember("attributeID")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "attributeID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.attributeID, value["attributeID"])); + } + valueCopy.removeMember("attributeID"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "attributeValue"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.attributeValue, value["attributeValue"])); + valueCopy.removeMember("attributeValue"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::Scenes::Structs::AttributeValuePair::Type & request) +{ + ComplexArgumentParser::Finalize(request.attributeID); + ComplexArgumentParser::Finalize(request.attributeValue); +} + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ExtensionFieldSet.clusterID", "clusterID", value.isMember("clusterID"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ExtensionFieldSet.attributeValueList", "attributeValueList", + value.isMember("attributeValueList"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "clusterID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.clusterID, value["clusterID"])); + valueCopy.removeMember("clusterID"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "attributeValueList"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.attributeValueList, value["attributeValueList"])); + valueCopy.removeMember("attributeValueList"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & request) +{ + ComplexArgumentParser::Finalize(request.clusterID); + ComplexArgumentParser::Finalize(request.attributeValueList); +} + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("DeviceTypeStruct.deviceType", "deviceType", value.isMember("deviceType"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("DeviceTypeStruct.revision", "revision", value.isMember("revision"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "deviceType"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.deviceType, value["deviceType"])); + valueCopy.removeMember("deviceType"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "revision"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.revision, value["revision"])); + valueCopy.removeMember("revision"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.deviceType); + ComplexArgumentParser::Finalize(request.revision); +} + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::Binding::Structs::TargetStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + char labelWithMember[kMaxLabelLength]; + if (value.isMember("node")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "node"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.node, value["node"])); + } + valueCopy.removeMember("node"); + + if (value.isMember("group")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "group"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.group, value["group"])); + } + valueCopy.removeMember("group"); + + if (value.isMember("endpoint")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); + } + valueCopy.removeMember("endpoint"); + + if (value.isMember("cluster")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "cluster"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.cluster, value["cluster"])); + } + valueCopy.removeMember("cluster"); + + if (value.isMember("fabricIndex")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); + } + valueCopy.removeMember("fabricIndex"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::Binding::Structs::TargetStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.node); + ComplexArgumentParser::Finalize(request.group); + ComplexArgumentParser::Finalize(request.endpoint); + ComplexArgumentParser::Finalize(request.cluster); + ComplexArgumentParser::Finalize(request.fabricIndex); +} + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::AccessControl::Structs::Target::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("Target.cluster", "cluster", value.isMember("cluster"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("Target.endpoint", "endpoint", value.isMember("endpoint"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("Target.deviceType", "deviceType", value.isMember("deviceType"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "cluster"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.cluster, value["cluster"])); + valueCopy.removeMember("cluster"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); + valueCopy.removeMember("endpoint"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "deviceType"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.deviceType, value["deviceType"])); + valueCopy.removeMember("deviceType"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::AccessControl::Structs::Target::Type & request) +{ + ComplexArgumentParser::Finalize(request.cluster); + ComplexArgumentParser::Finalize(request.endpoint); + ComplexArgumentParser::Finalize(request.deviceType); +} + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::AccessControl::Structs::AccessControlEntryStruct::Type & request, Json::Value & value) @@ -72,6 +319,7 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::AccessControl::Structs ComplexArgumentParser::Finalize(request.targets); ComplexArgumentParser::Finalize(request.fabricIndex); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::AccessControl::Structs::AccessControlExtensionStruct::Type & request, Json::Value & value) @@ -104,6 +352,7 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::AccessControl::Structs ComplexArgumentParser::Finalize(request.data); ComplexArgumentParser::Finalize(request.fabricIndex); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::Actions::Structs::ActionStruct::Type & request, Json::Value & value) { @@ -158,8 +407,9 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::Actions::Structs::Acti ComplexArgumentParser::Finalize(request.supportedCommands); ComplexArgumentParser::Finalize(request.state); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type & request, + chip::app::Clusters::Actions::Structs::EndpointListStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -167,28 +417,43 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("AdditionalInfoStruct.name", "name", value.isMember("name"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("AdditionalInfoStruct.value", "value", value.isMember("value"))); - - char labelWithMember[kMaxLabelLength]; + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("EndpointListStruct.endpointListID", "endpointListID", + value.isMember("endpointListID"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("EndpointListStruct.name", "name", value.isMember("name"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("EndpointListStruct.type", "type", value.isMember("type"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("EndpointListStruct.endpoints", "endpoints", value.isMember("endpoints"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpointListID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpointListID, value["endpointListID"])); + valueCopy.removeMember("endpointListID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); valueCopy.removeMember("name"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "value"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.value, value["value"])); - valueCopy.removeMember("value"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "type"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.type, value["type"])); + valueCopy.removeMember("type"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoints"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoints, value["endpoints"])); + valueCopy.removeMember("endpoints"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::Actions::Structs::EndpointListStruct::Type & request) { + ComplexArgumentParser::Finalize(request.endpointListID); ComplexArgumentParser::Finalize(request.name); - ComplexArgumentParser::Finalize(request.value); + ComplexArgumentParser::Finalize(request.type); + ComplexArgumentParser::Finalize(request.endpoints); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::Type & request, + chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -196,61 +461,33 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ApplicationEPStruct.application", "application", value.isMember("application"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( + "CapabilityMinimaStruct.caseSessionsPerFabric", "caseSessionsPerFabric", value.isMember("caseSessionsPerFabric"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( + "CapabilityMinimaStruct.subscriptionsPerFabric", "subscriptionsPerFabric", value.isMember("subscriptionsPerFabric"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "application"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.application, value["application"])); - valueCopy.removeMember("application"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "caseSessionsPerFabric"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.caseSessionsPerFabric, value["caseSessionsPerFabric"])); + valueCopy.removeMember("caseSessionsPerFabric"); - if (value.isMember("endpoint")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); - } - valueCopy.removeMember("endpoint"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "subscriptionsPerFabric"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.subscriptionsPerFabric, value["subscriptionsPerFabric"])); + valueCopy.removeMember("subscriptionsPerFabric"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::Type & request) -{ - ComplexArgumentParser::Finalize(request.application); - ComplexArgumentParser::Finalize(request.endpoint); -} -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request, - Json::Value & value) +void ComplexArgumentParser::Finalize(chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::Type & request) { - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); - - // Copy to track which members we already processed. - Json::Value valueCopy(value); - - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ApplicationStruct.catalogVendorID", "catalogVendorID", - value.isMember("catalogVendorID"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ApplicationStruct.applicationID", "applicationID", - value.isMember("applicationID"))); - - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "catalogVendorID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.catalogVendorID, value["catalogVendorID"])); - valueCopy.removeMember("catalogVendorID"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "applicationID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.applicationID, value["applicationID"])); - valueCopy.removeMember("applicationID"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); + ComplexArgumentParser::Finalize(request.caseSessionsPerFabric); + ComplexArgumentParser::Finalize(request.subscriptionsPerFabric); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request) -{ - ComplexArgumentParser::Finalize(request.catalogVendorID); - ComplexArgumentParser::Finalize(request.applicationID); -} CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::Scenes::Structs::AttributeValuePair::Type & request, + chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -258,64 +495,37 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("AttributeValuePair.attributeValue", "attributeValue", - value.isMember("attributeValue"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ProviderLocation.providerNodeID", "providerNodeID", + value.isMember("providerNodeID"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ProviderLocation.endpoint", "endpoint", value.isMember("endpoint"))); char labelWithMember[kMaxLabelLength]; - if (value.isMember("attributeID")) + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "providerNodeID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.providerNodeID, value["providerNodeID"])); + valueCopy.removeMember("providerNodeID"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); + valueCopy.removeMember("endpoint"); + + if (value.isMember("fabricIndex")) { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "attributeID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.attributeID, value["attributeID"])); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); } - valueCopy.removeMember("attributeID"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "attributeValue"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.attributeValue, value["attributeValue"])); - valueCopy.removeMember("attributeValue"); + valueCopy.removeMember("fabricIndex"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::Scenes::Structs::AttributeValuePair::Type & request) -{ - ComplexArgumentParser::Finalize(request.attributeID); - ComplexArgumentParser::Finalize(request.attributeValue); -} -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request, - Json::Value & value) +void ComplexArgumentParser::Finalize(chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request) { - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); - - // Copy to track which members we already processed. - Json::Value valueCopy(value); - - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("BasicCommissioningInfo.failSafeExpiryLengthSeconds", - "failSafeExpiryLengthSeconds", - value.isMember("failSafeExpiryLengthSeconds"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("BasicCommissioningInfo.maxCumulativeFailsafeSeconds", - "maxCumulativeFailsafeSeconds", - value.isMember("maxCumulativeFailsafeSeconds"))); - - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "failSafeExpiryLengthSeconds"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.failSafeExpiryLengthSeconds, value["failSafeExpiryLengthSeconds"])); - valueCopy.removeMember("failSafeExpiryLengthSeconds"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "maxCumulativeFailsafeSeconds"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.maxCumulativeFailsafeSeconds, value["maxCumulativeFailsafeSeconds"])); - valueCopy.removeMember("maxCumulativeFailsafeSeconds"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); + ComplexArgumentParser::Finalize(request.providerNodeID); + ComplexArgumentParser::Finalize(request.endpoint); + ComplexArgumentParser::Finalize(request.fabricIndex); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request) -{ - ComplexArgumentParser::Finalize(request.failSafeExpiryLengthSeconds); - ComplexArgumentParser::Finalize(request.maxCumulativeFailsafeSeconds); -} CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::PowerSource::Structs::BatChargeFaultChangeType::Type & request, Json::Value & value) @@ -347,6 +557,7 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::PowerSource::Structs:: ComplexArgumentParser::Finalize(request.current); ComplexArgumentParser::Finalize(request.previous); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::PowerSource::Structs::BatFaultChangeType::Type & request, Json::Value & value) @@ -378,8 +589,9 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::PowerSource::Structs:: ComplexArgumentParser::Finalize(request.current); ComplexArgumentParser::Finalize(request.previous); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type & request, + chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -387,63 +599,31 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("BrandingInformationStruct.providerName", "providerName", - value.isMember("providerName"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("WiredFaultChangeType.current", "current", value.isMember("current"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("WiredFaultChangeType.previous", "previous", value.isMember("previous"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "providerName"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.providerName, value["providerName"])); - valueCopy.removeMember("providerName"); - - if (value.isMember("background")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "background"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.background, value["background"])); - } - valueCopy.removeMember("background"); - - if (value.isMember("logo")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "logo"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.logo, value["logo"])); - } - valueCopy.removeMember("logo"); - - if (value.isMember("progressBar")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "progressBar"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.progressBar, value["progressBar"])); - } - valueCopy.removeMember("progressBar"); - - if (value.isMember("splash")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "splash"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.splash, value["splash"])); - } - valueCopy.removeMember("splash"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "current"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.current, value["current"])); + valueCopy.removeMember("current"); - if (value.isMember("waterMark")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "waterMark"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.waterMark, value["waterMark"])); - } - valueCopy.removeMember("waterMark"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "previous"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.previous, value["previous"])); + valueCopy.removeMember("previous"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::Type & request) { - ComplexArgumentParser::Finalize(request.providerName); - ComplexArgumentParser::Finalize(request.background); - ComplexArgumentParser::Finalize(request.logo); - ComplexArgumentParser::Finalize(request.progressBar); - ComplexArgumentParser::Finalize(request.splash); - ComplexArgumentParser::Finalize(request.waterMark); + ComplexArgumentParser::Finalize(request.current); + ComplexArgumentParser::Finalize(request.previous); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::Type & request, + chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -451,32 +631,35 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( - "CapabilityMinimaStruct.caseSessionsPerFabric", "caseSessionsPerFabric", value.isMember("caseSessionsPerFabric"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( - "CapabilityMinimaStruct.subscriptionsPerFabric", "subscriptionsPerFabric", value.isMember("subscriptionsPerFabric"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("BasicCommissioningInfo.failSafeExpiryLengthSeconds", + "failSafeExpiryLengthSeconds", + value.isMember("failSafeExpiryLengthSeconds"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("BasicCommissioningInfo.maxCumulativeFailsafeSeconds", + "maxCumulativeFailsafeSeconds", + value.isMember("maxCumulativeFailsafeSeconds"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "caseSessionsPerFabric"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "failSafeExpiryLengthSeconds"); ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.caseSessionsPerFabric, value["caseSessionsPerFabric"])); - valueCopy.removeMember("caseSessionsPerFabric"); + ComplexArgumentParser::Setup(labelWithMember, request.failSafeExpiryLengthSeconds, value["failSafeExpiryLengthSeconds"])); + valueCopy.removeMember("failSafeExpiryLengthSeconds"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "subscriptionsPerFabric"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "maxCumulativeFailsafeSeconds"); ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.subscriptionsPerFabric, value["subscriptionsPerFabric"])); - valueCopy.removeMember("subscriptionsPerFabric"); + ComplexArgumentParser::Setup(labelWithMember, request.maxCumulativeFailsafeSeconds, value["maxCumulativeFailsafeSeconds"])); + valueCopy.removeMember("maxCumulativeFailsafeSeconds"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request) { - ComplexArgumentParser::Finalize(request.caseSessionsPerFabric); - ComplexArgumentParser::Finalize(request.subscriptionsPerFabric); + ComplexArgumentParser::Finalize(request.failSafeExpiryLengthSeconds); + ComplexArgumentParser::Finalize(request.maxCumulativeFailsafeSeconds); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type & request, + chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -485,77 +668,104 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, Json::Value valueCopy(value); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ChannelInfoStruct.majorNumber", "majorNumber", value.isMember("majorNumber"))); + ComplexArgumentParser::EnsureMemberExist("NetworkInfo.networkID", "networkID", value.isMember("networkID"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ChannelInfoStruct.minorNumber", "minorNumber", value.isMember("minorNumber"))); + ComplexArgumentParser::EnsureMemberExist("NetworkInfo.connected", "connected", value.isMember("connected"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "majorNumber"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.majorNumber, value["majorNumber"])); - valueCopy.removeMember("majorNumber"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "minorNumber"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.minorNumber, value["minorNumber"])); - valueCopy.removeMember("minorNumber"); - - if (value.isMember("name")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); - } - valueCopy.removeMember("name"); - - if (value.isMember("callSign")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "callSign"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.callSign, value["callSign"])); - } - valueCopy.removeMember("callSign"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "networkID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.networkID, value["networkID"])); + valueCopy.removeMember("networkID"); - if (value.isMember("affiliateCallSign")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "affiliateCallSign"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.affiliateCallSign, value["affiliateCallSign"])); - } - valueCopy.removeMember("affiliateCallSign"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "connected"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.connected, value["connected"])); + valueCopy.removeMember("connected"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::Type & request) { - ComplexArgumentParser::Finalize(request.majorNumber); - ComplexArgumentParser::Finalize(request.minorNumber); - ComplexArgumentParser::Finalize(request.name); - ComplexArgumentParser::Finalize(request.callSign); - ComplexArgumentParser::Finalize(request.affiliateCallSign); + ComplexArgumentParser::Finalize(request.networkID); + ComplexArgumentParser::Finalize(request.connected); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & request, - Json::Value & value) + +CHIP_ERROR +ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::Type & request, + Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ContentSearchStruct.parameterList", "parameterList", - value.isMember("parameterList"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.panId", "panId", value.isMember("panId"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.extendedPanId", "extendedPanId", + value.isMember("extendedPanId"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.networkName", "networkName", + value.isMember("networkName"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.channel", "channel", value.isMember("channel"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.version", "version", value.isMember("version"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.extendedAddress", "extendedAddress", + value.isMember("extendedAddress"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.rssi", "rssi", value.isMember("rssi"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.lqi", "lqi", value.isMember("lqi"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "parameterList"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.parameterList, value["parameterList"])); - valueCopy.removeMember("parameterList"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "panId"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.panId, value["panId"])); + valueCopy.removeMember("panId"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extendedPanId"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.extendedPanId, value["extendedPanId"])); + valueCopy.removeMember("extendedPanId"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "networkName"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.networkName, value["networkName"])); + valueCopy.removeMember("networkName"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "channel"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.channel, value["channel"])); + valueCopy.removeMember("channel"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "version"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.version, value["version"])); + valueCopy.removeMember("version"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extendedAddress"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.extendedAddress, value["extendedAddress"])); + valueCopy.removeMember("extendedAddress"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rssi"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rssi, value["rssi"])); + valueCopy.removeMember("rssi"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lqi"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lqi, value["lqi"])); + valueCopy.removeMember("lqi"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::Type & request) { - ComplexArgumentParser::Finalize(request.parameterList); + ComplexArgumentParser::Finalize(request.panId); + ComplexArgumentParser::Finalize(request.extendedPanId); + ComplexArgumentParser::Finalize(request.networkName); + ComplexArgumentParser::Finalize(request.channel); + ComplexArgumentParser::Finalize(request.version); + ComplexArgumentParser::Finalize(request.extendedAddress); + ComplexArgumentParser::Finalize(request.rssi); + ComplexArgumentParser::Finalize(request.lqi); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::DoorLock::Structs::CredentialStruct::Type & request, + chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -563,30 +773,57 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("CredentialStruct.credentialType", "credentialType", - value.isMember("credentialType"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("CredentialStruct.credentialIndex", "credentialIndex", - value.isMember("credentialIndex"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.security", "security", value.isMember("security"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.ssid", "ssid", value.isMember("ssid"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.bssid", "bssid", value.isMember("bssid"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.channel", "channel", value.isMember("channel"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.wiFiBand", "wiFiBand", value.isMember("wiFiBand"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.rssi", "rssi", value.isMember("rssi"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "credentialType"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.credentialType, value["credentialType"])); - valueCopy.removeMember("credentialType"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "security"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.security, value["security"])); + valueCopy.removeMember("security"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "credentialIndex"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.credentialIndex, value["credentialIndex"])); - valueCopy.removeMember("credentialIndex"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "ssid"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.ssid, value["ssid"])); + valueCopy.removeMember("ssid"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "bssid"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.bssid, value["bssid"])); + valueCopy.removeMember("bssid"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "channel"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.channel, value["channel"])); + valueCopy.removeMember("channel"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "wiFiBand"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.wiFiBand, value["wiFiBand"])); + valueCopy.removeMember("wiFiBand"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rssi"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rssi, value["rssi"])); + valueCopy.removeMember("rssi"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::DoorLock::Structs::CredentialStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request) { - ComplexArgumentParser::Finalize(request.credentialType); - ComplexArgumentParser::Finalize(request.credentialIndex); + ComplexArgumentParser::Finalize(request.security); + ComplexArgumentParser::Finalize(request.ssid); + ComplexArgumentParser::Finalize(request.bssid); + ComplexArgumentParser::Finalize(request.channel); + ComplexArgumentParser::Finalize(request.wiFiBand); + ComplexArgumentParser::Finalize(request.rssi); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::Type & request, + chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -594,36 +831,75 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DSTOffsetStruct.offset", "offset", value.isMember("offset"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DSTOffsetStruct.validStarting", "validStarting", - value.isMember("validStarting"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("DSTOffsetStruct.validUntil", "validUntil", value.isMember("validUntil"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.name", "name", value.isMember("name"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.isOperational", "isOperational", + value.isMember("isOperational"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.offPremiseServicesReachableIPv4", + "offPremiseServicesReachableIPv4", + value.isMember("offPremiseServicesReachableIPv4"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.offPremiseServicesReachableIPv6", + "offPremiseServicesReachableIPv6", + value.isMember("offPremiseServicesReachableIPv6"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.hardwareAddress", "hardwareAddress", + value.isMember("hardwareAddress"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.IPv4Addresses", "IPv4Addresses", + value.isMember("IPv4Addresses"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.IPv6Addresses", "IPv6Addresses", + value.isMember("IPv6Addresses"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.type", "type", value.isMember("type"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "offset"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.offset, value["offset"])); - valueCopy.removeMember("offset"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + valueCopy.removeMember("name"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "validStarting"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.validStarting, value["validStarting"])); - valueCopy.removeMember("validStarting"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "isOperational"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.isOperational, value["isOperational"])); + valueCopy.removeMember("isOperational"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "validUntil"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.validUntil, value["validUntil"])); - valueCopy.removeMember("validUntil"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "offPremiseServicesReachableIPv4"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.offPremiseServicesReachableIPv4, + value["offPremiseServicesReachableIPv4"])); + valueCopy.removeMember("offPremiseServicesReachableIPv4"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "offPremiseServicesReachableIPv6"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.offPremiseServicesReachableIPv6, + value["offPremiseServicesReachableIPv6"])); + valueCopy.removeMember("offPremiseServicesReachableIPv6"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "hardwareAddress"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.hardwareAddress, value["hardwareAddress"])); + valueCopy.removeMember("hardwareAddress"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "IPv4Addresses"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.IPv4Addresses, value["IPv4Addresses"])); + valueCopy.removeMember("IPv4Addresses"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "IPv6Addresses"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.IPv6Addresses, value["IPv6Addresses"])); + valueCopy.removeMember("IPv6Addresses"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "type"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.type, value["type"])); + valueCopy.removeMember("type"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::Type & request) { - ComplexArgumentParser::Finalize(request.offset); - ComplexArgumentParser::Finalize(request.validStarting); - ComplexArgumentParser::Finalize(request.validUntil); + ComplexArgumentParser::Finalize(request.name); + ComplexArgumentParser::Finalize(request.isOperational); + ComplexArgumentParser::Finalize(request.offPremiseServicesReachableIPv4); + ComplexArgumentParser::Finalize(request.offPremiseServicesReachableIPv6); + ComplexArgumentParser::Finalize(request.hardwareAddress); + ComplexArgumentParser::Finalize(request.IPv4Addresses); + ComplexArgumentParser::Finalize(request.IPv6Addresses); + ComplexArgumentParser::Finalize(request.type); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::Type & request, + chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -631,65 +907,55 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("DeviceTypeStruct.deviceType", "deviceType", value.isMember("deviceType"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("DeviceTypeStruct.revision", "revision", value.isMember("revision"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadMetricsStruct.id", "id", value.isMember("id"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "deviceType"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.deviceType, value["deviceType"])); - valueCopy.removeMember("deviceType"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "revision"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.revision, value["revision"])); - valueCopy.removeMember("revision"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} - -void ComplexArgumentParser::Finalize(chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::Type & request) -{ - ComplexArgumentParser::Finalize(request.deviceType); - ComplexArgumentParser::Finalize(request.revision); -} -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::Type & request, - Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); - - // Copy to track which members we already processed. - Json::Value valueCopy(value); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "id"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.id, value["id"])); + valueCopy.removeMember("id"); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DimensionStruct.width", "width", value.isMember("width"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DimensionStruct.height", "height", value.isMember("height"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DimensionStruct.metric", "metric", value.isMember("metric"))); + if (value.isMember("name")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + } + valueCopy.removeMember("name"); - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "width"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.width, value["width"])); - valueCopy.removeMember("width"); + if (value.isMember("stackFreeCurrent")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "stackFreeCurrent"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.stackFreeCurrent, value["stackFreeCurrent"])); + } + valueCopy.removeMember("stackFreeCurrent"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "height"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.height, value["height"])); - valueCopy.removeMember("height"); + if (value.isMember("stackFreeMinimum")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "stackFreeMinimum"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.stackFreeMinimum, value["stackFreeMinimum"])); + } + valueCopy.removeMember("stackFreeMinimum"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "metric"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.metric, value["metric"])); - valueCopy.removeMember("metric"); + if (value.isMember("stackSize")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "stackSize"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.stackSize, value["stackSize"])); + } + valueCopy.removeMember("stackSize"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::Type & request) { - ComplexArgumentParser::Finalize(request.width); - ComplexArgumentParser::Finalize(request.height); - ComplexArgumentParser::Finalize(request.metric); + ComplexArgumentParser::Finalize(request.id); + ComplexArgumentParser::Finalize(request.name); + ComplexArgumentParser::Finalize(request.stackFreeCurrent); + ComplexArgumentParser::Finalize(request.stackFreeMinimum); + ComplexArgumentParser::Finalize(request.stackSize); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::Type & request, + chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -697,96 +963,112 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DoubleNestedStructList.a", "a", value.isMember("a"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("NeighborTable.extAddress", "extAddress", value.isMember("extAddress"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.age", "age", value.isMember("age"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.rloc16", "rloc16", value.isMember("rloc16"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.linkFrameCounter", "linkFrameCounter", + value.isMember("linkFrameCounter"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.mleFrameCounter", "mleFrameCounter", + value.isMember("mleFrameCounter"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.lqi", "lqi", value.isMember("lqi"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("NeighborTable.averageRssi", "averageRssi", value.isMember("averageRssi"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("NeighborTable.lastRssi", "lastRssi", value.isMember("lastRssi"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.frameErrorRate", "frameErrorRate", + value.isMember("frameErrorRate"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.messageErrorRate", "messageErrorRate", + value.isMember("messageErrorRate"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("NeighborTable.rxOnWhenIdle", "rxOnWhenIdle", value.isMember("rxOnWhenIdle"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.fullThreadDevice", "fullThreadDevice", + value.isMember("fullThreadDevice"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.fullNetworkData", "fullNetworkData", + value.isMember("fullNetworkData"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.isChild", "isChild", value.isMember("isChild"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "a"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.a, value["a"])); - valueCopy.removeMember("a"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extAddress"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.extAddress, value["extAddress"])); + valueCopy.removeMember("extAddress"); -void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::Type & request) -{ - ComplexArgumentParser::Finalize(request.a); -} -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::Actions::Structs::EndpointListStruct::Type & request, - Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "age"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.age, value["age"])); + valueCopy.removeMember("age"); - // Copy to track which members we already processed. - Json::Value valueCopy(value); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rloc16"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rloc16, value["rloc16"])); + valueCopy.removeMember("rloc16"); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("EndpointListStruct.endpointListID", "endpointListID", - value.isMember("endpointListID"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("EndpointListStruct.name", "name", value.isMember("name"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("EndpointListStruct.type", "type", value.isMember("type"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("EndpointListStruct.endpoints", "endpoints", value.isMember("endpoints"))); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "linkFrameCounter"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.linkFrameCounter, value["linkFrameCounter"])); + valueCopy.removeMember("linkFrameCounter"); - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpointListID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpointListID, value["endpointListID"])); - valueCopy.removeMember("endpointListID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "mleFrameCounter"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.mleFrameCounter, value["mleFrameCounter"])); + valueCopy.removeMember("mleFrameCounter"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); - valueCopy.removeMember("name"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lqi"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lqi, value["lqi"])); + valueCopy.removeMember("lqi"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "type"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.type, value["type"])); - valueCopy.removeMember("type"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "averageRssi"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.averageRssi, value["averageRssi"])); + valueCopy.removeMember("averageRssi"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoints"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoints, value["endpoints"])); - valueCopy.removeMember("endpoints"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lastRssi"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lastRssi, value["lastRssi"])); + valueCopy.removeMember("lastRssi"); - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "frameErrorRate"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.frameErrorRate, value["frameErrorRate"])); + valueCopy.removeMember("frameErrorRate"); -void ComplexArgumentParser::Finalize(chip::app::Clusters::Actions::Structs::EndpointListStruct::Type & request) -{ - ComplexArgumentParser::Finalize(request.endpointListID); - ComplexArgumentParser::Finalize(request.name); - ComplexArgumentParser::Finalize(request.type); - ComplexArgumentParser::Finalize(request.endpoints); -} -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & request, - Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "messageErrorRate"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.messageErrorRate, value["messageErrorRate"])); + valueCopy.removeMember("messageErrorRate"); - // Copy to track which members we already processed. - Json::Value valueCopy(value); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rxOnWhenIdle"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rxOnWhenIdle, value["rxOnWhenIdle"])); + valueCopy.removeMember("rxOnWhenIdle"); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ExtensionFieldSet.clusterID", "clusterID", value.isMember("clusterID"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ExtensionFieldSet.attributeValueList", "attributeValueList", - value.isMember("attributeValueList"))); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fullThreadDevice"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fullThreadDevice, value["fullThreadDevice"])); + valueCopy.removeMember("fullThreadDevice"); - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "clusterID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.clusterID, value["clusterID"])); - valueCopy.removeMember("clusterID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fullNetworkData"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fullNetworkData, value["fullNetworkData"])); + valueCopy.removeMember("fullNetworkData"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "attributeValueList"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.attributeValueList, value["attributeValueList"])); - valueCopy.removeMember("attributeValueList"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "isChild"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.isChild, value["isChild"])); + valueCopy.removeMember("isChild"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::Type & request) { - ComplexArgumentParser::Finalize(request.clusterID); - ComplexArgumentParser::Finalize(request.attributeValueList); + ComplexArgumentParser::Finalize(request.extAddress); + ComplexArgumentParser::Finalize(request.age); + ComplexArgumentParser::Finalize(request.rloc16); + ComplexArgumentParser::Finalize(request.linkFrameCounter); + ComplexArgumentParser::Finalize(request.mleFrameCounter); + ComplexArgumentParser::Finalize(request.lqi); + ComplexArgumentParser::Finalize(request.averageRssi); + ComplexArgumentParser::Finalize(request.lastRssi); + ComplexArgumentParser::Finalize(request.frameErrorRate); + ComplexArgumentParser::Finalize(request.messageErrorRate); + ComplexArgumentParser::Finalize(request.rxOnWhenIdle); + ComplexArgumentParser::Finalize(request.fullThreadDevice); + ComplexArgumentParser::Finalize(request.fullNetworkData); + ComplexArgumentParser::Finalize(request.isChild); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::Type & request, + chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -794,59 +1076,108 @@ ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.rootPublicKey", "rootPublicKey", - value.isMember("rootPublicKey"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( + "OperationalDatasetComponents.activeTimestampPresent", "activeTimestampPresent", value.isMember("activeTimestampPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.pendingTimestampPresent", + "pendingTimestampPresent", + value.isMember("pendingTimestampPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.masterKeyPresent", + "masterKeyPresent", value.isMember("masterKeyPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.networkNamePresent", + "networkNamePresent", value.isMember("networkNamePresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.extendedPanIdPresent", + "extendedPanIdPresent", value.isMember("extendedPanIdPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( + "OperationalDatasetComponents.meshLocalPrefixPresent", "meshLocalPrefixPresent", value.isMember("meshLocalPrefixPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.delayPresent", "delayPresent", + value.isMember("delayPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.panIdPresent", "panIdPresent", + value.isMember("panIdPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.channelPresent", "channelPresent", + value.isMember("channelPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.pskcPresent", "pskcPresent", + value.isMember("pskcPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( + "OperationalDatasetComponents.securityPolicyPresent", "securityPolicyPresent", value.isMember("securityPolicyPresent"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.channelMaskPresent", + "channelMaskPresent", value.isMember("channelMaskPresent"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "activeTimestampPresent"); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.vendorID", "vendorID", value.isMember("vendorID"))); + ComplexArgumentParser::Setup(labelWithMember, request.activeTimestampPresent, value["activeTimestampPresent"])); + valueCopy.removeMember("activeTimestampPresent"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "pendingTimestampPresent"); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.fabricID", "fabricID", value.isMember("fabricID"))); + ComplexArgumentParser::Setup(labelWithMember, request.pendingTimestampPresent, value["pendingTimestampPresent"])); + valueCopy.removeMember("pendingTimestampPresent"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "masterKeyPresent"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.masterKeyPresent, value["masterKeyPresent"])); + valueCopy.removeMember("masterKeyPresent"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "networkNamePresent"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.networkNamePresent, value["networkNamePresent"])); + valueCopy.removeMember("networkNamePresent"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extendedPanIdPresent"); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.nodeID", "nodeID", value.isMember("nodeID"))); + ComplexArgumentParser::Setup(labelWithMember, request.extendedPanIdPresent, value["extendedPanIdPresent"])); + valueCopy.removeMember("extendedPanIdPresent"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "meshLocalPrefixPresent"); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.label", "label", value.isMember("label"))); + ComplexArgumentParser::Setup(labelWithMember, request.meshLocalPrefixPresent, value["meshLocalPrefixPresent"])); + valueCopy.removeMember("meshLocalPrefixPresent"); - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rootPublicKey"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rootPublicKey, value["rootPublicKey"])); - valueCopy.removeMember("rootPublicKey"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "delayPresent"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.delayPresent, value["delayPresent"])); + valueCopy.removeMember("delayPresent"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "vendorID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.vendorID, value["vendorID"])); - valueCopy.removeMember("vendorID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "panIdPresent"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.panIdPresent, value["panIdPresent"])); + valueCopy.removeMember("panIdPresent"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricID, value["fabricID"])); - valueCopy.removeMember("fabricID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "channelPresent"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.channelPresent, value["channelPresent"])); + valueCopy.removeMember("channelPresent"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nodeID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nodeID, value["nodeID"])); - valueCopy.removeMember("nodeID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "pskcPresent"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.pskcPresent, value["pskcPresent"])); + valueCopy.removeMember("pskcPresent"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "label"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.label, value["label"])); - valueCopy.removeMember("label"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "securityPolicyPresent"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.securityPolicyPresent, value["securityPolicyPresent"])); + valueCopy.removeMember("securityPolicyPresent"); - if (value.isMember("fabricIndex")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); - } - valueCopy.removeMember("fabricIndex"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "channelMaskPresent"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.channelMaskPresent, value["channelMaskPresent"])); + valueCopy.removeMember("channelMaskPresent"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::Type & request) +void ComplexArgumentParser::Finalize( + chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type & request) { - ComplexArgumentParser::Finalize(request.rootPublicKey); - ComplexArgumentParser::Finalize(request.vendorID); - ComplexArgumentParser::Finalize(request.fabricID); - ComplexArgumentParser::Finalize(request.nodeID); - ComplexArgumentParser::Finalize(request.label); - ComplexArgumentParser::Finalize(request.fabricIndex); + ComplexArgumentParser::Finalize(request.activeTimestampPresent); + ComplexArgumentParser::Finalize(request.pendingTimestampPresent); + ComplexArgumentParser::Finalize(request.masterKeyPresent); + ComplexArgumentParser::Finalize(request.networkNamePresent); + ComplexArgumentParser::Finalize(request.extendedPanIdPresent); + ComplexArgumentParser::Finalize(request.meshLocalPrefixPresent); + ComplexArgumentParser::Finalize(request.delayPresent); + ComplexArgumentParser::Finalize(request.panIdPresent); + ComplexArgumentParser::Finalize(request.channelPresent); + ComplexArgumentParser::Finalize(request.pskcPresent); + ComplexArgumentParser::Finalize(request.securityPolicyPresent); + ComplexArgumentParser::Finalize(request.channelMaskPresent); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::Type & request, + chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -855,45 +1186,79 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, Json::Value valueCopy(value); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("GroupInfoMapStruct.groupId", "groupId", value.isMember("groupId"))); + ComplexArgumentParser::EnsureMemberExist("RouteTable.extAddress", "extAddress", value.isMember("extAddress"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.rloc16", "rloc16", value.isMember("rloc16"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.routerId", "routerId", value.isMember("routerId"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.nextHop", "nextHop", value.isMember("nextHop"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.pathCost", "pathCost", value.isMember("pathCost"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.LQIIn", "LQIIn", value.isMember("LQIIn"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.LQIOut", "LQIOut", value.isMember("LQIOut"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.age", "age", value.isMember("age"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("GroupInfoMapStruct.endpoints", "endpoints", value.isMember("endpoints"))); + ComplexArgumentParser::EnsureMemberExist("RouteTable.allocated", "allocated", value.isMember("allocated"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.linkEstablished", "linkEstablished", + value.isMember("linkEstablished"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupId"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupId, value["groupId"])); - valueCopy.removeMember("groupId"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extAddress"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.extAddress, value["extAddress"])); + valueCopy.removeMember("extAddress"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoints"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoints, value["endpoints"])); - valueCopy.removeMember("endpoints"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rloc16"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rloc16, value["rloc16"])); + valueCopy.removeMember("rloc16"); - if (value.isMember("groupName")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupName"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupName, value["groupName"])); - } - valueCopy.removeMember("groupName"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "routerId"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.routerId, value["routerId"])); + valueCopy.removeMember("routerId"); - if (value.isMember("fabricIndex")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); - } - valueCopy.removeMember("fabricIndex"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nextHop"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nextHop, value["nextHop"])); + valueCopy.removeMember("nextHop"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "pathCost"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.pathCost, value["pathCost"])); + valueCopy.removeMember("pathCost"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "LQIIn"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.LQIIn, value["LQIIn"])); + valueCopy.removeMember("LQIIn"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "LQIOut"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.LQIOut, value["LQIOut"])); + valueCopy.removeMember("LQIOut"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "age"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.age, value["age"])); + valueCopy.removeMember("age"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "allocated"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.allocated, value["allocated"])); + valueCopy.removeMember("allocated"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "linkEstablished"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.linkEstablished, value["linkEstablished"])); + valueCopy.removeMember("linkEstablished"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::Type & request) { - ComplexArgumentParser::Finalize(request.groupId); - ComplexArgumentParser::Finalize(request.endpoints); - ComplexArgumentParser::Finalize(request.groupName); - ComplexArgumentParser::Finalize(request.fabricIndex); + ComplexArgumentParser::Finalize(request.extAddress); + ComplexArgumentParser::Finalize(request.rloc16); + ComplexArgumentParser::Finalize(request.routerId); + ComplexArgumentParser::Finalize(request.nextHop); + ComplexArgumentParser::Finalize(request.pathCost); + ComplexArgumentParser::Finalize(request.LQIIn); + ComplexArgumentParser::Finalize(request.LQIOut); + ComplexArgumentParser::Finalize(request.age); + ComplexArgumentParser::Finalize(request.allocated); + ComplexArgumentParser::Finalize(request.linkEstablished); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type & request, + chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -902,37 +1267,29 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, Json::Value valueCopy(value); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("GroupKeyMapStruct.groupId", "groupId", value.isMember("groupId"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeyMapStruct.groupKeySetID", "groupKeySetID", - value.isMember("groupKeySetID"))); + ComplexArgumentParser::EnsureMemberExist("SecurityPolicy.rotationTime", "rotationTime", value.isMember("rotationTime"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SecurityPolicy.flags", "flags", value.isMember("flags"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupId"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupId, value["groupId"])); - valueCopy.removeMember("groupId"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupKeySetID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupKeySetID, value["groupKeySetID"])); - valueCopy.removeMember("groupKeySetID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rotationTime"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rotationTime, value["rotationTime"])); + valueCopy.removeMember("rotationTime"); - if (value.isMember("fabricIndex")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); - } - valueCopy.removeMember("fabricIndex"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "flags"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.flags, value["flags"])); + valueCopy.removeMember("flags"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type & request) { - ComplexArgumentParser::Finalize(request.groupId); - ComplexArgumentParser::Finalize(request.groupKeySetID); - ComplexArgumentParser::Finalize(request.fabricIndex); + ComplexArgumentParser::Finalize(request.rotationTime); + ComplexArgumentParser::Finalize(request.flags); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::Type & request, + chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -940,73 +1297,37 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.groupKeySetID", "groupKeySetID", - value.isMember("groupKeySetID"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( - "GroupKeySetStruct.groupKeySecurityPolicy", "groupKeySecurityPolicy", value.isMember("groupKeySecurityPolicy"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochKey0", "epochKey0", value.isMember("epochKey0"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochStartTime0", "epochStartTime0", - value.isMember("epochStartTime0"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochKey1", "epochKey1", value.isMember("epochKey1"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochStartTime1", "epochStartTime1", - value.isMember("epochStartTime1"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DSTOffsetStruct.offset", "offset", value.isMember("offset"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DSTOffsetStruct.validStarting", "validStarting", + value.isMember("validStarting"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochKey2", "epochKey2", value.isMember("epochKey2"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochStartTime2", "epochStartTime2", - value.isMember("epochStartTime2"))); + ComplexArgumentParser::EnsureMemberExist("DSTOffsetStruct.validUntil", "validUntil", value.isMember("validUntil"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupKeySetID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupKeySetID, value["groupKeySetID"])); - valueCopy.removeMember("groupKeySetID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "offset"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.offset, value["offset"])); + valueCopy.removeMember("offset"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupKeySecurityPolicy"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.groupKeySecurityPolicy, value["groupKeySecurityPolicy"])); - valueCopy.removeMember("groupKeySecurityPolicy"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "validStarting"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.validStarting, value["validStarting"])); + valueCopy.removeMember("validStarting"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochKey0"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochKey0, value["epochKey0"])); - valueCopy.removeMember("epochKey0"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "validUntil"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.validUntil, value["validUntil"])); + valueCopy.removeMember("validUntil"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochStartTime0"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochStartTime0, value["epochStartTime0"])); - valueCopy.removeMember("epochStartTime0"); + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochKey1"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochKey1, value["epochKey1"])); - valueCopy.removeMember("epochKey1"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochStartTime1"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochStartTime1, value["epochStartTime1"])); - valueCopy.removeMember("epochStartTime1"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochKey2"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochKey2, value["epochKey2"])); - valueCopy.removeMember("epochKey2"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochStartTime2"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochStartTime2, value["epochStartTime2"])); - valueCopy.removeMember("epochStartTime2"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} - -void ComplexArgumentParser::Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::Type & request) { - ComplexArgumentParser::Finalize(request.groupKeySetID); - ComplexArgumentParser::Finalize(request.groupKeySecurityPolicy); - ComplexArgumentParser::Finalize(request.epochKey0); - ComplexArgumentParser::Finalize(request.epochStartTime0); - ComplexArgumentParser::Finalize(request.epochKey1); - ComplexArgumentParser::Finalize(request.epochStartTime1); - ComplexArgumentParser::Finalize(request.epochKey2); - ComplexArgumentParser::Finalize(request.epochStartTime2); + ComplexArgumentParser::Finalize(request.offset); + ComplexArgumentParser::Finalize(request.validStarting); + ComplexArgumentParser::Finalize(request.validUntil); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type & request, + chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1014,69 +1335,99 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("InputInfoStruct.index", "index", value.isMember("index"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("InputInfoStruct.inputType", "inputType", value.isMember("inputType"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("InputInfoStruct.name", "name", value.isMember("name"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("InputInfoStruct.description", "description", value.isMember("description"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("TimeZoneStruct.offset", "offset", value.isMember("offset"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("TimeZoneStruct.validAt", "validAt", value.isMember("validAt"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "index"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.index, value["index"])); - valueCopy.removeMember("index"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "offset"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.offset, value["offset"])); + valueCopy.removeMember("offset"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "inputType"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.inputType, value["inputType"])); - valueCopy.removeMember("inputType"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "validAt"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.validAt, value["validAt"])); + valueCopy.removeMember("validAt"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + if (value.isMember("name")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + } valueCopy.removeMember("name"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "description"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.description, value["description"])); - valueCopy.removeMember("description"); - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request) { - ComplexArgumentParser::Finalize(request.index); - ComplexArgumentParser::Finalize(request.inputType); + ComplexArgumentParser::Finalize(request.offset); + ComplexArgumentParser::Finalize(request.validAt); ComplexArgumentParser::Finalize(request.name); - ComplexArgumentParser::Finalize(request.description); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::detail::Structs::LabelStruct::Type & request, - Json::Value & value) + +CHIP_ERROR +ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::Type & request, + Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("LabelStruct.label", "label", value.isMember("label"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("LabelStruct.value", "value", value.isMember("value"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.rootPublicKey", "rootPublicKey", + value.isMember("rootPublicKey"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.vendorID", "vendorID", value.isMember("vendorID"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.fabricID", "fabricID", value.isMember("fabricID"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.nodeID", "nodeID", value.isMember("nodeID"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("FabricDescriptorStruct.label", "label", value.isMember("label"))); char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rootPublicKey"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rootPublicKey, value["rootPublicKey"])); + valueCopy.removeMember("rootPublicKey"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "vendorID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.vendorID, value["vendorID"])); + valueCopy.removeMember("vendorID"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricID, value["fabricID"])); + valueCopy.removeMember("fabricID"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nodeID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nodeID, value["nodeID"])); + valueCopy.removeMember("nodeID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "label"); ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.label, value["label"])); valueCopy.removeMember("label"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "value"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.value, value["value"])); - valueCopy.removeMember("value"); + if (value.isMember("fabricIndex")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); + } + valueCopy.removeMember("fabricIndex"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::detail::Structs::LabelStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::Type & request) { + ComplexArgumentParser::Finalize(request.rootPublicKey); + ComplexArgumentParser::Finalize(request.vendorID); + ComplexArgumentParser::Finalize(request.fabricID); + ComplexArgumentParser::Finalize(request.nodeID); ComplexArgumentParser::Finalize(request.label); - ComplexArgumentParser::Finalize(request.value); + ComplexArgumentParser::Finalize(request.fabricIndex); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type & request, + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1084,46 +1435,37 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters: // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("LineupInfoStruct.operatorName", "operatorName", value.isMember("operatorName"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("LineupInfoStruct.lineupInfoType", "lineupInfoType", - value.isMember("lineupInfoType"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NOCStruct.noc", "noc", value.isMember("noc"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NOCStruct.icac", "icac", value.isMember("icac"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "operatorName"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.operatorName, value["operatorName"])); - valueCopy.removeMember("operatorName"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "noc"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.noc, value["noc"])); + valueCopy.removeMember("noc"); - if (value.isMember("lineupName")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lineupName"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lineupName, value["lineupName"])); - } - valueCopy.removeMember("lineupName"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "icac"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.icac, value["icac"])); + valueCopy.removeMember("icac"); - if (value.isMember("postalCode")) + if (value.isMember("fabricIndex")) { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "postalCode"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.postalCode, value["postalCode"])); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); } - valueCopy.removeMember("postalCode"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lineupInfoType"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lineupInfoType, value["lineupInfoType"])); - valueCopy.removeMember("lineupInfoType"); + valueCopy.removeMember("fabricIndex"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::Type & request) { - ComplexArgumentParser::Finalize(request.operatorName); - ComplexArgumentParser::Finalize(request.lineupName); - ComplexArgumentParser::Finalize(request.postalCode); - ComplexArgumentParser::Finalize(request.lineupInfoType); + ComplexArgumentParser::Finalize(request.noc); + ComplexArgumentParser::Finalize(request.icac); + ComplexArgumentParser::Finalize(request.fabricIndex); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type & request, + chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1131,35 +1473,47 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ModeOptionStruct.label", "label", value.isMember("label"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ModeOptionStruct.mode", "mode", value.isMember("mode"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ModeOptionStruct.semanticTags", "semanticTags", value.isMember("semanticTags"))); + ComplexArgumentParser::EnsureMemberExist("GroupInfoMapStruct.groupId", "groupId", value.isMember("groupId"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("GroupInfoMapStruct.endpoints", "endpoints", value.isMember("endpoints"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "label"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.label, value["label"])); - valueCopy.removeMember("label"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupId"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupId, value["groupId"])); + valueCopy.removeMember("groupId"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "mode"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.mode, value["mode"])); - valueCopy.removeMember("mode"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoints"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoints, value["endpoints"])); + valueCopy.removeMember("endpoints"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "semanticTags"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.semanticTags, value["semanticTags"])); - valueCopy.removeMember("semanticTags"); + if (value.isMember("groupName")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupName"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupName, value["groupName"])); + } + valueCopy.removeMember("groupName"); + + if (value.isMember("fabricIndex")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); + } + valueCopy.removeMember("fabricIndex"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::Type & request) { - ComplexArgumentParser::Finalize(request.label); - ComplexArgumentParser::Finalize(request.mode); - ComplexArgumentParser::Finalize(request.semanticTags); + ComplexArgumentParser::Finalize(request.groupId); + ComplexArgumentParser::Finalize(request.endpoints); + ComplexArgumentParser::Finalize(request.groupName); + ComplexArgumentParser::Finalize(request.fabricIndex); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request, + chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1167,18 +1521,19 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MonitoringRegistration.clientNodeId", "clientNodeId", - value.isMember("clientNodeId"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MonitoringRegistration.ICid", "ICid", value.isMember("ICid"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("GroupKeyMapStruct.groupId", "groupId", value.isMember("groupId"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeyMapStruct.groupKeySetID", "groupKeySetID", + value.isMember("groupKeySetID"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "clientNodeId"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.clientNodeId, value["clientNodeId"])); - valueCopy.removeMember("clientNodeId"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupId"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupId, value["groupId"])); + valueCopy.removeMember("groupId"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "ICid"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.ICid, value["ICid"])); - valueCopy.removeMember("ICid"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupKeySetID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupKeySetID, value["groupKeySetID"])); + valueCopy.removeMember("groupKeySetID"); if (value.isMember("fabricIndex")) { @@ -1190,14 +1545,15 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type & request) { - ComplexArgumentParser::Finalize(request.clientNodeId); - ComplexArgumentParser::Finalize(request.ICid); + ComplexArgumentParser::Finalize(request.groupId); + ComplexArgumentParser::Finalize(request.groupKeySetID); ComplexArgumentParser::Finalize(request.fabricIndex); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::Type & request, + chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1205,146 +1561,74 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NOCStruct.noc", "noc", value.isMember("noc"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NOCStruct.icac", "icac", value.isMember("icac"))); - - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "noc"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.noc, value["noc"])); - valueCopy.removeMember("noc"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "icac"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.icac, value["icac"])); - valueCopy.removeMember("icac"); - - if (value.isMember("fabricIndex")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); - } - valueCopy.removeMember("fabricIndex"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} - -void ComplexArgumentParser::Finalize(chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::Type & request) -{ - ComplexArgumentParser::Finalize(request.noc); - ComplexArgumentParser::Finalize(request.icac); - ComplexArgumentParser::Finalize(request.fabricIndex); -} -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::Type & request, - Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); - - // Copy to track which members we already processed. - Json::Value valueCopy(value); - - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("NeighborTable.extAddress", "extAddress", value.isMember("extAddress"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.age", "age", value.isMember("age"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.rloc16", "rloc16", value.isMember("rloc16"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.linkFrameCounter", "linkFrameCounter", - value.isMember("linkFrameCounter"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.mleFrameCounter", "mleFrameCounter", - value.isMember("mleFrameCounter"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.lqi", "lqi", value.isMember("lqi"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.groupKeySetID", "groupKeySetID", + value.isMember("groupKeySetID"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( + "GroupKeySetStruct.groupKeySecurityPolicy", "groupKeySecurityPolicy", value.isMember("groupKeySecurityPolicy"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("NeighborTable.averageRssi", "averageRssi", value.isMember("averageRssi"))); + ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochKey0", "epochKey0", value.isMember("epochKey0"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochStartTime0", "epochStartTime0", + value.isMember("epochStartTime0"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("NeighborTable.lastRssi", "lastRssi", value.isMember("lastRssi"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.frameErrorRate", "frameErrorRate", - value.isMember("frameErrorRate"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.messageErrorRate", "messageErrorRate", - value.isMember("messageErrorRate"))); + ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochKey1", "epochKey1", value.isMember("epochKey1"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochStartTime1", "epochStartTime1", + value.isMember("epochStartTime1"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("NeighborTable.rxOnWhenIdle", "rxOnWhenIdle", value.isMember("rxOnWhenIdle"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.fullThreadDevice", "fullThreadDevice", - value.isMember("fullThreadDevice"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.fullNetworkData", "fullNetworkData", - value.isMember("fullNetworkData"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NeighborTable.isChild", "isChild", value.isMember("isChild"))); + ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochKey2", "epochKey2", value.isMember("epochKey2"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("GroupKeySetStruct.epochStartTime2", "epochStartTime2", + value.isMember("epochStartTime2"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extAddress"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.extAddress, value["extAddress"])); - valueCopy.removeMember("extAddress"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "age"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.age, value["age"])); - valueCopy.removeMember("age"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rloc16"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rloc16, value["rloc16"])); - valueCopy.removeMember("rloc16"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "linkFrameCounter"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.linkFrameCounter, value["linkFrameCounter"])); - valueCopy.removeMember("linkFrameCounter"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "mleFrameCounter"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.mleFrameCounter, value["mleFrameCounter"])); - valueCopy.removeMember("mleFrameCounter"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lqi"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lqi, value["lqi"])); - valueCopy.removeMember("lqi"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "averageRssi"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.averageRssi, value["averageRssi"])); - valueCopy.removeMember("averageRssi"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupKeySetID"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.groupKeySetID, value["groupKeySetID"])); + valueCopy.removeMember("groupKeySetID"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lastRssi"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lastRssi, value["lastRssi"])); - valueCopy.removeMember("lastRssi"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "groupKeySecurityPolicy"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.groupKeySecurityPolicy, value["groupKeySecurityPolicy"])); + valueCopy.removeMember("groupKeySecurityPolicy"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "frameErrorRate"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.frameErrorRate, value["frameErrorRate"])); - valueCopy.removeMember("frameErrorRate"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochKey0"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochKey0, value["epochKey0"])); + valueCopy.removeMember("epochKey0"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "messageErrorRate"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.messageErrorRate, value["messageErrorRate"])); - valueCopy.removeMember("messageErrorRate"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochStartTime0"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochStartTime0, value["epochStartTime0"])); + valueCopy.removeMember("epochStartTime0"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rxOnWhenIdle"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rxOnWhenIdle, value["rxOnWhenIdle"])); - valueCopy.removeMember("rxOnWhenIdle"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochKey1"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochKey1, value["epochKey1"])); + valueCopy.removeMember("epochKey1"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fullThreadDevice"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fullThreadDevice, value["fullThreadDevice"])); - valueCopy.removeMember("fullThreadDevice"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochStartTime1"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochStartTime1, value["epochStartTime1"])); + valueCopy.removeMember("epochStartTime1"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fullNetworkData"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fullNetworkData, value["fullNetworkData"])); - valueCopy.removeMember("fullNetworkData"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochKey2"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochKey2, value["epochKey2"])); + valueCopy.removeMember("epochKey2"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "isChild"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.isChild, value["isChild"])); - valueCopy.removeMember("isChild"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "epochStartTime2"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.epochStartTime2, value["epochStartTime2"])); + valueCopy.removeMember("epochStartTime2"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::Type & request) { - ComplexArgumentParser::Finalize(request.extAddress); - ComplexArgumentParser::Finalize(request.age); - ComplexArgumentParser::Finalize(request.rloc16); - ComplexArgumentParser::Finalize(request.linkFrameCounter); - ComplexArgumentParser::Finalize(request.mleFrameCounter); - ComplexArgumentParser::Finalize(request.lqi); - ComplexArgumentParser::Finalize(request.averageRssi); - ComplexArgumentParser::Finalize(request.lastRssi); - ComplexArgumentParser::Finalize(request.frameErrorRate); - ComplexArgumentParser::Finalize(request.messageErrorRate); - ComplexArgumentParser::Finalize(request.rxOnWhenIdle); - ComplexArgumentParser::Finalize(request.fullThreadDevice); - ComplexArgumentParser::Finalize(request.fullNetworkData); - ComplexArgumentParser::Finalize(request.isChild); + ComplexArgumentParser::Finalize(request.groupKeySetID); + ComplexArgumentParser::Finalize(request.groupKeySecurityPolicy); + ComplexArgumentParser::Finalize(request.epochKey0); + ComplexArgumentParser::Finalize(request.epochStartTime0); + ComplexArgumentParser::Finalize(request.epochKey1); + ComplexArgumentParser::Finalize(request.epochStartTime1); + ComplexArgumentParser::Finalize(request.epochKey2); + ComplexArgumentParser::Finalize(request.epochStartTime2); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::NestedStruct::Type & request, + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1352,34 +1636,30 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters: // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStruct.a", "a", value.isMember("a"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStruct.b", "b", value.isMember("b"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStruct.c", "c", value.isMember("c"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("SemanticTagStruct.mfgCode", "mfgCode", value.isMember("mfgCode"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SemanticTagStruct.value", "value", value.isMember("value"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "a"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.a, value["a"])); - valueCopy.removeMember("a"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "b"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.b, value["b"])); - valueCopy.removeMember("b"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "mfgCode"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.mfgCode, value["mfgCode"])); + valueCopy.removeMember("mfgCode"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "c"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.c, value["c"])); - valueCopy.removeMember("c"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "value"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.value, value["value"])); + valueCopy.removeMember("value"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::NestedStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::Type & request) { - ComplexArgumentParser::Finalize(request.a); - ComplexArgumentParser::Finalize(request.b); - ComplexArgumentParser::Finalize(request.c); + ComplexArgumentParser::Finalize(request.mfgCode); + ComplexArgumentParser::Finalize(request.value); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::UnitTesting::Structs::NestedStructList::Type & request, + chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1387,58 +1667,36 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.a", "a", value.isMember("a"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.b", "b", value.isMember("b"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.c", "c", value.isMember("c"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.d", "d", value.isMember("d"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.e", "e", value.isMember("e"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.f", "f", value.isMember("f"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.g", "g", value.isMember("g"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ModeOptionStruct.label", "label", value.isMember("label"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ModeOptionStruct.mode", "mode", value.isMember("mode"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ModeOptionStruct.semanticTags", "semanticTags", value.isMember("semanticTags"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "a"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.a, value["a"])); - valueCopy.removeMember("a"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "b"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.b, value["b"])); - valueCopy.removeMember("b"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "c"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.c, value["c"])); - valueCopy.removeMember("c"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "d"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.d, value["d"])); - valueCopy.removeMember("d"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "e"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.e, value["e"])); - valueCopy.removeMember("e"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "label"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.label, value["label"])); + valueCopy.removeMember("label"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "f"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.f, value["f"])); - valueCopy.removeMember("f"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "mode"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.mode, value["mode"])); + valueCopy.removeMember("mode"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "g"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.g, value["g"])); - valueCopy.removeMember("g"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "semanticTags"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.semanticTags, value["semanticTags"])); + valueCopy.removeMember("semanticTags"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::NestedStructList::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type & request) { - ComplexArgumentParser::Finalize(request.a); - ComplexArgumentParser::Finalize(request.b); - ComplexArgumentParser::Finalize(request.c); - ComplexArgumentParser::Finalize(request.d); - ComplexArgumentParser::Finalize(request.e); - ComplexArgumentParser::Finalize(request.f); - ComplexArgumentParser::Finalize(request.g); + ComplexArgumentParser::Finalize(request.label); + ComplexArgumentParser::Finalize(request.mode); + ComplexArgumentParser::Finalize(request.semanticTags); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::Type & request, + chip::app::Clusters::DoorLock::Structs::CredentialStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1446,30 +1704,31 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("NetworkInfo.networkID", "networkID", value.isMember("networkID"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("NetworkInfo.connected", "connected", value.isMember("connected"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("CredentialStruct.credentialType", "credentialType", + value.isMember("credentialType"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("CredentialStruct.credentialIndex", "credentialIndex", + value.isMember("credentialIndex"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "networkID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.networkID, value["networkID"])); - valueCopy.removeMember("networkID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "credentialType"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.credentialType, value["credentialType"])); + valueCopy.removeMember("credentialType"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "connected"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.connected, value["connected"])); - valueCopy.removeMember("connected"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "credentialIndex"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.credentialIndex, value["credentialIndex"])); + valueCopy.removeMember("credentialIndex"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::DoorLock::Structs::CredentialStruct::Type & request) { - ComplexArgumentParser::Finalize(request.networkID); - ComplexArgumentParser::Finalize(request.connected); + ComplexArgumentParser::Finalize(request.credentialType); + ComplexArgumentParser::Finalize(request.credentialIndex); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::Type & request, + chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1477,74 +1736,38 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.name", "name", value.isMember("name"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.isOperational", "isOperational", - value.isMember("isOperational"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.offPremiseServicesReachableIPv4", - "offPremiseServicesReachableIPv4", - value.isMember("offPremiseServicesReachableIPv4"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.offPremiseServicesReachableIPv6", - "offPremiseServicesReachableIPv6", - value.isMember("offPremiseServicesReachableIPv6"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.hardwareAddress", "hardwareAddress", - value.isMember("hardwareAddress"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.IPv4Addresses", "IPv4Addresses", - value.isMember("IPv4Addresses"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.IPv6Addresses", "IPv6Addresses", - value.isMember("IPv6Addresses"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NetworkInterface.type", "type", value.isMember("type"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThermostatScheduleTransition.transitionTime", "transitionTime", + value.isMember("transitionTime"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThermostatScheduleTransition.heatSetpoint", "heatSetpoint", + value.isMember("heatSetpoint"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThermostatScheduleTransition.coolSetpoint", "coolSetpoint", + value.isMember("coolSetpoint"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); - valueCopy.removeMember("name"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "isOperational"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.isOperational, value["isOperational"])); - valueCopy.removeMember("isOperational"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "offPremiseServicesReachableIPv4"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.offPremiseServicesReachableIPv4, - value["offPremiseServicesReachableIPv4"])); - valueCopy.removeMember("offPremiseServicesReachableIPv4"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "offPremiseServicesReachableIPv6"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.offPremiseServicesReachableIPv6, - value["offPremiseServicesReachableIPv6"])); - valueCopy.removeMember("offPremiseServicesReachableIPv6"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "hardwareAddress"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.hardwareAddress, value["hardwareAddress"])); - valueCopy.removeMember("hardwareAddress"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "IPv4Addresses"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.IPv4Addresses, value["IPv4Addresses"])); - valueCopy.removeMember("IPv4Addresses"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "transitionTime"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.transitionTime, value["transitionTime"])); + valueCopy.removeMember("transitionTime"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "IPv6Addresses"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.IPv6Addresses, value["IPv6Addresses"])); - valueCopy.removeMember("IPv6Addresses"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "heatSetpoint"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.heatSetpoint, value["heatSetpoint"])); + valueCopy.removeMember("heatSetpoint"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "type"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.type, value["type"])); - valueCopy.removeMember("type"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "coolSetpoint"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.coolSetpoint, value["coolSetpoint"])); + valueCopy.removeMember("coolSetpoint"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::Type & request) { - ComplexArgumentParser::Finalize(request.name); - ComplexArgumentParser::Finalize(request.isOperational); - ComplexArgumentParser::Finalize(request.offPremiseServicesReachableIPv4); - ComplexArgumentParser::Finalize(request.offPremiseServicesReachableIPv6); - ComplexArgumentParser::Finalize(request.hardwareAddress); - ComplexArgumentParser::Finalize(request.IPv4Addresses); - ComplexArgumentParser::Finalize(request.IPv6Addresses); - ComplexArgumentParser::Finalize(request.type); + ComplexArgumentParser::Finalize(request.transitionTime); + ComplexArgumentParser::Finalize(request.heatSetpoint); + ComplexArgumentParser::Finalize(request.coolSetpoint); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::Type & request, + chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1552,221 +1775,54 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NullablesAndOptionalsStruct.nullableInt", "nullableInt", - value.isMember("nullableInt"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NullablesAndOptionalsStruct.nullableString", "nullableString", - value.isMember("nullableString"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NullablesAndOptionalsStruct.nullableStruct", "nullableStruct", - value.isMember("nullableStruct"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NullablesAndOptionalsStruct.nullableList", "nullableList", - value.isMember("nullableList"))); - - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableInt"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nullableInt, value["nullableInt"])); - valueCopy.removeMember("nullableInt"); - - if (value.isMember("optionalInt")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "optionalInt"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.optionalInt, value["optionalInt"])); - } - valueCopy.removeMember("optionalInt"); - - if (value.isMember("nullableOptionalInt")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableOptionalInt"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.nullableOptionalInt, value["nullableOptionalInt"])); - } - valueCopy.removeMember("nullableOptionalInt"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableString"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nullableString, value["nullableString"])); - valueCopy.removeMember("nullableString"); - - if (value.isMember("optionalString")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "optionalString"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.optionalString, value["optionalString"])); - } - valueCopy.removeMember("optionalString"); - - if (value.isMember("nullableOptionalString")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableOptionalString"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.nullableOptionalString, value["nullableOptionalString"])); - } - valueCopy.removeMember("nullableOptionalString"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableStruct"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nullableStruct, value["nullableStruct"])); - valueCopy.removeMember("nullableStruct"); - - if (value.isMember("optionalStruct")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "optionalStruct"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.optionalStruct, value["optionalStruct"])); - } - valueCopy.removeMember("optionalStruct"); - - if (value.isMember("nullableOptionalStruct")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableOptionalStruct"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.nullableOptionalStruct, value["nullableOptionalStruct"])); - } - valueCopy.removeMember("nullableOptionalStruct"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableList"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nullableList, value["nullableList"])); - valueCopy.removeMember("nullableList"); - - if (value.isMember("optionalList")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "optionalList"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.optionalList, value["optionalList"])); - } - valueCopy.removeMember("optionalList"); - - if (value.isMember("nullableOptionalList")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableOptionalList"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.nullableOptionalList, value["nullableOptionalList"])); - } - valueCopy.removeMember("nullableOptionalList"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} - -void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::Type & request) -{ - ComplexArgumentParser::Finalize(request.nullableInt); - ComplexArgumentParser::Finalize(request.optionalInt); - ComplexArgumentParser::Finalize(request.nullableOptionalInt); - ComplexArgumentParser::Finalize(request.nullableString); - ComplexArgumentParser::Finalize(request.optionalString); - ComplexArgumentParser::Finalize(request.nullableOptionalString); - ComplexArgumentParser::Finalize(request.nullableStruct); - ComplexArgumentParser::Finalize(request.optionalStruct); - ComplexArgumentParser::Finalize(request.nullableOptionalStruct); - ComplexArgumentParser::Finalize(request.nullableList); - ComplexArgumentParser::Finalize(request.optionalList); - ComplexArgumentParser::Finalize(request.nullableOptionalList); -} -CHIP_ERROR -ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type & request, - Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); - - // Copy to track which members we already processed. - Json::Value valueCopy(value); - - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( - "OperationalDatasetComponents.activeTimestampPresent", "activeTimestampPresent", value.isMember("activeTimestampPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.pendingTimestampPresent", - "pendingTimestampPresent", - value.isMember("pendingTimestampPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.masterKeyPresent", - "masterKeyPresent", value.isMember("masterKeyPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.networkNamePresent", - "networkNamePresent", value.isMember("networkNamePresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.extendedPanIdPresent", - "extendedPanIdPresent", value.isMember("extendedPanIdPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( - "OperationalDatasetComponents.meshLocalPrefixPresent", "meshLocalPrefixPresent", value.isMember("meshLocalPrefixPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.delayPresent", "delayPresent", - value.isMember("delayPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.panIdPresent", "panIdPresent", - value.isMember("panIdPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.channelPresent", "channelPresent", - value.isMember("channelPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.pskcPresent", "pskcPresent", - value.isMember("pskcPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist( - "OperationalDatasetComponents.securityPolicyPresent", "securityPolicyPresent", value.isMember("securityPolicyPresent"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OperationalDatasetComponents.channelMaskPresent", - "channelMaskPresent", value.isMember("channelMaskPresent"))); - - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "activeTimestampPresent"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.activeTimestampPresent, value["activeTimestampPresent"])); - valueCopy.removeMember("activeTimestampPresent"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "pendingTimestampPresent"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.pendingTimestampPresent, value["pendingTimestampPresent"])); - valueCopy.removeMember("pendingTimestampPresent"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "masterKeyPresent"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.masterKeyPresent, value["masterKeyPresent"])); - valueCopy.removeMember("masterKeyPresent"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "networkNamePresent"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.networkNamePresent, value["networkNamePresent"])); - valueCopy.removeMember("networkNamePresent"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extendedPanIdPresent"); ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.extendedPanIdPresent, value["extendedPanIdPresent"])); - valueCopy.removeMember("extendedPanIdPresent"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "meshLocalPrefixPresent"); + ComplexArgumentParser::EnsureMemberExist("ChannelInfoStruct.majorNumber", "majorNumber", value.isMember("majorNumber"))); ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.meshLocalPrefixPresent, value["meshLocalPrefixPresent"])); - valueCopy.removeMember("meshLocalPrefixPresent"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "delayPresent"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.delayPresent, value["delayPresent"])); - valueCopy.removeMember("delayPresent"); + ComplexArgumentParser::EnsureMemberExist("ChannelInfoStruct.minorNumber", "minorNumber", value.isMember("minorNumber"))); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "panIdPresent"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.panIdPresent, value["panIdPresent"])); - valueCopy.removeMember("panIdPresent"); + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "majorNumber"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.majorNumber, value["majorNumber"])); + valueCopy.removeMember("majorNumber"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "channelPresent"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.channelPresent, value["channelPresent"])); - valueCopy.removeMember("channelPresent"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "minorNumber"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.minorNumber, value["minorNumber"])); + valueCopy.removeMember("minorNumber"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "pskcPresent"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.pskcPresent, value["pskcPresent"])); - valueCopy.removeMember("pskcPresent"); + if (value.isMember("name")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + } + valueCopy.removeMember("name"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "securityPolicyPresent"); - ReturnErrorOnFailure( - ComplexArgumentParser::Setup(labelWithMember, request.securityPolicyPresent, value["securityPolicyPresent"])); - valueCopy.removeMember("securityPolicyPresent"); + if (value.isMember("callSign")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "callSign"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.callSign, value["callSign"])); + } + valueCopy.removeMember("callSign"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "channelMaskPresent"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.channelMaskPresent, value["channelMaskPresent"])); - valueCopy.removeMember("channelMaskPresent"); + if (value.isMember("affiliateCallSign")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "affiliateCallSign"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.affiliateCallSign, value["affiliateCallSign"])); + } + valueCopy.removeMember("affiliateCallSign"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize( - chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type & request) { - ComplexArgumentParser::Finalize(request.activeTimestampPresent); - ComplexArgumentParser::Finalize(request.pendingTimestampPresent); - ComplexArgumentParser::Finalize(request.masterKeyPresent); - ComplexArgumentParser::Finalize(request.networkNamePresent); - ComplexArgumentParser::Finalize(request.extendedPanIdPresent); - ComplexArgumentParser::Finalize(request.meshLocalPrefixPresent); - ComplexArgumentParser::Finalize(request.delayPresent); - ComplexArgumentParser::Finalize(request.panIdPresent); - ComplexArgumentParser::Finalize(request.channelPresent); - ComplexArgumentParser::Finalize(request.pskcPresent); - ComplexArgumentParser::Finalize(request.securityPolicyPresent); - ComplexArgumentParser::Finalize(request.channelMaskPresent); + ComplexArgumentParser::Finalize(request.majorNumber); + ComplexArgumentParser::Finalize(request.minorNumber); + ComplexArgumentParser::Finalize(request.name); + ComplexArgumentParser::Finalize(request.callSign); + ComplexArgumentParser::Finalize(request.affiliateCallSign); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::Type & request, + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1774,35 +1830,47 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OutputInfoStruct.index", "index", value.isMember("index"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("OutputInfoStruct.outputType", "outputType", value.isMember("outputType"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OutputInfoStruct.name", "name", value.isMember("name"))); + ComplexArgumentParser::EnsureMemberExist("LineupInfoStruct.operatorName", "operatorName", value.isMember("operatorName"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("LineupInfoStruct.lineupInfoType", "lineupInfoType", + value.isMember("lineupInfoType"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "index"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.index, value["index"])); - valueCopy.removeMember("index"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "operatorName"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.operatorName, value["operatorName"])); + valueCopy.removeMember("operatorName"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "outputType"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.outputType, value["outputType"])); - valueCopy.removeMember("outputType"); + if (value.isMember("lineupName")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lineupName"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lineupName, value["lineupName"])); + } + valueCopy.removeMember("lineupName"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); - valueCopy.removeMember("name"); + if (value.isMember("postalCode")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "postalCode"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.postalCode, value["postalCode"])); + } + valueCopy.removeMember("postalCode"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lineupInfoType"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lineupInfoType, value["lineupInfoType"])); + valueCopy.removeMember("lineupInfoType"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type & request) { - ComplexArgumentParser::Finalize(request.index); - ComplexArgumentParser::Finalize(request.outputType); - ComplexArgumentParser::Finalize(request.name); + ComplexArgumentParser::Finalize(request.operatorName); + ComplexArgumentParser::Finalize(request.lineupName); + ComplexArgumentParser::Finalize(request.postalCode); + ComplexArgumentParser::Finalize(request.lineupInfoType); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & request, + chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1810,34 +1878,28 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ParameterStruct.type", "type", value.isMember("type"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ParameterStruct.value", "value", value.isMember("value"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("TargetInfoStruct.identifier", "identifier", value.isMember("identifier"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("TargetInfoStruct.name", "name", value.isMember("name"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "type"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.type, value["type"])); - valueCopy.removeMember("type"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "value"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.value, value["value"])); - valueCopy.removeMember("value"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "identifier"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.identifier, value["identifier"])); + valueCopy.removeMember("identifier"); - if (value.isMember("externalIDList")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "externalIDList"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.externalIDList, value["externalIDList"])); - } - valueCopy.removeMember("externalIDList"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + valueCopy.removeMember("name"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Type & request) { - ComplexArgumentParser::Finalize(request.type); - ComplexArgumentParser::Finalize(request.value); - ComplexArgumentParser::Finalize(request.externalIDList); + ComplexArgumentParser::Finalize(request.identifier); + ComplexArgumentParser::Finalize(request.name); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::Type & request, Json::Value & value) @@ -1869,8 +1931,9 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::MediaPlayback::Structs ComplexArgumentParser::Finalize(request.updatedAt); ComplexArgumentParser::Finalize(request.position); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request, + chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1878,38 +1941,43 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ProviderLocation.providerNodeID", "providerNodeID", - value.isMember("providerNodeID"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("InputInfoStruct.index", "index", value.isMember("index"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ProviderLocation.endpoint", "endpoint", value.isMember("endpoint"))); + ComplexArgumentParser::EnsureMemberExist("InputInfoStruct.inputType", "inputType", value.isMember("inputType"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("InputInfoStruct.name", "name", value.isMember("name"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("InputInfoStruct.description", "description", value.isMember("description"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "providerNodeID"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.providerNodeID, value["providerNodeID"])); - valueCopy.removeMember("providerNodeID"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "index"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.index, value["index"])); + valueCopy.removeMember("index"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); - valueCopy.removeMember("endpoint"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "inputType"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.inputType, value["inputType"])); + valueCopy.removeMember("inputType"); - if (value.isMember("fabricIndex")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); - } - valueCopy.removeMember("fabricIndex"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + valueCopy.removeMember("name"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "description"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.description, value["description"])); + valueCopy.removeMember("description"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type & request) { - ComplexArgumentParser::Finalize(request.providerNodeID); - ComplexArgumentParser::Finalize(request.endpoint); - ComplexArgumentParser::Finalize(request.fabricIndex); + ComplexArgumentParser::Finalize(request.index); + ComplexArgumentParser::Finalize(request.inputType); + ComplexArgumentParser::Finalize(request.name); + ComplexArgumentParser::Finalize(request.description); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::Type & request, + chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1917,79 +1985,35 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("RouteTable.extAddress", "extAddress", value.isMember("extAddress"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.rloc16", "rloc16", value.isMember("rloc16"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.routerId", "routerId", value.isMember("routerId"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.nextHop", "nextHop", value.isMember("nextHop"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.pathCost", "pathCost", value.isMember("pathCost"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.LQIIn", "LQIIn", value.isMember("LQIIn"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.LQIOut", "LQIOut", value.isMember("LQIOut"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.age", "age", value.isMember("age"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("RouteTable.allocated", "allocated", value.isMember("allocated"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("RouteTable.linkEstablished", "linkEstablished", - value.isMember("linkEstablished"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DimensionStruct.width", "width", value.isMember("width"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DimensionStruct.height", "height", value.isMember("height"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DimensionStruct.metric", "metric", value.isMember("metric"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extAddress"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.extAddress, value["extAddress"])); - valueCopy.removeMember("extAddress"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rloc16"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rloc16, value["rloc16"])); - valueCopy.removeMember("rloc16"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "routerId"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.routerId, value["routerId"])); - valueCopy.removeMember("routerId"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nextHop"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nextHop, value["nextHop"])); - valueCopy.removeMember("nextHop"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "pathCost"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.pathCost, value["pathCost"])); - valueCopy.removeMember("pathCost"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "LQIIn"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.LQIIn, value["LQIIn"])); - valueCopy.removeMember("LQIIn"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "LQIOut"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.LQIOut, value["LQIOut"])); - valueCopy.removeMember("LQIOut"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "age"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.age, value["age"])); - valueCopy.removeMember("age"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "allocated"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.allocated, value["allocated"])); - valueCopy.removeMember("allocated"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "linkEstablished"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.linkEstablished, value["linkEstablished"])); - valueCopy.removeMember("linkEstablished"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "width"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.width, value["width"])); + valueCopy.removeMember("width"); - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "height"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.height, value["height"])); + valueCopy.removeMember("height"); -void ComplexArgumentParser::Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::Type & request) -{ - ComplexArgumentParser::Finalize(request.extAddress); - ComplexArgumentParser::Finalize(request.rloc16); - ComplexArgumentParser::Finalize(request.routerId); - ComplexArgumentParser::Finalize(request.nextHop); - ComplexArgumentParser::Finalize(request.pathCost); - ComplexArgumentParser::Finalize(request.LQIIn); - ComplexArgumentParser::Finalize(request.LQIOut); - ComplexArgumentParser::Finalize(request.age); - ComplexArgumentParser::Finalize(request.allocated); - ComplexArgumentParser::Finalize(request.linkEstablished); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "metric"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.metric, value["metric"])); + valueCopy.removeMember("metric"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.width); + ComplexArgumentParser::Finalize(request.height); + ComplexArgumentParser::Finalize(request.metric); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type & request, + chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -1997,29 +2021,29 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("SecurityPolicy.rotationTime", "rotationTime", value.isMember("rotationTime"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SecurityPolicy.flags", "flags", value.isMember("flags"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("AdditionalInfoStruct.name", "name", value.isMember("name"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("AdditionalInfoStruct.value", "value", value.isMember("value"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rotationTime"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rotationTime, value["rotationTime"])); - valueCopy.removeMember("rotationTime"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + valueCopy.removeMember("name"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "flags"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.flags, value["flags"])); - valueCopy.removeMember("flags"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "value"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.value, value["value"])); + valueCopy.removeMember("value"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type & request) { - ComplexArgumentParser::Finalize(request.rotationTime); - ComplexArgumentParser::Finalize(request.flags); + ComplexArgumentParser::Finalize(request.name); + ComplexArgumentParser::Finalize(request.value); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::Type & request, + chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2027,28 +2051,37 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("SemanticTagStruct.mfgCode", "mfgCode", value.isMember("mfgCode"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SemanticTagStruct.value", "value", value.isMember("value"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ParameterStruct.type", "type", value.isMember("type"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ParameterStruct.value", "value", value.isMember("value"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "mfgCode"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.mfgCode, value["mfgCode"])); - valueCopy.removeMember("mfgCode"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "type"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.type, value["type"])); + valueCopy.removeMember("type"); snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "value"); ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.value, value["value"])); valueCopy.removeMember("value"); + if (value.isMember("externalIDList")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "externalIDList"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.externalIDList, value["externalIDList"])); + } + valueCopy.removeMember("externalIDList"); + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & request) { - ComplexArgumentParser::Finalize(request.mfgCode); + ComplexArgumentParser::Finalize(request.type); ComplexArgumentParser::Finalize(request.value); + ComplexArgumentParser::Finalize(request.externalIDList); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::SimpleStruct::Type & request, + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2056,62 +2089,22 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters: // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.a", "a", value.isMember("a"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.b", "b", value.isMember("b"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.c", "c", value.isMember("c"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.d", "d", value.isMember("d"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.e", "e", value.isMember("e"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.f", "f", value.isMember("f"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.g", "g", value.isMember("g"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.h", "h", value.isMember("h"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ContentSearchStruct.parameterList", "parameterList", + value.isMember("parameterList"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "a"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.a, value["a"])); - valueCopy.removeMember("a"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "b"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.b, value["b"])); - valueCopy.removeMember("b"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "c"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.c, value["c"])); - valueCopy.removeMember("c"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "d"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.d, value["d"])); - valueCopy.removeMember("d"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "e"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.e, value["e"])); - valueCopy.removeMember("e"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "f"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.f, value["f"])); - valueCopy.removeMember("f"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "g"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.g, value["g"])); - valueCopy.removeMember("g"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "h"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.h, value["h"])); - valueCopy.removeMember("h"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "parameterList"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.parameterList, value["parameterList"])); + valueCopy.removeMember("parameterList"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::SimpleStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & request) { - ComplexArgumentParser::Finalize(request.a); - ComplexArgumentParser::Finalize(request.b); - ComplexArgumentParser::Finalize(request.c); - ComplexArgumentParser::Finalize(request.d); - ComplexArgumentParser::Finalize(request.e); - ComplexArgumentParser::Finalize(request.f); - ComplexArgumentParser::Finalize(request.g); - ComplexArgumentParser::Finalize(request.h); + ComplexArgumentParser::Finalize(request.parameterList); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::StyleInformationStruct::Type & request, Json::Value & value) @@ -2152,7 +2145,9 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Struc ComplexArgumentParser::Finalize(request.color); ComplexArgumentParser::Finalize(request.size); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::AccessControl::Structs::Target::Type & request, + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2160,34 +2155,134 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters: // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("Target.cluster", "cluster", value.isMember("cluster"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("Target.endpoint", "endpoint", value.isMember("endpoint"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("Target.deviceType", "deviceType", value.isMember("deviceType"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("BrandingInformationStruct.providerName", "providerName", + value.isMember("providerName"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "cluster"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.cluster, value["cluster"])); - valueCopy.removeMember("cluster"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "providerName"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.providerName, value["providerName"])); + valueCopy.removeMember("providerName"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); - valueCopy.removeMember("endpoint"); + if (value.isMember("background")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "background"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.background, value["background"])); + } + valueCopy.removeMember("background"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "deviceType"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.deviceType, value["deviceType"])); - valueCopy.removeMember("deviceType"); + if (value.isMember("logo")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "logo"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.logo, value["logo"])); + } + valueCopy.removeMember("logo"); + + if (value.isMember("progressBar")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "progressBar"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.progressBar, value["progressBar"])); + } + valueCopy.removeMember("progressBar"); + + if (value.isMember("splash")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "splash"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.splash, value["splash"])); + } + valueCopy.removeMember("splash"); + + if (value.isMember("waterMark")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "waterMark"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.waterMark, value["waterMark"])); + } + valueCopy.removeMember("waterMark"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::AccessControl::Structs::Target::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type & request) { - ComplexArgumentParser::Finalize(request.cluster); + ComplexArgumentParser::Finalize(request.providerName); + ComplexArgumentParser::Finalize(request.background); + ComplexArgumentParser::Finalize(request.logo); + ComplexArgumentParser::Finalize(request.progressBar); + ComplexArgumentParser::Finalize(request.splash); + ComplexArgumentParser::Finalize(request.waterMark); +} + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OutputInfoStruct.index", "index", value.isMember("index"))); + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("OutputInfoStruct.outputType", "outputType", value.isMember("outputType"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("OutputInfoStruct.name", "name", value.isMember("name"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "index"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.index, value["index"])); + valueCopy.removeMember("index"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "outputType"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.outputType, value["outputType"])); + valueCopy.removeMember("outputType"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); + valueCopy.removeMember("name"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.index); + ComplexArgumentParser::Finalize(request.outputType); + ComplexArgumentParser::Finalize(request.name); +} + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, + chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::Type & request, + Json::Value & value) +{ + VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + + // Copy to track which members we already processed. + Json::Value valueCopy(value); + + ReturnErrorOnFailure( + ComplexArgumentParser::EnsureMemberExist("ApplicationEPStruct.application", "application", value.isMember("application"))); + + char labelWithMember[kMaxLabelLength]; + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "application"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.application, value["application"])); + valueCopy.removeMember("application"); + + if (value.isMember("endpoint")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); + } + valueCopy.removeMember("endpoint"); + + return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); +} + +void ComplexArgumentParser::Finalize(chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::Type & request) +{ + ComplexArgumentParser::Finalize(request.application); ComplexArgumentParser::Finalize(request.endpoint); - ComplexArgumentParser::Finalize(request.deviceType); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Type & request, + chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2195,28 +2290,37 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("TargetInfoStruct.identifier", "identifier", value.isMember("identifier"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("TargetInfoStruct.name", "name", value.isMember("name"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MonitoringRegistration.clientNodeId", "clientNodeId", + value.isMember("clientNodeId"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("MonitoringRegistration.ICid", "ICid", value.isMember("ICid"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "identifier"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.identifier, value["identifier"])); - valueCopy.removeMember("identifier"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "clientNodeId"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.clientNodeId, value["clientNodeId"])); + valueCopy.removeMember("clientNodeId"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); - valueCopy.removeMember("name"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "ICid"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.ICid, value["ICid"])); + valueCopy.removeMember("ICid"); + + if (value.isMember("fabricIndex")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); + } + valueCopy.removeMember("fabricIndex"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request) { - ComplexArgumentParser::Finalize(request.identifier); - ComplexArgumentParser::Finalize(request.name); + ComplexArgumentParser::Finalize(request.clientNodeId); + ComplexArgumentParser::Finalize(request.ICid); + ComplexArgumentParser::Finalize(request.fabricIndex); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::Binding::Structs::TargetStruct::Type & request, + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::SimpleStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2224,53 +2328,63 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters: // Copy to track which members we already processed. Json::Value valueCopy(value); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.a", "a", value.isMember("a"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.b", "b", value.isMember("b"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.c", "c", value.isMember("c"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.d", "d", value.isMember("d"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.e", "e", value.isMember("e"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.f", "f", value.isMember("f"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.g", "g", value.isMember("g"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("SimpleStruct.h", "h", value.isMember("h"))); + char labelWithMember[kMaxLabelLength]; - if (value.isMember("node")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "node"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.node, value["node"])); - } - valueCopy.removeMember("node"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "a"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.a, value["a"])); + valueCopy.removeMember("a"); - if (value.isMember("group")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "group"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.group, value["group"])); - } - valueCopy.removeMember("group"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "b"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.b, value["b"])); + valueCopy.removeMember("b"); - if (value.isMember("endpoint")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "endpoint"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.endpoint, value["endpoint"])); - } - valueCopy.removeMember("endpoint"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "c"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.c, value["c"])); + valueCopy.removeMember("c"); - if (value.isMember("cluster")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "cluster"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.cluster, value["cluster"])); - } - valueCopy.removeMember("cluster"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "d"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.d, value["d"])); + valueCopy.removeMember("d"); - if (value.isMember("fabricIndex")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "fabricIndex"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.fabricIndex, value["fabricIndex"])); - } - valueCopy.removeMember("fabricIndex"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "e"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.e, value["e"])); + valueCopy.removeMember("e"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "f"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.f, value["f"])); + valueCopy.removeMember("f"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "g"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.g, value["g"])); + valueCopy.removeMember("g"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "h"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.h, value["h"])); + valueCopy.removeMember("h"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::Binding::Structs::TargetStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::SimpleStruct::Type & request) { - ComplexArgumentParser::Finalize(request.node); - ComplexArgumentParser::Finalize(request.group); - ComplexArgumentParser::Finalize(request.endpoint); - ComplexArgumentParser::Finalize(request.cluster); - ComplexArgumentParser::Finalize(request.fabricIndex); + ComplexArgumentParser::Finalize(request.a); + ComplexArgumentParser::Finalize(request.b); + ComplexArgumentParser::Finalize(request.c); + ComplexArgumentParser::Finalize(request.d); + ComplexArgumentParser::Finalize(request.e); + ComplexArgumentParser::Finalize(request.f); + ComplexArgumentParser::Finalize(request.g); + ComplexArgumentParser::Finalize(request.h); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::TestFabricScoped::Type & request, Json::Value & value) @@ -2355,39 +2469,9 @@ void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs:: ComplexArgumentParser::Finalize(request.fabricSensitiveInt8uList); ComplexArgumentParser::Finalize(request.fabricIndex); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::Type & request, - Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); - - // Copy to track which members we already processed. - Json::Value valueCopy(value); - - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("TestListStructOctet.member1", "member1", value.isMember("member1"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("TestListStructOctet.member2", "member2", value.isMember("member2"))); - - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "member1"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.member1, value["member1"])); - valueCopy.removeMember("member1"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "member2"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.member2, value["member2"])); - valueCopy.removeMember("member2"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} -void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::Type & request) -{ - ComplexArgumentParser::Finalize(request.member1); - ComplexArgumentParser::Finalize(request.member2); -} CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::Type & request, + chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2395,110 +2479,112 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThermostatScheduleTransition.transitionTime", "transitionTime", - value.isMember("transitionTime"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThermostatScheduleTransition.heatSetpoint", "heatSetpoint", - value.isMember("heatSetpoint"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThermostatScheduleTransition.coolSetpoint", "coolSetpoint", - value.isMember("coolSetpoint"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NullablesAndOptionalsStruct.nullableInt", "nullableInt", + value.isMember("nullableInt"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NullablesAndOptionalsStruct.nullableString", "nullableString", + value.isMember("nullableString"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NullablesAndOptionalsStruct.nullableStruct", "nullableStruct", + value.isMember("nullableStruct"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NullablesAndOptionalsStruct.nullableList", "nullableList", + value.isMember("nullableList"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "transitionTime"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.transitionTime, value["transitionTime"])); - valueCopy.removeMember("transitionTime"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "heatSetpoint"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.heatSetpoint, value["heatSetpoint"])); - valueCopy.removeMember("heatSetpoint"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "coolSetpoint"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.coolSetpoint, value["coolSetpoint"])); - valueCopy.removeMember("coolSetpoint"); - - return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); -} - -void ComplexArgumentParser::Finalize(chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::Type & request) -{ - ComplexArgumentParser::Finalize(request.transitionTime); - ComplexArgumentParser::Finalize(request.heatSetpoint); - ComplexArgumentParser::Finalize(request.coolSetpoint); -} -CHIP_ERROR -ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::Type & request, - Json::Value & value) -{ - VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableInt"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nullableInt, value["nullableInt"])); + valueCopy.removeMember("nullableInt"); - // Copy to track which members we already processed. - Json::Value valueCopy(value); + if (value.isMember("optionalInt")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "optionalInt"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.optionalInt, value["optionalInt"])); + } + valueCopy.removeMember("optionalInt"); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.panId", "panId", value.isMember("panId"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.extendedPanId", "extendedPanId", - value.isMember("extendedPanId"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.networkName", "networkName", - value.isMember("networkName"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.channel", "channel", value.isMember("channel"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.version", "version", value.isMember("version"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.extendedAddress", "extendedAddress", - value.isMember("extendedAddress"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.rssi", "rssi", value.isMember("rssi"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadInterfaceScanResult.lqi", "lqi", value.isMember("lqi"))); + if (value.isMember("nullableOptionalInt")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableOptionalInt"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.nullableOptionalInt, value["nullableOptionalInt"])); + } + valueCopy.removeMember("nullableOptionalInt"); - char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "panId"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.panId, value["panId"])); - valueCopy.removeMember("panId"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableString"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nullableString, value["nullableString"])); + valueCopy.removeMember("nullableString"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extendedPanId"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.extendedPanId, value["extendedPanId"])); - valueCopy.removeMember("extendedPanId"); + if (value.isMember("optionalString")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "optionalString"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.optionalString, value["optionalString"])); + } + valueCopy.removeMember("optionalString"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "networkName"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.networkName, value["networkName"])); - valueCopy.removeMember("networkName"); + if (value.isMember("nullableOptionalString")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableOptionalString"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.nullableOptionalString, value["nullableOptionalString"])); + } + valueCopy.removeMember("nullableOptionalString"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "channel"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.channel, value["channel"])); - valueCopy.removeMember("channel"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableStruct"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nullableStruct, value["nullableStruct"])); + valueCopy.removeMember("nullableStruct"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "version"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.version, value["version"])); - valueCopy.removeMember("version"); + if (value.isMember("optionalStruct")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "optionalStruct"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.optionalStruct, value["optionalStruct"])); + } + valueCopy.removeMember("optionalStruct"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "extendedAddress"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.extendedAddress, value["extendedAddress"])); - valueCopy.removeMember("extendedAddress"); + if (value.isMember("nullableOptionalStruct")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableOptionalStruct"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.nullableOptionalStruct, value["nullableOptionalStruct"])); + } + valueCopy.removeMember("nullableOptionalStruct"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rssi"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rssi, value["rssi"])); - valueCopy.removeMember("rssi"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableList"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.nullableList, value["nullableList"])); + valueCopy.removeMember("nullableList"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "lqi"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.lqi, value["lqi"])); - valueCopy.removeMember("lqi"); + if (value.isMember("optionalList")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "optionalList"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.optionalList, value["optionalList"])); + } + valueCopy.removeMember("optionalList"); + + if (value.isMember("nullableOptionalList")) + { + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "nullableOptionalList"); + ReturnErrorOnFailure( + ComplexArgumentParser::Setup(labelWithMember, request.nullableOptionalList, value["nullableOptionalList"])); + } + valueCopy.removeMember("nullableOptionalList"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::Type & request) { - ComplexArgumentParser::Finalize(request.panId); - ComplexArgumentParser::Finalize(request.extendedPanId); - ComplexArgumentParser::Finalize(request.networkName); - ComplexArgumentParser::Finalize(request.channel); - ComplexArgumentParser::Finalize(request.version); - ComplexArgumentParser::Finalize(request.extendedAddress); - ComplexArgumentParser::Finalize(request.rssi); - ComplexArgumentParser::Finalize(request.lqi); + ComplexArgumentParser::Finalize(request.nullableInt); + ComplexArgumentParser::Finalize(request.optionalInt); + ComplexArgumentParser::Finalize(request.nullableOptionalInt); + ComplexArgumentParser::Finalize(request.nullableString); + ComplexArgumentParser::Finalize(request.optionalString); + ComplexArgumentParser::Finalize(request.nullableOptionalString); + ComplexArgumentParser::Finalize(request.nullableStruct); + ComplexArgumentParser::Finalize(request.optionalStruct); + ComplexArgumentParser::Finalize(request.nullableOptionalStruct); + ComplexArgumentParser::Finalize(request.nullableList); + ComplexArgumentParser::Finalize(request.optionalList); + ComplexArgumentParser::Finalize(request.nullableOptionalList); } -CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::Type & request, + +CHIP_ERROR ComplexArgumentParser::Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::NestedStruct::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2506,54 +2592,35 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("ThreadMetricsStruct.id", "id", value.isMember("id"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStruct.a", "a", value.isMember("a"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStruct.b", "b", value.isMember("b"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStruct.c", "c", value.isMember("c"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "id"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.id, value["id"])); - valueCopy.removeMember("id"); - - if (value.isMember("name")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); - } - valueCopy.removeMember("name"); - - if (value.isMember("stackFreeCurrent")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "stackFreeCurrent"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.stackFreeCurrent, value["stackFreeCurrent"])); - } - valueCopy.removeMember("stackFreeCurrent"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "a"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.a, value["a"])); + valueCopy.removeMember("a"); - if (value.isMember("stackFreeMinimum")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "stackFreeMinimum"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.stackFreeMinimum, value["stackFreeMinimum"])); - } - valueCopy.removeMember("stackFreeMinimum"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "b"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.b, value["b"])); + valueCopy.removeMember("b"); - if (value.isMember("stackSize")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "stackSize"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.stackSize, value["stackSize"])); - } - valueCopy.removeMember("stackSize"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "c"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.c, value["c"])); + valueCopy.removeMember("c"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::NestedStruct::Type & request) { - ComplexArgumentParser::Finalize(request.id); - ComplexArgumentParser::Finalize(request.name); - ComplexArgumentParser::Finalize(request.stackFreeCurrent); - ComplexArgumentParser::Finalize(request.stackFreeMinimum); - ComplexArgumentParser::Finalize(request.stackSize); + ComplexArgumentParser::Finalize(request.a); + ComplexArgumentParser::Finalize(request.b); + ComplexArgumentParser::Finalize(request.c); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request, + chip::app::Clusters::UnitTesting::Structs::NestedStructList::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2561,36 +2628,59 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("TimeZoneStruct.offset", "offset", value.isMember("offset"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("TimeZoneStruct.validAt", "validAt", value.isMember("validAt"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.a", "a", value.isMember("a"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.b", "b", value.isMember("b"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.c", "c", value.isMember("c"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.d", "d", value.isMember("d"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.e", "e", value.isMember("e"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.f", "f", value.isMember("f"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("NestedStructList.g", "g", value.isMember("g"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "offset"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.offset, value["offset"])); - valueCopy.removeMember("offset"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "a"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.a, value["a"])); + valueCopy.removeMember("a"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "validAt"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.validAt, value["validAt"])); - valueCopy.removeMember("validAt"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "b"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.b, value["b"])); + valueCopy.removeMember("b"); - if (value.isMember("name")) - { - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "name"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.name, value["name"])); - } - valueCopy.removeMember("name"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "c"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.c, value["c"])); + valueCopy.removeMember("c"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "d"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.d, value["d"])); + valueCopy.removeMember("d"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "e"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.e, value["e"])); + valueCopy.removeMember("e"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "f"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.f, value["f"])); + valueCopy.removeMember("f"); + + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "g"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.g, value["g"])); + valueCopy.removeMember("g"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::NestedStructList::Type & request) { - ComplexArgumentParser::Finalize(request.offset); - ComplexArgumentParser::Finalize(request.validAt); - ComplexArgumentParser::Finalize(request.name); + ComplexArgumentParser::Finalize(request.a); + ComplexArgumentParser::Finalize(request.b); + ComplexArgumentParser::Finalize(request.c); + ComplexArgumentParser::Finalize(request.d); + ComplexArgumentParser::Finalize(request.e); + ComplexArgumentParser::Finalize(request.f); + ComplexArgumentParser::Finalize(request.g); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request, + chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2598,56 +2688,23 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, // Copy to track which members we already processed. Json::Value valueCopy(value); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.security", "security", value.isMember("security"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.ssid", "ssid", value.isMember("ssid"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.bssid", "bssid", value.isMember("bssid"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.channel", "channel", value.isMember("channel"))); - ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.wiFiBand", "wiFiBand", value.isMember("wiFiBand"))); - ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("WiFiInterfaceScanResult.rssi", "rssi", value.isMember("rssi"))); + ReturnErrorOnFailure(ComplexArgumentParser::EnsureMemberExist("DoubleNestedStructList.a", "a", value.isMember("a"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "security"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.security, value["security"])); - valueCopy.removeMember("security"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "ssid"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.ssid, value["ssid"])); - valueCopy.removeMember("ssid"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "bssid"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.bssid, value["bssid"])); - valueCopy.removeMember("bssid"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "channel"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.channel, value["channel"])); - valueCopy.removeMember("channel"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "wiFiBand"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.wiFiBand, value["wiFiBand"])); - valueCopy.removeMember("wiFiBand"); - - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "rssi"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.rssi, value["rssi"])); - valueCopy.removeMember("rssi"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "a"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.a, value["a"])); + valueCopy.removeMember("a"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::Type & request) { - ComplexArgumentParser::Finalize(request.security); - ComplexArgumentParser::Finalize(request.ssid); - ComplexArgumentParser::Finalize(request.bssid); - ComplexArgumentParser::Finalize(request.channel); - ComplexArgumentParser::Finalize(request.wiFiBand); - ComplexArgumentParser::Finalize(request.rssi); + ComplexArgumentParser::Finalize(request.a); } + CHIP_ERROR ComplexArgumentParser::Setup(const char * label, - chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::Type & request, + chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::Type & request, Json::Value & value) { VerifyOrReturnError(value.isObject(), CHIP_ERROR_INVALID_ARGUMENT); @@ -2656,24 +2713,24 @@ CHIP_ERROR ComplexArgumentParser::Setup(const char * label, Json::Value valueCopy(value); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("WiredFaultChangeType.current", "current", value.isMember("current"))); + ComplexArgumentParser::EnsureMemberExist("TestListStructOctet.member1", "member1", value.isMember("member1"))); ReturnErrorOnFailure( - ComplexArgumentParser::EnsureMemberExist("WiredFaultChangeType.previous", "previous", value.isMember("previous"))); + ComplexArgumentParser::EnsureMemberExist("TestListStructOctet.member2", "member2", value.isMember("member2"))); char labelWithMember[kMaxLabelLength]; - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "current"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.current, value["current"])); - valueCopy.removeMember("current"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "member1"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.member1, value["member1"])); + valueCopy.removeMember("member1"); - snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "previous"); - ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.previous, value["previous"])); - valueCopy.removeMember("previous"); + snprintf(labelWithMember, sizeof(labelWithMember), "%s.%s", label, "member2"); + ReturnErrorOnFailure(ComplexArgumentParser::Setup(labelWithMember, request.member2, value["member2"])); + valueCopy.removeMember("member2"); return ComplexArgumentParser::EnsureNoMembersRemaining(label, valueCopy); } -void ComplexArgumentParser::Finalize(chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::Type & request) +void ComplexArgumentParser::Finalize(chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::Type & request) { - ComplexArgumentParser::Finalize(request.current); - ComplexArgumentParser::Finalize(request.previous); + ComplexArgumentParser::Finalize(request.member1); + ComplexArgumentParser::Finalize(request.member2); } diff --git a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h index 8c0036f996e70c..990126cbc87187 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/ComplexArgumentParser.h @@ -22,242 +22,299 @@ #include #include +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::detail::Structs::LabelStruct::Type & request, Json::Value & value); + +static void Finalize(chip::app::Clusters::detail::Structs::LabelStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Scenes::Structs::AttributeValuePair::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::Scenes::Structs::AttributeValuePair::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Binding::Structs::TargetStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::Binding::Structs::TargetStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::AccessControl::Structs::Target::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::AccessControl::Structs::Target::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::AccessControl::Structs::AccessControlEntryStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::AccessControl::Structs::AccessControlEntryStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::AccessControl::Structs::AccessControlExtensionStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::AccessControl::Structs::AccessControlExtensionStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Actions::Structs::ActionStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::Actions::Structs::ActionStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type & request, - Json::Value & value); -static void Finalize(chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::Type & request, +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Actions::Structs::EndpointListStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request, - Json::Value & value); +static void Finalize(chip::app::Clusters::Actions::Structs::EndpointListStruct::Type & request); -static void Finalize(chip::app::Clusters::detail::Structs::ApplicationStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Scenes::Structs::AttributeValuePair::Type & request, +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::Scenes::Structs::AttributeValuePair::Type & request); +static void Finalize(chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::Type & request); + static CHIP_ERROR Setup(const char * label, - chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request, + chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request); +static void Finalize(chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::PowerSource::Structs::BatChargeFaultChangeType::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::PowerSource::Structs::BatChargeFaultChangeType::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::PowerSource::Structs::BatFaultChangeType::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::PowerSource::Structs::BatFaultChangeType::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::Type & request); + static CHIP_ERROR Setup(const char * label, - chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type & request, + chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::Type & request, +static void Finalize(chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type & request, +static void Finalize(chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::Type & request); + +static CHIP_ERROR Setup(const char * label, + chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & request, +static void Finalize(chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::Type & request); + +static CHIP_ERROR Setup(const char * label, + chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::DoorLock::Structs::CredentialStruct::Type & request, +static void Finalize(chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::DoorLock::Structs::CredentialStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::Type & request, +static void Finalize(chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::Type & request, +static void Finalize(chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::Type & request, +static void Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::Type & request); + +static CHIP_ERROR Setup(const char * label, + chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::Type & request, +static void Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Actions::Structs::EndpointListStruct::Type & request, +static void Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::Actions::Structs::EndpointListStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & request, +static void Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::Type & request); +static void Finalize(chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::Type & request, + Json::Value & value); + +static void Finalize(chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type & request, - Json::Value & value); -static void Finalize(chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::detail::Structs::LabelStruct::Type & request, Json::Value & value); - -static void Finalize(chip::app::Clusters::detail::Structs::LabelStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type & request, +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type & request); +static void Finalize(chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request, - Json::Value & value); -static void Finalize(chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::Type & request, +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::DoorLock::Structs::CredentialStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::Type & request, - Json::Value & value); +static void Finalize(chip::app::Clusters::DoorLock::Structs::CredentialStruct::Type & request); -static void Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::NestedStruct::Type & request, +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::UnitTesting::Structs::NestedStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::NestedStructList::Type & request, - Json::Value & value); +static void Finalize(chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::Type & request); -static void Finalize(chip::app::Clusters::UnitTesting::Structs::NestedStructList::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::Type & request, +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::Type & request, - Json::Value & value); +static void Finalize(chip::app::Clusters::Channel::Structs::ChannelInfoStruct::Type & request); -static void Finalize(chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::Type & request, +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::Type & request); -static CHIP_ERROR Setup(const char * label, - chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type & request, - Json::Value & value); +static void Finalize(chip::app::Clusters::Channel::Structs::LineupInfoStruct::Type & request); -static void Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::Type & request, +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & request, - Json::Value & value); +static void Finalize(chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Type & request); -static void Finalize(chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & request); static CHIP_ERROR Setup(const char * label, chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::Type & request); -static CHIP_ERROR Setup(const char * label, - chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request, + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::Type & request, +static void Finalize(chip::app::Clusters::MediaInput::Structs::InputInfoStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type & request, +static void Finalize(chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::Type & request, +static void Finalize(chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::SimpleStruct::Type & request, +static void Finalize(chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::UnitTesting::Structs::SimpleStruct::Type & request); +static void Finalize(chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::Type & request); + static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ContentLauncher::Structs::StyleInformationStruct::Type & request, Json::Value & value); static void Finalize(chip::app::Clusters::ContentLauncher::Structs::StyleInformationStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::AccessControl::Structs::Target::Type & request, + +static CHIP_ERROR Setup(const char * label, + chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::AccessControl::Structs::Target::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Type & request, +static void Finalize(chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Binding::Structs::TargetStruct::Type & request, +static void Finalize(chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::Binding::Structs::TargetStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::TestFabricScoped::Type & request, +static void Finalize(chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::UnitTesting::Structs::TestFabricScoped::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::Type & request, +static void Finalize(chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::SimpleStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::Type & request, +static void Finalize(chip::app::Clusters::UnitTesting::Structs::SimpleStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::TestFabricScoped::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::Type & request); -static CHIP_ERROR Setup(const char * label, - chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::Type & request, +static void Finalize(chip::app::Clusters::UnitTesting::Structs::TestFabricScoped::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::Type & request, +static void Finalize(chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::NestedStruct::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request, +static void Finalize(chip::app::Clusters::UnitTesting::Structs::NestedStruct::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::NestedStructList::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::Type & request); -static CHIP_ERROR Setup(const char * label, - chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request, +static void Finalize(chip::app::Clusters::UnitTesting::Structs::NestedStructList::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::Type & request); -static CHIP_ERROR Setup(const char * label, chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::Type & request, +static void Finalize(chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::Type & request); + +static CHIP_ERROR Setup(const char * label, chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::Type & request, Json::Value & value); -static void Finalize(chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::Type & request); +static void Finalize(chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::Type & request); diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp index 578944136f8fdd..e85d4920b846c2 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp @@ -21,48 +21,73 @@ using namespace chip::app::Clusters; -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::AccessControl::Structs::AccessControlEntryStruct::DecodableType & value) +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::detail::Structs::ApplicationStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Privilege", indent + 1, value.privilege); + CHIP_ERROR err = LogValue("CatalogVendorID", indent + 1, value.catalogVendorID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Privilege'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CatalogVendorID'"); return err; } } { - CHIP_ERROR err = LogValue("AuthMode", indent + 1, value.authMode); + CHIP_ERROR err = LogValue("ApplicationID", indent + 1, value.applicationID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AuthMode'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ApplicationID'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::detail::Structs::LabelStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Subjects", indent + 1, value.subjects); + CHIP_ERROR err = LogValue("Label", indent + 1, value.label); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Subjects'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Label'"); return err; } } { - CHIP_ERROR err = LogValue("Targets", indent + 1, value.targets); + CHIP_ERROR err = LogValue("Value", indent + 1, value.value); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Targets'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Value'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::Scenes::Structs::AttributeValuePair::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("AttributeID", indent + 1, value.attributeID); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AttributeID'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("AttributeValue", indent + 1, value.attributeValue); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AttributeValue'"); return err; } } @@ -70,24 +95,24 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::AccessControl::Structs::AccessControlExtensionStruct::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Data", indent + 1, value.data); + CHIP_ERROR err = LogValue("ClusterID", indent + 1, value.clusterID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Data'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ClusterID'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("AttributeValueList", indent + 1, value.attributeValueList); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AttributeValueList'"); return err; } } @@ -95,55 +120,73 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Actions::Structs::ActionStruct::DecodableType & value) + const chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ActionID", indent + 1, value.actionID); + CHIP_ERROR err = LogValue("DeviceType", indent + 1, value.deviceType); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ActionID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'DeviceType'"); return err; } } { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); + CHIP_ERROR err = LogValue("Revision", indent + 1, value.revision); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Revision'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::Binding::Structs::TargetStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("Node", indent + 1, value.node); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Node'"); return err; } } { - CHIP_ERROR err = LogValue("Type", indent + 1, value.type); + CHIP_ERROR err = LogValue("Group", indent + 1, value.group); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Type'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Group'"); return err; } } { - CHIP_ERROR err = LogValue("EndpointListID", indent + 1, value.endpointListID); + CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EndpointListID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); return err; } } { - CHIP_ERROR err = LogValue("SupportedCommands", indent + 1, value.supportedCommands); + CHIP_ERROR err = LogValue("Cluster", indent + 1, value.cluster); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'SupportedCommands'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Cluster'"); return err; } } { - CHIP_ERROR err = LogValue("State", indent + 1, value.state); + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'State'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } @@ -151,24 +194,32 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::AccessControl::Structs::Target::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); + CHIP_ERROR err = LogValue("Cluster", indent + 1, value.cluster); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Cluster'"); return err; } } { - CHIP_ERROR err = LogValue("Value", indent + 1, value.value); + CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Value'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("DeviceType", indent + 1, value.deviceType); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'DeviceType'"); return err; } } @@ -176,48 +227,49 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::DecodableType & value) + const chip::app::Clusters::AccessControl::Structs::AccessControlEntryStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Application", indent + 1, value.application); + CHIP_ERROR err = LogValue("Privilege", indent + 1, value.privilege); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Application'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Privilege'"); return err; } } { - CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); + CHIP_ERROR err = LogValue("AuthMode", indent + 1, value.authMode); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AuthMode'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::detail::Structs::ApplicationStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("CatalogVendorID", indent + 1, value.catalogVendorID); + CHIP_ERROR err = LogValue("Subjects", indent + 1, value.subjects); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CatalogVendorID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Subjects'"); return err; } } { - CHIP_ERROR err = LogValue("ApplicationID", indent + 1, value.applicationID); + CHIP_ERROR err = LogValue("Targets", indent + 1, value.targets); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ApplicationID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Targets'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } @@ -225,23 +277,25 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Scenes::Structs::AttributeValuePair::DecodableType & value) + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::AccessControl::Structs::AccessControlExtensionStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("AttributeID", indent + 1, value.attributeID); + CHIP_ERROR err = LogValue("Data", indent + 1, value.data); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AttributeID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Data'"); return err; } } { - CHIP_ERROR err = LogValue("AttributeValue", indent + 1, value.attributeValue); + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AttributeValue'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } @@ -249,73 +303,56 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::Actions::Structs::ActionStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("FailSafeExpiryLengthSeconds", indent + 1, value.failSafeExpiryLengthSeconds); + CHIP_ERROR err = LogValue("ActionID", indent + 1, value.actionID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FailSafeExpiryLengthSeconds'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ActionID'"); return err; } } { - CHIP_ERROR err = LogValue("MaxCumulativeFailsafeSeconds", indent + 1, value.maxCumulativeFailsafeSeconds); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MaxCumulativeFailsafeSeconds'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::PowerSource::Structs::BatChargeFaultChangeType::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Current", indent + 1, value.current); + CHIP_ERROR err = LogValue("Type", indent + 1, value.type); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Current'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Type'"); return err; } } { - CHIP_ERROR err = LogValue("Previous", indent + 1, value.previous); + CHIP_ERROR err = LogValue("EndpointListID", indent + 1, value.endpointListID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Previous'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EndpointListID'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::PowerSource::Structs::BatFaultChangeType::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Current", indent + 1, value.current); + CHIP_ERROR err = LogValue("SupportedCommands", indent + 1, value.supportedCommands); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Current'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'SupportedCommands'"); return err; } } { - CHIP_ERROR err = LogValue("Previous", indent + 1, value.previous); + CHIP_ERROR err = LogValue("State", indent + 1, value.state); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Previous'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'State'"); return err; } } @@ -323,56 +360,66 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::Actions::Structs::EndpointListStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ProviderName", indent + 1, value.providerName); + CHIP_ERROR err = LogValue("EndpointListID", indent + 1, value.endpointListID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ProviderName'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EndpointListID'"); return err; } } { - CHIP_ERROR err = LogValue("Background", indent + 1, value.background); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Background'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } { - CHIP_ERROR err = LogValue("Logo", indent + 1, value.logo); + CHIP_ERROR err = LogValue("Type", indent + 1, value.type); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Logo'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Type'"); return err; } } { - CHIP_ERROR err = LogValue("ProgressBar", indent + 1, value.progressBar); + CHIP_ERROR err = LogValue("Endpoints", indent + 1, value.endpoints); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ProgressBar'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoints'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Splash", indent + 1, value.splash); + CHIP_ERROR err = LogValue("CaseSessionsPerFabric", indent + 1, value.caseSessionsPerFabric); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Splash'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CaseSessionsPerFabric'"); return err; } } { - CHIP_ERROR err = LogValue("WaterMark", indent + 1, value.waterMark); + CHIP_ERROR err = LogValue("SubscriptionsPerFabric", indent + 1, value.subscriptionsPerFabric); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'WaterMark'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'SubscriptionsPerFabric'"); return err; } } @@ -380,24 +427,33 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::DecodableType & value) + const chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("CaseSessionsPerFabric", indent + 1, value.caseSessionsPerFabric); + CHIP_ERROR err = LogValue("ProviderNodeID", indent + 1, value.providerNodeID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CaseSessionsPerFabric'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ProviderNodeID'"); return err; } } { - CHIP_ERROR err = LogValue("SubscriptionsPerFabric", indent + 1, value.subscriptionsPerFabric); + CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'SubscriptionsPerFabric'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } @@ -405,47 +461,75 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Channel::Structs::ChannelInfoStruct::DecodableType & value) + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::PowerSource::Structs::BatChargeFaultChangeType::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("MajorNumber", indent + 1, value.majorNumber); + CHIP_ERROR err = LogValue("Current", indent + 1, value.current); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MajorNumber'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Current'"); return err; } } { - CHIP_ERROR err = LogValue("MinorNumber", indent + 1, value.minorNumber); + CHIP_ERROR err = LogValue("Previous", indent + 1, value.previous); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Previous'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::PowerSource::Structs::BatFaultChangeType::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("Current", indent + 1, value.current); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MinorNumber'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Current'"); return err; } } { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); + CHIP_ERROR err = LogValue("Previous", indent + 1, value.previous); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Previous'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("CallSign", indent + 1, value.callSign); + CHIP_ERROR err = LogValue("Current", indent + 1, value.current); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CallSign'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Current'"); return err; } } { - CHIP_ERROR err = LogValue("AffiliateCallSign", indent + 1, value.affiliateCallSign); + CHIP_ERROR err = LogValue("Previous", indent + 1, value.previous); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AffiliateCallSign'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Previous'"); return err; } } @@ -453,16 +537,25 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::DecodableType & value) + const chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ParameterList", indent + 1, value.parameterList); + CHIP_ERROR err = LogValue("FailSafeExpiryLengthSeconds", indent + 1, value.failSafeExpiryLengthSeconds); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ParameterList'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FailSafeExpiryLengthSeconds'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("MaxCumulativeFailsafeSeconds", indent + 1, value.maxCumulativeFailsafeSeconds); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MaxCumulativeFailsafeSeconds'"); return err; } } @@ -470,23 +563,24 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::DoorLock::Structs::CredentialStruct::DecodableType & value) + const chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("CredentialType", indent + 1, value.credentialType); + CHIP_ERROR err = LogValue("NetworkID", indent + 1, value.networkID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CredentialType'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NetworkID'"); return err; } } { - CHIP_ERROR err = LogValue("CredentialIndex", indent + 1, value.credentialIndex); + CHIP_ERROR err = LogValue("Connected", indent + 1, value.connected); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CredentialIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Connected'"); return err; } } @@ -494,88 +588,73 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue( + const char * label, size_t indent, + const chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Offset", indent + 1, value.offset); + CHIP_ERROR err = LogValue("PanId", indent + 1, value.panId); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Offset'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PanId'"); return err; } } { - CHIP_ERROR err = LogValue("ValidStarting", indent + 1, value.validStarting); + CHIP_ERROR err = LogValue("ExtendedPanId", indent + 1, value.extendedPanId); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ValidStarting'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExtendedPanId'"); return err; } } { - CHIP_ERROR err = LogValue("ValidUntil", indent + 1, value.validUntil); + CHIP_ERROR err = LogValue("NetworkName", indent + 1, value.networkName); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ValidUntil'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NetworkName'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("DeviceType", indent + 1, value.deviceType); + CHIP_ERROR err = LogValue("Channel", indent + 1, value.channel); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'DeviceType'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Channel'"); return err; } } { - CHIP_ERROR err = LogValue("Revision", indent + 1, value.revision); + CHIP_ERROR err = LogValue("Version", indent + 1, value.version); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Revision'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Version'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Width", indent + 1, value.width); + CHIP_ERROR err = LogValue("ExtendedAddress", indent + 1, value.extendedAddress); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Width'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExtendedAddress'"); return err; } } { - CHIP_ERROR err = LogValue("Height", indent + 1, value.height); + CHIP_ERROR err = LogValue("Rssi", indent + 1, value.rssi); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Height'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Rssi'"); return err; } } { - CHIP_ERROR err = LogValue("Metric", indent + 1, value.metric); + CHIP_ERROR err = LogValue("Lqi", indent + 1, value.lqi); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Metric'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Lqi'"); return err; } } @@ -583,79 +662,57 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); - { - CHIP_ERROR err = LogValue("A", indent + 1, value.a); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'A'"); - return err; - } - } - DataModelLogger::LogString(indent, "}"); - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Actions::Structs::EndpointListStruct::DecodableType & value) +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("EndpointListID", indent + 1, value.endpointListID); + CHIP_ERROR err = LogValue("Security", indent + 1, value.security); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EndpointListID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Security'"); return err; } } { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); + CHIP_ERROR err = LogValue("Ssid", indent + 1, value.ssid); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Ssid'"); return err; } } { - CHIP_ERROR err = LogValue("Type", indent + 1, value.type); + CHIP_ERROR err = LogValue("Bssid", indent + 1, value.bssid); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Type'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Bssid'"); return err; } } { - CHIP_ERROR err = LogValue("Endpoints", indent + 1, value.endpoints); + CHIP_ERROR err = LogValue("Channel", indent + 1, value.channel); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoints'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Channel'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ClusterID", indent + 1, value.clusterID); + CHIP_ERROR err = LogValue("WiFiBand", indent + 1, value.wiFiBand); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ClusterID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'WiFiBand'"); return err; } } { - CHIP_ERROR err = LogValue("AttributeValueList", indent + 1, value.attributeValueList); + CHIP_ERROR err = LogValue("Rssi", indent + 1, value.rssi); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AttributeValueList'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Rssi'"); return err; } } @@ -663,130 +720,123 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::DecodableType & value) + const chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("RootPublicKey", indent + 1, value.rootPublicKey); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RootPublicKey'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } { - CHIP_ERROR err = LogValue("VendorID", indent + 1, value.vendorID); + CHIP_ERROR err = LogValue("IsOperational", indent + 1, value.isOperational); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'VendorID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'IsOperational'"); return err; } } { - CHIP_ERROR err = LogValue("FabricID", indent + 1, value.fabricID); + CHIP_ERROR err = LogValue("OffPremiseServicesReachableIPv4", indent + 1, value.offPremiseServicesReachableIPv4); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OffPremiseServicesReachableIPv4'"); return err; } } { - CHIP_ERROR err = LogValue("NodeID", indent + 1, value.nodeID); + CHIP_ERROR err = LogValue("OffPremiseServicesReachableIPv6", indent + 1, value.offPremiseServicesReachableIPv6); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NodeID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OffPremiseServicesReachableIPv6'"); return err; } } { - CHIP_ERROR err = LogValue("Label", indent + 1, value.label); + CHIP_ERROR err = LogValue("HardwareAddress", indent + 1, value.hardwareAddress); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Label'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'HardwareAddress'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("IPv4Addresses", indent + 1, value.IPv4Addresses); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'IPv4Addresses'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("GroupId", indent + 1, value.groupId); + CHIP_ERROR err = LogValue("IPv6Addresses", indent + 1, value.IPv6Addresses); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupId'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'IPv6Addresses'"); return err; } } { - CHIP_ERROR err = LogValue("Endpoints", indent + 1, value.endpoints); + CHIP_ERROR err = LogValue("Type", indent + 1, value.type); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoints'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Type'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("GroupName", indent + 1, value.groupName); + CHIP_ERROR err = LogValue("Id", indent + 1, value.id); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupName'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Id'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("GroupId", indent + 1, value.groupId); + CHIP_ERROR err = LogValue("StackFreeCurrent", indent + 1, value.stackFreeCurrent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupId'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'StackFreeCurrent'"); return err; } } { - CHIP_ERROR err = LogValue("GroupKeySetID", indent + 1, value.groupKeySetID); + CHIP_ERROR err = LogValue("StackFreeMinimum", indent + 1, value.stackFreeMinimum); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupKeySetID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'StackFreeMinimum'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("StackSize", indent + 1, value.stackSize); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'StackSize'"); return err; } } @@ -794,136 +844,121 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::DecodableType & value) + const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("GroupKeySetID", indent + 1, value.groupKeySetID); + CHIP_ERROR err = LogValue("ExtAddress", indent + 1, value.extAddress); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupKeySetID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExtAddress'"); return err; } } { - CHIP_ERROR err = LogValue("GroupKeySecurityPolicy", indent + 1, value.groupKeySecurityPolicy); + CHIP_ERROR err = LogValue("Age", indent + 1, value.age); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupKeySecurityPolicy'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Age'"); return err; } } { - CHIP_ERROR err = LogValue("EpochKey0", indent + 1, value.epochKey0); + CHIP_ERROR err = LogValue("Rloc16", indent + 1, value.rloc16); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochKey0'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Rloc16'"); return err; } } { - CHIP_ERROR err = LogValue("EpochStartTime0", indent + 1, value.epochStartTime0); + CHIP_ERROR err = LogValue("LinkFrameCounter", indent + 1, value.linkFrameCounter); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochStartTime0'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LinkFrameCounter'"); return err; } } { - CHIP_ERROR err = LogValue("EpochKey1", indent + 1, value.epochKey1); + CHIP_ERROR err = LogValue("MleFrameCounter", indent + 1, value.mleFrameCounter); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochKey1'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MleFrameCounter'"); return err; } } { - CHIP_ERROR err = LogValue("EpochStartTime1", indent + 1, value.epochStartTime1); + CHIP_ERROR err = LogValue("Lqi", indent + 1, value.lqi); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochStartTime1'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Lqi'"); return err; } } { - CHIP_ERROR err = LogValue("EpochKey2", indent + 1, value.epochKey2); + CHIP_ERROR err = LogValue("AverageRssi", indent + 1, value.averageRssi); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochKey2'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AverageRssi'"); return err; } } { - CHIP_ERROR err = LogValue("EpochStartTime2", indent + 1, value.epochStartTime2); + CHIP_ERROR err = LogValue("LastRssi", indent + 1, value.lastRssi); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochStartTime2'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LastRssi'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::MediaInput::Structs::InputInfoStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Index", indent + 1, value.index); + CHIP_ERROR err = LogValue("FrameErrorRate", indent + 1, value.frameErrorRate); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Index'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FrameErrorRate'"); return err; } } { - CHIP_ERROR err = LogValue("InputType", indent + 1, value.inputType); + CHIP_ERROR err = LogValue("MessageErrorRate", indent + 1, value.messageErrorRate); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'InputType'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MessageErrorRate'"); return err; } } { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); + CHIP_ERROR err = LogValue("RxOnWhenIdle", indent + 1, value.rxOnWhenIdle); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RxOnWhenIdle'"); return err; } } { - CHIP_ERROR err = LogValue("Description", indent + 1, value.description); + CHIP_ERROR err = LogValue("FullThreadDevice", indent + 1, value.fullThreadDevice); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Description'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FullThreadDevice'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::detail::Structs::LabelStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Label", indent + 1, value.label); + CHIP_ERROR err = LogValue("FullNetworkData", indent + 1, value.fullNetworkData); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Label'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FullNetworkData'"); return err; } } { - CHIP_ERROR err = LogValue("Value", indent + 1, value.value); + CHIP_ERROR err = LogValue("IsChild", indent + 1, value.isChild); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Value'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'IsChild'"); return err; } } @@ -931,136 +966,105 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Channel::Structs::LineupInfoStruct::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue( + const char * label, size_t indent, + const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("OperatorName", indent + 1, value.operatorName); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OperatorName'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("LineupName", indent + 1, value.lineupName); + CHIP_ERROR err = LogValue("ActiveTimestampPresent", indent + 1, value.activeTimestampPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LineupName'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ActiveTimestampPresent'"); return err; } } { - CHIP_ERROR err = LogValue("PostalCode", indent + 1, value.postalCode); + CHIP_ERROR err = LogValue("PendingTimestampPresent", indent + 1, value.pendingTimestampPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PostalCode'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PendingTimestampPresent'"); return err; } } { - CHIP_ERROR err = LogValue("LineupInfoType", indent + 1, value.lineupInfoType); + CHIP_ERROR err = LogValue("MasterKeyPresent", indent + 1, value.masterKeyPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LineupInfoType'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MasterKeyPresent'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Label", indent + 1, value.label); + CHIP_ERROR err = LogValue("NetworkNamePresent", indent + 1, value.networkNamePresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Label'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NetworkNamePresent'"); return err; } } { - CHIP_ERROR err = LogValue("Mode", indent + 1, value.mode); + CHIP_ERROR err = LogValue("ExtendedPanIdPresent", indent + 1, value.extendedPanIdPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Mode'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExtendedPanIdPresent'"); return err; } } { - CHIP_ERROR err = LogValue("SemanticTags", indent + 1, value.semanticTags); + CHIP_ERROR err = LogValue("MeshLocalPrefixPresent", indent + 1, value.meshLocalPrefixPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'SemanticTags'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MeshLocalPrefixPresent'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ClientNodeId", indent + 1, value.clientNodeId); + CHIP_ERROR err = LogValue("DelayPresent", indent + 1, value.delayPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ClientNodeId'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'DelayPresent'"); return err; } } { - CHIP_ERROR err = LogValue("ICid", indent + 1, value.ICid); + CHIP_ERROR err = LogValue("PanIdPresent", indent + 1, value.panIdPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ICid'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PanIdPresent'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("ChannelPresent", indent + 1, value.channelPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ChannelPresent'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Noc", indent + 1, value.noc); + CHIP_ERROR err = LogValue("PskcPresent", indent + 1, value.pskcPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Noc'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PskcPresent'"); return err; } } { - CHIP_ERROR err = LogValue("Icac", indent + 1, value.icac); + CHIP_ERROR err = LogValue("SecurityPolicyPresent", indent + 1, value.securityPolicyPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Icac'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'SecurityPolicyPresent'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("ChannelMaskPresent", indent + 1, value.channelMaskPresent); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ChannelMaskPresent'"); return err; } } @@ -1068,9 +1072,10 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::DecodableType & value) + const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { @@ -1081,14 +1086,6 @@ DataModelLogger::LogValue(const char * label, size_t indent, return err; } } - { - CHIP_ERROR err = LogValue("Age", indent + 1, value.age); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Age'"); - return err; - } - } { CHIP_ERROR err = LogValue("Rloc16", indent + 1, value.rloc16); if (err != CHIP_NO_ERROR) @@ -1098,90 +1095,92 @@ DataModelLogger::LogValue(const char * label, size_t indent, } } { - CHIP_ERROR err = LogValue("LinkFrameCounter", indent + 1, value.linkFrameCounter); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LinkFrameCounter'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("MleFrameCounter", indent + 1, value.mleFrameCounter); + CHIP_ERROR err = LogValue("RouterId", indent + 1, value.routerId); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MleFrameCounter'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RouterId'"); return err; } } { - CHIP_ERROR err = LogValue("Lqi", indent + 1, value.lqi); + CHIP_ERROR err = LogValue("NextHop", indent + 1, value.nextHop); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Lqi'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NextHop'"); return err; } } { - CHIP_ERROR err = LogValue("AverageRssi", indent + 1, value.averageRssi); + CHIP_ERROR err = LogValue("PathCost", indent + 1, value.pathCost); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AverageRssi'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PathCost'"); return err; } } { - CHIP_ERROR err = LogValue("LastRssi", indent + 1, value.lastRssi); + CHIP_ERROR err = LogValue("LQIIn", indent + 1, value.LQIIn); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LastRssi'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LQIIn'"); return err; } } { - CHIP_ERROR err = LogValue("FrameErrorRate", indent + 1, value.frameErrorRate); + CHIP_ERROR err = LogValue("LQIOut", indent + 1, value.LQIOut); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FrameErrorRate'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LQIOut'"); return err; } } { - CHIP_ERROR err = LogValue("MessageErrorRate", indent + 1, value.messageErrorRate); + CHIP_ERROR err = LogValue("Age", indent + 1, value.age); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MessageErrorRate'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Age'"); return err; } } { - CHIP_ERROR err = LogValue("RxOnWhenIdle", indent + 1, value.rxOnWhenIdle); + CHIP_ERROR err = LogValue("Allocated", indent + 1, value.allocated); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RxOnWhenIdle'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Allocated'"); return err; } } { - CHIP_ERROR err = LogValue("FullThreadDevice", indent + 1, value.fullThreadDevice); + CHIP_ERROR err = LogValue("LinkEstablished", indent + 1, value.linkEstablished); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FullThreadDevice'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LinkEstablished'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("FullNetworkData", indent + 1, value.fullNetworkData); + CHIP_ERROR err = LogValue("RotationTime", indent + 1, value.rotationTime); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FullNetworkData'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RotationTime'"); return err; } } { - CHIP_ERROR err = LogValue("IsChild", indent + 1, value.isChild); + CHIP_ERROR err = LogValue("Flags", indent + 1, value.flags); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'IsChild'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Flags'"); return err; } } @@ -1189,31 +1188,33 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::NestedStruct::DecodableType & value) + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("A", indent + 1, value.a); + CHIP_ERROR err = LogValue("Offset", indent + 1, value.offset); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'A'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Offset'"); return err; } } { - CHIP_ERROR err = LogValue("B", indent + 1, value.b); + CHIP_ERROR err = LogValue("ValidStarting", indent + 1, value.validStarting); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'B'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ValidStarting'"); return err; } } { - CHIP_ERROR err = LogValue("C", indent + 1, value.c); + CHIP_ERROR err = LogValue("ValidUntil", indent + 1, value.validUntil); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'C'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ValidUntil'"); return err; } } @@ -1221,63 +1222,90 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::NestedStructList::DecodableType & value) + const chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("A", indent + 1, value.a); + CHIP_ERROR err = LogValue("Offset", indent + 1, value.offset); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Offset'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("ValidAt", indent + 1, value.validAt); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ValidAt'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'A'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("B", indent + 1, value.b); + CHIP_ERROR err = LogValue("RootPublicKey", indent + 1, value.rootPublicKey); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'B'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RootPublicKey'"); return err; } } { - CHIP_ERROR err = LogValue("C", indent + 1, value.c); + CHIP_ERROR err = LogValue("VendorID", indent + 1, value.vendorID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'C'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'VendorID'"); return err; } } { - CHIP_ERROR err = LogValue("D", indent + 1, value.d); + CHIP_ERROR err = LogValue("FabricID", indent + 1, value.fabricID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'D'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricID'"); return err; } } { - CHIP_ERROR err = LogValue("E", indent + 1, value.e); + CHIP_ERROR err = LogValue("NodeID", indent + 1, value.nodeID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'E'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NodeID'"); return err; } } { - CHIP_ERROR err = LogValue("F", indent + 1, value.f); + CHIP_ERROR err = LogValue("Label", indent + 1, value.label); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'F'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Label'"); return err; } } { - CHIP_ERROR err = LogValue("G", indent + 1, value.g); + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'G'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } @@ -1285,23 +1313,32 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::DecodableType & value) + const chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("NetworkID", indent + 1, value.networkID); + CHIP_ERROR err = LogValue("Noc", indent + 1, value.noc); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NetworkID'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Noc'"); return err; } } { - CHIP_ERROR err = LogValue("Connected", indent + 1, value.connected); + CHIP_ERROR err = LogValue("Icac", indent + 1, value.icac); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Connected'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Icac'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } @@ -1309,72 +1346,75 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::DecodableType & value) + const chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("IsOperational", indent + 1, value.isOperational); + CHIP_ERROR err = LogValue("GroupId", indent + 1, value.groupId); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'IsOperational'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupId'"); return err; } } { - CHIP_ERROR err = LogValue("OffPremiseServicesReachableIPv4", indent + 1, value.offPremiseServicesReachableIPv4); + CHIP_ERROR err = LogValue("Endpoints", indent + 1, value.endpoints); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OffPremiseServicesReachableIPv4'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoints'"); return err; } } { - CHIP_ERROR err = LogValue("OffPremiseServicesReachableIPv6", indent + 1, value.offPremiseServicesReachableIPv6); + CHIP_ERROR err = LogValue("GroupName", indent + 1, value.groupName); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OffPremiseServicesReachableIPv6'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupName'"); return err; } } { - CHIP_ERROR err = LogValue("HardwareAddress", indent + 1, value.hardwareAddress); + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'HardwareAddress'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("IPv4Addresses", indent + 1, value.IPv4Addresses); + CHIP_ERROR err = LogValue("GroupId", indent + 1, value.groupId); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'IPv4Addresses'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupId'"); return err; } } { - CHIP_ERROR err = LogValue("IPv6Addresses", indent + 1, value.IPv6Addresses); + CHIP_ERROR err = LogValue("GroupKeySetID", indent + 1, value.groupKeySetID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'IPv6Addresses'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupKeySetID'"); return err; } } { - CHIP_ERROR err = LogValue("Type", indent + 1, value.type); + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Type'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } @@ -1382,104 +1422,98 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::DecodableType & value) + const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("NullableInt", indent + 1, value.nullableInt); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableInt'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("OptionalInt", indent + 1, value.optionalInt); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OptionalInt'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("NullableOptionalInt", indent + 1, value.nullableOptionalInt); + CHIP_ERROR err = LogValue("GroupKeySetID", indent + 1, value.groupKeySetID); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableOptionalInt'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupKeySetID'"); return err; } } { - CHIP_ERROR err = LogValue("NullableString", indent + 1, value.nullableString); + CHIP_ERROR err = LogValue("GroupKeySecurityPolicy", indent + 1, value.groupKeySecurityPolicy); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableString'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'GroupKeySecurityPolicy'"); return err; } } { - CHIP_ERROR err = LogValue("OptionalString", indent + 1, value.optionalString); + CHIP_ERROR err = LogValue("EpochKey0", indent + 1, value.epochKey0); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OptionalString'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochKey0'"); return err; } } { - CHIP_ERROR err = LogValue("NullableOptionalString", indent + 1, value.nullableOptionalString); + CHIP_ERROR err = LogValue("EpochStartTime0", indent + 1, value.epochStartTime0); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableOptionalString'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochStartTime0'"); return err; } } { - CHIP_ERROR err = LogValue("NullableStruct", indent + 1, value.nullableStruct); + CHIP_ERROR err = LogValue("EpochKey1", indent + 1, value.epochKey1); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableStruct'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochKey1'"); return err; } } { - CHIP_ERROR err = LogValue("OptionalStruct", indent + 1, value.optionalStruct); + CHIP_ERROR err = LogValue("EpochStartTime1", indent + 1, value.epochStartTime1); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OptionalStruct'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochStartTime1'"); return err; } } { - CHIP_ERROR err = LogValue("NullableOptionalStruct", indent + 1, value.nullableOptionalStruct); + CHIP_ERROR err = LogValue("EpochKey2", indent + 1, value.epochKey2); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableOptionalStruct'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochKey2'"); return err; } } { - CHIP_ERROR err = LogValue("NullableList", indent + 1, value.nullableList); + CHIP_ERROR err = LogValue("EpochStartTime2", indent + 1, value.epochStartTime2); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableList'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'EpochStartTime2'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("OptionalList", indent + 1, value.optionalList); + CHIP_ERROR err = LogValue("MfgCode", indent + 1, value.mfgCode); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OptionalList'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MfgCode'"); return err; } } { - CHIP_ERROR err = LogValue("NullableOptionalList", indent + 1, value.nullableOptionalList); + CHIP_ERROR err = LogValue("Value", indent + 1, value.value); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableOptionalList'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Value'"); return err; } } @@ -1487,104 +1521,140 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue( - const char * label, size_t indent, - const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ActiveTimestampPresent", indent + 1, value.activeTimestampPresent); + CHIP_ERROR err = LogValue("Label", indent + 1, value.label); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ActiveTimestampPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Label'"); return err; } } { - CHIP_ERROR err = LogValue("PendingTimestampPresent", indent + 1, value.pendingTimestampPresent); + CHIP_ERROR err = LogValue("Mode", indent + 1, value.mode); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PendingTimestampPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Mode'"); return err; } } { - CHIP_ERROR err = LogValue("MasterKeyPresent", indent + 1, value.masterKeyPresent); + CHIP_ERROR err = LogValue("SemanticTags", indent + 1, value.semanticTags); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MasterKeyPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'SemanticTags'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::DoorLock::Structs::CredentialStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("CredentialType", indent + 1, value.credentialType); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CredentialType'"); return err; } } { - CHIP_ERROR err = LogValue("NetworkNamePresent", indent + 1, value.networkNamePresent); + CHIP_ERROR err = LogValue("CredentialIndex", indent + 1, value.credentialIndex); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NetworkNamePresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CredentialIndex'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ExtendedPanIdPresent", indent + 1, value.extendedPanIdPresent); + CHIP_ERROR err = LogValue("TransitionTime", indent + 1, value.transitionTime); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExtendedPanIdPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'TransitionTime'"); return err; } } { - CHIP_ERROR err = LogValue("MeshLocalPrefixPresent", indent + 1, value.meshLocalPrefixPresent); + CHIP_ERROR err = LogValue("HeatSetpoint", indent + 1, value.heatSetpoint); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MeshLocalPrefixPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'HeatSetpoint'"); return err; } } { - CHIP_ERROR err = LogValue("DelayPresent", indent + 1, value.delayPresent); + CHIP_ERROR err = LogValue("CoolSetpoint", indent + 1, value.coolSetpoint); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'DelayPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CoolSetpoint'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::Channel::Structs::ChannelInfoStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("PanIdPresent", indent + 1, value.panIdPresent); + CHIP_ERROR err = LogValue("MajorNumber", indent + 1, value.majorNumber); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PanIdPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MajorNumber'"); return err; } } { - CHIP_ERROR err = LogValue("ChannelPresent", indent + 1, value.channelPresent); + CHIP_ERROR err = LogValue("MinorNumber", indent + 1, value.minorNumber); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ChannelPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MinorNumber'"); return err; } } { - CHIP_ERROR err = LogValue("PskcPresent", indent + 1, value.pskcPresent); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PskcPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } { - CHIP_ERROR err = LogValue("SecurityPolicyPresent", indent + 1, value.securityPolicyPresent); + CHIP_ERROR err = LogValue("CallSign", indent + 1, value.callSign); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'SecurityPolicyPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CallSign'"); return err; } } { - CHIP_ERROR err = LogValue("ChannelMaskPresent", indent + 1, value.channelMaskPresent); + CHIP_ERROR err = LogValue("AffiliateCallSign", indent + 1, value.affiliateCallSign); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ChannelMaskPresent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'AffiliateCallSign'"); return err; } } @@ -1592,31 +1662,40 @@ CHIP_ERROR DataModelLogger::LogValue( return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::DecodableType & value) + const chip::app::Clusters::Channel::Structs::LineupInfoStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Index", indent + 1, value.index); + CHIP_ERROR err = LogValue("OperatorName", indent + 1, value.operatorName); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Index'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OperatorName'"); return err; } } { - CHIP_ERROR err = LogValue("OutputType", indent + 1, value.outputType); + CHIP_ERROR err = LogValue("LineupName", indent + 1, value.lineupName); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OutputType'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LineupName'"); return err; } } { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); + CHIP_ERROR err = LogValue("PostalCode", indent + 1, value.postalCode); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PostalCode'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("LineupInfoType", indent + 1, value.lineupInfoType); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LineupInfoType'"); return err; } } @@ -1624,31 +1703,24 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::DecodableType & value) + const chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Type", indent + 1, value.type); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Type'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("Value", indent + 1, value.value); + CHIP_ERROR err = LogValue("Identifier", indent + 1, value.identifier); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Value'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Identifier'"); return err; } } { - CHIP_ERROR err = LogValue("ExternalIDList", indent + 1, value.externalIDList); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExternalIDList'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } @@ -1656,6 +1728,7 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::DecodableType & value) @@ -1681,121 +1754,132 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::MediaInput::Structs::InputInfoStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ProviderNodeID", indent + 1, value.providerNodeID); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ProviderNodeID'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); + CHIP_ERROR err = LogValue("Index", indent + 1, value.index); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Index'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("InputType", indent + 1, value.inputType); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'InputType'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ExtAddress", indent + 1, value.extAddress); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExtAddress'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } { - CHIP_ERROR err = LogValue("Rloc16", indent + 1, value.rloc16); + CHIP_ERROR err = LogValue("Description", indent + 1, value.description); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Rloc16'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Description'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("RouterId", indent + 1, value.routerId); + CHIP_ERROR err = LogValue("Width", indent + 1, value.width); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RouterId'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Width'"); return err; } } { - CHIP_ERROR err = LogValue("NextHop", indent + 1, value.nextHop); + CHIP_ERROR err = LogValue("Height", indent + 1, value.height); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NextHop'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Height'"); return err; } } { - CHIP_ERROR err = LogValue("PathCost", indent + 1, value.pathCost); + CHIP_ERROR err = LogValue("Metric", indent + 1, value.metric); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PathCost'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Metric'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("LQIIn", indent + 1, value.LQIIn); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LQIIn'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } { - CHIP_ERROR err = LogValue("LQIOut", indent + 1, value.LQIOut); + CHIP_ERROR err = LogValue("Value", indent + 1, value.value); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LQIOut'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Value'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Age", indent + 1, value.age); + CHIP_ERROR err = LogValue("Type", indent + 1, value.type); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Age'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Type'"); return err; } } { - CHIP_ERROR err = LogValue("Allocated", indent + 1, value.allocated); + CHIP_ERROR err = LogValue("Value", indent + 1, value.value); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Allocated'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Value'"); return err; } } { - CHIP_ERROR err = LogValue("LinkEstablished", indent + 1, value.linkEstablished); + CHIP_ERROR err = LogValue("ExternalIDList", indent + 1, value.externalIDList); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'LinkEstablished'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExternalIDList'"); return err; } } @@ -1803,24 +1887,17 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::DecodableType & value) + const chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("RotationTime", indent + 1, value.rotationTime); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'RotationTime'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("Flags", indent + 1, value.flags); + CHIP_ERROR err = LogValue("ParameterList", indent + 1, value.parameterList); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Flags'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ParameterList'"); return err; } } @@ -1828,23 +1905,33 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::DecodableType & value) + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ContentLauncher::Structs::StyleInformationStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("MfgCode", indent + 1, value.mfgCode); + CHIP_ERROR err = LogValue("ImageURL", indent + 1, value.imageURL); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'MfgCode'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ImageURL'"); return err; } } { - CHIP_ERROR err = LogValue("Value", indent + 1, value.value); + CHIP_ERROR err = LogValue("Color", indent + 1, value.color); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Value'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Color'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("Size", indent + 1, value.size); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Size'"); return err; } } @@ -1852,71 +1939,90 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::SimpleStruct::DecodableType & value) + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("A", indent + 1, value.a); + CHIP_ERROR err = LogValue("ProviderName", indent + 1, value.providerName); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'A'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ProviderName'"); return err; } } { - CHIP_ERROR err = LogValue("B", indent + 1, value.b); + CHIP_ERROR err = LogValue("Background", indent + 1, value.background); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'B'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Background'"); return err; } } { - CHIP_ERROR err = LogValue("C", indent + 1, value.c); + CHIP_ERROR err = LogValue("Logo", indent + 1, value.logo); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'C'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Logo'"); return err; } } { - CHIP_ERROR err = LogValue("D", indent + 1, value.d); + CHIP_ERROR err = LogValue("ProgressBar", indent + 1, value.progressBar); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'D'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ProgressBar'"); return err; } } { - CHIP_ERROR err = LogValue("E", indent + 1, value.e); + CHIP_ERROR err = LogValue("Splash", indent + 1, value.splash); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'E'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Splash'"); return err; } } { - CHIP_ERROR err = LogValue("F", indent + 1, value.f); + CHIP_ERROR err = LogValue("WaterMark", indent + 1, value.waterMark); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'F'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'WaterMark'"); + return err; + } + } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); + { + CHIP_ERROR err = LogValue("Index", indent + 1, value.index); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Index'"); return err; } } { - CHIP_ERROR err = LogValue("G", indent + 1, value.g); + CHIP_ERROR err = LogValue("OutputType", indent + 1, value.outputType); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'G'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OutputType'"); return err; } } { - CHIP_ERROR err = LogValue("H", indent + 1, value.h); + CHIP_ERROR err = LogValue("Name", indent + 1, value.name); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'H'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); return err; } } @@ -1924,32 +2030,25 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::StyleInformationStruct::DecodableType & value) + const chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("ImageURL", indent + 1, value.imageURL); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ImageURL'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("Color", indent + 1, value.color); + CHIP_ERROR err = LogValue("Application", indent + 1, value.application); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Color'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Application'"); return err; } } { - CHIP_ERROR err = LogValue("Size", indent + 1, value.size); + CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Size'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); return err; } } @@ -1957,31 +2056,33 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::AccessControl::Structs::Target::DecodableType & value) + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Cluster", indent + 1, value.cluster); + CHIP_ERROR err = LogValue("ClientNodeId", indent + 1, value.clientNodeId); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Cluster'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ClientNodeId'"); return err; } } { - CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); + CHIP_ERROR err = LogValue("ICid", indent + 1, value.ICid); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ICid'"); return err; } } { - CHIP_ERROR err = LogValue("DeviceType", indent + 1, value.deviceType); + CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'DeviceType'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); return err; } } @@ -1989,71 +2090,72 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::DecodableType & value) + const chip::app::Clusters::UnitTesting::Structs::SimpleStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Identifier", indent + 1, value.identifier); + CHIP_ERROR err = LogValue("A", indent + 1, value.a); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Identifier'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'A'"); return err; } } { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); + CHIP_ERROR err = LogValue("B", indent + 1, value.b); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'B'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Binding::Structs::TargetStruct::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Node", indent + 1, value.node); + CHIP_ERROR err = LogValue("C", indent + 1, value.c); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Node'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'C'"); return err; } } { - CHIP_ERROR err = LogValue("Group", indent + 1, value.group); + CHIP_ERROR err = LogValue("D", indent + 1, value.d); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Group'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'D'"); return err; } } { - CHIP_ERROR err = LogValue("Endpoint", indent + 1, value.endpoint); + CHIP_ERROR err = LogValue("E", indent + 1, value.e); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Endpoint'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'E'"); return err; } } { - CHIP_ERROR err = LogValue("Cluster", indent + 1, value.cluster); + CHIP_ERROR err = LogValue("F", indent + 1, value.f); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Cluster'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'F'"); return err; } } { - CHIP_ERROR err = LogValue("FabricIndex", indent + 1, value.fabricIndex); + CHIP_ERROR err = LogValue("G", indent + 1, value.g); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'FabricIndex'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'G'"); + return err; + } + } + { + CHIP_ERROR err = LogValue("H", indent + 1, value.h); + if (err != CHIP_NO_ERROR) + { + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'H'"); return err; } } @@ -2061,6 +2163,7 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, const chip::app::Clusters::UnitTesting::Structs::TestFabricScoped::DecodableType & value) { @@ -2134,129 +2237,105 @@ CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } -CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::DecodableType & value) + +CHIP_ERROR +DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Member1", indent + 1, value.member1); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Member1'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("Member2", indent + 1, value.member2); + CHIP_ERROR err = LogValue("NullableInt", indent + 1, value.nullableInt); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Member2'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableInt'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("TransitionTime", indent + 1, value.transitionTime); + CHIP_ERROR err = LogValue("OptionalInt", indent + 1, value.optionalInt); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'TransitionTime'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OptionalInt'"); return err; } } { - CHIP_ERROR err = LogValue("HeatSetpoint", indent + 1, value.heatSetpoint); + CHIP_ERROR err = LogValue("NullableOptionalInt", indent + 1, value.nullableOptionalInt); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'HeatSetpoint'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableOptionalInt'"); return err; } } { - CHIP_ERROR err = LogValue("CoolSetpoint", indent + 1, value.coolSetpoint); + CHIP_ERROR err = LogValue("NullableString", indent + 1, value.nullableString); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'CoolSetpoint'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableString'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR DataModelLogger::LogValue( - const char * label, size_t indent, - const chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("PanId", indent + 1, value.panId); + CHIP_ERROR err = LogValue("OptionalString", indent + 1, value.optionalString); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'PanId'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OptionalString'"); return err; } } { - CHIP_ERROR err = LogValue("ExtendedPanId", indent + 1, value.extendedPanId); + CHIP_ERROR err = LogValue("NullableOptionalString", indent + 1, value.nullableOptionalString); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExtendedPanId'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableOptionalString'"); return err; } } { - CHIP_ERROR err = LogValue("NetworkName", indent + 1, value.networkName); + CHIP_ERROR err = LogValue("NullableStruct", indent + 1, value.nullableStruct); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NetworkName'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableStruct'"); return err; } } { - CHIP_ERROR err = LogValue("Channel", indent + 1, value.channel); + CHIP_ERROR err = LogValue("OptionalStruct", indent + 1, value.optionalStruct); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Channel'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OptionalStruct'"); return err; } } { - CHIP_ERROR err = LogValue("Version", indent + 1, value.version); + CHIP_ERROR err = LogValue("NullableOptionalStruct", indent + 1, value.nullableOptionalStruct); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Version'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableOptionalStruct'"); return err; } } { - CHIP_ERROR err = LogValue("ExtendedAddress", indent + 1, value.extendedAddress); + CHIP_ERROR err = LogValue("NullableList", indent + 1, value.nullableList); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ExtendedAddress'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableList'"); return err; } } { - CHIP_ERROR err = LogValue("Rssi", indent + 1, value.rssi); + CHIP_ERROR err = LogValue("OptionalList", indent + 1, value.optionalList); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Rssi'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'OptionalList'"); return err; } } { - CHIP_ERROR err = LogValue("Lqi", indent + 1, value.lqi); + CHIP_ERROR err = LogValue("NullableOptionalList", indent + 1, value.nullableOptionalList); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Lqi'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'NullableOptionalList'"); return err; } } @@ -2264,48 +2343,32 @@ CHIP_ERROR DataModelLogger::LogValue( return CHIP_NO_ERROR; } -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::DecodableType & value) + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::UnitTesting::Structs::NestedStruct::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Id", indent + 1, value.id); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Id'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("StackFreeCurrent", indent + 1, value.stackFreeCurrent); + CHIP_ERROR err = LogValue("A", indent + 1, value.a); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'StackFreeCurrent'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'A'"); return err; } } { - CHIP_ERROR err = LogValue("StackFreeMinimum", indent + 1, value.stackFreeMinimum); + CHIP_ERROR err = LogValue("B", indent + 1, value.b); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'StackFreeMinimum'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'B'"); return err; } } { - CHIP_ERROR err = LogValue("StackSize", indent + 1, value.stackSize); + CHIP_ERROR err = LogValue("C", indent + 1, value.c); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'StackSize'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'C'"); return err; } } @@ -2313,88 +2376,81 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::DecodableType & value) + const chip::app::Clusters::UnitTesting::Structs::NestedStructList::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Offset", indent + 1, value.offset); - if (err != CHIP_NO_ERROR) - { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Offset'"); - return err; - } - } - { - CHIP_ERROR err = LogValue("ValidAt", indent + 1, value.validAt); + CHIP_ERROR err = LogValue("A", indent + 1, value.a); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'ValidAt'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'A'"); return err; } } { - CHIP_ERROR err = LogValue("Name", indent + 1, value.name); + CHIP_ERROR err = LogValue("B", indent + 1, value.b); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Name'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'B'"); return err; } } - DataModelLogger::LogString(indent, "}"); - - return CHIP_NO_ERROR; -} -CHIP_ERROR -DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::DecodableType & value) -{ - DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Security", indent + 1, value.security); + CHIP_ERROR err = LogValue("C", indent + 1, value.c); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Security'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'C'"); return err; } } { - CHIP_ERROR err = LogValue("Ssid", indent + 1, value.ssid); + CHIP_ERROR err = LogValue("D", indent + 1, value.d); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Ssid'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'D'"); return err; } } { - CHIP_ERROR err = LogValue("Bssid", indent + 1, value.bssid); + CHIP_ERROR err = LogValue("E", indent + 1, value.e); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Bssid'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'E'"); return err; } } { - CHIP_ERROR err = LogValue("Channel", indent + 1, value.channel); + CHIP_ERROR err = LogValue("F", indent + 1, value.f); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Channel'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'F'"); return err; } } { - CHIP_ERROR err = LogValue("WiFiBand", indent + 1, value.wiFiBand); + CHIP_ERROR err = LogValue("G", indent + 1, value.g); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'WiFiBand'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'G'"); return err; } } + DataModelLogger::LogString(indent, "}"); + + return CHIP_NO_ERROR; +} + +CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, + const chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::DecodableType & value) +{ + DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Rssi", indent + 1, value.rssi); + CHIP_ERROR err = LogValue("A", indent + 1, value.a); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Rssi'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'A'"); return err; } } @@ -2402,23 +2458,24 @@ DataModelLogger::LogValue(const char * label, size_t indent, return CHIP_NO_ERROR; } + CHIP_ERROR DataModelLogger::LogValue(const char * label, size_t indent, - const chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::DecodableType & value) + const chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::DecodableType & value) { DataModelLogger::LogString(label, indent, "{"); { - CHIP_ERROR err = LogValue("Current", indent + 1, value.current); + CHIP_ERROR err = LogValue("Member1", indent + 1, value.member1); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Current'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Member1'"); return err; } } { - CHIP_ERROR err = LogValue("Previous", indent + 1, value.previous); + CHIP_ERROR err = LogValue("Member2", indent + 1, value.member2); if (err != CHIP_NO_ERROR) { - DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Previous'"); + DataModelLogger::LogString(indent + 1, "Struct truncated due to invalid value for 'Member2'"); return err; } } diff --git a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h index cb1d136ebc92b7..368f75af3cfc10 100644 --- a/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h +++ b/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.h @@ -20,126 +20,183 @@ #include #include +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::detail::Structs::ApplicationStruct::DecodableType & value); + +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::detail::Structs::LabelStruct::DecodableType & value); + +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::Scenes::Structs::AttributeValuePair::DecodableType & value); + +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::DecodableType & value); + +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::DecodableType & value); + +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::Binding::Structs::TargetStruct::DecodableType & value); + +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::AccessControl::Structs::Target::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::AccessControl::Structs::AccessControlEntryStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::AccessControl::Structs::AccessControlExtensionStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::Actions::Structs::ActionStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::detail::Structs::ApplicationStruct::DecodableType & value); + const chip::app::Clusters::Actions::Structs::EndpointListStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::Scenes::Structs::AttributeValuePair::DecodableType & value); + const chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::DecodableType & value); + const chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::PowerSource::Structs::BatChargeFaultChangeType::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::PowerSource::Structs::BatFaultChangeType::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::BasicInformation::Structs::CapabilityMinimaStruct::DecodableType & value); + const chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::Channel::Structs::ChannelInfoStruct::DecodableType & value); + const chip::app::Clusters::GeneralCommissioning::Structs::BasicCommissioningInfo::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::DecodableType & value); + const chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::DecodableType & value); + +static CHIP_ERROR +LogValue(const char * label, size_t indent, + const chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::DecodableType & value); + +static CHIP_ERROR +LogValue(const char * label, size_t indent, + const chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::DoorLock::Structs::CredentialStruct::DecodableType & value); + const chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::DecodableType & value); + const chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::Descriptor::Structs::DeviceTypeStruct::DecodableType & value); + const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::DecodableType & value); + +static CHIP_ERROR +LogValue(const char * label, size_t indent, + const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::DecodableType & value); + const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::DecodableType & value); + const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::Actions::Structs::EndpointListStruct::DecodableType & value); + const chip::app::Clusters::TimeSynchronization::Structs::DSTOffsetStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::Scenes::Structs::ExtensionFieldSet::DecodableType & value); + const chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::OperationalCredentials::Structs::FabricDescriptorStruct::DecodableType & value); + +static CHIP_ERROR LogValue(const char * label, size_t indent, + const chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::GroupKeyManagement::Structs::GroupInfoMapStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeyMapStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::GroupKeyManagement::Structs::GroupKeySetStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::MediaInput::Structs::InputInfoStruct::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::detail::Structs::LabelStruct::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::Channel::Structs::LineupInfoStruct::DecodableType & value); + const chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::ModeSelect::Structs::ModeOptionStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::DecodableType & value); + const chip::app::Clusters::DoorLock::Structs::CredentialStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::OperationalCredentials::Structs::NOCStruct::DecodableType & value); + const chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::NeighborTable::DecodableType & value); + const chip::app::Clusters::Channel::Structs::ChannelInfoStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::NestedStruct::DecodableType & value); + const chip::app::Clusters::Channel::Structs::LineupInfoStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::NestedStructList::DecodableType & value); + const chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::NetworkCommissioning::Structs::NetworkInfo::DecodableType & value); + const chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::GeneralDiagnostics::Structs::NetworkInterface::DecodableType & value); + const chip::app::Clusters::MediaInput::Structs::InputInfoStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::DecodableType & value); -static CHIP_ERROR -LogValue(const char * label, size_t indent, - const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::OperationalDatasetComponents::DecodableType & value); + const chip::app::Clusters::ContentLauncher::Structs::DimensionStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::DecodableType & value); + const chip::app::Clusters::ContentLauncher::Structs::AdditionalInfoStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::ContentLauncher::Structs::ParameterStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::MediaPlayback::Structs::PlaybackPositionStruct::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::OtaSoftwareUpdateRequestor::Structs::ProviderLocation::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::RouteTable::DecodableType & value); -static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ThreadNetworkDiagnostics::Structs::SecurityPolicy::DecodableType & value); + const chip::app::Clusters::ContentLauncher::Structs::ContentSearchStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ModeSelect::Structs::SemanticTagStruct::DecodableType & value); + const chip::app::Clusters::ContentLauncher::Structs::StyleInformationStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::SimpleStruct::DecodableType & value); + const chip::app::Clusters::ContentLauncher::Structs::BrandingInformationStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::ContentLauncher::Structs::StyleInformationStruct::DecodableType & value); + const chip::app::Clusters::AudioOutput::Structs::OutputInfoStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::AccessControl::Structs::Target::DecodableType & value); + const chip::app::Clusters::ApplicationLauncher::Structs::ApplicationEPStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::TargetNavigator::Structs::TargetInfoStruct::DecodableType & value); + const chip::app::Clusters::ClientMonitoring::Structs::MonitoringRegistration::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::Binding::Structs::TargetStruct::DecodableType & value); + const chip::app::Clusters::UnitTesting::Structs::SimpleStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::UnitTesting::Structs::TestFabricScoped::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::DecodableType & value); + const chip::app::Clusters::UnitTesting::Structs::NullablesAndOptionalsStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::Thermostat::Structs::ThermostatScheduleTransition::DecodableType & value); -static CHIP_ERROR -LogValue(const char * label, size_t indent, - const chip::app::Clusters::NetworkCommissioning::Structs::ThreadInterfaceScanResult::DecodableType & value); + const chip::app::Clusters::UnitTesting::Structs::NestedStruct::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::SoftwareDiagnostics::Structs::ThreadMetricsStruct::DecodableType & value); + const chip::app::Clusters::UnitTesting::Structs::NestedStructList::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::TimeSynchronization::Structs::TimeZoneStruct::DecodableType & value); -static CHIP_ERROR -LogValue(const char * label, size_t indent, - const chip::app::Clusters::NetworkCommissioning::Structs::WiFiInterfaceScanResult::DecodableType & value); + const chip::app::Clusters::UnitTesting::Structs::DoubleNestedStructList::DecodableType & value); + static CHIP_ERROR LogValue(const char * label, size_t indent, - const chip::app::Clusters::PowerSource::Structs::WiredFaultChangeType::DecodableType & value); + const chip::app::Clusters::UnitTesting::Structs::TestListStructOctet::DecodableType & value); static CHIP_ERROR LogValue(const char * label, size_t indent, const chip::app::Clusters::AccessControl::Events::AccessControlEntryChanged::DecodableType & value); From fa3563a9ea15f9baa34b3cb4434e4131f5e33643 Mon Sep 17 00:00:00 2001 From: Kamil Kasperczyk <66371704+kkasperczyk-no@users.noreply.github.com> Date: Wed, 26 Apr 2023 20:42:15 +0200 Subject: [PATCH 47/54] [dnssd] Fixed OT DNS API usage for Thread platform (#26199) * [dnssd] Fixed OT DNS API usage for Thread platform Introduced several fixes to the Thread platform DNS implementation: * Added checking if memory allocation for DnsResult was successful and dispatching dedicated methods to inform upper layer in case of memory allocation failure * Added checking if DNS response for DNS resolve includes AAAA record. In case it doesn't the additional DNS query to obtain IPv6 address will be sent. * Added checking if DNS response for DNS browse includes SRV, TXT and AAAA records. In case it doesn't the additional DNS queries to obtain SRV + TXT, and AAAA records will be sent. * Addressed review comments * Fixed error handling and potential memory leaks * Moved handling resolve after browse from Thread platform to Discovery_ImplPlatform. * Addressed second code review * Fixed string copying by adding the exact size of data to copy instead of relying on the max buffer size. --- src/lib/dnssd/Discovery_ImplPlatform.cpp | 4 +- ...nericThreadStackManagerImpl_OpenThread.cpp | 199 ++++++++++++++---- ...GenericThreadStackManagerImpl_OpenThread.h | 11 +- 3 files changed, 168 insertions(+), 46 deletions(-) diff --git a/src/lib/dnssd/Discovery_ImplPlatform.cpp b/src/lib/dnssd/Discovery_ImplPlatform.cpp index bffd7e8bff9872..675e7ac238106b 100644 --- a/src/lib/dnssd/Discovery_ImplPlatform.cpp +++ b/src/lib/dnssd/Discovery_ImplPlatform.cpp @@ -172,7 +172,9 @@ static void HandleNodeBrowse(void * context, DnssdService * services, size_t ser { proxy->Retain(); // For some platforms browsed services are already resolved, so verify if resolve is really needed or call resolve callback - if (!services[i].mAddress.HasValue()) + + // Check if SRV, TXT and AAAA records were received in DNS responses + if (strlen(services[i].mHostName) == 0 || services[i].mTextEntrySize == 0 || !services[i].mAddress.HasValue()) { ChipDnssdResolve(&services[i], services[i].mInterface, HandleNodeResolve, context); } diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp index 603924e71bbc34..3142fd102ba670 100644 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.cpp @@ -2498,31 +2498,20 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_SetSrpDnsCallba template CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::FromOtDnsResponseToMdnsData( otDnsServiceInfo & serviceInfo, const char * serviceType, chip::Dnssd::DnssdService & mdnsService, - DnsServiceTxtEntries & serviceTxtEntries) + DnsServiceTxtEntries & serviceTxtEntries, otError error) { char protocol[chip::Dnssd::kDnssdProtocolTextMaxSize + 1]; - if (strchr(serviceInfo.mHostNameBuffer, '.') == nullptr) - return CHIP_ERROR_INVALID_ARGUMENT; - - // Extract from the .. the part. - size_t substringSize = strchr(serviceInfo.mHostNameBuffer, '.') - serviceInfo.mHostNameBuffer; - if (substringSize >= ArraySize(mdnsService.mHostName)) - { - return CHIP_ERROR_INVALID_ARGUMENT; - } - Platform::CopyString(mdnsService.mHostName, serviceInfo.mHostNameBuffer); - if (strchr(serviceType, '.') == nullptr) return CHIP_ERROR_INVALID_ARGUMENT; // Extract from the ... the part. - substringSize = strchr(serviceType, '.') - serviceType; + size_t substringSize = strchr(serviceType, '.') - serviceType; if (substringSize >= ArraySize(mdnsService.mType)) { return CHIP_ERROR_INVALID_ARGUMENT; } - Platform::CopyString(mdnsService.mType, serviceType); + Platform::CopyString(mdnsService.mType, substringSize + 1, serviceType); // Extract from the ... the part. const char * protocolSubstringStart = serviceType + substringSize + 1; @@ -2535,7 +2524,7 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::FromOtDnsRespons { return CHIP_ERROR_INVALID_ARGUMENT; } - Platform::CopyString(protocol, protocolSubstringStart); + Platform::CopyString(protocol, substringSize + 1, protocolSubstringStart); if (strncmp(protocol, "_udp", chip::Dnssd::kDnssdProtocolTextMaxSize) == 0) { @@ -2549,37 +2538,97 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::FromOtDnsRespons { mdnsService.mProtocol = chip::Dnssd::DnssdServiceProtocol::kDnssdProtocolUnknown; } - mdnsService.mPort = serviceInfo.mPort; - mdnsService.mInterface = Inet::InterfaceId::Null(); - mdnsService.mAddressType = Inet::IPAddressType::kIPv6; - mdnsService.mAddress = chip::Optional(ToIPAddress(serviceInfo.mHostAddress)); - otDnsTxtEntryIterator iterator; - otDnsInitTxtEntryIterator(&iterator, serviceInfo.mTxtData, serviceInfo.mTxtDataSize); + // Check if SRV record was included in DNS response. + if (error != OT_ERROR_NOT_FOUND) + { + if (strchr(serviceInfo.mHostNameBuffer, '.') == nullptr) + return CHIP_ERROR_INVALID_ARGUMENT; - otDnsTxtEntry txtEntry; - FixedBufferAllocator alloc(serviceTxtEntries.mBuffer); + // Extract from the .. the part. + substringSize = strchr(serviceInfo.mHostNameBuffer, '.') - serviceInfo.mHostNameBuffer; + if (substringSize >= ArraySize(mdnsService.mHostName)) + { + return CHIP_ERROR_INVALID_ARGUMENT; + } + Platform::CopyString(mdnsService.mHostName, substringSize + 1, serviceInfo.mHostNameBuffer); - uint8_t entryIndex = 0; - while ((otDnsGetNextTxtEntry(&iterator, &txtEntry) == OT_ERROR_NONE) && entryIndex < kMaxDnsServiceTxtEntriesNumber) - { - if (txtEntry.mKey == nullptr || txtEntry.mValue == nullptr) - continue; + mdnsService.mPort = serviceInfo.mPort; + } - serviceTxtEntries.mTxtEntries[entryIndex].mKey = alloc.Clone(txtEntry.mKey); - serviceTxtEntries.mTxtEntries[entryIndex].mData = alloc.Clone(txtEntry.mValue, txtEntry.mValueLength); - serviceTxtEntries.mTxtEntries[entryIndex].mDataSize = txtEntry.mValueLength; - entryIndex++; + mdnsService.mInterface = Inet::InterfaceId::Null(); + + // Check if AAAA record was included in DNS response. + + if (!otIp6IsAddressUnspecified(&serviceInfo.mHostAddress)) + { + mdnsService.mAddressType = Inet::IPAddressType::kIPv6; + mdnsService.mAddress = MakeOptional(ToIPAddress(serviceInfo.mHostAddress)); } - ReturnErrorCodeIf(alloc.AnyAllocFailed(), CHIP_ERROR_BUFFER_TOO_SMALL); + // Check if TXT record was included in DNS response. + if (serviceInfo.mTxtDataSize != 0) + { + otDnsTxtEntryIterator iterator; + otDnsInitTxtEntryIterator(&iterator, serviceInfo.mTxtData, serviceInfo.mTxtDataSize); + + otDnsTxtEntry txtEntry; + FixedBufferAllocator alloc(serviceTxtEntries.mBuffer); - mdnsService.mTextEntries = serviceTxtEntries.mTxtEntries; - mdnsService.mTextEntrySize = entryIndex; + uint8_t entryIndex = 0; + while ((otDnsGetNextTxtEntry(&iterator, &txtEntry) == OT_ERROR_NONE) && entryIndex < kMaxDnsServiceTxtEntriesNumber) + { + if (txtEntry.mKey == nullptr || txtEntry.mValue == nullptr) + continue; + + serviceTxtEntries.mTxtEntries[entryIndex].mKey = alloc.Clone(txtEntry.mKey); + serviceTxtEntries.mTxtEntries[entryIndex].mData = alloc.Clone(txtEntry.mValue, txtEntry.mValueLength); + serviceTxtEntries.mTxtEntries[entryIndex].mDataSize = txtEntry.mValueLength; + entryIndex++; + } + + ReturnErrorCodeIf(alloc.AnyAllocFailed(), CHIP_ERROR_BUFFER_TOO_SMALL); + + mdnsService.mTextEntries = serviceTxtEntries.mTxtEntries; + mdnsService.mTextEntrySize = entryIndex; + } return CHIP_NO_ERROR; } +template +CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::ResolveAddress(intptr_t context, otDnsAddressCallback callback) +{ + DnsResult * dnsResult = reinterpret_cast(context); + + ThreadStackMgrImpl().LockThreadStack(); + + char fullHostName[chip::Dnssd::kHostNameMaxLength + 1 + SrpClient::kDefaultDomainNameSize + 1]; + snprintf(fullHostName, sizeof(fullHostName), "%s.%s", dnsResult->mMdnsService.mHostName, SrpClient::kDefaultDomainName); + + CHIP_ERROR error = MapOpenThreadError(otDnsClientResolveAddress(ThreadStackMgrImpl().OTInstance(), fullHostName, callback, + reinterpret_cast(dnsResult), NULL)); + + ThreadStackMgrImpl().UnlockThreadStack(); + + return error; +} + +template +void GenericThreadStackManagerImpl_OpenThread::DispatchAddressResolve(intptr_t context) +{ + CHIP_ERROR error = ResolveAddress(context, OnDnsAddressResolveResult); + + // In case of address resolve failure, fill the error code field and dispatch method to end resolve process. + if (error != CHIP_NO_ERROR) + { + DnsResult * dnsResult = reinterpret_cast(context); + dnsResult->error = error; + + DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolve, reinterpret_cast(dnsResult)); + } +} + template void GenericThreadStackManagerImpl_OpenThread::DispatchResolve(intptr_t context) { @@ -2596,6 +2645,13 @@ void GenericThreadStackManagerImpl_OpenThread::DispatchResolve(intptr Platform::Delete(dnsResult); } +template +void GenericThreadStackManagerImpl_OpenThread::DispatchResolveNoMemory(intptr_t context) +{ + Span ipAddrs; + ThreadStackMgrImpl().mDnsResolveCallback(reinterpret_cast(context), nullptr, ipAddrs, CHIP_ERROR_NO_MEMORY); +} + template void GenericThreadStackManagerImpl_OpenThread::DispatchBrowseEmpty(intptr_t context) { @@ -2612,6 +2668,12 @@ void GenericThreadStackManagerImpl_OpenThread::DispatchBrowse(intptr_ Platform::Delete(dnsResult); } +template +void GenericThreadStackManagerImpl_OpenThread::DispatchBrowseNoMemory(intptr_t context) +{ + ThreadStackMgrImpl().mDnsBrowseCallback(reinterpret_cast(context), nullptr, 0, true, CHIP_ERROR_NO_MEMORY); +} + template void GenericThreadStackManagerImpl_OpenThread::OnDnsBrowseResult(otError aError, const otDnsBrowseResponse * aResponse, void * aContext) @@ -2647,12 +2709,16 @@ void GenericThreadStackManagerImpl_OpenThread::OnDnsBrowseResult(otEr serviceInfo.mTxtData = txtBuffer; serviceInfo.mTxtDataSize = sizeof(txtBuffer); - error = MapOpenThreadError(otDnsBrowseResponseGetServiceInfo(aResponse, serviceName, &serviceInfo)); + otError err = otDnsBrowseResponseGetServiceInfo(aResponse, serviceName, &serviceInfo); + error = MapOpenThreadError(err); - VerifyOrExit(error == CHIP_NO_ERROR, ); + VerifyOrExit(err == OT_ERROR_NOT_FOUND || err == OT_ERROR_NONE, ); DnsResult * dnsResult = Platform::New(aContext, CHIP_NO_ERROR); - error = FromOtDnsResponseToMdnsData(serviceInfo, type, dnsResult->mMdnsService, dnsResult->mServiceTxtEntry); + + VerifyOrExit(dnsResult != nullptr, error = CHIP_ERROR_NO_MEMORY); + + error = FromOtDnsResponseToMdnsData(serviceInfo, type, dnsResult->mMdnsService, dnsResult->mServiceTxtEntry, err); if (CHIP_NO_ERROR == error) { // Invoke callback for every service one by one instead of for the whole @@ -2672,7 +2738,15 @@ void GenericThreadStackManagerImpl_OpenThread::OnDnsBrowseResult(otEr exit: // Invoke callback to notify about end-of-browse or failure DnsResult * dnsResult = Platform::New(aContext, error); - DeviceLayer::PlatformMgr().ScheduleWork(DispatchBrowseEmpty, reinterpret_cast(dnsResult)); + + if (dnsResult == nullptr) + { + DeviceLayer::PlatformMgr().ScheduleWork(DispatchBrowseNoMemory, reinterpret_cast(aContext)); + } + else + { + DeviceLayer::PlatformMgr().ScheduleWork(DispatchBrowseEmpty, reinterpret_cast(dnsResult)); + } } template @@ -2701,12 +2775,36 @@ CHIP_ERROR GenericThreadStackManagerImpl_OpenThread::_DnsBrowse(const return error; } +template +void GenericThreadStackManagerImpl_OpenThread::OnDnsAddressResolveResult(otError aError, + const otDnsAddressResponse * aResponse, + void * aContext) +{ + CHIP_ERROR error; + DnsResult * dnsResult = reinterpret_cast(aContext); + otIp6Address address; + + error = MapOpenThreadError(otDnsAddressResponseGetAddress(aResponse, 0, &address, nullptr)); + if (error == CHIP_NO_ERROR) + { + dnsResult->mMdnsService.mAddress = MakeOptional(ToIPAddress(address)); + } + + dnsResult->error = error; + + DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolve, reinterpret_cast(dnsResult)); +} + template void GenericThreadStackManagerImpl_OpenThread::OnDnsResolveResult(otError aError, const otDnsServiceResponse * aResponse, void * aContext) { CHIP_ERROR error; + otError otErr; DnsResult * dnsResult = Platform::New(aContext, MapOpenThreadError(aError)); + + VerifyOrExit(dnsResult != nullptr, error = CHIP_ERROR_NO_MEMORY); + // type buffer size is kDnssdTypeAndProtocolMaxSize + . + kMaxDomainNameSize + . + termination character char type[Dnssd::kDnssdTypeAndProtocolMaxSize + SrpClient::kMaxDomainNameSize + 3]; // hostname buffer size is kHostNameMaxLength + . + kMaxDomainNameSize + . + termination character @@ -2718,7 +2816,7 @@ void GenericThreadStackManagerImpl_OpenThread::OnDnsResolveResult(otE if (ThreadStackMgrImpl().mDnsResolveCallback == nullptr) { - ChipLogError(DeviceLayer, "Invalid dns browse callback"); + ChipLogError(DeviceLayer, "Invalid dns resolve callback"); return; } @@ -2734,16 +2832,31 @@ void GenericThreadStackManagerImpl_OpenThread::OnDnsResolveResult(otE serviceInfo.mTxtData = txtBuffer; serviceInfo.mTxtDataSize = sizeof(txtBuffer); - error = MapOpenThreadError(otDnsServiceResponseGetServiceInfo(aResponse, &serviceInfo)); + otErr = otDnsServiceResponseGetServiceInfo(aResponse, &serviceInfo); + error = MapOpenThreadError(otErr); VerifyOrExit(error == CHIP_NO_ERROR, ); - error = FromOtDnsResponseToMdnsData(serviceInfo, type, dnsResult->mMdnsService, dnsResult->mServiceTxtEntry); + error = FromOtDnsResponseToMdnsData(serviceInfo, type, dnsResult->mMdnsService, dnsResult->mServiceTxtEntry, otErr); exit: + if (dnsResult == nullptr) + { + DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolveNoMemory, reinterpret_cast(aContext)); + return; + } dnsResult->error = error; - DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolve, reinterpret_cast(dnsResult)); + + // If IPv6 address in unspecified (AAAA record not present), send additional DNS query to obtain IPv6 address. + if (otIp6IsAddressUnspecified(&serviceInfo.mHostAddress)) + { + DeviceLayer::PlatformMgr().ScheduleWork(DispatchAddressResolve, reinterpret_cast(dnsResult)); + } + else + { + DeviceLayer::PlatformMgr().ScheduleWork(DispatchResolve, reinterpret_cast(dnsResult)); + } } template diff --git a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h index 413f00649ab593..2397b5e143828d 100755 --- a/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h +++ b/src/platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h @@ -136,8 +136,11 @@ class GenericThreadStackManagerImpl_OpenThread CHIP_ERROR _DnsBrowse(const char * aServiceName, DnsBrowseCallback aCallback, void * aContext); CHIP_ERROR _DnsResolve(const char * aServiceName, const char * aInstanceName, DnsResolveCallback aCallback, void * aContext); static void DispatchResolve(intptr_t context); + static void DispatchResolveNoMemory(intptr_t context); + static void DispatchAddressResolve(intptr_t context); static void DispatchBrowseEmpty(intptr_t context); static void DispatchBrowse(intptr_t context); + static void DispatchBrowseNoMemory(intptr_t context); #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT @@ -261,9 +264,13 @@ class GenericThreadStackManagerImpl_OpenThread static void OnDnsBrowseResult(otError aError, const otDnsBrowseResponse * aResponse, void * aContext); static void OnDnsResolveResult(otError aError, const otDnsServiceResponse * aResponse, void * aContext); + static void OnDnsAddressResolveResult(otError aError, const otDnsAddressResponse * aResponse, void * aContext); + + static CHIP_ERROR ResolveAddress(intptr_t context, otDnsAddressCallback callback); + static CHIP_ERROR FromOtDnsResponseToMdnsData(otDnsServiceInfo & serviceInfo, const char * serviceType, - chip::Dnssd::DnssdService & mdnsService, - DnsServiceTxtEntries & serviceTxtEntries); + chip::Dnssd::DnssdService & mdnsService, DnsServiceTxtEntries & serviceTxtEntries, + otError error); #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_DNS_CLIENT #endif // CHIP_DEVICE_CONFIG_ENABLE_THREAD_SRP_CLIENT From a4365db5f13a8b75295ca099a8395d50bdf7356d Mon Sep 17 00:00:00 2001 From: sharad-patil24 <100128124+sharad-patil24@users.noreply.github.com> Date: Thu, 27 Apr 2023 00:28:05 +0530 Subject: [PATCH 48/54] [Silabs] : SiWX917- Reduce the task stack and buffer size to reduce the Ram Consumption (#26242) * [Silabs] : SiWX917- Reduce the task stack and buffer size to reduce the RAM consumption * Restyled by clang-format * Review Comment addressed --------- Co-authored-by: Restyled.io --- examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h index 09a44344bafb45..cb1279590926c7 100644 --- a/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h +++ b/examples/platform/silabs/SiWx917/SiWx917/wfx_rsi.h @@ -21,10 +21,10 @@ * Interface to RSI Sapis */ -#define WFX_RSI_WLAN_TASK_SZ (1024 + 512 + 256 + 1024 + 512) /* Unknown how big this should be */ -#define WFX_RSI_TASK_SZ (1024 + 1024 + 1024) /* Stack for the WFX/RSI task */ -#define WFX_RSI_BUF_SZ (1024 * 15) /* May need tweak */ -#define WFX_RSI_CONFIG_MAX_JOIN (5) /* Max join retries */ +#define WFX_RSI_WLAN_TASK_SZ (1024 + 512 + 256) /* Stack for the WLAN task */ +#define WFX_RSI_TASK_SZ (1024 + 1024) /* Stack for the WFX/RSI task */ +#define WFX_RSI_BUF_SZ (1024 * 10) /* May need tweak */ +#define WFX_RSI_CONFIG_MAX_JOIN (5) /* Max join retries */ /* * Various events fielded by the wfx_rsi task From b1009b42b46a44edeec1b6f3b60a4cf294f1dc9d Mon Sep 17 00:00:00 2001 From: chirag-silabs <100861685+chirag-silabs@users.noreply.github.com> Date: Thu, 27 Apr 2023 00:29:32 +0530 Subject: [PATCH 49/54] bugfix for the zap file missing reset counts for DGWIFI (#26220) --- .../thermostat-common/thermostat.matter | 2 ++ .../thermostat/thermostat-common/thermostat.zap | 15 +++++++++++++-- examples/window-app/common/window-app.matter | 2 ++ examples/window-app/common/window-app.zap | 15 +++++++++++++-- 4 files changed, 30 insertions(+), 4 deletions(-) diff --git a/examples/thermostat/thermostat-common/thermostat.matter b/examples/thermostat/thermostat-common/thermostat.matter index bba43c1a883bca..5711a58d2c24d8 100644 --- a/examples/thermostat/thermostat-common/thermostat.matter +++ b/examples/thermostat/thermostat-common/thermostat.matter @@ -1283,6 +1283,8 @@ server cluster WiFiNetworkDiagnostics = 54 { readonly attribute attrib_id attributeList[] = 65531; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; + + command ResetCounts(): DefaultSuccess = 0; } /** The Ethernet Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ diff --git a/examples/thermostat/thermostat-common/thermostat.zap b/examples/thermostat/thermostat-common/thermostat.zap index a7dbfd6603f3dd..81ca71a259c3be 100644 --- a/examples/thermostat/thermostat-common/thermostat.zap +++ b/examples/thermostat/thermostat-common/thermostat.zap @@ -1,5 +1,5 @@ { - "featureLevel": 92, + "featureLevel": 96, "creator": "zap", "keyValuePairs": [ { @@ -4118,6 +4118,16 @@ "define": "WIFI_NETWORK_DIAGNOSTICS_CLUSTER", "side": "client", "enabled": 0, + "commands": [ + { + "name": "ResetCounts", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], "attributes": [ { "name": "ClusterRevision", @@ -14772,5 +14782,6 @@ "endpointVersion": 1, "deviceIdentifier": 769 } - ] + ], + "log": [] } \ No newline at end of file diff --git a/examples/window-app/common/window-app.matter b/examples/window-app/common/window-app.matter index 0ed782bffccebb..0ac80a3916d20e 100644 --- a/examples/window-app/common/window-app.matter +++ b/examples/window-app/common/window-app.matter @@ -1414,6 +1414,8 @@ server cluster WiFiNetworkDiagnostics = 54 { readonly attribute attrib_id attributeList[] = 65531; readonly attribute bitmap32 featureMap = 65532; readonly attribute int16u clusterRevision = 65533; + + command ResetCounts(): DefaultSuccess = 0; } /** The Ethernet Network Diagnostics Cluster provides a means to acquire standardized diagnostics metrics that MAY be used by a Node to assist a user or Administrative Node in diagnosing potential problems. */ diff --git a/examples/window-app/common/window-app.zap b/examples/window-app/common/window-app.zap index e58cbfacb7c805..72c2db91f20e28 100644 --- a/examples/window-app/common/window-app.zap +++ b/examples/window-app/common/window-app.zap @@ -1,5 +1,5 @@ { - "featureLevel": 92, + "featureLevel": 96, "creator": "zap", "keyValuePairs": [ { @@ -4804,6 +4804,16 @@ "define": "WIFI_NETWORK_DIAGNOSTICS_CLUSTER", "side": "client", "enabled": 0, + "commands": [ + { + "name": "ResetCounts", + "code": 0, + "mfgCode": null, + "source": "client", + "incoming": 1, + "outgoing": 0 + } + ], "attributes": [ { "name": "ClusterRevision", @@ -9335,5 +9345,6 @@ "endpointVersion": 2, "deviceIdentifier": 514 } - ] + ], + "log": [] } \ No newline at end of file From 32eef3ecd7c402aed48e0f8f4a1cdc71f4650c3c Mon Sep 17 00:00:00 2001 From: chirag-silabs <100861685+chirag-silabs@users.noreply.github.com> Date: Thu, 27 Apr 2023 01:04:50 +0530 Subject: [PATCH 50/54] [Silabs] [SiWx917] Addressing build failures on 917 SOC due to GCC update (#26266) * addressing build failures on 917 SOC due to GCC update * updating the matter support pointer --- examples/platform/silabs/SiWx917/BUILD.gn | 3 +++ src/platform/silabs/SiWx917/wifi/dhcp_client.h | 1 + src/platform/silabs/SiWx917/wifi/wfx_msgs.h | 2 ++ third_party/silabs/matter_support | 2 +- 4 files changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/platform/silabs/SiWx917/BUILD.gn b/examples/platform/silabs/SiWx917/BUILD.gn index 7404436fbc90d8..ad3775845f3efa 100644 --- a/examples/platform/silabs/SiWx917/BUILD.gn +++ b/examples/platform/silabs/SiWx917/BUILD.gn @@ -186,6 +186,8 @@ config("siwx917-common-config") { if (siwx917_commissionable_data) { defines += [ "SIWX917_USE_COMISSIONABLE_DATA=1" ] } + + ldflags = [ "-Wl,--no-warn-rwx-segment" ] } config("silabs-wifi-config") { @@ -238,6 +240,7 @@ source_set("siwx917-common") { sources = [ "${silabs_common_plat_dir}/LEDWidget.cpp", "${silabs_common_plat_dir}/heap_4_silabs.c", + "${silabs_common_plat_dir}/syscalls_stubs.cpp", "${wifi_sdk_dir}/dhcp_client.cpp", "${wifi_sdk_dir}/ethernetif.cpp", "${wifi_sdk_dir}/lwip_netif.cpp", diff --git a/src/platform/silabs/SiWx917/wifi/dhcp_client.h b/src/platform/silabs/SiWx917/wifi/dhcp_client.h index 4ee9d2f5d0d68d..d5a6bd903104bd 100644 --- a/src/platform/silabs/SiWx917/wifi/dhcp_client.h +++ b/src/platform/silabs/SiWx917/wifi/dhcp_client.h @@ -18,6 +18,7 @@ #if LWIP_IPV4 && LWIP_DHCP #pragma once +#include #ifdef __cplusplus extern "C" { #endif diff --git a/src/platform/silabs/SiWx917/wifi/wfx_msgs.h b/src/platform/silabs/SiWx917/wifi/wfx_msgs.h index 44ff525a56a347..b87a7c070716a2 100644 --- a/src/platform/silabs/SiWx917/wifi/wfx_msgs.h +++ b/src/platform/silabs/SiWx917/wifi/wfx_msgs.h @@ -17,6 +17,8 @@ #ifndef _WFX_MSGS_H_ #define _WFX_MSGS_H_ + +#include /* * Taken from sl_wfx firmware - so I can re-use. * I need to do a better job than to use this stuff diff --git a/third_party/silabs/matter_support b/third_party/silabs/matter_support index 53c27ef4ed0cff..4d93227fc8679d 160000 --- a/third_party/silabs/matter_support +++ b/third_party/silabs/matter_support @@ -1 +1 @@ -Subproject commit 53c27ef4ed0cff01ad913b9e25d57ccb58cd49f4 +Subproject commit 4d93227fc8679d66f0dd8d408b114425ca73bc0c From 6678adb30898a9e071610090fd9726297380c6c8 Mon Sep 17 00:00:00 2001 From: chirag-silabs <100861685+chirag-silabs@users.noreply.github.com> Date: Thu, 27 Apr 2023 01:06:30 +0530 Subject: [PATCH 51/54] [Silabs] RS911x not going into power save upon power cycle (#26260) * Calling power save at only position * stopping the ble advertisement after sta was connected * removing the condition for wf200 and keeping it only for rs9116 * addressing review comments * Restyled by clang-format * Restyled by gn * address review comments * Restyled by clang-format --------- Co-authored-by: Restyled.io --- .../platform/silabs/efr32/rs911x/rsi_if.c | 34 ++++++++--------- .../platform/silabs/efr32/rs911x/wfx_rsi.h | 3 ++ .../silabs/efr32/rs911x/wfx_rsi_host.c | 20 ++++++++++ src/platform/silabs/BLEManagerImpl.h | 5 +-- .../silabs/ConnectivityManagerImpl_WIFI.cpp | 13 ++++++- .../silabs/efr32/rs911x/BLEManagerImpl.cpp | 38 +++++-------------- .../silabs/efr32/wifi/wfx_host_events.h | 4 ++ third_party/silabs/efr32_sdk.gni | 11 ++++-- 8 files changed, 75 insertions(+), 53 deletions(-) diff --git a/examples/platform/silabs/efr32/rs911x/rsi_if.c b/examples/platform/silabs/efr32/rs911x/rsi_if.c index 324f635f3015f0..dae7b0cd4f762e 100644 --- a/examples/platform/silabs/efr32/rs911x/rsi_if.c +++ b/examples/platform/silabs/efr32/rs911x/rsi_if.c @@ -181,6 +181,7 @@ int32_t wfx_rsi_disconnect() return status; } +#if CHIP_DEVICE_CONFIG_ENABLE_SED /****************************************************************** * @fn wfx_rsi_power_save() * @brief @@ -190,16 +191,29 @@ int32_t wfx_rsi_disconnect() * @return * None *********************************************************************/ -void wfx_rsi_power_save() +int32_t wfx_rsi_power_save() { - int32_t status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); + int32_t status; +#ifdef RSI_BLE_ENABLE + status = rsi_bt_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); + if (status != RSI_SUCCESS) + { + SILABS_LOG("BT Powersave Config Failed, Error Code : 0x%lX", status); + return status; + } +#endif /* RSI_BLE_ENABLE */ + + status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); if (status != RSI_SUCCESS) { SILABS_LOG("Powersave Config Failed, Error Code : 0x%lX", status); - return; + return status; } SILABS_LOG("Powersave Config Success"); + return status; } +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ + /****************************************************************** * @fn wfx_rsi_join_cb(uint16_t status, const uint8_t *buf, const uint16_t len) * @brief @@ -596,13 +610,6 @@ void wfx_rsi_task(void * arg) { wfx_dhcp_got_ipv4((uint32_t) sta_netif->ip_addr.u_addr.ip4.addr); hasNotifiedIPV4 = true; -#if CHIP_DEVICE_CONFIG_ENABLE_SED -#ifndef RSI_BLE_ENABLE - // enabling the power save mode for RS9116 if sleepy device is enabled - // if BLE is used on the rs9116 then powersave config is done after ble disconnect event - wfx_rsi_power_save(); -#endif /* RSI_BLE_ENABLE */ -#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ if (!hasNotifiedWifiConnectivity) { wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac); @@ -622,13 +629,6 @@ void wfx_rsi_task(void * arg) { wfx_ipv6_notify(GET_IPV6_SUCCESS); hasNotifiedIPV6 = true; -#if CHIP_DEVICE_CONFIG_ENABLE_SED -#ifndef RSI_BLE_ENABLE - // enabling the power save mode for RS9116 if sleepy device is enabled - // if BLE is used on the rs9116 then powersave config is done after ble disconnect event - wfx_rsi_power_save(); -#endif /* RSI_BLE_ENABLE */ -#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ if (!hasNotifiedWifiConnectivity) { wfx_connected_notify(CONNECTION_STATUS_SUCCESS, &wfx_rsi.ap_mac); diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi.h b/examples/platform/silabs/efr32/rs911x/wfx_rsi.h index 846644f2ba7f55..7292970a11c011 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi.h +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi.h @@ -91,6 +91,9 @@ int32_t wfx_rsi_get_ap_info(wfx_wifi_scan_result_t * ap); int32_t wfx_rsi_get_ap_ext(wfx_wifi_scan_ext_t * extra_info); int32_t wfx_rsi_reset_count(); int32_t wfx_rsi_disconnect(); +#if CHIP_DEVICE_CONFIG_ENABLE_SED +int32_t wfx_rsi_power_save(); +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ #define SILABS_LOG(...) efr32Log(__VA_ARGS__); #ifdef __cplusplus diff --git a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c index 9f89a678dfce0a..0691c21670518a 100644 --- a/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c +++ b/examples/platform/silabs/efr32/rs911x/wfx_rsi_host.c @@ -30,6 +30,7 @@ #include "event_groups.h" #include "task.h" +#include "rsi_error.h" #include "wfx_host_events.h" #include "wfx_rsi.h" @@ -195,6 +196,25 @@ sl_status_t wfx_connect_to_ap(void) return SL_STATUS_OK; } +#if CHIP_DEVICE_CONFIG_ENABLE_SED +/********************************************************************* + * @fn sl_status_t wfx_power_save() + * @brief + * Implements the power save in sleepy application + * @param[in] None + * @return SL_STATUS_OK if successful, + * SL_STATUS_FAIL otherwise + ***********************************************************************/ +sl_status_t wfx_power_save() +{ + if (wfx_rsi_power_save() != RSI_ERROR_NONE) + { + return SL_STATUS_FAIL; + } + return SL_STATUS_OK; +} +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ + /********************************************************************* * @fn void wfx_setup_ip6_link_local(sl_wfx_interface_t whichif) * @brief diff --git a/src/platform/silabs/BLEManagerImpl.h b/src/platform/silabs/BLEManagerImpl.h index 330aad5a1c4be6..da6ce3bb4e3002 100644 --- a/src/platform/silabs/BLEManagerImpl.h +++ b/src/platform/silabs/BLEManagerImpl.h @@ -72,7 +72,6 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla void HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId); void HandleTXCharCCCDWrite(rsi_ble_event_write_t * evt); void HandleSoftTimerEvent(void); - CHIP_ERROR StartAdvertising(void); #else void HandleConnectEvent(volatile sl_bt_msg_t * evt); void HandleConnectionCloseEvent(volatile sl_bt_msg_t * evt); @@ -81,8 +80,9 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla void HandleTxConfirmationEvent(BLE_CONNECTION_OBJECT conId); void HandleTXCharCCCDWrite(volatile sl_bt_msg_t * evt); void HandleSoftTimerEvent(volatile sl_bt_msg_t * evt); - CHIP_ERROR StartAdvertising(void); #endif // RSI_BLE_ENABLE + CHIP_ERROR StartAdvertising(void); + CHIP_ERROR StopAdvertising(void); #if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING #ifdef RSI_BLE_ENABLE @@ -187,7 +187,6 @@ class BLEManagerImpl final : public BLEManager, private BleLayer, private BlePla CHIP_ERROR MapBLEError(int bleErr); void DriveBLEState(void); CHIP_ERROR ConfigureAdvertisingData(void); - CHIP_ERROR StopAdvertising(void); #if CHIP_ENABLE_ADDITIONAL_DATA_ADVERTISING CHIP_ERROR EncodeAdditionalDataTlv(); #endif diff --git a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp index edbff853f34e8f..6b10b294b5ad02 100644 --- a/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp +++ b/src/platform/silabs/ConnectivityManagerImpl_WIFI.cpp @@ -380,7 +380,18 @@ void ConnectivityManagerImpl::OnStationConnected() event.Type = DeviceEventType::kWiFiConnectivityChange; event.WiFiConnectivityChange.Result = kConnectivity_Established; (void) PlatformMgr().PostEvent(&event); - + // Setting the rs911x in the power save mode +#if (CHIP_DEVICE_CONFIG_ENABLE_SED && RS911X_WIFI) + // TODO: Remove stop advertising after BLEManagerImpl is fixed +#if RSI_BLE_ENABLE + chip::DeviceLayer::Internal::BLEManagerImpl().StopAdvertising(); +#endif /* RSI_BLE_ENABLE */ + sl_status_t err = wfx_power_save(); + if (err != SL_STATUS_OK) + { + ChipLogError(DeviceLayer, "Power save config for Wifi failed"); + } +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED && RS911X_WIFI */ UpdateInternetConnectivityState(); } diff --git a/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp b/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp index f03e9d1356543c..4a910e0a29aae5 100644 --- a/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp +++ b/src/platform/silabs/efr32/rs911x/BLEManagerImpl.cpp @@ -661,23 +661,21 @@ CHIP_ERROR BLEManagerImpl::StartAdvertising(void) return CHIP_NO_ERROR; // err; } -// TODO:: Implementation need to be done. CHIP_ERROR BLEManagerImpl::StopAdvertising(void) { CHIP_ERROR err = CHIP_NO_ERROR; int32_t status = 0; - if (mFlags.Has(Flags::kAdvertising)) + // TODO: add the below code in a condition if (mFlags.Has(Flags::kAdvertising)) + // Since DriveBLEState is not called the device is still advertising + mFlags.Clear(Flags::kAdvertising).Clear(Flags::kRestartAdvertising); + mFlags.Set(Flags::kFastAdvertisingEnabled, true); + status = rsi_ble_stop_advertising(); + if (status != RSI_SUCCESS) { - mFlags.Clear(Flags::kAdvertising).Clear(Flags::kRestartAdvertising); - mFlags.Set(Flags::kFastAdvertisingEnabled, true); - status = rsi_ble_stop_advertising(); - if (status != RSI_SUCCESS) - { - ChipLogProgress(DeviceLayer, "advertising failed to stop, with status = 0x%lx", status); - } - advertising_set_handle = 0xff; - CancelBleAdvTimeoutTimer(); + ChipLogProgress(DeviceLayer, "advertising failed to stop, with status = 0x%lx", status); } + advertising_set_handle = 0xff; + CancelBleAdvTimeoutTimer(); // exit: return err; @@ -723,24 +721,6 @@ void BLEManagerImpl::HandleConnectionCloseEvent(uint16_t reason) ChipLogProgress(DeviceLayer, "Disconnect Event for handle : %d", connHandle); -#if CHIP_DEVICE_CONFIG_ENABLE_SED - int32_t status; - status = rsi_bt_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); - if (status != RSI_SUCCESS) - { - SILABS_LOG("BT Powersave Config Failed, Error Code : 0x%lX", status); - return; - } - - status = rsi_wlan_power_save_profile(RSI_SLEEP_MODE_2, RSI_MAX_PSP); - if (status != RSI_SUCCESS) - { - SILABS_LOG("WLAN Powersave Config Failed, Error Code : 0x%lX", status); - return; - } - SILABS_LOG("Powersave Config Success"); -#endif - if (RemoveConnection(connHandle)) { ChipDeviceEvent event; diff --git a/src/platform/silabs/efr32/wifi/wfx_host_events.h b/src/platform/silabs/efr32/wifi/wfx_host_events.h index 1d41c750517c82..c0724b7237e808 100644 --- a/src/platform/silabs/efr32/wifi/wfx_host_events.h +++ b/src/platform/silabs/efr32/wifi/wfx_host_events.h @@ -352,6 +352,10 @@ void wfx_ip_changed_notify(int got_ip); void wfx_ipv6_notify(int got_ip); #ifdef RS911X_WIFI +/* RSI Power Save */ +#if CHIP_DEVICE_CONFIG_ENABLE_SED +sl_status_t wfx_power_save(); +#endif /* CHIP_DEVICE_CONFIG_ENABLE_SED */ /* RSI for LWIP */ void * wfx_rsi_alloc_pkt(void); void wfx_rsi_pkt_add_data(void * p, uint8_t * buf, uint16_t len, uint16_t off); diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index 97de1caf125afe..f84e257af916f5 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -338,10 +338,15 @@ template("efr32_sdk") { "SL_CATALOG_POWER_MANAGER_PRESENT", "SL_CATALOG_SLEEPTIMER_PRESENT", "SL_SLEEP_TIME_MS=${sleep_time_ms}", - - # Used for wifi devices to get packet details - "WIFI_DEBUG_ENABLED=1", ] + + if (defined(invoker.chip_enable_wifi) && invoker.chip_enable_wifi) { + defines += [ + # Used for wifi devices to get packet details + # TODO: Remove this flag, once the communication is fixed + "WIFI_DEBUG_ENABLED=1", + ] + } } if (chip_build_libshell) { # matter shell From 8cdd0aa0b3a37f6f6abf2458adbb3d274f43337f Mon Sep 17 00:00:00 2001 From: Terence Hampson Date: Wed, 26 Apr 2023 16:21:38 -0400 Subject: [PATCH 52/54] Add LightSensorType to IlluminanceMeasurement for chef lighting example (#26269) --- .../devices/rootnode_lightsensor_lZQycTFcJK.matter | 2 ++ .../chef/devices/rootnode_lightsensor_lZQycTFcJK.zap | 11 ++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter index e60751a893b628..6ed3b14735881e 100644 --- a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter +++ b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.matter @@ -1229,6 +1229,7 @@ server cluster IlluminanceMeasurement = 1024 { readonly attribute nullable int16u measuredValue = 0; readonly attribute nullable int16u minMeasuredValue = 1; readonly attribute nullable int16u maxMeasuredValue = 2; + readonly attribute nullable enum8 lightSensorType = 4; readonly attribute command_id generatedCommandList[] = 65528; readonly attribute command_id acceptedCommandList[] = 65529; readonly attribute event_id eventList[] = 65530; @@ -1440,6 +1441,7 @@ endpoint 1 { ram attribute measuredValue default = 0xC351; ram attribute minMeasuredValue default = 1; ram attribute maxMeasuredValue default = 0xfffe; + ram attribute lightSensorType default = 1; callback attribute generatedCommandList default = 0; callback attribute acceptedCommandList default = 0; callback attribute attributeList default = 0; diff --git a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.zap b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.zap index 1ad280a7a693bd..0404fe4a4b3339 100644 --- a/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.zap +++ b/examples/chef/devices/rootnode_lightsensor_lZQycTFcJK.zap @@ -1,5 +1,5 @@ { - "featureLevel": 92, + "featureLevel": 96, "creator": "zap", "keyValuePairs": [ { @@ -6141,11 +6141,11 @@ "mfgCode": null, "side": "server", "type": "enum8", - "included": 0, + "included": 1, "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "0xFF", + "defaultValue": "1", "reportable": 1, "minInterval": 1, "maxInterval": 65534, @@ -6255,5 +6255,6 @@ "endpointVersion": 1, "deviceIdentifier": 262 } - ] -} \ No newline at end of file + ], + "log": [] +} From c837ea3d0b48da9b869e89d5128b3e497376fe60 Mon Sep 17 00:00:00 2001 From: Ezra Hale Date: Thu, 27 Apr 2023 01:14:30 -0400 Subject: [PATCH 53/54] updated board references from BRD4161A to BRD4187C in example commands (#26264) * updated board references from BRD4161A to BRD4187C in example commands * change EFR32_BOARD to SILABS_BOARD * change references to silabs_board to SILABS_BOARD --- examples/light-switch-app/silabs/efr32/README.md | 14 +++++++------- examples/lighting-app/silabs/efr32/README.md | 12 ++++++------ examples/lock-app/silabs/efr32/README.md | 14 +++++++------- examples/thermostat/silabs/efr32/README.md | 14 +++++++------- examples/window-app/silabs/efr32/README.md | 12 ++++++------ 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/examples/light-switch-app/silabs/efr32/README.md b/examples/light-switch-app/silabs/efr32/README.md index 5651486640ee0e..bf18af9f03c0b2 100644 --- a/examples/light-switch-app/silabs/efr32/README.md +++ b/examples/light-switch-app/silabs/efr32/README.md @@ -106,7 +106,7 @@ Silicon Labs platform. * Build the example application: cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/efr32/ ./out/light-switch-app BRD4161A + ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/efr32/ ./out/light-switch-app BRD4187C - To delete generated executable, libraries and object files use: @@ -118,7 +118,7 @@ Silicon Labs platform. $ cd ~/connectedhomeip/examples/light-switch-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug $ ninja -C out/debug @@ -129,26 +129,26 @@ Silicon Labs platform. * Build the example with Matter shell - ./scripts/examples/gn_efr32_example.sh examples/light-switch-app/silabs/efr32/ out/light-switch-app BRD4161A chip_build_libshell=true + ./scripts/examples/gn_efr32_example.sh examples/light-switch-app/silabs/efr32/ out/light-switch-app BRD4187C chip_build_libshell=true * Build the example as Sleepy End Device (SED) - $ ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/efr32/ ./out/light-switch-app_SED BRD4161A --sed + $ ./scripts/examples/gn_efr32_example.sh ./examples/light-switch-app/silabs/efr32/ ./out/light-switch-app_SED BRD4187C --sed or use gn as previously mentioned but adding the following arguments: - $ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false chip_build_libshell=true' + $ gn gen out/debug '--args=SILABS_BOARD="BRD4187C" enable_sleepy_device=true chip_openthread_ftd=false chip_build_libshell=true' * Build the example with pigweed RCP - $ ./scripts/examples/gn_efr32_example.sh examples/light-switch-app/silabs/efr32/ out/light-switch-app_rpc BRD4161A 'import("//with_pw_rpc.gni")' + $ ./scripts/examples/gn_efr32_example.sh examples/light-switch-app/silabs/efr32/ out/light-switch-app_rpc BRD4187C 'import("//with_pw_rpc.gni")' or use GN/Ninja Directly $ cd ~/connectedhomeip/examples/light-switch-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug --args='import("//with_pw_rpc.gni")' $ ninja -C out/debug diff --git a/examples/lighting-app/silabs/efr32/README.md b/examples/lighting-app/silabs/efr32/README.md index 4dde93ddcb93ca..1cd0ed3df33193 100644 --- a/examples/lighting-app/silabs/efr32/README.md +++ b/examples/lighting-app/silabs/efr32/README.md @@ -100,7 +100,7 @@ Silicon Labs platform. * Build the example application: cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/silabs/efr32/ ./out/lighting-app BRD4161A + ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/silabs/efr32/ ./out/lighting-app BRD4187C - To delete generated executable, libraries and object files use: @@ -112,7 +112,7 @@ Silicon Labs platform. $ cd ~/connectedhomeip/examples/lighting-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export silabs_board=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug $ ninja -C out/debug @@ -123,22 +123,22 @@ Silicon Labs platform. * Build the example as Sleepy End Device (SED) - $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/silabs/efr32/ ./out/lighting-app_SED BRD4161A --sed + $ ./scripts/examples/gn_efr32_example.sh ./examples/lighting-app/silabs/efr32/ ./out/lighting-app_SED BRD4187C --sed or use gn as previously mentioned but adding the following arguments: - $ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false' + $ gn gen out/debug '--args=SILABS_BOARD="BRD4187C" enable_sleepy_device=true chip_openthread_ftd=false' * Build the example with pigweed RPC - $ ./scripts/examples/gn_efr32_example.sh examples/lighting-app/silabs/efr32/ out/lighting_app_rpc BRD4161A 'import("//with_pw_rpc.gni")' + $ ./scripts/examples/gn_efr32_example.sh examples/lighting-app/silabs/efr32/ out/lighting_app_rpc BRD4187C 'import("//with_pw_rpc.gni")' or use GN/Ninja Directly $ cd ~/connectedhomeip/examples/lighting-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export silabs_board=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug --args='import("//with_pw_rpc.gni")' $ ninja -C out/debug diff --git a/examples/lock-app/silabs/efr32/README.md b/examples/lock-app/silabs/efr32/README.md index 8d6ed7776bb565..6c3fe8453ec3ee 100644 --- a/examples/lock-app/silabs/efr32/README.md +++ b/examples/lock-app/silabs/efr32/README.md @@ -102,7 +102,7 @@ Mac OS X ``` cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/efr32/ ./out/lock_app BRD4161A + ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/efr32/ ./out/lock_app BRD4187C ``` - To delete generated executable, libraries and object files use: @@ -118,8 +118,8 @@ Mac OS X $ cd ~/connectedhomeip/examples/silabs/lock-app/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A - $ gn gen out/debug --args="efr32_sdk_root=\"${EFR32_SDK_ROOT}\" silabs_board=\"${EFR32_BOARD}\"" + $ export SILABS_BOARD=BRD4187C + $ gn gen out/debug --args="efr32_sdk_root=\"${EFR32_SDK_ROOT}\" SILABS_BOARD=\"${SILABS_BOARD}\"" $ ninja -C out/debug ``` @@ -133,19 +133,19 @@ Mac OS X * Build the example as Sleepy End Device (SED) ``` - $ ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/efr32/ ./out/lock-app_SED BRD4161A --sed + $ ./scripts/examples/gn_efr32_example.sh ./examples/lock-app/silabs/efr32/ ./out/lock-app_SED BRD4187C --sed ``` or use gn as previously mentioned but adding the following arguments: ``` - $ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false' + $ gn gen out/debug '--args=SILABS_BOARD="BRD4187C" enable_sleepy_device=true chip_openthread_ftd=false' ``` * Build the example with pigweed RCP ``` - $ ./scripts/examples/gn_efr32_example.sh examples/lock-app/silabs/efr32/ out/lock_app_rpc BRD4161A 'import("//with_pw_rpc.gni")' + $ ./scripts/examples/gn_efr32_example.sh examples/lock-app/silabs/efr32/ out/lock_app_rpc BRD4187C 'import("//with_pw_rpc.gni")' ``` or use GN/Ninja Directly @@ -154,7 +154,7 @@ Mac OS X $ cd ~/connectedhomeip/examples/lock-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug --args='import("//with_pw_rpc.gni")' $ ninja -C out/debug ``` diff --git a/examples/thermostat/silabs/efr32/README.md b/examples/thermostat/silabs/efr32/README.md index 2a6cfb9289bdf0..8fafaa7827ba05 100644 --- a/examples/thermostat/silabs/efr32/README.md +++ b/examples/thermostat/silabs/efr32/README.md @@ -106,7 +106,7 @@ Silicon Labs platform. * Build the example application: cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/thermostat/silabs/efr32/ ./out/thermostat-app BRD4161A + ./scripts/examples/gn_efr32_example.sh ./examples/thermostat/silabs/efr32/ ./out/thermostat-app BRD4187C - To delete generated executable, libraries and object files use: @@ -118,7 +118,7 @@ Silicon Labs platform. $ cd ~/connectedhomeip/examples/thermostat/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug $ ninja -C out/debug @@ -129,26 +129,26 @@ Silicon Labs platform. * Build the example with Matter shell - ./scripts/examples/gn_efr32_example.sh examples/thermostat/silabs/efr32/ out/thermostat-app BRD4161A chip_build_libshell=true + ./scripts/examples/gn_efr32_example.sh examples/thermostat/silabs/efr32/ out/thermostat-app BRD4187C chip_build_libshell=true * Build the example as Sleepy End Device (SED) - $ ./scripts/examples/gn_efr32_example.sh ./examples/thermostat/silabs/efr32/ ./out/thermostat-app_SED BRD4161A --sed + $ ./scripts/examples/gn_efr32_example.sh ./examples/thermostat/silabs/efr32/ ./out/thermostat-app_SED BRD4187C --sed or use gn as previously mentioned but adding the following arguments: - $ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false chip_build_libshell=true' + $ gn gen out/debug '--args=SILABS_BOARD="BRD4187C" enable_sleepy_device=true chip_openthread_ftd=false chip_build_libshell=true' * Build the example with pigweed RCP - $ ./scripts/examples/gn_efr32_example.sh examples/thermostat/silabs/efr32/ out/thermostat-app_rpc BRD4161A 'import("//with_pw_rpc.gni")' + $ ./scripts/examples/gn_efr32_example.sh examples/thermostat/silabs/efr32/ out/thermostat-app_rpc BRD4187C 'import("//with_pw_rpc.gni")' or use GN/Ninja Directly $ cd ~/connectedhomeip/examples/thermostat/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug --args='import("//with_pw_rpc.gni")' $ ninja -C out/debug diff --git a/examples/window-app/silabs/efr32/README.md b/examples/window-app/silabs/efr32/README.md index 9e531212f85cee..4d5231863c9aae 100644 --- a/examples/window-app/silabs/efr32/README.md +++ b/examples/window-app/silabs/efr32/README.md @@ -99,7 +99,7 @@ Silicon Labs platform. * Build the example application: cd ~/connectedhomeip - ./scripts/examples/gn_efr32_example.sh ./examples/window-app/silabs/efr32/ ./out/window-app BRD4161A + ./scripts/examples/gn_efr32_example.sh ./examples/window-app/silabs/efr32/ ./out/window-app BRD4187C - To delete generated executable, libraries and object files use: @@ -111,7 +111,7 @@ Silicon Labs platform. $ cd ~/connectedhomeip/examples/window-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug $ ninja -C out/debug @@ -122,22 +122,22 @@ Silicon Labs platform. * Build the example as Sleepy End Device (SED) - $ ./scripts/examples/gn_efr32_example.sh ./examples/window-app/silabs/efr32/ ./out/window-app_SED BRD4161A --sed + $ ./scripts/examples/gn_efr32_example.sh ./examples/window-app/silabs/efr32/ ./out/window-app_SED BRD4187C --sed or use gn as previously mentioned but adding the following arguments: - $ gn gen out/debug '--args=silabs_board="BRD4161A" enable_sleepy_device=true chip_openthread_ftd=false' + $ gn gen out/debug '--args=SILABS_BOARD="BRD4187C" enable_sleepy_device=true chip_openthread_ftd=false' * Build the example with pigweed RCP - $ ./scripts/examples/gn_efr32_example.sh examples/window-app/silabs/efr32/ out/window_app_rpc BRD4161A 'import("//with_pw_rpc.gni")' + $ ./scripts/examples/gn_efr32_example.sh examples/window-app/silabs/efr32/ out/window_app_rpc BRD4187C 'import("//with_pw_rpc.gni")' or use GN/Ninja Directly $ cd ~/connectedhomeip/examples/window-app/silabs/efr32 $ git submodule update --init $ source third_party/connectedhomeip/scripts/activate.sh - $ export EFR32_BOARD=BRD4161A + $ export SILABS_BOARD=BRD4187C $ gn gen out/debug --args='import("//with_pw_rpc.gni")' $ ninja -C out/debug From c1108d7f7360e9065c9e3dd5f4d2d9cfabdffbbe Mon Sep 17 00:00:00 2001 From: mkardous-silabs <84793247+mkardous-silabs@users.noreply.github.com> Date: Thu, 27 Apr 2023 01:30:10 -0400 Subject: [PATCH 54/54] Added build configuration flags (#26273) --- .../silabs/efr32/project_include/OpenThreadConfig.h | 9 ++++++--- src/platform/silabs/CHIPDevicePlatformConfig.h | 8 ++++++-- third_party/silabs/efr32_sdk.gni | 9 +++++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h b/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h index c8f39692a69b0e..ea67df3ba27829 100644 --- a/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h +++ b/examples/platform/silabs/efr32/project_include/OpenThreadConfig.h @@ -37,13 +37,16 @@ #define OPENTHREAD_CONFIG_HEAP_EXTERNAL_ENABLE 1 #if CHIP_DEVICE_CONFIG_ENABLE_SED + #define OPENTHREAD_CONFIG_PARENT_SEARCH_ENABLE 0 + // In seconds -#define SL_MLE_TIMEOUT_seconds (SL_SLEEP_TIME_MS / 1000) +#define SL_MLE_TIMEOUT_s (SL_OT_IDLE_INTERVAL / 1000) // Timeout after 2 missed checkin or 4 mins if sleep interval is too short. -#define OPENTHREAD_CONFIG_MLE_CHILD_TIMEOUT_DEFAULT ((SL_MLE_TIMEOUT_seconds < 120) ? 240 : ((SL_MLE_TIMEOUT_seconds * 2) + 1)) -#endif +#define OPENTHREAD_CONFIG_MLE_CHILD_TIMEOUT_DEFAULT ((SL_MLE_TIMEOUT_s < 120) ? 240 : ((SL_MLE_TIMEOUT_s * 2) + 1)) + +#endif // CHIP_DEVICE_CONFIG_ENABLE_SED /****Uncomment below section for OpenThread Debug logs*/ // #define OPENTHREAD_CONFIG_LOG_LEVEL OT_LOG_LEVEL_DEBG diff --git a/src/platform/silabs/CHIPDevicePlatformConfig.h b/src/platform/silabs/CHIPDevicePlatformConfig.h index 45f9c83ace6272..fb749556e19b2c 100644 --- a/src/platform/silabs/CHIPDevicePlatformConfig.h +++ b/src/platform/silabs/CHIPDevicePlatformConfig.h @@ -117,13 +117,17 @@ #endif // CHIP_DEVICE_CONFIG_CHIP_TASK_STACK_SIZE #ifndef CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL -#define CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL chip::System::Clock::Milliseconds32(SL_SLEEP_TIME_MS) +#define CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL chip::System::Clock::Milliseconds32(SL_OT_IDLE_INTERVAL) #endif // CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL #ifndef CHIP_DEVICE_CONFIG_SED_ACTIVE_INTERVAL -#define CHIP_DEVICE_CONFIG_SED_ACTIVE_INTERVAL chip::System::Clock::Milliseconds32(200) +#define CHIP_DEVICE_CONFIG_SED_ACTIVE_INTERVAL chip::System::Clock::Milliseconds32(SL_OT_ACTIVE_INTERVAL) #endif // CHIP_DEVICE_CONFIG_SED_ACTIVE_INTERVAL +#ifndef CHIP_DEVICE_CONFIG_SED_ACTIVE_THRESHOLD +#define CHIP_DEVICE_CONFIG_SED_ACTIVE_THRESHOLD chip::System::Clock::Milliseconds32(SL_ACTIVE_MODE_THRESHOLD) +#endif // CHIP_DEVICE_CONFIG_SED_ACTIVE_THRESHOLD + #ifndef CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE #if defined(EFR32MG21) #define CHIP_DEVICE_CONFIG_THREAD_TASK_STACK_SIZE (2 * 1024) diff --git a/third_party/silabs/efr32_sdk.gni b/third_party/silabs/efr32_sdk.gni index f84e257af916f5..5e6905ebb83e7c 100644 --- a/third_party/silabs/efr32_sdk.gni +++ b/third_party/silabs/efr32_sdk.gni @@ -45,7 +45,10 @@ declare_args() { # Enable Segger System View use_system_view = false - sleep_time_ms = 30000 # 30 seconds sleep + # ICD Configuration flags + sl_ot_idle_interval_ms = 30000 # 30s Idle Intervals + sl_ot_active_interval_ms = 200 # 500ms Active Intervals + sl_active_mode_threshold = 1000 # 1s Active mode threshold silabs_log_enabled = true @@ -337,7 +340,9 @@ template("efr32_sdk") { "CHIP_DEVICE_CONFIG_ENABLE_SED=1", "SL_CATALOG_POWER_MANAGER_PRESENT", "SL_CATALOG_SLEEPTIMER_PRESENT", - "SL_SLEEP_TIME_MS=${sleep_time_ms}", + "SL_OT_IDLE_INTERVAL=${sl_ot_idle_interval_ms}", + "SL_OT_ACTIVE_INTERVAL=${sl_ot_active_interval_ms}", + "SL_ACTIVE_MODE_THRESHOLD=${sl_active_mode_threshold}", ] if (defined(invoker.chip_enable_wifi) && invoker.chip_enable_wifi) {